今日到访 for 2.5
原作者:cnteacher
修改:muhan
1.升级数据库
- ALTER TABLE `cdb_members` ADD `logintime` INT(10) DEFAULT '0' NOT NULL,ADD `periodoftime` INT(10) DEFAULT '0' NOT NULL;
复制代码
2.修改db_mysql.php
找到
- if ($GLOBALS['debug_on']){
- $mtime = explode(' ', microtime());
- $endtime =$mtime[1] + $mtime[0] - $stime;
- $this->queryinfo .=sprintf('<li><b>%1.5f</b> %s<hr size=1 noshadow>', $endtime, $sql);
- $this->querytime += $endtime;
- }
- return $query;
- }
复制代码
下面添加
- function unbuffered_query($sql, $silence = 0) {
- $func_unbuffered_query = @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
- $query = $func_unbuffered_query($sql);
- if(!$query && !$silence) {
- $this->halt('MySQL Query Error', $sql);
- }
- $this->querynum++;
- return $query;
- }
复制代码
3.修改common.php
找到
上面添加
- //今日到访 by cnteacher 分时段详细列表 by DyNE
- list($thisyear,$thismonth,$thisday,$thishour) = explode(':',gmdate('Y:m:d:H',$timestamp + $timeoffset * 3600));
- $todaylogincheck =gmmktime(0,0,0,$thismonth,$thisday,$thisyear) - $timeoffset * 3600;
- if ($discuz_user) {
- $lasthour = gmdate('H',$logintime + $timeoffset * 3600);
- if ($logintime < $todaylogincheck) {
- $periodoftime = 1 << $thishour;
- $db->unbuffered_query("UPDATE $table_members SET logintime='".$timestamp."', periodoftime ='".$periodoftime."' WHERE username='$discuz_user'");
- } elseif ($thishour > $lasthour) {
- $periodoftime = $periodoftime | (1 << $thishour);
- $db->unbuffered_query("UPDATE $table_members SET logintime='".$timestamp."', periodoftime ='".$periodoftime."' WHERE username='$discuz_user'");
- }
- }
- //End
复制代码
找到
前面添加
- m.logintime, m.periodoftime,
复制代码 |