/*-----------------------------------------------------
COPYRIGHT NOTICE
Copyright (c) 2004 - Ketut Aryadana
All Rights Reserved
Script name : ArdGuest Standard
Version : 1.6
WebSite : http://www.promosi-web.com/script/guestbook
Email : aryasmail@yahoo.com.au
File name : ardguest.php
------------------------------------------------------*/
//--Change the following variables
//Title of your guestbook
$title = "";
//Change "admin" with your own password. It's required when you delete an entry
$admin_password = "dplsgt";
//Enter your email here
$admin_email = "jeroenvanveen@hotmail.com";
//Your website URL
$home = "http://www.veendownunder.nl";
//Send you an email when someone add your guestbook, YES or NO
$notify = "NO";
//Your Operating System
//For Windows/NT user : WIN
//For Linux/Unix user : UNIX
$os = "WIN";
//Maximum entry per page when you view your guestbook
$max_entry_per_page = "20";
//Name of file used to store your entry, change it if necessary
$data_file = "ardgb.dat";
//Maximum entry stored in data file
$max_record_in_data_file = "1000";
//Color & font setting
$background = "FFFFFF";
$table_top = "CC0000";
$table_content_1a = "FFFFFF";
$table_content_1b = "FFFFFF";
$table_content_2a = "FFFFFF";
$table_content_2b = "FFFFFF";
$table_bottom = "0000FF";
$table_border = "000000";
$title_color = "black";
$link = "white";
$visited_link = "black";
$active_link = "black";
$font_face = "verdana";
$message_font_face = "arial";
$message_font_size = "2";
$font_color = "000000";
//-- Don't change bellow this line
if (!empty($_GET)) {
if (isset($_GET["do"])) $do = $_GET["do"];
if (isset($_GET["id"])) $id = $_GET["id"];
if (isset($_GET["page"])) $page = $_GET["page"];
} else if (!empty($HTTP_GET_VARS)) {
if (isset($HTTP_GET_VARS["do"])) $do = $HTTP_GET_VARS["do"];
if (isset($HTTP_GET_VARS["id"])) $id = trim($HTTP_GET_VARS["id"]);
if (isset($HTTP_GET_VARS["page"])) $page = trim($HTTP_GET_VARS["page"]);
}
if (isset($_POST["do"])) $do = $_POST["do"];
else if (isset($HTTP_POST_VARS["do"])) $do = $HTTP_POST_VARS["do"];
if (!isset($PHP_SELF)) {
if (isset($_SERVER["PHP_SELF"])) $PHP_SELF = $_SERVER["PHP_SELF"];
else if (isset($HTTP_SERVER_VARS["PHP_SELF"])) $PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"];
}
if (!isset($do)) $do = "";
else if (preg_match("/\W/",$do)) $do = "";
if (!isset($page) or $page == 0) $page=1;
if (!file_exists($data_file)) {
echo "Error !! Can't find data file : $data_file.
";
exit;
} else {
if ($max_record_in_data_file <> 0) {
$f = file($data_file);
rsort($f);
$j = count($f);
if ($j > $max_record_in_data_file) {
$rf = fopen($data_file,"w");
if (strtoupper($os)=="UNIX") {
if (flock($rf,LOCK_EX)) {
for ($i=0; $i<$max_record_in_data_file; $i++) {
fwrite($rf,$f[$i]);
}
flock($rf,LOCK_UN);
}
} else {
for ($i=0; $i<$max_record_in_data_file; $i++) {
fwrite($rf,$f[$i]);
}
}
fclose($rf);
}
}
}
switch ($do) {
case "":
$record = file($data_file);
rsort($record);
$jmlrec = count($record);
?>
" background link="" vlink="" alink="" topmargin="0" marginheight="0">
">
">(:: ">">Home ::)
Klik ">hier om een bericht achter te laten
|
">
|
$jml_page = intval($jmlrec/$max_entry_per_page);
$sisa = $jmlrec%$max_entry_per_page;
if ($sisa > 0) $jml_page++;
$no = $page*$max_entry_per_page-$max_entry_per_page;
if ($jmlrec == 0) echo "There is no entry yet. | ";
$w = 0; //--Color
for ($i=0; $i<$max_entry_per_page; $i++) {
$no++;
$recno = $no-1;
if (isset($record[$recno])) {
$row = explode("|~~|",$record[$recno]);
if ($w==0) {
$warna = $table_content_1a;
$warna2 = $table_content_1b;
$w=1;
} else {
$warna = $table_content_2a;
$warna2 = $table_content_2b;
$w=0;
}
echo "
$no
|
$row[2]
$row[3] uit $row[5]
|
";
echo "
";
if (trim($row[7])<>"" and trim($row[7])<>"http://") {
if (ereg("^http://", trim($row[7]))) echo " ";
else echo " ";
}
echo " | ";
echo "
";
echo " | ";
echo "
|
";
} //--end if
} //--end for
echo "";
if ($jml_page > 1) {
if ($page <> 1) echo "[Top] "; else echo "[Top] ";
echo "Page # ";
if ($jml_page > 10) {
if ($page < 5) {
$start = 1;
$stop = 10;
} elseif ($jml_page - $page < 5) {
$start = $jml_page - 9;
$stop = $jml_page;
} else {
$start = $page-4;
$stop = $page+5;
}
if ($start <> 1) echo "... ";
for ($p=$start; $p<=$stop; $p++) {
if ($p == $page) echo "$p ";
else echo "$p ";
}
if ($stop <> $jml_page) echo "... ";
echo "of $jml_page ";
} else {
for ($p=1; $p<=$jml_page; $p++) {
if ($p == $page) echo "$p ";
else echo "$p ";
}
}
if ($page <> $jml_page) echo "[Bottom]"; else echo "[bottom]";
} else echo "Pagina #1 van 1";
echo " | ";
?>
|
" SIZE=1>">Ard Guestbook 1.6
break;
case "add_form":
?>
">
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["vcountry"])) {
$vcountry = $_POST["vcountry"];
if (strlen($vcountry) > 50) $vcountry = substr($vcountry,0,50);
}
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["vcountry"])) {
$vcountry = $HTTP_POST_VARS["vcountry"];
if (strlen($vcountry) > 50) $vcountry = substr($vcountry,0,50);
}
if (isset($HTTP_POST_VARS["vcomment"])) $vcomment = $HTTP_POST_VARS["vcomment"];
}
if (trim($vname)=="" or trim($vcomment=="") or trim($vemail)=="") {
echo "Error !
You may left some fields. Please click here and try again.";
exit;
}
if (!preg_match("/([\w\.\-]+)(\@[\w\.\-]+)(\.[a-z]{2,4})+/i", $vemail)) {
echo "Error !
Invalid email address. 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!
Please don't abuse my guestbook. Click here and try again.";
exit;
}
}
//--only 2000 characters allowed for comment, change this value if necessary
$maxchar = 2000;
if (strlen($vcomment) > $maxchar) $vcomment = substr($vcomment,0,$maxchar)."...";
$idx = date("YmdHis");
$tgl = date("F d, Y - H:i");
$vname = str_replace("<","",$vname);
$vname = str_replace(">","",$vname);
$vname = str_replace("~","-",$vname);
$vname = str_replace("\"",""",$vname);
$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);
}
if (preg_match("#<|>|\"\~#",$vcountry)) exit;
if (preg_match("/[^a-z ]/i",$vcountry)) $vcountry = "...";
$newdata = "|~~|$idx|~~|$tgl|~~|$vname|~~|$vemail|~~|$vcountry|~~|$vcomment|~~|$vurl|~~|\n";
$newdata = stripslashes($newdata);
$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 = "Someone signed your guestbook";
$vcomment = str_replace(""","\"",$vcomment);
$vcomment = stripslashes($vcomment);
$vcomment = str_replace("
","\n",$vcomment);
$msgcontent = "Local time : $tgl\n\nThe addition from $vname :\n----------------------------\n\n$vcomment\n\n-----End Message-----";
mail($admin_email,$msgtitle,$msgcontent,"From: $vemail\n");
}
//-----------
echo "Bedankt, je bericht is toegevoegd.
Even geduld...";
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
Delete Confirmation
$row[2] $row[3] from $row[5] $row[4]$row[6]
|
";
break;
}
}
echo "";
break;
case "del2":
if (isset($_POST["pwd"])) $pwd = $_POST["pwd"];
else if (isset($HTTP_POST_VARS["pwd"])) $pwd = $HTTP_POST_VARS["pwd"];
if (isset($_POST["id"])) $id = $_POST["id"];
else if (isset($HTTP_POST_VARS["id"])) $id = $HTTP_POST_VARS["id"];
if (isset($_POST["page"])) $page = $_POST["page"];
else if (isset($HTTP_POST_VARS["page"])) $page = $HTTP_POST_VARS["page"];
if ($pwd <> $admin_password) {
echo "Invalid admin password !
Please wait...";
exit;
}
$record = file($data_file);
$jmlrec = count($record);
for ($i=0; $i<$jmlrec; $i++) {
$row = explode("|~~|",$record[$i]);
if ($id==$row[1]) {
$record[$i] = "";
break;
}
}
$update_data = fopen($data_file,"w");
if (strtoupper($os) == "UNIX") {
if (flock($update_data,LOCK_EX)) {
for ($j=0; $j<$jmlrec; $j++) {
if ($record[$j] <> "") fputs($update_data,$record[$j]);
}
flock($update_data,LOCK_UN);
}
} else {
for ($j=0; $j<$jmlrec; $j++) {
if ($record[$j] <> "") fputs($update_data,$record[$j]);
}
}
fclose($update_data);
echo "Record has been deleted !
Please wait...";
break;
} //--end switch
?>