靖飒大大帮我看下
我已经按照455楼的修改了
还是一样
- <script language="JavaScript">
- if(top.location==window.location) top.location = "postmach.php";
- </script>
- <?
- require './include/common.php';
- if($adminid!=1)exit;
- //参数设置=====================
- $query = $db->query("SELECT * FROM cdb_postmach WHERE style='set'");
- while($dataset = $db->fetch_array($query)){
- $set[$dataset['value']]=$dataset['sside'];
- }
- $thison=$set['thison'];
- $reftime=$set['reftime'];
- $whatis=$set['whatis'];
- $usertime=$set['usertime'];
- $psottime=$set['psottime'];
- $postmachother=$set['other'];
- $fids=$thison?$set['fids']:NULL;
- $tids=$thison?$set['posttid']:NULL;
- $reftime=$reftime+rand(-3,3);
- $moneys=$set['moneys'];
- $moneys=$moneys?"money=money+".$moneys.", ":NULL;
- $whatis=$whatis?"replies<=".$whatis." and ":NULL;
- //参数结束=====================
- $cccc="creditsrequire=0 and";
- //取出FID,TID值
- if (!$fids){
- $fidis=NULL;
- }else{
- $fidis=NULL;
- $fidis = "fid IN (".$fids.") and";
- }
- if (!$tids){
- $tidis=NULL;
- }else{
- $fidis=NULL;
- $tidis=NULL;
- $whatis=NULL;
- $cccc=NULL;
- $tidis = "tid IN (".$tids.") and";
- }
- if($thison){
- $stime=time();
- $dtime=3600*20;#3600=1天, *10表示10天, 意思是机器人只顶10天内的新贴.
- $ltime=$stime-$dtime;
- $timecc="and dateline>$ltime";
- }else{$timecc=NULL;}
- $query = $db->query("SELECT fid, tid, subject, author, replies FROM $table_threads WHERE $fidis $tidis $whatis $cccc closed=0 $timecc ORDER BY rand() DESC LIMIT 1");
- if(!$thread = $db->fetch_array($query))showmessage("对不起, 没有找到符合条件的记录!", "javascript:history.go(-1);");
- //取出发言机器人的名字
- $uptime=$usertime;
- $usertime=time()-$usertime;
- $query = $db->query("SELECT d.*, a.logintime FROM cdb_postmach d LEFT JOIN $table_members a ON a.uid=d.sside WHERE d.style='user' and d.cdate<'$usertime' ORDER BY rand() DESC LIMIT 1");
- if(!$userplay = $db->fetch_array($query))showmessage("对不起, 没有找到可用的参数, 请设置好所有参数后使用!", "javascript:history.go(-1);");
- $upalltime=$uptime*rand(5,20);
- $upmonth=date(n);
- if($lastmonth<$upmonth){
- $upmonthtime=0;
- }else{
- $upmonthtime="onlinemonth+".$upalltime;
- }
- $db->query("UPDATE $table_members SET onlinetime=onlinetime+$upalltime, onlinemonth=$upmonthtime, lastmonth=$upmonth WHERE username='$userplay[value]'");
- if($thison){
- //沙发,板凳,地板的特殊效果
- if($postmachother){
- if($thread['replies']==0){
- $seles="style='onep'";
- }elseif($thread['replies']==1){
- $seles="style='twop'";
- }elseif($thread['replies']==3){
- $seles="style='thrp'";
- }else{
- $seles="style='post' and ( sside='$thread[fid]' or sside='0' )";
- }
- }else{
- $seles="style='post' and ( sside='$thread[fid]' or sside='0' )";
- }
- //取出发言信息
- $posttime=time()-$posttime;
- $query = $db->query("SELECT * FROM cdb_postmach WHERE $seles and cdate<'$posttime' ORDER BY rand() DESC LIMIT 1");
- if(!$postplay = $db->fetch_array($query))showmessage("对不起, 没有找到可用的参数, 请设置好所有参数后使用!", "javascript:history.go(-1);");
- $aslong = "主题:<b>".$thread['subject']."</b><hr>(<font color=red>".$userplay['value']."</font>)回复: ".$postplay['value'];
- //增加机器人发言
- $timeer=time();
- $db->query("INSERT INTO $table_posts (fid, tid, author, authorid, dateline, message, bbcodeoff)
- VALUES ('$thread[fid]', '$thread[tid]', '$userplay[value]', '$userplay[sside]', '$timeer', '$postplay[value]', '0')");
- $db->query("UPDATE $table_threads SET lastpost='$timeer', lastposter='$userplay[value]', views=views+1, replies=replies+1 WHERE tid='$thread[tid]'");
- $db->query("UPDATE $table_forums SET lastpost='".addslashes($thread['subject'])."\t$timestamp\t$userplay[value]', posts=posts+1 WHERE fid='$thread[fid]'", 'UNBUFFERED');
- if ($forum['fup'] && $forum['type'] == 'sub' && !$forum['viewperm']) {
- $db->query("UPDATE $table_forums SET lastpost='".addslashes($thread['subject'])."\t$timestamp\t$userplay[value]' WHERE fid='$forum[fup]'", 'UNBUFFERED');
- }
- machermember($userplay['sside'], $replycredits);
- machersession($userplay['sside'], $userplay['value'], $thread['fid'], $thread['tid']);
- }
- else{
- $aslong = "发言功能为关闭状态, 目前只启动机器人在线功能!刷新速度:".$reftime;
- machersession($userplay['sside'], $userplay['value'], $thread['fid'], $thread['tid']);
- }
- include template('macher');
- //定义机器人在线函数
- function machersession($uids, $userss, $fid, $tid) {
- global $db, $sid, $sessionexists, $timestamp, $onlinehold, $table_sessions, $table_members, $onlineip;
- $ips = explode('.', $onlineip);
- $acti = rand(0,3)<2 ? 3 : 12;
- $query = $db->query("SELECT groupid, styleid, invisible FROM $table_members WHERE uid='$uids'");
- $usergid = $db->fetch_array($query);
- $db->query("DELETE FROM $table_sessions WHERE sid='$uids'");
- $db->query("INSERT INTO $table_sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, action, lastactivity, fid, tid)
- VALUES ('$uids', '$ips[0]', '$ips[1]', '$ips[2]', '$ips[3]', '$uids', '$userss', '$usergid[groupid]', '$usergid[styleid]', '$usergid[invisible]', '$acti', '$timestamp', '$fid', '$tid')");
- if($discuz_uid) {
- $db->query("UPDATE $table_members SET sinew=sinew+1, credit=credit+".intval($logincredits).", lastip='$onlineip', lastvisit=lastactivity, lastactivity=$timestamp WHERE uid='$uids'", 'UNBUFFERED');
- }
- $sessionupdated = 1;
- }
- //机器人发贴加积分,金钱,及升级函数
- function machermember($uidss, $credits) {
- global $db, $table_members, $table_usergroups, $timestamp;
-
- $addcredit = $addpost = $newcredit = $newpost =0;
- if(!$uidss ) return;
- $query = $db->query("SELECT credit FROM $table_members WHERE uid='$uidss'");
- $usercr = $db->fetch_array($query);
- $groupidadd = NULL;
- $newcredit = $usercr['credit'] + intval("$credits");
- if($credits <> 0 && !($newcredit % 10)) {
- $query = $db->query("SELECT groupid FROM $table_usergroups WHERE type='member' AND '$newcredit'>=creditshigher AND '$newcredit'<creditslower");
- $groupidadd = ", groupid='".$db->result($query, 0)."'";
- }
- $db->query("UPDATE $table_members SET $moneys postnum=postnum+1, credit=$newcredit, lastpost='$timestamp' $groupidadd WHERE uid='$uidss'");
- }
- ?>
复制代码 |