<?
//de eerste spatie dient voor geen redirect meer te kunnen doen in de code hierdoor is een /n Dit is belangerijk voor gastenboek.
$inifile = $guestbookloc."inifile.dat";
$file = $guestbookloc."guestbook.dat";
//moet opgeroepen worden via inc en vieuwport.
//TODO maken van een gastenboek met bestandsnaam met een teller naar boven. voor een druk bezocht gastenboek te verdelen over verschillende pagina
$name = addslashes($_POST['name'] );
$email= $_POST['email'] ;
$comments = $_POST['comments'];
$ip = ( isset( $_POST['ip'] )) ? $_POST['ip']: "no ip" ;//not used option
echo "<body >\n";
if (!$_POST['upload']=='submit') {
if (is_file($file) && (filesize($file)>0)) {
$gbfile = fopen ($file,'r');
while (!feof($gbfile))
{ $gbline = fgets($gbfile,1024);
print "$gbline<br>\n";
}
fclose ($gbfile);
} else {
print "Het gastenboek is leeg momenteel.<br>\n";
}
} else { // upload uitgevoerd
// START CONTROLE OP INVOER
$fout = 0;
if (!$name || $name == "naam") $name = "";
if (trim ($name) == "")
{ print "<b>Error(s):</b><br><br>\n";
print "- geen naam ingegeven!<br>\n";
$fout = 1;
}
if (!$email || $email == "e mail") $email = "";
else
{ $at = strpos ($email, "@");
$punt = strpos ($email, ".");
if (!$at) $at = "";
if (!$punt) $punt = "";
if ($at == "" || $punt == "")
{ if ($fout == 0) print "<b>Error(s):</b><br><br>\n";
print "- geen geldig email! <i>(u hebt geen geldig email adress gegeven!)</i><br>\n";
$fout = 1;
}
}
if (!$comments || trim ($comments) == "" || $comments == "commentaar")
{ if ($fout == 0) print "<b>Error(s):</b><br><br>\n";
print "restricted Error - u hebt geen commentaar gegeven<br>\n";
$fout = 1;
}else {
$comments = " ".$comments;
}
if (strpos ($comments, "search") or strpos ($comments, "sex") or strpos ($comments, "6X") or strpos ($comments, "SEX") or strpos ($comments, "drugshop") )
{ print "restricted Error Geen kwaadwiligen<br>\n";
print "<META HTTP-EQUIV=Refresh CONTENT='0; URL=/error/traceer.php?ip=".$ip."'>";
$fout = 1;
}
if (strpos ($comments, "ripstore")or strpos ($comments, "netstreamsol"))
{ print "restricted Error <br>\n";
$fout = 1;
}
if (strpos ($comments, "htm") or strpos ($comments, "http") or strpos ($comments, "a href"))
{ print "restricted Error geen linken plaatsen <br>\n";
$fout = 1;
}
if (strpos ($comments, "cheap hotel"))
{ print "restricted Error dit is geen advertentiesite.<br>\n";
$fout = 1;
}
if ($fout==1)
{ print "<br><input class=\"ibb\" type='button' id='button' onClick='javascript:history.go(-1)' value=' Return '>\n";
print "</html>\n";
exit;
}
// EINDE CONTROLE OP INVOER
$name = trim ($name);
$email = trim ($email);
$comments = trim ($comments);
$datum = date("l j F Y");
if ($email == "") $from = $name;
else { $from = "<a href=\"mailto:".$email."\">".$name."</a>"; }
if (is_file($file) && (filesize($file)>0))
{ $t_file = fopen ($inifile,'w');
fputs ($t_file, "<div id=commentaar> <img src=/layout/".$pic.">By <b>");
fputs ($t_file, $from.", ".$datum.".</b>\n");
fputs ($t_file, $comments."\n");
fputs ($t_file, "</div><hr noshade size=\"1\" color=\"#FFFFCC\">");
$gbfile = fopen ($file,'r');
while (!feof($gbfile))
{ $gbline = fgets($gbfile,1024);
fputs ($t_file, $gbline);
}
fclose ($gbfile);
fclose ($t_file);
if (!copy ($inifile,$file))
{ print "<br><input class=\"ibb\" type='button' id='button' onClick='javascript:history.go(-1)' value=' Return '>\n";
print "</html>\n";
exit;
}
if (!unlink ($inifile))
{ print "<br><input class=\"ibb\" type='button' id='button' onClick='javascript:history.go(-1)' value=' Return '>\n";
print "</html>\n";
exit;
}
}
else
{ $gbfile = fopen ('$file','w');
fputs ($gbfile, $comments."\n");
fputs ($gbfile, $from."\n");
fclose ($gbfile);
}
print "$name,<br>\n";
print "<br>\n";
print "Dank u.<br>\n";
}
?>