|
本帖最后由 追影 于 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- public function update_forum_counter($fid, $threads = 0, $posts = 0, $todayposts = 0, $modwork = 0, $favtimes = 0) {
- if(!dintval($fid)) {
- return false;
- }
- $addsql = array();
- if($threads) {
- $addsql[] = "threads=threads+'".intval($threads)."'";
- }
- if($posts) {
- $addsql[] = "posts=posts+'".intval($posts)."'";
- }
- //尝试将当天发帖数换成7天发帖数
- $day_beforet = time() - 7*86400;
- $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() ."'";
- $seven_posts = DB::result_first($sql);
- /*if($todayposts) {
- $addsql[] = "todayposts=todayposts+'".intval($todayposts)."'";
- }*/
- if($seven_posts) {
- $addsql[] = "todayposts='".intval($seven_posts)."'";
- }
- if($modwork) {
- $addsql[] = "modworks='1'";
- }
- if($favtimes) {
- $addsql[] = "favtimes=favtimes+'".intval($favtimes)."'";
- }
- if($addsql) {
- DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(', ', $addsql)." WHERE ".DB::field('fid', $fid), 'UNBUFFERED');
- }
- }
复制代码
(2) function clear_todayposts()
- public function clear_todayposts() {
- //这里改写成一周的数据
- $res = DB::fetch_all("select * from ". DB::table($this->_table) ." where status=1 and type='forum'");
- $day_beforet = time() - 7*86400;
- foreach($res as $k=>$v){
- $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()."'");
- DB::query("UPDATE ".DB::table($this->_table)." SET todayposts='{$seven_posts}'where fid=".$v['fid']);
- }
-
- //DB::query("UPDATE ".DB::table($this->_table)." SET todayposts='0'");
- }
复制代码
|
|