Location: PHPKode > scripts > Piece Of Cake Guestbook > piece-of-cake-guestbook/update_guestbook.php
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Guestbook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Markgreat Free Guestbook">
<meta name="keywords" content="Guestbook, Free Guestbook, Free Guestbook by Markgreat, Markgreat free guestbook">
<META NAME="AUTHOR" CONTENT="hide@address.com">
<META NAME="OWNER" CONTENT="hide@address.com">
<META NAME="RATING" CONTENT="BUSINESS">
<META NAME="REVISIT-AFTER" CONTENT="10 DAYS">
<META NAME="LANGUAGE" CONTENT="EN">
<META NAME="COPYRIGHT" CONTENT="markgreat ltd">
<META NAME="ROBOTS" CONTENT="index,follow">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<style type="text/css">
body { FONT-FAMILY: Arial;
scrollbar-face-color: #000066; scrollbar-shadow-color: #000066;
scrollbar-highlight-color: #000066; scrollbar-3dlight-color: #CCCCFF;
scrollbar-track-color: #000099; scrollbar-arrow-color: #CCCCFF;}
</style>
</head>

<body bgcolor="#000099">
<?php


$MaxMsg = stripslashes($MaxMsg);
$title_show = stripslashes($title_show);
$t_words = stripslashes($t_words);
$d_no = stripslashes($d_no);
$q_policy = stripslashes($q_policy);
$pword = stripslashes($pword);

$error_flag = 1;
echo "&error_flag=$error_flag";

$filename = "pass.txt";
($fp = fopen($filename, "r")) or die ("Cannot open the file - pass.txt - Unable to continue");
$fsize = filesize($filename);
$old_password = fread($fp, ($fsize));
fclose ($fp);
$pword="pass";
if (empty($old_password) or $fsize == 0) {
   //$password = md5($pword);
   $password = $pword;
   ($fp = fopen($filename, "w")) or die ("Cannot open the file - pass.txt - Unable to continue");
   flock ($fp, LOCK_EX);
   fwrite($fp, $password);
   flock ($fp, LOCK_UN);
   fclose ($fp);
} else {
   //if (md5($pword) == $old_password)
   if (($pword) == $old_password)
      {  
         echo "Password verified!";
		       }
         else
      {
          echo "&Status=The password is incorrect";
		  die ("&Status=The password is incorrect");
		  echo "&error_flag=$error_flag";
      }

}

echo "&title_show=$title_show";

$filename = "guest_max.txt";
touch($filename);
if ($MaxMsg < 5) {
   $MaxMsg = 5;
}
($fp = fopen($filename, "w")) or die ("Cannot open the file - guest_max.txt - Unable to continue");
flock ($fp, LOCK_EX);
fwrite($fp, $MaxMsg);
flock ($fp, LOCK_UN);
fclose ($fp);

if (isset ($title_show)){
   if (empty ($title_show)){
   $title_show = "1";
   } else {
// Its set and its not empty - go on.
   }
} else {
$title_show = "1";
}

$filename2 = "./titles";
$filename2 .= "/title";
$filename2 .= $title_show;
$filename2 .= "_1.swf";
($fp2 = fopen($filename2, "r")) or die ("Cannot open the file - titles/titleX_1 - Unable to continue");
$fsize = filesize($filename2);
$titleProgram = fread($fp2, ($fsize));
fclose ($fp2);

$filename3 = "title1";
$filename3 .= "_1.swf";
($fp3 = fopen($filename3, "w")) or die ("Cannot open the file - titleX_1 - Unable to continue");
flock ($fp3, LOCK_EX);
fwrite($fp3, $titleProgram);
flock ($fp3, LOCK_UN);
fclose ($fp3);

$filename2 = "./titles";
$filename2 .= "/title";
$filename2 .= $title_show;
$filename2 .= "_2.swf";
($fp2 = fopen($filename2, "r")) or die ("Cannot open the file - titles/titleX_2 - Unable to continue");
$fsize = filesize($filename2);
$titleProgram = fread($fp2, ($fsize));
fclose ($fp2);

$filename3 = "title1";
$filename3 .= "_2.swf";
($fp3 = fopen($filename3, "w")) or die ("Cannot open the file - titleX_2 - Unable to continue");
flock ($fp3, LOCK_EX);
fwrite($fp3, $titleProgram);
flock ($fp3, LOCK_UN);
fclose ($fp3);

$title_text="&text=$t_words";
$filename4 = "title.txt";
($fp4 = fopen($filename4, "w")) or die ("Cannot open the file - title.txt - Unable to continue");
flock ($fp4, LOCK_EX);
fwrite($fp4, $title_text);
flock ($fp4, LOCK_UN);
fclose ($fp4);

// "Delete" a message - ie replace the text part of it
   if (empty ($d_no)){
   $d_no = "nodelete";
   } else {


$today = date("d/M/Y");
$phpVars = "&ContactEmail= ";
$phpVars .= "&ContactName=withdrawn";
$phpVars .= "&email_show=0";
$phpVars .= "&WebSite= "; 
$phpVars .= "&textarea_desc=Private Message";
$phpVars .= "&today=$today";

$filename3 = "$guest_next";
$filename3.="guest_book.txt";
touch($filename3);
($fp3 = fopen($filename3, "w")) or die ("Cannot open the file - guest_book.txt - Unable to continue");

flock ($fp3, LOCK_EX);
fwrite($fp3, $phpVars);
flock ($fp3, LOCK_UN);
fclose ($fp3);
}

$error_flag = 0;
echo "&error_flag=$error_flag";
$phpVars = "&ContactEmail=$ContactEmail";
$phpVars .= "&ContactName=$ContactName";
$phpVars .= "&email_show=$email_show";
$phpVars .= "&WebSite=$WebSite"; 
$phpVars .= "&textarea_desc=$textarea_desc";
$phpVars .= "&today=$today";

$filename3 = "$d_no";
$filename3.="guest_book.txt";
($fp3 = fopen($filename3, "w")) or die ("Cannot open the file - guest_book.txt - Unable to continue");
/*{
   die ("Cannot open the file - guest_book.txt - Unable to continue");
   $error_flag=1;
}*/
flock ($fp3, LOCK_EX);
fwrite($fp3, $phpVars);
flock ($fp3, LOCK_UN);
fclose ($fp3);

//$phpVars = "&guest_next=$guest_next";
//$phpVars .= "&guest_max=$guest_max";
//$filename4 = "flash_next.txt";
//touch($filename4);
//($fp4 = fopen($filename4, "w")) or die ("Cannot open the file - flash_next.txt - Unable to continue");
//fwrite($fp4, $phpVars);
 echo "&dummy=dummy";
 
?>

</body>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
</html>
Return current item: Piece Of Cake Guestbook