query("SELECT `id`,`title` FROM `${db_prefix}forumname` ");
while($rxa=$DB->fetch_assoc($rx))
{
$boards.="$rxa[title] ";
}
switch($_GET[action])
{
case 'fix_users_posts':
{
$at=time();
$userid=intval($_GET[userid]);//过滤Id,Neeao
if($_GET[userid]>0) $cont="where `userid`>'$userid'";
else $cont='';
$re=$DB->query("SELECT userid from `${db_prefix}user` $cont order by userid");
while($r=$DB->fetch_assoc($re))
{
$posts=$DB->fetch_one_assoc("SELECT count(*) as total from `${db_prefix}forum` where `create_id`='$r[userid]'");
$postsg=$DB->fetch_one_assoc("SELECT count(*) as total from `${db_prefix}forum` where `create_id`='$r[userid]' and `jinghua`='1'");
$DB->query("update `${db_prefix}user` set `forum_posts`='$posts[total]',`forum_posts_good`='$postsg[total]' where `userid`='$r[userid]'");
if($at+20fetch_one_assoc("select id,bid,jinghua,create_id from `${db_prefix}forum` where `id`='$id'");
deltopcache($r[top_id]);
$DB->query("update `${db_prefix}forum` set lasttime=now() where `top_id`='$r[top_id]' and bid='$r[bid]'");
$DB->query("update `${db_prefix}forumname` set lasttime=now() where `id`='$r[bid]'");
if($r[id]=='') {
redirect("$phparticleurl/forum.php?action=view&id=$id","哦?!");
break;
}
if(GetForumQuanXian($r[bid])!=1) {
gotourl("$phparticleurl/forum.php?action=view&id=$id");
break;
}
if($r[jinghua]==1) $r[jinghua]=0;
else $r[jinghua]=1;
$DB->query("update `${db_prefix}forum` set `jinghua` = '$r[jinghua]' where `id`='$id'");
if($r[jinghua]==1)
$DB->query("update `${db_prefix}user` set `forum_posts_good` =`forum_posts_good`+1 where `userid`='$r[create_id]' limit 1");
else $DB->query("update `${db_prefix}user` set `forum_posts_good` =`forum_posts_good`-1 where `userid`='$r[create_id]' and `forum_posts_good`>0 limit 1");
$DB->query("update `${db_prefix}forumname` set `lasttime`=now() where id='rr[bid]'");
redirect("$phparticleurl/forum.php?action=view&id=$id","已设为精华贴!");
}
case 'go_other_board':
{
$id=intval($_GET[id]);//Neeao
$_GET[bid]=intval($_GET[bid]);
$r=$DB->fetch_one_assoc("SELECT * from `${db_prefix}forum` where `id`='$id'");
deltopcache($r[top_id]);
if(GetForumQuanXian($r[bid])!=1) {
redirect("$phparticleurl/forum.php?action=view&id=$_GET[id]","哦?!");
break;
}
$DB->query("update `${db_prefix}forum` set `bid`='$_GET[bid]' where `top_id`='$r[top_id]'");
$DB->query("DELETE FROM `${db_prefix}cache` WHERE `name` = 'ListCache!'");
$DB->query("update `${db_prefix}forumname` set lasttime=now() where `id`='$_GET[bid]' or `id`='$r[bid]'");
redirect("$phparticleurl/forum.php?action=view&id=$id","转移完成!");
break;
}
case 'fix1':
{
$id=intval($_GET[id]);//Neeao
if($id>0) $cont=" and `id`>'$id'"; else $cont='';
$re=$DB->query("SELECT * from `${db_prefix}forum` where `rid`='0' $cont");
$at=time();
while($r=$DB->fetch_assoc($re)) {
fix($r[id]);
if($at+20fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` WHERE `id`='$id' limit 1");
eval('$forum_css= "'.gettemplate('forum_css').'";');
eval('echo "'.gettemplate('forum_post').'";');
break;
}
case 'SetTop':
{
$id = intval($_GET[id]);//过滤ID,By:Neeao
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` WHERE `id`='$id' limit 1");
$DB->query("update `${db_prefix}forum` set lasttime=now() where `top_id`='$r[top_id]' and bid='$r[bid]'");
if(GetForumQuanXian($r[bid])==0) break;
$DB->QUERY("UPDATE `${db_prefix}forum` SET `top` = IF(`top`='0','1','0') where `id`='$r[id]' limit 1");
$DB->Query("DELETE from `${db_prefix}cache` where `name`='ListCache!' and `d1`='$r[bid]'");
$DB->query("update `${db_prefix}forumname` set `lasttime`=now() where `id`='$r[bid]'");
redirect("$phparticleurl/forum.php?action=list&id=$r[bid]","forum_set_top_ok");
break;
}
case 'sp':
{//将1分支升级为正贴
//$_GET[id]
$id = intval($_GET[id]);//过滤ID,By:Neeao
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` where `id`='$id' and `top_id`!=`id` limit 1");
$DB->query("update `${db_prefix}forum` set lasttime=now() where `top_id`='$r[top_id]' and bid='$r[bid]'");
if($r[id]!='') {
$r[title]=str_replace('Re:','',$r[title]);
$DB->query("update `${db_prefix}forum` set `top_id`='$r[id]',`rid`='0',`title`='$r[title]',`last_relay`=`createtime`,`last_relay_id`=`id` where `id`='$r[id]' limit 1");
fix($r[id]);
fix($r[top_id]);
deltopcache($r[top_id]);
$row=$DB->fetch_one_assoc("SELECT moditime as last_relay,id as last_relay_id from ${db_prefix}forum where `top_id`='$r[top_id]' order by `moditime` desc limit 1");
$DB->query("UPDATE ${db_prefix}forum set `last_relay`='$row[last_relay]',`last_relay_id`='$row[last_relay_id]' where `id`='$r[top_id]' limit 1");
$DB->query("DELETE FROM `${db_prefix}cache` WHERE `name` = 'ListCache!' and `d1`='$r[bid]'");
$DB->query("update `${db_prefix}forumname` set `lasttime`=now() where `id`='$r[bid]'");
}
fix($r[id]);
fix($r[top_id]);
deltopcache($r[id]);
redirect("$phparticleurl/forum.php?action=view&id=$r[id]","forum_split_ok");
break;
}
case 'deletebypassword':
{
//通过一个随机密码删除,随机密码在发贴时生成.
$id = intval($_GET[id]);//过滤ID,By:Neeao
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` WHERE `id`='$id' limit 1");
if($r[id]=='') die('ok!');
//redirect("$phparticleurl/forum.php","ok");
if($r[password]==$_GET[password])
{
$_SESSION[delete]='1';
delcache($r[id]);
deltopcache($r[top_id]);
$DB->query("delete from `${db_prefix}forum` where `id`='$id' limit 1 ");
if($r[top_id]==$r[id])
{
$DB->query("DELETE FROM `${db_prefix}forum` where `top_id`='$r[id]'");//删除所有的跟帖
}
else $DB->query("UPDATE `${db_prefix}forum` SET `rid`='$r[rid]' WHERE `rid`='$r[id]' and `type`='b'");//调整下级贴子的首贴号
$rowa=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum` where `bid`='$r[bid]' and `type`='b' ");
$row=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum` where `bid`='$r[bid]' and `id`=`top_id` and `type`='b'");
$DB->query("UPDATE `${db_prefix}forumname` set `lasttime`=now(),`total` = '$row[total]',`total_all`='$rowa[total]' where `id`='$r[bid]' limit 1");
$DB->query("UPDATE `${db_prefix}user` SET `forum_posts`=`forum_posts`-1 WHERE `userid`='$r[create_id]' and `forum_posts`>0 limit 1");
setre($r[rid]); //从统计此帖上面的贴子数 //递归
$lastrelay=$DB->fetch_one_assoc("SELECT moditime,id from `${db_prefix}forum` where `top_id`='$r[top_id]' order by `id` desc limit 1");
$DB->query("update `${db_prefix}forum` set `last_relay`='$lastrelay[moditime]',`last_relay_id`='$lastrelay[id]' where `top_id`='$r[top_id]' limit 1");
$row=$DB->fetch_one_assoc("SELECT moditime as last_relay,id as last_relay_id from ${db_prefix}forum where `top_id`='$r[top_id]' order by `moditime` desc limit 1");
$DB->query("UPDATE ${db_prefix}forum set `last_relay`='$row[last_relay]',`last_relay_id`='$row[last_relay_id]' where `id`='$r[top_id]' limit 1");
$DB->query("DELETE FROM `${db_prefix}cache` WHERE `name` = 'ListCache!' and `d1`='$r[bid]'");
$DB->query("update `${db_prefix}forum` set lasttime=now() where `top_id`='$r[top_id]' and bid='$r[bid]'");
$posts=$DB->fetch_one_assoc("SELECT count(*) as count from ${db_prefix}forum where `create_id`='$r[create_id]' and `bid`='$r[bid]'");
if($r[id]!=$r[top_id]) {
fix($r[top_id]);
}
gotourl("$phparticleurl/forum.php?action=dels&name_id=$r[create_id]&bid=$r[bid]&title=$r[title]&ip=$r[ip]");
}
die('no!');
break;
}
case 'delete':
{
$id = intval($_GET[id]);//过滤ID,By:Neeao
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` WHERE `id`='$id' limit 1");
if( $_SESSION[delete]!=1 and GetForumQuanXian($r[bid])==0) die('no!');
$DB->query("update `${db_prefix}forum` set lasttime=now() where `top_id`='$r[top_id]' and bid='$r[bid]'");
$DB->query("DELETE FROM `${db_prefix}forum` WHERE `id`='$_GET[id]' limit 1");//删
delcache($r[id]);
deltopcache($r[top_id]);
if($r[top_id]==$r[id])
$DB->query("DELETE FROM `${db_prefix}forum` where `top_id`='$r[id]'");//删除所有的跟帖
else $DB->query("UPDATE `${db_prefix}forum` SET `rid`='$r[rid]' WHERE `rid`='$r[id]' and `type`='b'");//调整下级贴子的首贴号
$rowa=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum` where `bid`='$r[bid]' and `type`='b' ");
$row=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum` where `bid`='$r[bid]' and `id`=`top_id` and `type`='b'");
$DB->query("UPDATE `${db_prefix}forumname` set `lasttime`=now(), `total` = '$row[total]',`total_all`='$rowa[total]' where `id`='$r[bid]' limit 1");
$DB->query("UPDATE `${db_prefix}user` SET `forum_posts`=`forum_posts`-1 WHERE `userid`='$r[create_id]' and `forum_posts` > 0");
setre($r[rid]); //从统计此帖上面的贴子数 //递归
$row=$DB->fetch_one_assoc("SELECT moditime as last_relay,id as last_relay_id from ${db_prefix}forum where `top_id`='$r[top_id]' order by `moditime` desc limit 1");
$DB->query("UPDATE ${db_prefix}forum set `last_relay`='$row[last_relay]',`last_relay_id`='$row[last_relay_id]' where `id`='$r[top_id]' limit 1");
$DB->query("DELETE FROM `${db_prefix}cache` WHERE `name` = 'ListCache!' and `d1`='$r[bid]'");
$DB->query("update `${db_prefix}forum` set `lasttime`=now() where `top_id`='$r[top_id]'");
if($r[id]!=$r[top_id]) {
fix($r[top_id]);
gotourl("$phparticleurl/forum.php?action=view&id=$r[top_id]");
}else gotourl("$phparticleurl/forum.php?action=list&id=$r[bid]");
break;
}
case 'post2':
{
if(get_str($_POST[check])!=$_SESSION[pic_check])
{
redirect("$phparticleurl/forum.php?action=view&id=".$id,"forum_post_ok");
break;
}
if($_SESSION[pauserinfo][usergroupid]==4) eval('$userinfo="'.gettemplate('forum_register').'";');
else $userinfo=$_SESSION[pauserinfo][username];
$name=htmlspecialchars(trim($_POST[name]));
$password=htmlspecialchars(trim($_POST[usrpass]));
$email=htmlspecialchars(trim($_POST[email]));
$_POST[face]=htmlspecialchars(trim($_POST[face]));//将特殊字符转成HTML格式,Neeao
$_POST[forumid]=intval($_POST[forumid]);
$_POST[rid]=intval($_POST[rid]);
if($_SESSION[logined]!=1)
{
if(empty($_POST[name]))
{
$msg="名字不能为空!";
eval('echo "'.gettemplate('forum_repost').'";');
exit();
}
}
if(!empty($_POST[name]))
{
$pass=login($name,$password);
if($pass==0)
{
if(adduser($name,$password,$email))
$pass=login($name,$password);
else
{
$msg="密码不对! ";
eval('echo "'.gettemplate('forum_repost').'";');
exit();
}
}
}
if($_SESSION[logined]==1 or $pass==1)
{
//!是否允许回复
$trans = array(''=>'',''=>'','
'=>'');
$_POST[subject]=htmlspecialchars(trim(strtr($_POST[subject],$trans)));//将特殊字符转成HTML格式,Neeao
if($_POST[subject]=='')
{
$msg="标题不能为空! ";
eval('echo "'.gettemplate('forum_repost').'";');
exit();
}
$_POST[body]=htmlspecialchars(trim(strtr($_POST[body],$trans)));//将特殊字符转成HTML格式,Neeao
if($_POST[emailme]=='on') $_POST[emailme]='1';
else $_POST[emailme]='0';
$rf=$DB->fetch_one_assoc("SELECT `id`,`title` from `${db_prefix}forumname` WHERE `id`='$_POST[forumid]' limit 1");
if($rf[id]=='') {
echo "错误号:232212";
exit();
}
if($_POST[rid]!='' and $_POST[rid]!=0) {
//判断没有任何修改的回复
$rad=$DB->fetch_one_assoc("SELECT `en_relay`,`title` FROM `${db_prefix}forum` WHERE `id`='$_POST[rid]' and `bid`='$_POST[forumid]' limit 1");
if($rad[en_relay]==0) break;
$trains = array("Re:Re:"=>"Re:");
$_POST[subject]=strtr($_POST[subject],$trains);
$trains = array("Re:" => "", "re:" => "","\n"=>"","\r"=>"");
if(strtr($_POST[subject],$trains)==strtr($rad[title],$trains) and $_POST[body]=='') {
echo "怎么也要改2个字,才能发布呀!";
eval('echo "'.gettemplate('forum_repost').'";');
break;
}
}
else $_POST[rid]=0;
$trans=array("15159516554"=>"8888888","1119023008"=>"888888","\n"=>" \n",'441399618'=>'441396618','雨过天晴'=>'3721','njanyue'=>'npanyue','jingxiaoshen'=>'jinxiaoshen','13728147188'=>'13728417188','6170213'=>'61170213','hongshengjt'=>'hongshengit','xinrongjt'=>'xinrongit','13712578558'=>'13712758558','21091822'=>'210191822');
$seedarray =microtime();
srand($seed);
$delpassword =md5(rand()); //直接删除帖子的密码.
$DB->query("INSERT INTO `${db_prefix}forum` (`lasttime`,`rid`,`face`,`ip`,`title`,`msg`,`bid`,`password`,
`create_id`,`create_userid`,`mail_me`,`createtime`,`moditime`,`type`,`act`,`size`,`last_relay`)
VALUES(now(),'".intval($_POST[rid])."','$_POST[face]','$_SERVER[REMOTE_ADDR]','$_POST[subject]','".strtr($_POST[body],$trans)."','$_POST[forumid]','$delpassword',
'".$_SESSION[pauserinfo][userid]."','".$_SESSION[pauserinfo][username]."','$_POST[emailme]','$timenow','$timenow','b','1','".strlen($_POST[body])."','$timenow')");
$id=$DB->insert_id();
$DB->query("update `${db_prefix}user` set `forum_posts`=`forum_posts`+1 where `userid`='".$_SESSION[pauserinfo][userid]."' limit 1");
$re=$DB->query("select user.email,user.username from `${db_prefix}manager` manager,`${db_prefix}user` user where manager.`type`='board' and manager.`sortid`='$_POST[forumid]' and user.userid=manager.userid");
$count=$DB->num_rows($re);
if($count>0)
{
$row=$DB->fetch_assoc($re);
$to=$row[username].'<'.$row[email].'>';
if($count>1)
{
while($row=$DB->fetch_assoc($re))
{
if($bcc!='') $bcc=$bcc.',';
else $bcc='Bcc: ';
$bcc.=$row[username].'<'.$row[email].'>';
}
$bcc.="\r\n";
}
mail($to,'['.$rf[title].']有新贴子了!',"浏览:http://$_SERVER[SERVER_NAME]$phparticleurl/$id.html\r\n发自:".$_SESSION[pauserinfo][username]."\n标题:\r\n$_POST[subject]\r\n发贴ip:$_SERVER[REMOTE_ADDR]\r\n直接删除:http://$_SERVER[SERVER_NAME]$phparticleurl/forum.php?action=deletebypassword&id=$id&password=$delpassword\r\n内容:\r\n$_POST[body]",$bcc."From: 安恒\nContent-Type: text/plain;\n charset=\"UTF-8\"\nX-Mailer: PHP"); //!
}
if(empty($_POST[rid])) {
$DB->query("UPDATE `${db_prefix}forumname` SET lasttime=now(),`total_all`=`total_all`+1,`total`=`total`+1 WHERE `id`='$_POST[forumid]' limit 1");
$DB->query("UPDATE `${db_prefix}forum` SET lasttime=now(),`top_id`=`id` where `id`='$id' limit 1");
deltopcache($id);
}
else {
$rad=$DB->fetch_one_assoc("SELECT top_id FROM `${db_prefix}forum` where `id`='$_POST[rid]'");
$DB->query("UPDATE `${db_prefix}forumname` SET lasttime=now(),`total_all`=`total_all`+1 WHERE `id`='$_POST[forumid]' limit 1");
$DB->query("UPDATE `${db_prefix}forum` SET `top_id`='$rad[top_id]' where `id`='$id' limit 1");
$DB->query("update `${db_prefix}forum` set `lasttime`=now() where `top_id`='$rad[top_id]'");
deltopcache($rad[top_id]);
}
$DB->query("UPDATE `${db_prefix}forum` SET `last_relay_id`='$id',`last_relay`='".date('Y-m-d H:i:s')."' WHERE `id`='$rad[top_id]' limit 1");
//!回帖email
//!回复加1
$rid=$_POST[rid];
$aa=0;
unset($ids);
unset($cc);
unset($to);
do{
$aa++;
if($aa>10) break; //最多10级
if($rid==0) break;
$rad=$DB->fetch_one_assoc("SELECT `title`, `top_id`, `create_id`,`rid`,`mail_me`,`createtime` FROM `${db_prefix}forum` where `id`='$rid' limit 1");
$DB->query("UPDATE `${db_prefix}forum` SET `relaycount`=`relaycount`+1 where `id`='$rid' limit 1");
if($rad[mail_me]==1)
{
$user=$DB->fetch_one_assoc("SELECT username,password,`email`,`userid` FROM `${db_prefix}user` WHERE `userid`='$rad[create_id]' and `mailsend`='0' and `userid`!='$_SESSION[pauserinfo][userid]' limit 1");
// if($email!='') {
// $DB->query("update `${db_prefix}user` set `email`='$email' where `userid`='$_SESSION[pauserinfo][userid]' limit 1");
// $user[email]=$email;
// $pauserinfo[email]=$email;
// $_SESSION[pauserinfo][email]=$email;
// }
if($user[email]!='' and $user[userid]!='')
{
$timea=time();
$DB->query("update `${db_prefix}user` set `mailsend`='1',`sendtime`='".date('Y-m-d H:i:s',$timea)."' where `userid`='$user[userid]' limit 1");
$mailmsg="您的标题:$rad[title] $rad[createtime]
http://$_SERVER[SERVER_NAME]$phparticleurl/forum.php?action=mailview&key=$timea&id=$rid
回复标题:$_POST[subject] ".date('Y-m-d H:i:s')."
http://$_SERVER[SERVER_NAME]$phparticleurl/forum.php?action=mvr&key=$timea&id=$rid&relayid=$id
在您通过上面的地址看帖子之前,将不会再发提醒邮件给您
点击这里取消帖子的订阅
http://$_SERVER[SERVER_NAME]$phparticleurl/forum.php?action=cmm&id=$rid&key=$user[password]
";
mail1('=?utf-8?B?'.base64_encode($user[username]).'?=<'.$user[email].'>',"您在[$rf[title]]的贴子有回复了!",$mailmsg,"安恒","forum@anheng.com.cn"); //!
}
}
if($rid==$rad[rid]) {echo "论坛id循环![$rid] ";break;}
$rid=$rad[rid];
}while($rad[rid]!=0); //有上一级的就循环找。
//清理cache.
$DB->query("DELETE FROM `${db_prefix}cache` WHERE `name` = 'ListCache!' and `d1`='$_POST[forumid]'");
$_SESSION[pic_check]='';
redirect("$phparticleurl/forum.php?action=view&id=".$id,"forum_post_ok");
}
break;
}
case 'post1':
{
redirect("$phparticleurl/forum.php?action=view&id=".$id,"forum_post_ok");
break;
}
case 'old_view':
{
$id = intval($_GET['id']);//强制整形 Neeao
$bid = intval($_GET['bid']);//强制整形 Neeao
$r=$DB->fetch_one_assoc("SELECT `id` from `${db_prefix}forum` where `old_number`='$id'
and `bid`='$bid' limit 1");
echo GetATieZi($r[id]);
exit();
break;
}
case 'mailview':
{
if($_GET[id]=='' or $_GET[key]=='') break;
$_GET[id] = intval($_GET['id']);//强制整形 Neeao
$r=$DB->fetch_one_assoc("select create_id from `${db_prefix}forum` where `id`='$_GET[id]'");
if($r[create_id]=='') break;
$DB->query("update `${db_prefix}user` set `mailsend`='0' where `userid`='$r[create_id]' and `sendtime`='".date('Y-m-d H:i:s',$_GET[key])."' limit 1");
gotourl("$phparticleurl/$_GET[id].html");
break;
}
case 'mvr'://'mailviewrelay':
{
if($_GET[id]=='' or $_GET[key]=='') break;
$_GET[id] = intval($_GET['id']);//强制整形 Neeao
$r=$DB->fetch_one_assoc("select create_id from `${db_prefix}forum` where `id`='$_GET[id]'");
if($r[create_id]=='') break;
$DB->query("update `${db_prefix}user` set `mailsend`='0' where `userid`='$r[create_id]' and `sendtime`='".date('Y-m-d H:i:s',$_GET[key])."' limit 1");
gotourl("$phparticleurl/$_GET[relayid].html");
break;
}
case 'cmm'://'cancel_mail_me':
{
$_GET[id] = intval($_GET['id']);//强制整形 Neeao
$_GET[key] = addslashes($_GET[key]);//过滤关键字 Neeao
if($_GET[id]=='' or $_GET[key]=='') break;
$r=$DB->fetch_one_assoc("select create_id,id from `${db_prefix}forum` where `id`='$_GET[id]'");
if($r[create_id]=='') break;
$user=$DB->fetch_one_assoc("select userid from `${db_prefix}user` where `userid`='$r[create_id]' and password='$_GET[key]'");
if($user[userid]!='')
{
$DB->query("update `${db_prefix}forum` set `mail_me`='0' where `id`='$r[id]' limit 1");
setcookie("pauserid",$user[userid],time()+3600*24*3650);
setcookie("papasswordhash",$_GET[key],time()+3600*24*3650);
}
gotourl("$phparticleurl/$_GET[id].html");
break;
}
case 'view':
{
$_GET[id] = intval($_GET['id']);//强制整形 Neeao
$msg=GetATieZi($_GET[id]);
echo $msg;
exit();
break;
}
case 'list':
{
if(!$_GET[id])
{
$re=$DB->query("SELECT * FROM `${db_prefix}forumname`");
echo "
";
while($r=$DB->fetch_assoc($re))
{
echo "$r[title]($r[total]) ";
}
echo '';
break;
}
//读列表cache
if(substr($_SERVER[HTTP_USER_AGENT],0,4)=='Wget') $_GET[page]=1;
if($_GET[page]=='') $_GET[page]=1;
$_GET[jh] = addslashes($_GET[jh]);//过滤关键字 Neeao
$_GET[id] = intval($_GET[id]);//强制整形 Neeao
$_GET[page] = intval($_GET[page]);//强制整形 Neeao
if($cache=$DB->fetch_one_assoc("SELECT `content` FROM `${db_prefix}cache` WHERE `name`='ListCache!$_GET[jh]' and `d1`='$_GET[id]' and `d2`='$_GET[page]' limit 1"))
{
cachetime($cache[time]);
$moditime=strtotime($cache[time]);
header("Last-Modified: ".gmdate("D, d M Y H:i:s",$moditime)." GMT"); // always modified
header("Expires: ".gmdate("D, d M Y H:i:s",time() + 3600*24*20)." GMT"); // always modified
header("Pragma: ");
echo base64_decode($cache[content]);
break;
}
else
{
$DB->query("delete from `${db_prefix}cache` where `name`='ListCache!$_GET[jh]' and `d1`='$_GET[id]' and `d2`='$_GET[page]' limit 1");
}
$foruminfo=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` where `id`='$_GET[id]'");
cachetime($foruminfo[lasttime]);
$bid=$foruminfo[id];
$_GET[bid]=$bid;
pageft($foruminfo[total],20);
if($jh!='') $jinghua="and `jinghua`='1'";
$re=$DB->Query("SELECT * FROM `${db_prefix}forum` WHERE `bid`='$foruminfo[id]' and `top`='1' and `act`='1' order by `id` DESC");
$forum_line_dings='';
while($r=$DB->fetch_assoc($re))
{
if($r[title]=='') $r[title]='-';
if($forum_line_dings!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
eval('$forum_line_dings.="'.gettemplate('forum_line_ding').'";');
}
$re=$DB->query("SELECT * FROM `${db_prefix}forum` WHERE `bid`='$foruminfo[id]' $jinghua and `rid`='0' and `act`='1' order by `last_relay` DESC limit $firstcount,$displaypg");
$forum_line='';
while($r=$DB->fetch_assoc($re))
{
if($r[title]=='') $r[title]='-';
if($forum_line!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
$forum_line.=GetListTree($r[id],$r[last_relay_id],0,$_GET[jh]);
}
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('$disp= "'.gettemplate('forum_list').'";');
header("Last-Modified: ".gmdate("D, d M Y H:i:s",strtotime($foruminfo[lasttime]))." GMT"); // always modified
header("Expires: ".gmdate("D, d M Y H:i:s",time() + 3600*20)." GMT"); // always modified
header("Pragma: ");
echo $disp;
//写列表cache
$DB->query("REPLACE INTO `${db_prefix}cache` SET `time`='$foruminfo[lastdata]', `content`='".base64_encode($disp)."',`name`='ListCache!$_GET[jh]',`d1`='$_GET[id]',`d2`='$_GET[page]'");
break;
}
case 'fix':
{//整理$_GET[id]一个
$_GET[id]=intval($_GET[id]);//继续过滤 Id Neeao
$r=$DB->fetch_one_assoc("SELECT * from `${db_prefix}forum` where `id`='$_GET[id]' limit 1");
{
fix($r[id]);
deltopcache($r[top_id]);
if($r[bid]>0)
$DB->query("update `${db_prefix}forum` set `bid`='$r[bid]' where `top_id`='$r[top_id]' ");
}
//redirect("$phparticleurl/forum.php?action=view&id=$r[id]","forum_fix_ok");
break;
}
case 'dels':
{
if($_SESSION[delete]!=1) die("no!");
if($_GET[bid]=='') $_GET[bid]=intval($_GET[id]);
if($_GET[name_id]=='') break;
$_GET[name_id]=intval($_GET[name_id]);
$isadmin=GetForumQuanXian($_GET[bid]);
$_GET[ip]=get_str($_GET[ip]);
$_GET[title]=get_str($_GET[title]);
$userfind=" and (`create_id`='$_GET[name_id]' or ip='$_GET[ip]' or title='$_GET[title]') ";
$_GET[bid]=intval($_GET[bid]);
$foruminfo=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` where `id`='$_GET[bid]'");
$r=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum`
where `bid`='$_GET[bid]' and `act`='1' $userfind ");
pageft($r[total],20);
$re=$DB->query("SELECT * FROM `${db_prefix}forum` WHERE `bid`='$_GET[bid]' and `act`='1' $userfind order by `id` DESC limit $firstcount,$displaypg");
$forum_line='';
while($r=$DB->fetch_assoc($re))
{
if($isadmin==1 or $_SESSION[delete]==1) $del="del ";
if($r[create_userid]) $userid=$r[create_userid];
if($forum_line!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
eval('$forum_line.="'.gettemplate('forum_line').'";');
}
if($userid!=''){
$pagenav="[$user[username] 注册时间:".date('Y-m-d',$user[joindate])."]发布的帖子:$pagenav";
$_GET[key]=$userid;
}
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('echo "'.gettemplate('forum_list').'";');
break;
}
case 'user_posts':
{
if($_GET[bid]=='') $_GET[bid]=intval($_GET[id]);
if($_GET[name_id]=='') break;
$_GET[name_id]=intval($_GET[name_id]);
$isadmin=GetForumQuanXian($_GET[bid]);
$userfind=" and `create_id`='$_GET[name_id]'";
$user=$DB->fetch_one_assoc("SELECT * from `${db_prefix}user` where `userid`='$_GET[name_id]'");
$_GET[bid]=intval($_GET[bid]);
$foruminfo=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` where `id`='$_GET[bid]'");
$r=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum`
where `bid`='$_GET[bid]' and `act`='1' $userfind ");
pageft($r[total],20);
$re=$DB->query("SELECT * FROM `${db_prefix}forum` WHERE `bid`='$_GET[bid]' and `act`='1' $userfind order by `id` DESC limit $firstcount,$displaypg");
$forum_line='';
while($r=$DB->fetch_assoc($re))
{
if($isadmin==1 or $_SESSION[delete]==1) $del="del ";
if($r[create_userid]) $userid=$r[create_userid];
if($forum_line!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
eval('$forum_line.="'.gettemplate('forum_line').'";');
}
if($userid!=''){
$pagenav="[$user[username] 注册时间:".date('Y-m-d',$user[joindate])."]发布的帖子:$pagenav";
$_GET[key]=$userid;
}
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('echo "'.gettemplate('forum_list').'";');
break;
}
case 'listbytime':
{
$foruminfo=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` where `id`='$_GET[id]'");
pageft($foruminfo[total_all],20);
$re=$DB->query("SELECT * FROM `${db_prefix}forum` WHERE `act`='1' and `bid`='$_GET[id]'
order by `id` DESC limit $firstcount,$displaypg");
$forum_line='';
while($r=$DB->fetch_assoc($re))
{
for($a=0;$a"$key ");
$r[msg]=strtr($r[msg],$trans);
$r[create_userid]=strtr($r[create_userid],$trans);
$r[title]=strtr($r[title],$trans);
}
if($forum_line!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
eval('$forum_line.="'.gettemplate('forum_line').'";');
}
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('echo "'.gettemplate('forum_list').'";');
break;
}
case 'find':
{ if($_GET[key]=='') break;
$akey=explode(" ",ucmd($_GET[key]));
for($a=0;$a0) $findkey.="and (`create_userid`='$key' or `title` like '%$key%' or `msg` like '%$key%')";
}
//echo $findkey;
$foruminfo=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` where `id`='$_GET[bid]'");
$r=$DB->fetch_one_assoc("SELECT count(id) as total FROM `${db_prefix}forum`
where `bid`='$_GET[bid]' and `act`='1' $findkey ");
pageft($r[total],20);
$pagenav='【搜索结果】:'.$pagenav;
$re=$DB->query("SELECT * FROM `${db_prefix}forum` WHERE `act`='1' and `bid`='$_GET[bid]' $findkey
order by `id` DESC limit $firstcount,$displaypg");
$forum_line='';
while($r=$DB->fetch_assoc($re))
{
for($a=0;$a"$key ");
$r[msg]=strtr($r[msg],$trans);
$r[create_userid]=strtr($r[create_userid],$trans);
$r[title]=strtr($r[title],$trans);
}
if($forum_line!='') eval('$forum_line.="'.gettemplate('forum_line_hr').'";');
eval('$forum_line.="'.gettemplate('forum_line').'";');
}
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('echo "'.gettemplate('forum_list').'";');
break;
}
default:
{
break;
}
}
function GetFaceList()
{
GLOBAL $rootdir,$phparticleurl,$faces,$aline;
$aline--;
$a=0;
while($r=each($faces))
{
if($a%8==0) $FaceAll.='';
$a++;
eval('$FaceAll.="'.gettemplate('forum_view_post_face').'";');
}
return $FaceAll;
}
function fix($id, $top_id = '')
{
global $DB,$db_prefix;
if($id==0) return;
if($top_id=='')
{
$fixlast=1; //最后要fix最后1贴
$top=$DB->fetch_one_assoc("SELECT `top_id` from `${db_prefix}forum` where `id`='$id' limit 1");
if($top[top_id]>0)
$top_id=$top[top_id];
else $top_id=$id;
unset($top);
}
$r=$DB->fetch_one_assoc("SELECT sum(relaycount) as total from `${db_prefix}forum` WHERE `rid`='$id'");
$DB->query("UPDATE `${db_prefix}forum` SET `relaycount`='$r[total]' where `id`='$id' limit 1");
$DB->query("UPDATE `${db_prefix}forum` SET `top_id`='$top_id' where `rid`='$id'"); //更新下级的top_id
$re=$DB->query("SELECT `id` from `${db_prefix}forum` where `rid`='$id'");
if($DB->num_rows($re)>0)
while($row=$DB->fetch_assoc($re))
{
fix($row[id],$top_id);
}
if($fixlast==1)
{
$r=$DB->fetch_one_assoc("SELECT `createtime`,`top_id`,`id` from `${db_prefix}forum` where `top_id`='$top_id' order by id desc limit 1");
$DB->query("UPDATE `${db_prefix}forum` set `last_relay`='$r[createtime]',`last_relay_id`='$r[id]' where `top_id`='$r[top_id]' and `last_relay`<'$r[createtime]' limit 1");
}
return;
}
function setre($id, $top_id = '')
{
//向上统计relaycount
global $DB,$db_prefix;
$r=$DB->fetch_one_assoc("SELECT sum(relaycount) as total from `${db_prefix}forum` WHERE `rid`='$id'");
$DB->query("UPDATE `${db_prefix}forum` SET lasttime=now(),`relaycount`='$r[total]' where `id`='$id' limit 1");
$r=$DB->fetch_one_assoc("SELECT `id`,`rid` from `${db_prefix}forum` WHERE `id`='$id' limit 1");
if ($r['id']==$r['rid']) {
return; //循环
}
if ($r['rid']!==0) {
setre($r['rid'], $top_id);
}
return;
}
function GetForumQuanXian($id = '')
{
//获得当前用户在论坛$bid里面的权限 放进$_SESSION['forumqx'];
global $db_prefix,$DB,$pauserinfo;
if ($_SESSION['pauserinfo']['username']=='admin') {
return 1;
}
if ($_SESSION['pauserinfo']['username']=='anheng') {
return 1;
}
#if($_SESSION['pauserinfo']['username']=='刘世伟') return 1;
$r=$DB->fetch_one_assoc("select * from `${db_prefix}manager` where `sortid`='$id' and `type`='board' and `userid`='".$_SESSION['pauserinfo']['userid']."' limit 1");
if ($r['userid']!='') {
return 1;
}
return 0;
}
function GetATieZi($id)
{
global $DB,$boards,$cachepath,$db_prefix,$pauserinfo,$phparticleurl,$style,$faces,$rootdir;
$cachepatha="$cachepath/forum/".intval($id/3000);
$DB->query("UPDATE `${db_prefix}forum` SET `viewcount`=`viewcount`+1 where `id`='$id'");
if ($pauserinfo['usergroupid']<3 and file_exists("$cachepatha/$id.html")) {
cachetime(filemtime("$cachepatha/$id.html"), 72000);
return file_get_contents("$cachepatha/$id.html");
exit();
}
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` WHERE `id`='$id' limit 1");
if ($r['id']=='') {
gotourl("http://www.anheng.com");
}
#$trans=array("\n"=>" \n",'441399618'=>'441396618','雨过天晴'=>'3721','njanyue'=>'npanyue','jingxiaoshen'=>'jinxiaoshen','13728147188'=>'13728417188','6170213'=>'61170213','hongshengjt'=>'hongshengit');
#$r[body]=strtr($r[body],$trans);
$user=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}user` WHERE `userid`='$r[create_id]' limit 1");
$moditime=strtotime($r[lasttime]);
$_SESSION[lastbid]=$r[bid];
if(GetForumQuanXian($r[bid])==1)
{
eval('$forum_view_delete="'.gettemplate('forum_view_delete').'";');
}
$row=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forumname` WHERE `id`='$r[bid]' limit 1");
if($r[top_id]!=0) $relay=GetListTree($r[top_id],$r[id],0,$_GET[jh]);
if($_SESSION[pauserinfo][usergroupid]==4) eval('$userinfo="'.gettemplate('forum_register').'";');
else $userinfo=$_SESSION[pauserinfo][username];
$trans = array("\n" => "\n:"," "=>"\n:");
// if($r[msg]) $remsg=':'.strtr($r[msg],$trans);
if($r[face]) {
$facesd=$faces[$r[face]];
eval('$face="'.gettemplate('forum_view_face').'";');
}
$FaceAll=GetFaceList();
$ips=explode('.',$r[ip]);
$r[ip]=$ips[0].'.'.$ips[1].'.'.$ips[2].'.*';
eval('$forum_css="'.gettemplate('forum_css').'";');
eval('$result="'.gettemplate('forum_view').'";');
if(!file_exists($cachepatha))
{
mkdir($cachepatha);
chmod($cachepatha,0777);
}
file_put_contents("$cachepatha/$id.html",$result);
chmod("$cachepatha/$id.html",0666);
touch("$cachepatha/$id.html",strtotime($r[lasttime]));
cachetime($r[lasttime]);
return $result;
}
function GetListTree($top_id, $local_id = 0, $jibie = 0, $jh = '') //得到一个列表树
{
global $foruminfo,$db_prefix,$DB,$phparticleurl,$faces;
if($jh!='') $jinghua="and `jinghua`='1'";
$r=$DB->fetch_one_assoc("SELECT * FROM `${db_prefix}forum` WHERE `id`='$top_id' $jinghua and `act`='1' limit 1");
if($r[size]==0) $r[size]='无内容';
else $r[size].='字节';
$forum_line='';
if($r[face]!='' and $r[face]!='0')
{
$facesd=$faces[$r[face]];
eval('$face="'.gettemplate(forum_view_face).'";');
}
if($r[id]==$local_id and $local_id!=$r[top_id]) eval('$forum_line.="'.gettemplate('forum_line_local').'";');
else eval('$forum_line.="'.gettemplate('forum_line').'";');
$re=$DB->query("SELECT `id` FROM `${db_prefix}forum` WHERE `rid`='$top_id' $jinghua and `act`='1' order by 'id' DESC $count");
if($DB->num_rows($re)==0)
{
return $forum_line.' ';
}
$jibie++;
if($jibie>0 and $jibie<10) $forum_line.='';
while($r=$DB->fetch_assoc($re))
{
$forum_line.=GetListTree($r[id],$local_id,$jibie,$jh);
}
if($jibie>0 and $jibie<10) $forum_line.=' ';
return $forum_line.'';
}
function ucmd($get)
{
return(addslashes(htmlspecialchars(trim($get))));
}
function mail1($email, $submit, $msg, $from = '论坛', $fromemail = 'noname@nodomain.com')
{
mail($email,'=?utf-8?B?'.base64_encode($submit).'?=',$msg,"From: =?utf-8?B?".base64_encode($from)."?=<$fromemail>\r\nContent-Transfer-Encoding: 8bit\r\nContent-Type: text/plain; charset=UTF-8"); //!
}
function delcache($id)
{
global $rootdir,$cachepath;
$cachepatha="$cachepath/forum/".intval($id/3000);
$file=$cachepatha.'/'.$id.'.html';
if(file_exists($file)) unlink($file);
}
function deltopcache($top_id)
{
global $DB,$db_prefix;
$top_id=intval($top_id);
$re=$DB->query("select id from ${db_prefix}forum where top_id='$top_id'");
while($a=$DB->fetch_assoc($re)) delcache($a[id]);
}
?>