include ("footer.html");
break;
case "add_form":
?>
Sign the Guestbook
">
Your Guestbook Entry:
break;
case "add":
if (!empty($_POST)) {
if (isset($_POST["vname"])) {
$vname = $_POST["vname"];
if (strlen($vname) > 70) $vname = substr($vname,0,70);
}
if (isset($_POST["vemail"])) {
$vemail = $_POST["vemail"];
if (strlen($vemail) > 100) $vemail = substr($vemail,0,100);
}
if (isset($_POST["vurl"])) {
$vurl = $_POST["vurl"];
if (strlen($vurl) > 150) $vurl = substr($vurl,0,150);
}
if (isset($_POST["vstate"])) {
$vstate = $_POST["vstate"];
if (strlen($vstate) > 50) $vstate = substr($vstate,0,50);
}
if (isset($_POST["vcity"])) {
$vcity = $_POST["vcity"];
if (strlen($vcity) > 70) $vcity = substr($vcity,0,70);
}
if (isset($_POST["vcountry"])) {
$vcountry = $_POST["vcountry"];
if (strlen($vcountry) > 50) $vcountry = substr($vcountry,0,50);
}
if (isset($_POST["testingbot"])) {
$testingbot = $_POST["testingbot"];
if (strlen($testingbot) > 10) $testingbot = substr($testingbot,0,10);
}
if (isset($_POST["vcomment"])) $vcomment = $_POST["vcomment"];
} else if (!empty($HTTP_POST_VARS)) {
if (isset($HTTP_POST_VARS["vname"])) {
$vname = $HTTP_POST_VARS["vname"];
if (strlen($vname) > 70) $vname = substr($vname,0,70);
}
if (isset($HTTP_POST_VARS["vemail"])) {
$vemail = $HTTP_POST_VARS["vemail"];
if (strlen($vemail) > 100) $vemail = substr($vemail,0,100);
}
if (isset($HTTP_POST_VARS["vurl"])) {
$vurl = $HTTP_POST_VARS["vurl"];
if (strlen($vurl) > 150) $vurl = substr($vurl,0,150);
}
if (isset($HTTP_POST_VARS["vcity"])) {
$vcity = $HTTP_POST_VARS["vcity"];
if (strlen($vcity) > 70) $vcity = substr($vcity,0,70);
}
if (isset($HTTP_POST_VARS["vstate"])) {
$vstate = $HTTP_POST_VARS["vstate"];
if (strlen($vstate) > 50) $vstate = substr($vstate,0,50);
}
if (isset($HTTP_POST_VARS["vcountry"])) {
$vcountry = $HTTP_POST_VARS["vcountry"];
if (strlen($vcountry) > 50) $vcountry = substr($vcountry,0,50);
}
if (isset($HTTP_POST_VARS["testingbot"])) {
$testingbot = $HTTP_POST_VARS["testingbot"];
if (strlen($testingbot) > 50) $testingbot = substr($testingbot,0,50);
}
if (isset($HTTP_POST_VARS["vcomment"])) $vcomment = $HTTP_POST_VARS["vcomment"];
}
if (ereg("silvia-online",$vemail) or ereg("silvia-online",$vurl)){
echo "
Error!
Your entry has been blocked by this server.";
exit;
}
if (trim($vname)=="" or trim($vcity=="") or trim($vstate=="") or trim($vcomment=="") or trim($vemail)=="") {
echo "
Error!
You may left some fields. Please click
here and try again.
";
exit;
}
if ($testingbot != "byebot") {
echo "
Error!
The code word you typed is incorrect!
Please click here
and try again.";
exit;
}
if (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]+$", $vemail)) {
list ($userName, $mailDomain) = split("@", $vemail);
if (!checkdnsrr($mailDomain, "MX")){
echo "
Error !
The email address:
$vemail
is INVALID
Please click here and try again.";
exit;
}
}
else{
echo "
Error !
The email address:
$vemail
is INVALID
Please click here and try again.";
exit;
}
if (trim($vurl) <> "") {
if (strtolower(trim($vurl)) <> "http://") {
if (!preg_match ("#^http://[_a-z0-9-]+\\.[_a-z0-9-]+#i", $vurl)) {
echo "
Error !
Invalid URL format.
Please click here and try
again.";
exit;
}
}
}
$test_comment = explode(" ",$vcomment);
$jmltest = count($test_comment);
for ($t=0; $t<$jmltest; $t++) {
if (strlen(trim($test_comment[$t])) > 35) {
echo "
Error!
You've entered some
non-words of excessive string length. Don't abuse this guestbook.
Click here and fix it.";
exit;
}
}
//--only 5000 characters allowed for comment, change this value if necessary
$maxchar = 5000;
if (strlen($vcomment) > $maxchar) $vcomment = substr($vcomment,0,$maxchar)."...";
$idx = date("YmdHis");
$tgl = date("F d, Y - h:i A");
$vname = str_replace("<","",$vname);
$vname = str_replace(">","",$vname);
$vname = str_replace("~","-",$vname);
$vname = str_replace("\"",""",$vname);
$vcity = str_replace("<","",$vcity);
$vcity = str_replace(">","",$vcity);
$vcity = str_replace("~","-",$vcity);
$vcity = str_replace("\"",""",$vcity);
$vcomment = str_replace("<","<",$vcomment);
$vcomment = str_replace(">",">",$vcomment);
$vcomment = str_replace("~","-",$vcomment);
$vcomment = str_replace("\"",""",$vcomment);
$vurl = str_replace("<","",$vurl);
$vurl = str_replace(">","",$vurl);
if (strtoupper($os) == "WIN") {
$vcomment = str_replace("\r\n"," ",$vcomment);
$vcomment = str_replace("\r","",$vcomment);
$vcomment = str_replace("\n","",$vcomment);
} else {
$vcomment = str_replace("\n"," ",$vcomment);
$vcomment = str_replace("\r","",$vcomment);
}
$newdata = "//|~~|$idx|~~|$tgl|~~|$vname|~~|$vemail|~~|$vcomment|~~|$vurl|~~|$vcity|~~|$vstate|~~|$vcountry|~~|?>\n";
$newdata = stripslashes($newdata);
$bagus = true;
$cekdata = file($data_file);
$jmlcekdata = count($cekdata);
if ($jmlcekdata > 0) {
rsort($cekdata);
if ($jmlcekdata > 2) {
$newrow = explode("|~~|",$newdata);
$jmlentry = 0;
for ($c=0; $c<3; $c++) {
$cekrow = explode("|~~|",$cekdata[$c]);
if ($cekrow[4] == $newrow[4] or ($cekrow[3] == $newrow[3] and $cekrow[5] == $newrow[5])) $jmlentry++;
}
if ($jmlentry < 3) $bagus = true; else $bagus = false;
}
}
if ($bagus) {
$tambah = fopen($data_file,"a");
if (strtoupper($os)=="UNIX") {
if (flock($tambah,LOCK_EX)) {
fwrite($tambah,$newdata);
flock($tambah,LOCK_UN);
}
} else fwrite($tambah,$newdata);
fclose($tambah);
//--SEND MAIL
if (strtoupper($notify) == "YES") {
$msgtitle = "New VIPER Guestbook Entry";
$vcomment = str_replace(""","\"",$vcomment);
$vcomment = stripslashes($vcomment);
$vcomment = str_replace(" ","\n",$vcomment);
$msgcontent = "Local time : $tgl\n\nThe addition from $vname:
----------------------------\n\n$vcomment\n\n-----End Message-----";
mail($admin_email,$msgtitle,$msgcontent,"From: $vemail\n");
}
}
echo "
Thank you, your entry has been added.
Please wait...
";
break;
case "del":
$record = file($data_file);
$jmlrec = count($record);
for ($i=0; $i<$jmlrec; $i++) {
$row = explode("|~~|",$record[$i]);
if ($id == $row[1]) {
echo "
Delete record