虽然这帖子年代比较久远了,但还是发下我的心得吧
楼主这个插件有个缺陷,就是可以无限插入,不受帖子长度限制,因此我改进为如下:- //连续回复自动合并 by wxyuan90 add
- $_insertword = "\n\n[b]$discuz_user 于 ".date("$dateformat $timeformat", $timestamp)." 补充以下内容:[/b]\n\n";//追加内容前缀
- $_maxlength = 80;//字符数大于此值则一律不合并,注意1中文=2字符(GBK)或3字符(UTF)
- $_reducesmile = 1;//设为1=去除表情之后计算字数,0=否
- $_reducequote = 1;//设为1=去除引用之后计算字数,0=否
- $_reducespace = 1;//设为1=去除空白换行之后计算字数,0=否
- $_blackfids = array();//版块FID黑名单,此名单内不进行合并
- $_whitefids = array();//版块FID白名单,此名单内进行合并,黑白名单同时存在时白名单无效
- //设置部分结束
- if($_blackfids && $_whitefids) unset($_whitefids);
- $temp = $message;
- if(is_array($smilies))if($_reducesmile) foreach($smilies as $sm) {
- $temp = str_replace($sm['code'], '', $temp);
- }
- if($_reducequote) $temp = preg_replace("/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", '', $temp);
- if($_reducespace) $temp = preg_replace("/\s/is", '', $temp);
- $temp = trim($temp);
- $length = strlen($temp);
- unset($temp);
- if($length <= $_maxlength && (!$_blackfids || !in_array($fid, $_blackfids)) && (!$_whitefids || in_array($fid, $_whitefids))) {
- $q = $db->query("SELECT authorid, pid, message FROM {$tablepre}posts WHERE tid='$tid' ORDER BY pid DESC LIMIT 1");
- $q = $db->fetch_array($q);
- if($q['authorid'] == $discuz_uid && strlen($q['message'].$_insertword.$message) <= $_DCACHE['settings']['maxpostsize'] && !$attachment && !$isanonymous) {
- $message = $_insertword . $message;
- $db->query("UPDATE {$tablepre}posts SET smileyoff = 0, bbcodeoff = 0, message = CONCAT(message, '$message') WHERE pid='{$q['pid']}'");
- showmessage('post_reply_succeed', "viewthread.php?tid=$tid&pid={$q[pid]}&page=".(@ceil(($thread['special'] ? $thread['replies'] : $thread['replies'] + 1) / $ppp))."&extra=$extra#pid{$q[pid]}");
- }
- }
- //连续回复自动合并 by wxyuan90 end
- //2011.01.21修改 by seahog004
复制代码 |