// Tiny Smart Guest Book (tsgb) version 1.0simple, free for none commercial use
// http://www.tjgy.com
// info@tjgy.com
// Sat Mar 30 23:54:58 PST 2002
//
// 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".
$sitename="http://www.tjgy.com";//Site name
$dir="/data3/tjin/htdocs/c/d"; //writable to keep datas for the guestbook
$headc="aacccc"; //define the message head color
$msgc="eeeeee"; //define the message color
$boardc="aacccc"; //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="";
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;
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"))
include "$dir/$page";
else{
if ( file_exists("$dir/0") ){
include "$dir/0";
$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;
?>