大米CMS官网论坛,大米站长联盟,大米站长之家,大米开发者社区

 找回密码
 注册大米会员

QQ登录

只需一步,快速开始

查看: 6980|回复: 0
打印 上一主题 下一主题

[原创]Discuz社区如何将当天发帖量改为7天内发帖量?

[复制链接]

498

主题

775

帖子

7645

积分

超级版主

Rank: 8Rank: 8

积分
7645

授权用户

跳转到指定楼层
楼主
发表于 2018-5-18 10:52:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 追影 于 2018-5-18 11:11 编辑

新建的Discuz社区或运营不久的社区 当天用户发帖量相对较少,如何将当天发帖量改为7天内发帖量?让社区看起比较活跃呢

经过本人研究 只需要改一个文件即可实现 不会代码的直接下载附件解压到对应路 table_forum_forum.rar (4.05 KB, 下载次数: 0, 售价: 2 大米)
\bbs\source\class\table\table_forum_forum.php
以下是主要改动 7天你可以换成自己想要的天数
主要改动 (1)function update_forum_counter
  1. public function update_forum_counter($fid, $threads = 0, $posts = 0, $todayposts = 0, $modwork = 0, $favtimes = 0) {
  2.                 if(!dintval($fid)) {
  3.                         return false;
  4.                 }
  5.                 $addsql = array();
  6.                 if($threads) {
  7.                         $addsql[] = "threads=threads+'".intval($threads)."'";
  8.                 }
  9.                 if($posts) {
  10.                         $addsql[] = "posts=posts+'".intval($posts)."'";
  11.                 }
  12.                 //尝试将当天发帖数换成7天发帖数
  13.                 $day_beforet = time() - 7*86400;
  14.                 $sql = "select count(tid) from ".DB::table("forum_post")." where `fid`={$fid} and `first`=1 and `invisible`=0 and `dateline`>'".$day_beforet."' and `dateline`<'". time() ."'";
  15.                 $seven_posts = DB::result_first($sql);               
  16.                 /*if($todayposts) {
  17.                         $addsql[] = "todayposts=todayposts+'".intval($todayposts)."'";
  18.                 }*/
  19.                 if($seven_posts) {
  20.                         $addsql[] = "todayposts='".intval($seven_posts)."'";
  21.                 }
  22.                 if($modwork) {
  23.                         $addsql[] = "modworks='1'";
  24.                 }
  25.                 if($favtimes) {
  26.                         $addsql[] = "favtimes=favtimes+'".intval($favtimes)."'";
  27.                 }
  28.                 if($addsql) {
  29.                         DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(', ', $addsql)." WHERE ".DB::field('fid', $fid), 'UNBUFFERED');
  30.                 }
  31.         }
复制代码



(2) function clear_todayposts()

  1. public function clear_todayposts() {
  2.                 //这里改写成一周的数据
  3.                 $res = DB::fetch_all("select * from ". DB::table($this->_table) ." where status=1 and type='forum'");
  4.                 $day_beforet = time() - 7*86400;        
  5.                 foreach($res as $k=>$v){
  6.                         $seven_posts = DB::result_first("select count(tid) from ".DB::table("forum_post")." where `fid`=".$v['fid']." and `first`=1 and `invisible`=0 and `dateline`>'$day_beforet' and `dateline`<'".time()."'");
  7.                         DB::query("UPDATE ".DB::table($this->_table)." SET todayposts='{$seven_posts}'where fid=".$v['fid']);
  8.                 }
  9.                
  10.                 //DB::query("UPDATE ".DB::table($this->_table)." SET todayposts='0'");
  11.         }
复制代码





分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册大米会员

本版积分规则

QQ|小黑屋|大米CMS社区 ( 蜀ICP备11002200号-2广告联系:广告联系 

Powered by 大米CMS

© 2010-2020 大米CMS Inc.

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