返回列表 发帖
查看: 1600|回复: 0

X3系列通用:连续回帖自动合并到同一楼层,小hack~!

17

主题

77

回帖

156

积分

渐入佳境

贡献
1 点
金币
50 个
发表于 2022-9-17 10:24:48 | 显示全部楼层 |阅读模式
效果如下图:
1.png
第一步: 修改方法:
打开文件: \source\include\post\post_newreply.php 查找:
  1. $return = $modpost->newreply($params);
  2. $pid = $modpost->pid;
复制代码
然后替换为:
  1.     ########### 叠加快速的回复#######################
  2.     $_insertword = "\n\n[size=2][color=gray][u]{$_G['username']} 于 ".date("Y-m-d H:i:s", time())." 补充以下内容[/u]:[/color][/size]\n";//追加内容前缀
  3.    
  4.     $_maxlength = 80;//字符数大于此值则一律不合并,注意1中文=2字符(GBK)或3字符(UTF)
  5.     $_reducesmile = 1;//设为1=去除表情之后计算字数,0=否
  6.     $_reducequote = 1;//设为1=去除引用之后计算字数,0=否
  7.     $_reducespace = 1;//设为1=去除空白换行之后计算字数,0=否
  8.     $_reducefirst = 1;//设为仅限回复, 0关闭.
  9.     $_reducetime  = 2000;//回复过多少秒后不再叠加
  10.     $_blackfids = array(53,54,55,61);//版块FID黑名单,此名单内不进行合并
  11.     $_whitefids = array();//版块FID白名单,此名单内进行合并,黑白名单同时存在时白名单无效
  12.     $discuz_uid = $_G['uid'];
  13.     $fid = $_GET['fid'];
  14.     $tid = $_GET['tid'];
  15.    
  16.     //设置部分结束
  17.     if($_blackfids && $_whitefids) unset($_whitefids);
  18.    
  19.     $temp = $message;
  20.     if(is_array($smilies))if($_reducesmile) foreach($smilies as $sm) {
  21.             $temp = str_replace($sm['code'], '', $temp);        
  22.     }
  23.     if($_reducequote) $temp = preg_replace("/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", '', $temp);
  24.     if($_reducespace) $temp = preg_replace("/\s/is", '', $temp);
  25.     $temp = trim($temp);
  26.     $length = strlen($temp);
  27.     unset($temp);
  28.    
  29.     if($length <= $_maxlength && (!$_blackfids || !in_array($fid, $_blackfids)) && (!$_whitefids || in_array($fid, $_whitefids))) {
  30.             $tablename = DB::table('forum_post');
  31.             
  32.             $q =  DB::fetch_all("SELECT `authorid`, `pid`,`first`,`dateline` FROM $tablename WHERE tid='$tid' AND invisible='0' ORDER BY pid DESC LIMIT 1");
  33.             $q = $q[0];
  34.             if($_reducefirst && $q['first']==1)
  35.                 $discuz_uid = 0;
  36.             if(($q['dateline']+$_reducetime) <= time())
  37.                 $discuz_uid = 0;
  38.             
  39.             if($q['authorid'] == $discuz_uid && !$attachment && !$isanonymous) {
  40.                 $message = $_insertword . $message;
  41.                 DB::query("UPDATE $tablename SET `smileyoff` = '0', `bbcodeoff` = '0',`tags`='superposition', `message` = CONCAT(message, '$message') WHERE pid='{$q['pid']}'");
  42.                 $pid  = ($q['pid']+0);
  43.                 $modpost->pid  = $pid;
  44.                 $return = 'post_reply_succeed';
  45.                 $modpost->param('showmsgparam', array('fid'=>$_GET['fid'], 'tid'=>$_GET['tid'],'pid'=>$pid, 'from'=>'','sechash'=>''));
  46.                 $page = getstatus($modpost->thread['status'], 4) ? 1 : @ceil(($modpost->thread['special'] ? $modpost->thread['replies'] + 1 : $modpost->thread['replies'] + 2) / getglobal('ppp'));
  47.                 $modpost->param('page', $page);
  48.             }
  49.     }
  50.    
  51.     if(!$pid){
  52.                $return = $modpost->newreply($params);
  53.             $pid = $modpost->pid;
  54.     }
  55.     ################################### 叠加回复处理完成 ################################
复制代码
第二步修改方法:
打开文件:\source\module\forum\forum_viewthread.php 查找:
  1. include template('common/footer_ajax');
复制代码
在这一行的上面增加如下代码(解决叠加时楼层显示多个的问题):
  1.     if($post['tags'] === 'superposition')
  2.     echo '<span id="tyjs"><script type="text/javascript">var rages = '.time().'; $("pid'.$_GET['viewpid'].'").parentNode.outerHTML=""; $("tyjs").outerHTML="";</script></span>';
复制代码


X3.5 建筑资源吧 www.jzbar.net
回复

使用道具 举报

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

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-3-28 20:57 , Processed in 0.231271 second(s), 8 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 快速发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表