本帖最后由 xinxin8816 于 2010-9-29 15:08 编辑
没想到这个帖子半个月也没掉,我在这更新下,资源占用,稳定,安全都有提高。
根据discuz!的会员UID上线,或批量注册、增加游客数、增加最高访问
本人推荐小站使用,想免费吧这样大的论坛就不需要了,因为这个插件会严重增加服务器负担,极易出现服务器500错误
V1.0 Beta 默认设置内存使用:100M-500M CPU:10-50%(设置数值越高,服务器压力越大)
V1.1 Beta 默认设置内存使用:50M-200M CPU:5-20%(设置数值越高,服务器压力越大)
务必先备份论坛数据
具体使用方法见附件,请将以下代码原样复制,少一个回车都有可能造成无法使用
代码见下:- // 虚拟在线会员+游客 V1.1 Beta
- //Powered by xinxin_8816
- $virtualhack = '1'; // 1=开 0=关
- if($virtualhack=='1') {
- $mintime = 100; // 在线的最小值(秒)
- $maxtime = 600; // 在线的最大值(秒)
- $dis_time = 610; // 超过dis_time(秒)删除
- $current_user = 10; // 当前用户少于10,就执行虚拟用户
- $min_user = 50; // 设定想增加多少会员的最小值
- $max_user = 200; // 设定想增加多少会员的最大值
- $min_guest = 10; // 设定想增加多少访客的最小值
- $max_guest = 50; // 设定想增加多少访客的最大值
- $start_uid = 3; // 起始会员UID
- $end_uid = 1000; // 结束会员UID
- $action_arr = array("0","0","1","1","2","191","1","2","2","2","31","51"); //设定虚拟用户允许动作
- $current = time();
- $current_different = $current - $dis_time;
- $db -> query("DELETE FROM {$tablepre}sessions WHERE ip1='000' AND lastactivity <='$current_different'");
- $query = $db -> query("SELECT COUNT(*) FROM {$tablepre}sessions ");
- $onlineuser = $db -> result($query, 0);
- if($onlineuser <= $current_user ) {
- $randguest = mt_rand($min_guest, $max_guest); //游客
- $randuser = mt_rand($min_user, $max_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++) {
- $randtime = mt_rand($mintime, $maxtime);
- $onlinetime = $current - $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)){
- $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++) {
- $randtime = mt_rand($mintime, $maxtime);
- $onlinetime = $current - $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')");
- }
- }
- }
- //Powered by xinxin_8816
复制代码 【V1.0 收费下载】 (←有钱在这里下载)
【V1.0 免费下载】 (←没钱在这里下载)
虚拟在线插件.rar (1.25 KB)
【V1.1 beta 下载】(NEW!)
虚拟在线插件 V1.1 beta.rar (1.30 KB)
|