原作者:cnteacher
修改:muhan
如果你是2.0升级用户并且2.0的时候使用过cnteacher的今日到访插件,就不必升级数据库
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,
复制代码
4.上传附件文件到论坛根目录
5.修改header.htm
找到
前面添加
- | <a href="membertoday.php">今日到访</a>
复制代码
6.完成
[ Last edited by muhan on 2005-2-1 at 09:51 ] |