<?php
include('sys.php');
if($name==""||$text=="")
{
print("错误！，你没有写名字或内容，请返回!");
echo "<meta http-equiv=Refresh content=1;url=javascript:history.back(1)>";
}
else
{
$mail=htmlspecialchars($mail);$mail=StripSlashes($mail);

$name=htmlspecialchars($name);$name=StripSlashes($name);$name=safe_convert($name);

$text=StripSlashes($text);$text=safe_convert($text);


$filelists=file("gb/list.php");
$count=count($filelists);
$count--;
$filelist=$filelists[$count];
$number=$filelist;
$filecount=$number+1;
$filename="gb/id_$filecount";
writetofile("$filename","$name||$mail||$homepage||$text||$ip||$oicp||$face||".date( "Y.m.d H:i:s"."\n" ));
$count=$filecount;
writetofile("gb/list.php","$count"."\n");
echo"感谢你的留言！系统正在返回.....";
echo "<meta http-equiv=Refresh content=2;url=index.php>";
}

function writetofile($filename,$book)
{
$fd=fopen("$filename","a+");
fwrite($fd,$book);
fclose($fd);
}

function getfromlist($file)
{
$fp=fopen("$file","a+");
$list=fgets($fp,5);
fclose($fp);
return $list;
}

function safe_convert($d) {
  $d = str_replace("\t","",$d);
  $d = str_replace("<","&lt;",$d);
  $d = str_replace(">","&gt;",$d);
  $d = str_replace("\r","<br>",$d);
  $d = str_replace("\n","",$d);
  $d = str_replace("|","│",$d);
  $d = str_replace("  "," &nbsp;",$d);
  return $d;
}
?>


