// TextGUESTBOOK version 1.0, free for none commercial use
//
// Features:
// 0. no db required
// 1. spam control
// 2. secure admin
// 3. simple
// 4. auto archive
$mypwd="freeke"; //so, contents is secure
$my_access_code="Camera"; //Prevent spam bot
$order=1; //try $order=0 :)
$maxmsgs=5; //max message per page
$maxpage=10; //max pages, old pages auto rename to old.date
//--------------------CSS style-------------------------//
$header='
home - guestbook
The Brownie Camera Page Guestbook
To protect commentors and stop spammers, the guestbook is now code protected and email is eliminated.
';
////////////////////////////////////update below at your own risk :)//////////////////////////////////////////////////
$uri=$_SERVER['HTTP_URI'];
$ref=$_SERVER['HTTP_REFERER'];
$dir = dirname(__FILE__) . "/d" ;
$p = $_GET['p'];
$edit = $_GET['edit'];
if ( $edit != '' ) {
$edit = "
Password Required
";
$pwd=$_POST['pwd'];
if ( $pwd == $mypwd ) {
if ( !isset($p) || $p == '' )
$p=0;
else
$p=preg_replace("/\#.*/",'',$p);
$m=$_POST['m'];
$submit=$_POST['submit'];
if ( isset($m) ) {
if ( preg_match("/delete/i",$submit) ) {
unlink("$dir/$p");
$ref=preg_replace("/\?.*/","",$ref);
header("Location: $ref");
} else {
file_put_contents("$dir/$p",$m);
$ref=preg_replace("/edit=[^&]*/","",$ref);
header("Location: $ref");
}
} else {
$m = file_get_contents("$dir/$p");
$i=0;
if ($dh= opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ( preg_match("/old/",$file ) ) {
$olds[$i]=$file;
$i++;
}
}
closedir($dh);
}
if ( $i > 0 ) {
sort($olds);
$old = "\n
Old Messages";
if ( $i > 23 )
$olds = array_slice($olds,0,23);
foreach ( $olds as $f )
$old .= "- $f
";
}
if ( $i > 23 )
$old .= "- remove to get more
";
$old .= "
";
if ( preg_match("/old/",$p) )
$delete = "
";
$edit = "$old
Editing page: $p
";
echo $header.$title.$edit."
".$footer;
}
exit;
} else {
if ( isset($pwd) )
$edit .= "wrong key";
}
echo $header.$title.$edit."".$footer;
exit;
}
$n=$_POST['n'];
$e=$_POST['e'];
$c=$_POST['c'];
$code=$_POST['code'];
if ( $c != '' && preg_match("/$my_access_code/i",$code) ) {
$c = preg_replace("/","<",$c);
$e = preg_replace("/","<",$e);
$n = preg_replace("/","<",$n);
$id=$_POST['id'];
$file="$dir/0";
if ( $id >= $maxmsgs ) {
$date=date("Yjdhi");
if ( file_exists("$dir/$maxpage") )
rename("$dir/$maxpage","$dir/old.$date");
while($maxpage) {
$maxpage--;
$newpage=$maxpage+1;
if ( file_exists("$dir/$maxpage") )
rename("$dir/$maxpage","$dir/$newpage");
}
$fp=fopen("$dir/0","a+");
fclose($fp);
$id=0;
}
if ( !$id )
$id=0;
$date = date( "F j Y, h:i a");
if ( $n == '' )
$n = "Anonymous";
if ( $e != "" )
$m=" \$id=$id; ?>\n";
while($i<$j){
if ($i == $p )
$navp .="
";
else
$navp .="
";
$i++;
}
if ( $p && file_exists("$dir/$p")){
echo $header.$title.$navp;
include "$dir/$p";
}else{
if ( file_exists("$dir/0") ){
echo $header.$title.$navp;
include "$dir/0";
$id++;
} else {
$fp=fopen("$dir/0","a+");
$empty=" \$id=0; ?>\n
New guestbook
\n
Congratulation! Here's your brand new guestbook.
Default password is \"123\".
\n";
$empty.="
By default, each page will hold 10 guest entries, and keep total of 18 pages visitable for public. That's 180 messsage total.
\n";
$empty.="
All these numbers including the password and access code can be easily changed at the beginning of this script.
\n";
$empty.="
Please sign my guestbook.
\n";
fwrite($fp,$empty);
fclose($fp);
echo "
Please wait...
or check the permision of your data directory. (chmod 777 $dir)";
exit;
}
}
}
$form = "
".$footer;
?>