Read($filename); } if (!isset($lines)) $lines = array(); if ($_POST[action]=='add') { $name = $_POST['name']; $email = $_POST['email']; $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"); if(empty($name) || empty($msg)) { readfile($errorpage); } else { $lines[count($lines)] = array("name"=>"$name","email"=>"$email","site"=>"$site","msg"=>"$msg", "date"=>"$date"); $csv->Write($filename, $lines); readfile($thankspage); } } 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) { $out = $out.$msgs; $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); } // echo $out; $tpl = str_replace('[$PHP_GUESTBOOK]', $out, $tpl); echo "$tpl"; } } ?>