关于"今日发贴"不准确以及相关错误的解决办法
作者:muhan修改难度:中
修改文件:include/common.inc.php, include/forum.fuc.php, include/post.fuc.php, topicadmin.php ,index.php
支持论坛:http://www.javawind.com
演示论坛:http://www.javawind.com
[color=red]注:只会在每天的0:00第一个打开首页的人才会增加一次数据库查询[/color]
解决的问题有:
1.准确显示当天"今日发帖",从每天的0:00开始统计.
2.解决删贴后"今日发帖"不更新的情况.
3.解决"今日发帖"会无限累加的情况.
第一步:
修改include/common.inc.php
找到
[code]function payment($amount, $orderid) {[/code]
上面添加
[code]//从0:00开始 by muhan start
list($thisyear,$thismonth,$thisday) = explode(':',gmdate('Y:m:d',$timestamp + $timeoffset * 3600));
$todaypostcheck = gmmktime(0,0,0,$thismonth,$thisday,$thisyear) - $timeoffset * 3600;
//end
[/code]
第二步:
修改include/forum.fuc.php
找到
[code]function forumtodayposts(&$forum) {
$forum['lastpost'] = explode("\t", $forum['lastpost']);
return $forum['todayposts'] = $GLOBALS['timestamp'] - $forum['lastpost'][2] > 86400 ? 0 : $forum['todayposts'];
}
[/code]
替换成:
[code]/*function forumtodayposts(&$forum) {
$forum['lastpost'] = explode("\t", $forum['lastpost']);
return $forum['todayposts'] = $GLOBALS['timestamp'] - $forum['lastpost'][2] > 86400 ? 0 : $forum['todayposts'];
}*/
//获得最后发贴时间 by muhan
function lastposttime(&$forum) {
return $forum['lastpost'][2];
}
//end
function forumtodayposts(&$forum) {
global $todaypostcheck;
return $forum['todayposts'] = $forum['lastpost'][2] < $todaypostcheck ? 0 : $forum['todayposts']; //获得今日贴数
}
[/code]
第三步:
修改文件include/post.fuc.php
找到
[code]global $forum, $timestamp, $_DCACHE;[/code]
替换成:
[code]global $forum, $timestamp, $_DCACHE, $todaypostcheck;[/code]
找到
[code]if($forum['lastpost'][2] > $timestamp - gmdate('G', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 3600 - gmdate('i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 60 - gmdate('s', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 1) {
[/code]
替换成
[code]//if($forum['lastpost'][2] > $timestamp - gmdate('G', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 3600 - gmdate('i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 60 - gmdate('s', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) * 1) {
if($forum['lastpost'][2] > $todaypostcheck) {//今日发贴从0:00开始 by muhan
[/code]
第四步:
修改文件topicadmin.php
找到第一个:
[code]if($post['dateline'] < $losslessdel) {
$uidarray[] = $post['authorid'];
}
[/code]
后面添加:
[code]elseif($post['dateline'] > $todaypostcheck){
$db->query("UPDATE {$tablepre}forums SET todayposts=todayposts-1 WHERE fid=$fid");//更新今日发贴
}
[/code]
5.然后修改index.php
找到
[code]$threads = $posts = $todayposts = 0;[/code]
换行添加
[code]$lastposttime = $todayposttemp = 0;//最后一贴时间变量 by muhan[/code]
找到
[code]if($forum['type'] != 'group') {
$threads += $forum['threads'];
$posts += $forum['posts'];
[/code]
换行添加
[code] $todayposttemp += $forum['todayposts'];//确定是否归零
$forum['lastpost'] = explode("\t", $forum['lastpost']); //by muhan
$lastposttime = lastposttime($forum) > $lastposttime ? lastposttime($forum) : $lastposttime;//获得全论坛最后一贴的发布时间 bymuhan
[/code]
找到
[code]if($categories) {[/code]
上面添加
[code]//0:00时执行此次更新
if($lastposttime < $todaypostcheck && $todayposttemp != 0){
$db->query("UPDATE {$tablepre}forums SET todayposts=0 ");//更新今日发贴
}
//end
[/code]
演示请看:[url=http://www.javawind.com/][color=#003366]www.javawind.com[/color][/url] 顶```这似乎有用 我改了怎么不行哦?
把他的by muhan去掉就不行??:')
页:
[1]