discuz反广告-防乱发广告帖

三月 17th, 2010 Posted in 6.综合内容 | 阅读次数: 886 次

让发垃圾广告帖的会员见鬼去吧

广告帖有好有坏,但会员乱发就很让站长头痛了,现在利用点空闲时间写了段代码,基本能阻止部分广告帖,且按会员等级限制

打开include/newthread.inc.php文件,找到以下代码:

if(!$sortid && !$special && $message == ”){
                showmessage(‘post_sm_isnull’);
}

在其下面插入以下代码:

 

// 指定用户组受此功能限制array(4,5,6,7,8,9,10)里的数字是用户组对应ID,可自行修改
//当然你也可以指定哪版块使用此功能,这里就不写上去了
if(in_array($groupid,array(4,5,6,7,8,9,10)) && CheckADMessage($message)){
showmessage(‘很抱谦!你级别还未达到能发布广告帖行为,请泡够级别再发吧!’);
}

 

在此文件最底部,即“?>”前插入以下代码:

function CheckADMessage($admessage){
$a=’/[0-9]{3,4}\-[0-9]{3,8}|[0-9]{5,8}|[0-9]{3,4}\[0-9]{3,8}|0{0,1}13[0-9]{9}|0{0,1}15[0-9]{9}/is’;//严禁出现电话号码
$b=’/([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*\.)+[a-zA-Z]*)/is’;//严禁出现邮件
$c=’/(http:\/\/)*(www)*[\w-]*(\.)*[\w-]+\.(com|net|org|gov|cc|fm|me|biz|info|cn)(\.(cn|hk))*(\/)*([\w-\]\/\.\?\=\&])*/’;//URL分析
$d=’/QQ|电话|网站/is’;//常见广告帖出现的中文字,可自行修改

$admessage1 = preg_replace($a, ‘|ISADTELSTOP|’, $admessage);
$admessage2 = preg_replace($b, ‘|ISADmaiSTOP|’, $admessage);
$admessage3 = preg_replace($c, ‘|ISADurlSTOP|’, $admessage);
$admessage4 = preg_replace($d, ‘|ISADOTHSTOP|’, $admessage);

$get_adnum1=substr_count($admessage1,"|ISADTELSTOP|");
$get_adnum2=substr_count($admessage2,"|ISADmaiSTOP|");
$get_adnum3=substr_count($admessage3,"|ISADurlSTOP|");
$get_adnum4=substr_count($admessage4,"|ISADOTHSTOP|");

return $get_adnum1>0 || $get_adnum2>0 || $get_adnum3>0 || $get_adnum4>1 ? true : false;
}

以上功能适用DZ任何版本,对着修改就可以了,我在7.0已经测试通过,一般的广告帖低级会员都无法发布。回复帖同样也可以这样写,只要相对修改“include/newreply.inc.php”文件就可以了

附上默认的用户组ID变量

15==论坛元老
14==金牌会员
13==高级会员
12==中级会员
11==注册会员
10==新手上路
9==乞丐
8==等待验证会员
7==游客
6==禁止 IP
5==禁止访问
4==禁止发言
3==版主
2==超级版主
1==管理员

需要的站长就用吧

相关日志:

Tags:

5 Responses to “discuz反广告-防乱发广告帖”

  1. Panic Away Review Says:

    Some New Sites I Like…

    [...]below you’ll find the link to some websites that I think you should go and see http://www.panicattackstreatmentcure.net/links/ some are related to my site and others are unrelated but definitely worth visiting[...]…


  2. Get Rid of Yeast Infection Says:

    Recommended Sites…

    [...]below you’ll see my links page http://www.yeastinfectiontreatmentcure.net/links/ with some fantastic sites that I think you should visit[...]…


  3. Related Resources Says:

    Interesting Article…

    [...]some interesting sites worth visitng. We recommend all our readers go and check these out[...]……


  4. backpain in clifton new jersey Says:

    Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……


  5. Africans Speak Says:

    Cool sites……

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]………


留下您的脚印