Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[补丁] 关于"今日发贴"不准确以及相关错误的解决办法!(已更新1.22)

[复制链接]
muhan 发表于 2006-1-19 18:31:16 | 显示全部楼层 |阅读模式
作者: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
找到
  1. function payment($amount, $orderid) {
复制代码

上面添加
  1. //从0:00开始 by muhan  start
  2. list($thisyear,$thismonth,$thisday) = explode(':',gmdate('Y:m:d',$timestamp + $timeoffset * 3600));
  3. $todaypostcheck = gmmktime(0,0,0,$thismonth,$thisday,$thisyear) - $timeoffset * 3600;  
  4. //end
复制代码

第二步:
修改include/forum.fuc.php
找到
  1. function forumtodayposts(&$forum) {
  2.         $forum['lastpost'] = explode("\t", $forum['lastpost']);
  3.         return $forum['todayposts'] = $GLOBALS['timestamp'] - $forum['lastpost'][2] > 86400 ? 0 : $forum['todayposts'];
  4. }
复制代码

替换成:
  1. /*function forumtodayposts(&$forum) {
  2.         $forum['lastpost'] = explode("\t", $forum['lastpost']);
  3.         return $forum['todayposts'] = $GLOBALS['timestamp'] - $forum['lastpost'][2] > 86400 ? 0 : $forum['todayposts'];
  4. }*/
  5. //获得最后发贴时间 by muhan
  6. function lastposttime(&$forum)        {
  7.         return $forum['lastpost'][2];
  8.         }
  9. //end

  10. function forumtodayposts(&$forum) {
  11.         global $todaypostcheck;
  12.         return $forum['todayposts'] = $forum['lastpost'][2] < $todaypostcheck ? 0 : $forum['todayposts']; //获得今日贴数
  13. }
复制代码

第三步:
修改文件include/post.fuc.php
找到
  1. global $forum, $timestamp, $_DCACHE;
复制代码

替换成:
  1. global $forum, $timestamp, $_DCACHE, $todaypostcheck;
复制代码

找到
  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) {
复制代码

替换成
  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) {
  2.                 if($forum['lastpost'][2] > $todaypostcheck) {//今日发贴从0:00开始 by muhan
复制代码

第四步:
修改文件topicadmin.php
找到第一个:
  1. if($post['dateline'] < $losslessdel) {
  2.                                         $uidarray[] = $post['authorid'];
  3.                                 }
复制代码

后面添加:
  1. elseif($post['dateline'] > $todaypostcheck){
  2.                                         $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts-1 WHERE fid=$fid");//更新今日发贴
  3.                                 }
复制代码



5.然后修改index.php
找到
  1. $threads = $posts = $todayposts = 0;
复制代码

换行添加
  1. $lastposttime = $todayposttemp = 0;//最后一贴时间变量 by muhan
复制代码

找到
  1. if($forum['type'] != 'group') {
  2.                         $threads += $forum['threads'];
  3.                         $posts += $forum['posts'];
复制代码

换行添加
  1.                 $todayposttemp += $forum['todayposts'];//确定是否归零
  2. $forum['lastpost'] = explode("\t", $forum['lastpost']); //by muhan
  3.                         $lastposttime = lastposttime($forum) > $lastposttime ? lastposttime($forum) : $lastposttime;//获得全论坛最后一贴的发布时间 bymuhan
复制代码

找到
  1. if($categories) {
复制代码

上面添加

  1. //0:00时执行此次更新
  2. if($lastposttime < $todaypostcheck  && $todayposttemp != 0){
  3.                 $db->query("UPDATE {$tablepre}forums SET todayposts=0 ");//更新今日发贴
  4.         }
  5. //end
复制代码


小弟能力有限,如有缺陷请提出!!

演示请看:www.javawind.com

[ 本帖最后由 muhan 于 2006-1-22 10:26 编辑 ]

评分

1

查看全部评分

 楼主| muhan 发表于 2006-1-19 18:32:34 | 显示全部楼层
以前修改过的请看下面,没有修改过的请略过此贴,只需按照一楼的修改!!!!!
打开include/forum.fuc.php文件
找到
  1. function forumtodayposts(&$forum) {
  2.         global $todaypostcheck, $db, $tablepre;
  3.         $forum['lastpost'] = explode("\t", $forum['lastpost']);
  4.         if($forum['lastpost'][2] < $todaypostcheck){
  5.                         $db->query("UPDATE {$tablepre}forums SET todayposts=0 WHERE fid=$forum[fid]");//更新今日发贴
  6.                         $forum['todayposts'] = 0;
  7.                 }
  8.         return $forum['todayposts'];
  9. }
复制代码

替换成

  1. //获得最后发贴时间 by muhan
  2. function lastposttime(&$forum)        {
  3.         return $forum['lastpost'][2];
  4.         }
  5. //end

  6. function forumtodayposts(&$forum) {
  7.         global $todaypostcheck;
  8.         return $forum['todayposts'] = $forum['lastpost'][2] < $todaypostcheck ? 0 : $forum['todayposts']; //获得今日贴数
  9. }
复制代码


然后修改index.php
找到
  1. $threads = $posts = $todayposts = 0;
复制代码

换行添加
  1. $lastposttime = $todayposttemp =  0;//最后一贴时间变量 by muhan
复制代码

找到
  1. if($forum['type'] != 'group') {
  2.                         $threads += $forum['threads'];
  3.                         $posts += $forum['posts'];
复制代码

换行添加
  1.                 $todayposttemp += $forum['todayposts'];//确定是否归零
  2. $forum['lastpost'] = explode("\t", $forum['lastpost']); //by muhan
  3.                         $lastposttime = lastposttime($forum) > $lastposttime ? lastposttime($forum) : $lastposttime;//获得全论坛最后一贴的发布时间 bymuhan
复制代码

找到
  1. if($categories) {
复制代码

上面添加

  1. //0:00时执行此次更新
  2. if($lastposttime < $todaypostcheck && $todayposttemp !=0){
  3.                 $db->query("UPDATE {$tablepre}forums SET todayposts=0 ");//更新今日发贴
  4.         }
  5. //end
复制代码

[ 本帖最后由 muhan 于 2006-1-22 10:29 编辑 ]
回复

使用道具 举报

木偶人. 发表于 2006-1-19 18:32:40 | 显示全部楼层
老大今天下午不是发过一篇了吗?这篇呢?
回复

使用道具 举报

 楼主| muhan 发表于 2006-1-19 18:34:11 | 显示全部楼层
不一样
那一篇不全面
没有解决删贴和更新问题
回复

使用道具 举报

freddy 发表于 2006-1-19 18:34:45 | 显示全部楼层
那另外一篇是????????
回复

使用道具 举报

 楼主| muhan 发表于 2006-1-19 18:37:35 | 显示全部楼层
那一篇 是中午发的 中午的时候还没有发现
2.删贴后"今日发帖"不更新的情况.
3."今日发帖"会无限累加的情况.
的问题.
把那篇删了吧 .
一切以这篇为主!!!!
回复

使用道具 举报

uzone02 发表于 2006-1-19 18:53:31 | 显示全部楼层
支持下先!!!
回复

使用道具 举报

chipdog 发表于 2006-1-20 11:37:24 | 显示全部楼层
安装了,没有出现什么错误提示,但现在查看新贴显示 没有符合条件的,不知道明天会不会还是这样!
还有一个疑问,如果装了帖子买卖HACK的话,在第4步修改中,就会有两个地方有

  1. ]if($post['dateline'] < $losslessdel) {
  2.                                         $uidarray[] = $post['authorid'];
  3.                                 }
复制代码

不知道第二个帖子买卖的地方需不需要增加那段代码?
回复

使用道具 举报

fantasy520 发表于 2006-1-20 11:54:11 | 显示全部楼层
啊咧咧咧@@""

Parse error: parse error, unexpected $ in /home/s760502/public_html/efon/include/forum.func.php on line 161


繼續觀察中...
回复

使用道具 举报

踏雪无痕㊣ 发表于 2006-1-20 11:54:30 | 显示全部楼层
什么意思啊?

好不好用的说
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-7 01:13 , Processed in 0.120995 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表