秋刀鱼设计

团队专业网站建设、品牌产品推广服务

@helosh15年前

2009/08/07
16:08 星期五
代码猿

虚拟论坛在线人数和会员

曾经也介绍过虚拟发贴数量,大家怎么用我就不说了,大家自各看着办。在6.0开始大家就知道这样的方法,现在已经到了7.1了,以前是修改index.php。
现在修改/include/index_classics.inc.php
查找

$discuz_action = 1;

//    虚拟在线会员+游客 START  
//=========================================================================================



$virtualhack = 1; //1开 0关

if ($virtualhack == 1) {

        $randtime = mt_rand(51, 486); //在线的最小, 最大值(秒)

        $visttime = 900; //虚拟在线时间(秒)

        $current_user = 50; // 当前用户少于30,执行虚拟

        $randuser = mt_rand(3, 20); //列出会员值

        $randguest = mt_rand(20, 100); //列出游客值

        $start_uid = 3000; //起始uid

        $end_uid = 3500; //结束uid

        $action_arr = array(0, 0, 1, 1, 2, 1, 2, 2, 2, 31, 51, 41); //虚拟用户允许动作

        $current_different = $timestamp - $visttime;

        $db->query("DELETE FROM {$tablepre}sessions WHERE ip1='000' AND lastactivity<='$current_different'"); //超时清除在线

        $havuid = array();

        $onlineuser = 0;

        $query = $db->query("SELECT uid FROM {$tablepre}sessions");

        while($row = $db->fetch_array($query)){

                $havuid[] = $row['uid'];

                $onlineuser++;

        } //取得当前在线以避免重复显示

        if ($onlineuser <= $current_user ) {

                $query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='forum'");

                while($fidresult = $db->fetch_array($query)) {

                        $fidscope[] = $fidresult['fid']; 

                }

                for($i = 1; $i <= $randuser; $i++) { // 随机插入会员

                        $onlinetime = $timestamp - $randtime;

                        $randaction = mt_rand(0, count($action_arr));

                        $onlineaction = $action_arr[$randaction];

                        $onlinefid = 0;

                        if($onlineaction == 2) {

                                $randfid = mt_rand(0, count($fidscope));

                                $onlinefid = $fidscope[$randfid];

                        }

                        $online_sid = random(6);

                        $rand_uid = mt_rand($start_uid, $end_uid);

                        $query = $db->query("SELECT `uid`,`username` FROM {$tablepre}members WHERE `uid`='$rand_uid'");

                        while($row = $db->fetch_array($query)){

                                if (!in_array($row['uid'], $havuid)) {//避免在线会员重复

                                        $db->query("INSERT INTO {$tablepre}sessions (sid,ip1, groupid, styleid, lastactivity, action, fid, uid, username) 

                                        VALUES ('$online_sid', 000, 10, 1, '$onlinetime', '$onlineaction', '$onlinefid', '$row[uid]', '$row[username]')");

                                }

                        }

                }

                for($i = 1; $i <= $randguest; $i++) { // 随机插入游客

                        $onlinetime = $timestamp - $randtime;

                        $randaction = mt_rand(0, count($action_arr));

                        $onlineaction = $action_arr[$randaction];

                        $onlinefid = 0;

                        if($onlineaction == 2) {

                                $randfid = mt_rand(0,count($fidscope));

                                $onlinefid = $fidscope[$randfid];

                        }

                        $online_sid = random(6);

                        $db->query("INSERT INTO {$tablepre}sessions (sid,ip1, groupid, styleid, lastactivity, action, fid) 

                                VALUES ('$online_sid', 000 , 7, 1, '$onlinetime', '$onlineaction', '$onlinefid')");

                }

        }

}

//    虚拟在线会员+游客     END
//=========================================================================================

虚拟论坛在线人数和会员