/* Variablen */
$filename = "guestbook.txt";
$ipfile = "ip.php";
$spamfile ="spam.php";
$spamfile1 ="spam1.php";
$guestpage = "gaestebuch.html";
$thankspage = "gaestebuch_danke.html";
$errorpage = "gaestebuch_fehler.html";
$frei =0;
$links = "Kommentar: ";
$leer = "";
/* Main */
require_once("csv1.php");
include("guest_config.php");
$csv = new csv1();
if (file_exists($filename)) {
$lines = $csv->Read($filename);
}
if (!isset($lines))
$lines = array();{
if ($_POST[action]=='add')
{
$date = date("d.m.Y G:i:s T");
/*Captcha*/
session_start();
if(isset($_SESSION['captcha_spam']) AND $_POST["sicherheitscode"] == $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']);
/*Captcha*/
$name = $_POST['name'];
$email = $_POST['email'];
$mail="$mail_admin";
$ip = getenv('REMOTE_ADDR');
$site = $_POST['site'];
if (substr($site, 0, 7) != 'http://') $site = 'http://'.$site;
if ($site=='http://') $site = '';
$msg = $_POST['msg'];
$msg = str_replace("\n", "
", $msg);
//$date = date("d.m.Y G:i:s T");
}
else
{
readfile($errorpage);
die;
}
if($ip=="")
{
//SPAM-Speichern Beginn
$stats=stat("spam.php");
//echo "Die SPAM.php ist $stats[size] bytes groß
";
if ($stats[size]>'100000')
{
//echo "Die Datei wird gelöscht
";
mail("$mail_admin","SPAM-Datei", "Die spam.php wurde wegen übergrösse gelöscht\n eine Kopie der alten Datei ist unter spam1.php verfügbar", "From: $mail_admin");
copy ("spam.php","spam1.php");
$file=file($spamfile1);
$fd=fopen($spamfile1, "a");
fwrite($fd, "SPAM-Datei wurde am ");
fwrite($fd, "$date");
fwrite($fd, " wegen Übergröße gespeichert");
fwrite($fd, "|-|");
fclose ($fd);
$file=file($spamfile);
$fd=fopen($spamfile, "w+");
fwrite($fd, "Datei neu angelegt am ");
fwrite($fd, "$date");
fwrite($fd, "|-|");
fwrite($fd, "Die alte Datei wurde unter spam1.php gespeichert ");
fwrite($fd, "\n");
fclose ($fd);
//echo "Die alte SPAM-Datei wurde in der Datei spam1.php gespeichert !!!";
}
else
{
$file=file($spamfile);
$fd=fopen($spamfile, "a+");
fwrite($fd, "$date");
fwrite($fd, "|-|");
fwrite($fd, "SPAM abgewehrt");
fwrite($fd, "|-|\n");
//SPAM-Speichern Ende
readfile($thankspage);
}
}
else
{
if(empty($name) || empty($msg) || empty($date))
{
readfile($errorpage);
}
else
{
$lines[count($lines)] = array("frei"=>"$frei","name"=>"$name","email"=>"$email","site"=>"$site","msg"=>"$msg", "date"=>"$date", "kom"=>"$kom", "ip"=>"$ip");
$csv->Write($filename, $lines);
//Ip-Speichern Beginn
$file=file($ipfile);
$fd=fopen($ipfile, "a+");
fwrite($fd, "$name");
fwrite($fd, "|-|");
fwrite($fd, "$date");
fwrite($fd, "|-|");
fwrite($fd, "$ip");
fwrite($fd, "|-|\n");
//Ip-Speichern Ende
mail("$mail_admin","Neuer Gästebucheintrag", "Neuer Eintrag:\n\nDatum:\n$date\nvon:\n$name\nEmail:\n$email\nURL:\n$site\n\nText:\n$msg", "From: $mail_admin");
readfile($thankspage);
/*Fuss captcha*/
}
}
}
else {
$file = "$guestpage";
if (file_exists($file)) {
$file = "$guestpage";
$f = fopen ($file, "r");
$tpl = fread ($f,filesize ($file));
fclose ($f);
$msgs = substr($tpl, strpos($tpl,'') + 24, strpos($tpl, '') - (strpos($tpl,'') + 24));
$pre = substr($tpl, 0, strpos($tpl,''));
$post = substr($tpl, strpos($tpl, '')+22);
$tpl = $pre.'[$PHP_GUESTBOOK]'.$post;
$out = '';
krsort($lines);
foreach($lines as $line) {
if ($line["frei"]=="1") {
$out = $out.$msgs;
$out = str_replace('[$PHP_GUEST_FREI]', $line["frei"], $out);
$out = str_replace('[$PHP_GUEST_NAME]', $line["name"], $out);
$out = str_replace('[$PHP_GUEST_EMAIL]', $line["email"], $out);
$out = str_replace('[$PHP_GUEST_WEBSEITE]', $line["site"], $out);
$out = str_replace('[$PHP_GUEST_TEXT]', $line["msg"], $out);
$out = str_replace('[$PHP_GUEST_DATUM]', $line["date"], $out);
if ($line["kom"]=="") {
$out = str_replace('[$PHP_GUEST_KOM_L]', $leer, $out);
$out = str_replace('[$PHP_GUEST_KOM]', $leer, $out);
}
else
{
$out = str_replace('[$PHP_GUEST_KOM_L]', $links, $out);
$out = str_replace('[$PHP_GUEST_KOM]', $line["kom"], $out);
}
}
}
// echo $out;
$tpl = str_replace('[$PHP_GUESTBOOK]', $out, $tpl);
echo "$tpl";
}
}}
?>