正在浏览:   1 名游客


 到底部   前一个主题   下一个主题  [无发表权] 请登录或者注册



记录用户总在线时间的HACK
网站管理员
注册日期:
2004/7/5 23:02
所属群组:
网站管理员
注册会员
帖子: 533
等级: 21; EXP: 27
HP : 101 / 506
MP : 177 / 1747
离线
未完成版.

现在只能记录时间,而不能在其他地方看出来.有时间再把等级也弄进去.

1.运行sql
alter table xoops_users add onlinetime int not null default 0

xoops_ 是你的数据库前缀 默认为xoops
2.修改kernel/online.php

修改 write 函数为


function write($uid, $uname, $time, $module, $ip)
    {
        
$uid = intval($uid);
        if (
$uid > 0) {
            
//$sql = "SELECT COUNT(*) FROM ".$this->db->prefix('online')." WHERE online_uid=".$uid;
            
$sql = "SELECT `online_updated` FROM ".$this->db->prefix('online')." WHERE online_uid=".$uid;
        } else {
            
$sql = "SELECT COUNT(*) FROM ".$this->db->prefix('online')." WHERE online_uid=".$uid." AND online_ip='".$ip."'";
        }
        list(
$count) = $this->db->fetchRow($this->db->queryF($sql));
        if (
$count > 0 ) {
            
$onlinetime = ($time - $count)>0?($time - $count):0;//count is online_updated when uid > 0
            //$sql = "UPDATE ".$this->db->prefix('online')." SET online_updated=".$time.", online_module = ".$module." WHERE online_uid = ".$uid;
            
$sql = "UPDATE ".$this->db->prefix('online').",".$this->db->prefix('users')." SET online_updated=".$time.", online_module = ".$module.", onlinetime = onlinetime + ".$onlinetime." WHERE online_uid = ".$uid." AND uid = ".$uid;
            if (
$uid == 0) {
                
$sql .= " AND online_ip='".$ip."'";
            }
        } else {
            
$sql = sprintf("INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_module) VALUES (%u, %s, %u, %s, %u)", $this->db->prefix('online'), $uid, $this->db->quoteString($uname), $time, $this->db->quoteString($ip), $module);
        }
        if (!
$this->db->queryF($sql)) {
            return
false;
        }
        return
true;
    }


必须打开who's online区块才能统计.

本来修改session.php也能有一样的结果且不用打开who's online也可以统计 但修改这个比较方便就偷懒了~~ :-D

4/6 1:17:22
_________________
泡泡堂
生成PDF文件 打印



 回顶部   前一个主题   下一个主题

 [无发表权] 请登录或者注册



发表回复
账号用户名   密码   登录
*
* = 必填项


可以查看帖子.
不可发帖.
不可回复.
不可编辑自己的帖子.
不可删除自己的帖子.
不可发起投票调查.
不可在投票调查中投票.
不可上传附件.
不可不经审核直接发帖.

[高级搜索]