Discuz限制重复发贴设置,适用于所有版本

作者是开卷工作室,域名太难记,就不写了,哈哈。

安装难度:非常简单
适用版本:Discuz!所有版本


安装步骤:

一、修改核心

1.打开 include\newthread.inc.php
2.查找:

程序代码 程序代码

        if($subject == '' || $message == '') {
                showmessage('post_sm_isnull');
        }


3.在下一行添加:

程序代码 程序代码

//Refuse repeated post. Code by KaijuanStudio
        if($repeated == 1) {
                $query = $db->query("Select tid, subject FROM {$tablepre}threads Where authorid='$discuz_uid' AND subject='$subject'");
                if($db->num_rows($query)) {
                        $repeat = $db->fetch_array($query);
                        showmessage('post_repeated', 'index.php');
                }
        } elseif ($repeated == 2) {
                $query = $db->query("Select tid, subject FROM {$tablepre}threads Where subject='$subject'");
                if($db->num_rows($query)) {
                        $repeat = $db->fetch_array($query);
                        showmessage('post_repeated', 'index.php');
                }
        } elseif ($repeated == 3) {
                $query = $db->query("Select tid, authorid, subject, message FROM {$tablepre}posts Where first='1' AND subject='$subject'");
                if($db->num_rows($query)) {
                        $repeat = $db->fetch_array($query);
                        if($repeat['authorid'] == $discuz_uid) {
                                showmessage('post_repeated', 'index.php');
                        }

                        function SubString($str, $start, $len = 0xFFFFFFFF) {
                                if($start < 0) {
                                        $start = strlen($str) + $start;
                                }
                                if($len < 0) {
                                        $len = strlen($str) - $start + $len;
                                }
                                $tmp = '';
                                $result = '';
                                $strlen = strlen($str);
                                $begin = 0;
                                $subLen = 0;
                                for($i = 0; $i < $start + $len && $i < $strlen; $i++) {
                                        if($i < $start) {
                                                if(ord($str[$i]) >= 161 && ord($str[$i]) <= 247 && ord($str[$i+1]) >= 161 && ord($str[$i+1]) <= 254) $i++;
                                        } else {
                                                $begin=$i;
                                                for(; $i<$start+$len && $i<$strlen; $i++) {
                                                        if(ord($str[$i]) >= 161 && ord($str[$i]) <= 247 && ord($str[$i+1])>=161 && ord($str[$i+1])<=254) $i++;
                                                }
                                                return substr($str,$begin,$i-$begin);
                                        }
                                }
                        }

                        if(strlen($message) > 60) {
                                if(SubString($message, -100) == SubString($repeat['message'], -100) || SubString($message, 50, 100) == SubString($repeat['message'], 50, 100)) {
                                        showmessage('post_repeated', 'index.php');
                                }
                        } else {
                                if($message == SubString($repeat['message'], 0, 60)) {
                                        showmessage('post_repeated', 'index.php');
                                }
                        }
                }
        }
//Refuse repeated post. Code End


二、添加提示信息

1.打开:templates\default\messages.lang.php

2.查找:
程序代码 程序代码
        'post_net_price_iszero' => '您的主题售价扣除积分交易税后为 0,请返回修改。',


3.在下边一行添加:
程序代码 程序代码
        'post_repeated' => '您所发布的主题已存在:《<a href=\"viewthread.php?tid=$repeat[tid]\" target=\"_blank\">$repeat[subject]</a>》请勿重复发布。',


三、配置功能开关

1.打开:config.inc.php
2.在最后添加一段:
程序代码 程序代码
        $repeated = 0;        //设置防范重复发贴的级别,0=关闭,1=防范相同ID发布相同标题的新主题,2=防范发布相同标题的新主题,3=防范发布相同标题且内容部分相同的新主题。


根据自己需求更改$repeated的数值


设置完毕!


[本日志由 默默鸟 于 2009-11-27 03:33 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: Discuz 限制重复发贴
评论: 0 | 引用: 0 | 查看次数: 12278
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 2 字 | UBB代码 开启 | [img]标签 关闭