查看: 130|回复: 1

新版X5.0 连续回帖自动合并到同一楼层,避免灌水楼层过多!

[复制链接]
发表于 2026-8-24 08:19:17 |四川| 显示全部楼层 |阅读模式
第一步:修改 source/app/forum/child/post/newreply.php
找到第 485-486 行:
  1.         $return = $modpost->newreply($params);
  2.         $pid = $modpost->pid;
复制代码
替换为:
  1.         ########### 叠加快速回复(X5.0适配版)#######################
  2.         $pid = 0;
  3.         $_insertword = "\n[size=2][color=gray][u]{$_G['username']} 于 ".date('Y-m-d H:i:s', TIMESTAMP)." 补充以下内容[/u]:[/color][/size]\n";

  4.         $_maxlength = 80;       // 字符数大于此值则不合并(1中文=3字符UTF-8)
  5.         $_reducesmile = 1;      // 去除表情后计算字数
  6.         $_reducequote = 1;      // 去除引用后计算字数
  7.         $_reducespace = 1;      // 去除空白换行后计算字数
  8.         $_reducefirst = 1;      // 仅限回复,不合并到楼主帖
  9.         $_reducetime  = 2000;   // 超过多少秒后不再叠加
  10.         $_blackfids = [53,54,55,61]; // 版块FID黑名单
  11.         $_whitefids = [];             // 版块FID白名单(黑白同时存在时白无效)

  12.         $discuz_uid = $_G['uid'];
  13.         $fid = $_G['fid'];
  14.         $tid = $_G['tid'];

  15.         if($_blackfids && $_whitefids) unset($_whitefids);

  16.         // ---- 计算有效字数 ----
  17.         $temp = $message;
  18.         if($_reducesmile) {
  19.                 loadcache('smilies');
  20.                 $smilies = [];
  21.                 foreach($_G['cache']['smilies'] as $smgroup) {
  22.                         if(is_array($smgroup)) {
  23.                                 foreach($smgroup as $sm) {
  24.                                         if(isset($sm['code'])) $smilies[] = $sm;
  25.                                 }
  26.                         }
  27.                 }
  28.                 foreach($smilies as $sm) {
  29.                         $temp = str_replace($sm['code'], '', $temp);
  30.                 }
  31.                 unset($smilies);
  32.         }
  33.         if($_reducequote) $temp = preg_replace("/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", '', $temp);
  34.         if($_reducespace) $temp = preg_replace("/\s/is", '', $temp);
  35.         $temp = trim($temp);
  36.         $length = strlen($temp);
  37.         unset($temp);

  38.         // ---- 附件/匿名/JSON富文本一律不走合并 ----
  39.         $hasattachment = !empty($_GET['attachnew']);
  40.         $isanonymous   = !empty($params['isanonymous']);
  41.         $isjsoncontent = is_valid_non_empty_json($content, true);

  42.         if($length <= $_maxlength && !$isjsoncontent
  43.                 && (!$_blackfids || !in_array($fid, $_blackfids))
  44.                 && (!$_whitefids || in_array($fid, $_whitefids))) {

  45.                 $tablename = DB::table('forum_post');
  46.                 $q = DB::fetch_first("SELECT `authorid`,`pid`,`first`,`dateline` FROM $tablename WHERE tid='{$tid}' AND invisible='0' ORDER BY pid DESC LIMIT 1");

  47.                 if($q) {
  48.                         if($_reducefirst && $q['first'] == 1)
  49.                                 $discuz_uid = 0;
  50.                         if(($q['dateline'] + $_reducetime) <= TIMESTAMP)
  51.                                 $discuz_uid = 0;

  52.                         if($q['authorid'] == $discuz_uid && !$hasattachment && !$isanonymous) {
  53.                                 $message = $_insertword . $message;
  54.                                 $message_esc = daddslashes($message);
  55.                                 DB::query("UPDATE $tablename SET `smileyoff`='0',`bbcodeoff`='0',`tags`='superposition',`message`=CONCAT(message,'$message_esc') WHERE pid='{$q['pid']}'");

  56.                                 $pid = intval($q['pid']);
  57.                                 $modpost->pid = $pid;
  58.                                 $return = 'post_reply_succeed';
  59.                                 $modpost->param('showmsgparam', ['fid'=>$fid,'tid'=>$tid,'pid'=>$pid,'from'=>'','sechash'=>'']);
  60.                                 $page = getstatus($modpost->thread['status'], 4) ? 1 : @ceil(($modpost->thread['special'] ? $modpost->thread['replies']+1 : $modpost->thread['replies']+2) / getglobal('ppp'));
  61.                                 $modpost->param('page', $page);
  62.                         }
  63.                 }
  64.         }

  65.         if(!$pid) {
  66.                 $return = $modpost->newreply($params);
  67.                 $pid = $modpost->pid;
  68.         }
  69.         ################################### 叠加回复处理完成 ################################
复制代码
第二步:修改source/app/forum/module/viewthread.php
找到第 872 行(在 `viewpid` 的 else 分支内):
  1.         include template('common/footer_ajax');
复制代码
在它上面插入:
  1.         if(!empty($post['tags']) && $post['tags'] === 'superposition') {
  2.                 echo '<span id="tyjs"><script type="text/javascript">(function(){var e=document.getElementById("pid'.$_GET['viewpid'].'");if(e&&e.parentNode){e.parentNode.outerHTML="";}var t=document.getElementById("tyjs");if(t){t.outerHTML="";}})();</script></span>';
  3.         }
复制代码
发表于 6 天前 |四川 | 显示全部楼层
现在网站已经升级完毕了吗?我看很多功能都恢复了。
回复

使用道具 举报

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

本版积分规则

手机版|Archiver|站点地图|小黑屋|建筑吧

2005-2026 © 建筑资源吧 [蜀ICP备13014264号-2] [Discuz! Git] [Discuz! X5.0]
建筑资源吧所有内容均来源于会员发布或网络,禁止发布色情、政治、反动等国家法律不允许的内容!
如果您认为建筑资源吧的内容侵犯了您的合法权益,请发电子邮件并告诉详情【 web@jzbar.net 】我们会尽快处理。
虚拟的网络世界更加能反映人的本性,请大家理智和谐的发表自己的观点勿人身攻击,违者封停ID账号,谢谢支持!
在本版发帖QQ客服返回顶部