if($_GET["action"]!=1)
{
?>
$boardname="RUIZHINET留言本";
$host="localhost";
$user="root";
$password="";
$database="ruizhi_messageboard";
$pagenum="10";
$admin_name="admin";
$admin_password="admin";
$conn=mysql_connect($host,$user,$password);
mysql_select_db($database,$conn);
?>
if(!$_GET["page"]){
$page=1;
}else{
$page=$_GET["page"];
}
$sql="SELECT id FROM messageboard";
$result=mysql_query($sql,$conn);
$row_num=mysql_num_rows($result);
$page_count=ceil($row_num/$pagenum);
echo "当前共有".$row_num."条留言";
echo " 共分".$page_count."页显示";
echo " 当前为第".$page."页";
?>
if($row_num==0){
echo "暂时没有留言";
}else{
?>
"; echo $offset.". echo base64_decode($row[title])." - ".base64_decode($row[author])." [".date("Y年m月d日",$row[addtime])."] "; if(isset($_SESSION["admin_name"]) && $_SESSION["admin_name"]!=""){ echo "删除 | "; echo "回复"; } echo " |
".base64_decode($row["content"])." |
回复:".date("Y年m月d日",$row3[addtime]); if(isset($_SESSION["admin_name"]) && $_SESSION["admin_name"]!=""){ echo "删除"; } echo " |
".base64_decode($row3[content])." |
if(!$_POST["author"] || !$_POST["content"])
{
echo "n";
echo "你没有填写留言姓名或内容,2秒钟返回首页";
exit();
}else{
$imgflag=0;
function random($length)
{
$hash = 'IMG-';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
echo (double)microtime() * 1000000;
for($i = 0; $i
{
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}
function fileext($filename)
{
return substr(strrchr($filename, '.'), 1);
}
if($_FILES["upfile"]["name"]!=""){
$uploaddir="upfile/";
$type=array("jpg","gif","bmp","jpeg","png");
if(!in_array(strtolower(fileext($_FILES['upfile']['name'])),$type))
{
echo "n";
$text=implode(",",$type);
echo "您只能上传以下类型文件: ",$text,"
";
exit();
}
else
{
$filename=explode(".",$_FILES['upfile']['name']);
do
{
$filename[0]=random(10);
$randname=implode(".",$filename);
$uploadfile=$uploaddir.$randname;
} while(file_exists($uploadfile));
if (move_uploaded_file($_FILES['upfile']['tmp_name'],$uploadfile)){
echo "上传图片成功";
$imgflag=1;
}
else{
echo "上传图片失败!";
$imgflag=0;
}
}
}
$author=base64_encode($_POST["author"]);
$content=base64_encode(ereg_replace("rn","
",htmlspecialchars($_POST["content"])));
$smiles=base64_encode($_POST["smiles"]);
if($_POST["title"]){
$title=base64_encode($_POST["title"]);
}else{
$title=base64_encode("无标题");
}
$addtime=time();
if($imgflag==1){
$photo=base64_encode($randname);
}else{
$photo="NONE";
}
//保存数据
$sql="INSERT INTO messageboard(author,title,smiles,content,photo,addtime) VALUES('$author','$title','$smiles','$content','$photo',$addtime)";
mysql_query($sql,$conn);
echo "n";
echo "谢谢您的留言,2秒钟返回首页";
}
?>
savereply.php:保存回复
if(isset($_SESSION["admin_name"]) && $_SESSION["admin_name"]!="")
{
if(!$_POST["content"])
{
echo "n";
echo "你没有填写回复内容,2秒钟返回首页";
exit();
}else{
$msgid=$_POST["msgid"];
$content=base64_encode(ereg_replace("rn","
",htmlspecialchars($_POST["content"])));
$addtime=time();
//保存数据
$sql="INSERT INTO reply(msgid,content,addtime) VALUES($msgid,'$content',$addtime)";
mysql_query($sql,$conn);
echo "n";
echo "谢谢您的留言,2秒钟返回首页";
}
}
?>
已抢23197个
抢已抢117613个
抢已抢139160个
抢已抢6209个
抢已抢35294个
抢已抢7913个
抢