作者: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
注:只会在每天的0:00第一个打开首页的人才会增加一次数据库查询
解决的问题有:
1.准确显示当天"今日发帖",从每天的0:00开始统计.
2.解决删贴后"今日发帖"不更新的情况.
3.解决"今日发帖"会无限累加的情况.
第一步:
修改include/common.inc.php
找到
- function payment($amount, $orderid) {
复制代码
上面添加
- //从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
复制代码
第二步:
修改include/forum.fuc.php
找到
- function forumtodayposts(&$forum) {
- $forum['lastpost'] = explode("\t", $forum['lastpost']);
- return $forum['todayposts'] = $GLOBALS['timestamp'] - $forum['lastpost'][2] > 86400 ? 0 : $forum['todayposts'];
- }
复制代码
替换成:
- /*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']; //获得今日贴数
- }
复制代码
第三步:
修改文件include/post.fuc.php
找到
- global $forum, $timestamp, $_DCACHE;
复制代码
替换成:
- global $forum, $timestamp, $_DCACHE, $todaypostcheck;
复制代码
找到
- 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] > $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
复制代码
第四步:
修改文件topicadmin.php
找到第一个:
- if($post['dateline'] < $losslessdel) {
- $uidarray[] = $post['authorid'];
- }
复制代码
后面添加:
- elseif($post['dateline'] > $todaypostcheck){
- $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts-1 WHERE fid=$fid");//更新今日发贴
- }
复制代码
5.然后修改index.php
找到
- $threads = $posts = $todayposts = 0;
复制代码
换行添加
- $lastposttime = $todayposttemp = 0;//最后一贴时间变量 by muhan
复制代码
找到
- if($forum['type'] != 'group') {
- $threads += $forum['threads'];
- $posts += $forum['posts'];
复制代码
换行添加
- $todayposttemp += $forum['todayposts'];//确定是否归零
- $forum['lastpost'] = explode("\t", $forum['lastpost']); //by muhan
- $lastposttime = lastposttime($forum) > $lastposttime ? lastposttime($forum) : $lastposttime;//获得全论坛最后一贴的发布时间 bymuhan
复制代码
找到
上面添加
- //0:00时执行此次更新
- if($lastposttime < $todaypostcheck && $todayposttemp != 0){
- $db->query("UPDATE {$tablepre}forums SET todayposts=0 ");//更新今日发贴
- }
- //end
复制代码
小弟能力有限,如有缺陷请提出!!
演示请看:www.javawind.com
[ 本帖最后由 muhan 于 2006-1-22 10:26 编辑 ] |