// Tiny Smart Guest Book (tsgb) version 1.0, free for none commercial use
// http://www.tjgy.com
// info@tjgy.com
// Sat Mar 30 23:54:58 PST 2002
// Version 2.0
// Wed May 1 14:44:51 PDT 2002
// Change the message order from newest to oldest.
//
// Features:
// 0. auto archiving
// 1. multipule pages
//
// Detail:
// Each page can hold up to "$maxmsgs" messages, once this number has been reached,
// a new message files will be created in data directory.
//
// You can define how may pages you want to keep by this "$maxpage" variable. Pages
// greater or older than that number will be auto renamed to "archive.dateformt".
//
// * you may need to download the proper corner clips/images
// * or use the round corner script @http://www.tjgy.com/round_corner/ to generate them
$sitename="http://www.tjgy.com"; //Site Name
$dir="/absolute/path/to/data/dir"; //writable to keep datas for the guestbook
$headc="aacccc"; //define the message head color
$msgc="eeeeee"; //define the message color
$boardc="cccccc"; //define the board color
$maxmsgs=30; //define total messages per page
$maxpage=30; //define total pages, pages great than this numbers will be auto archived
$version="
Tiny Smart Guest Book (tsgb) version 1.0 @ $sitename
";
$style="";
$msgframe1="";
if ($n && $c ) {
$e=str_replace('<','<',$e);
$e=stripslashes($e);
$e=substr($e,0,32);
$n=str_replace('<','<',$n);
$n=stripslashes($n);
$n=substr($n,0,32);
$c=str_replace('<','<',$c);
$c=stripslashes($c);
$c=preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "$1",$c);
$c=eregi_replace("\n",'
',$c);
$file="$dir/0";
if ( $id >= $maxmsgs ) {
$date=date("Yjdhi");
rename("$dir/$maxpage","$dir/archive.$date");
while($maxpage) {
$maxpage--;
$newpage=$maxpage+1;
#echo "rename(\"$dir/$maxpage\",\"$dir/$newpage)";
rename("$dir/$maxpage","$dir/$newpage");
}
}
if ( !$id || $id >= $maxmsgs )
$id=0;
$date = date( "l, F j Y, h:i a");
$m=" \$id=$id; ?>| | | From: $n | Email: $e | $date | top |
| |  | |
| |  | |
\n";
# Version 2 insert the new message at the top
#
$fp = fopen ($file,"r+");
$current = fread($fp,filesize($file));
$current = eregi_replace('<\? \$id=[0-9]*; \?>','',$current);
fseek($fp,0);
fputs($fp,"$m\n$current");
# Version 1 append the new message at the end
#
# $fp = fopen($file,"a");
# fwrite ($fp, $m);
fclose ($fp);
header("Location: ./");
} else {
$i=0;$j=1;
while(1) {
if ( file_exists("$dir/$j") )
$j++;
else
break;
}
$head ="| G u e s t B o o k | page: ";
while($i<$j){
if ($i == $page )
$head .="$i ";
else
$head .="$i ";
$i++;
}
$head .=" | |
";
echo $style;
echo $head;
if ( $page && file_exists("$dir/$page")){
echo $msgframe1;
include "$dir/$page";
echo $msgframe2;
}else{
if ( file_exists("$dir/0") ){
echo $msgframe1;
include "$dir/0";
echo $msgframe2;
$id++;
} else {
$fh=fopen("$dir/0","a+");
fclose($fh);
$id=0;
}
}
$out .="
Your comments, suggestions, feedbacks are wellcome. $sitename
|
";
if ( !$page )
echo $out;
}
echo $version;
?>