首页 > wordpress > 防垃圾评论最简单方法

防垃圾评论最简单方法

2010年4月7日 eric 发表评论 阅读评论

        博客刚搭建好没几天,就开始有人在我的博客里发垃圾评论,每天都会有 500多条,很恶心,在后台删也删不完,就google了一下,没想到很多人都会有同样的遭遇,看到一篇文章,利用简单算法来验证,看了效果不错,这样能有效的防止,垃圾评论。因为不需要用插件吗,利于博客的访问速度很快。

首先在修改博客根目录的wp-comments-post.php

在代码

elseif ( !is_email($comment_author_email))
                wp_die( __('Error: please enter a valid email address.') );
}

下添加:

if (!$user->ID) {
        $aaa = trim($_POST[aaa]);
        $bbb = trim($_POST[bbb]);
        $subab = trim($_POST[subab]);
        if ((($aaa + $bbb)!= $subab) || empty($subab)) {
                wp_die(__('Error:Please enter the correct results of the math problems.'));
        }
}

因为我用的 inove模板所以进入wp-content/themes/inove/ 修改comments.php

找到:

 <a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Subscribe to comments feed', 'inove'); ?></a>

<div class="submitbutton">

在下面添加:

<?php if (!$user_ID) : ?>
<?php $aaa=rand(0,5); $bbb=rand(3,9); ?><?php echo $aaa; ?>+<?php echo $bbb; ?>=
<input type="text" name="subab" id="subab" size="2" tabindex="5" style="width:20px" />
<?php if ($req) _e('(required)', 'inove'); ?>
<input name="aaa" value="<?php echo $aaa; ?>" type="hidden" />
<input name="bbb" value="<?php echo $bbb; ?>" type="hidden" />
<?php endif; ?>

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/108.html

  1. 2018年1月1日18:45 | #1

    free casino games
    [url=http://bom777casino.com/]real money casino[/url]
    free casino games
    casino games

  2. 2018年1月2日00:01 | #2

    usa casinos for iphone
    casino real money
    new bingo sites paypal

  3. 2018年1月2日11:50 | #3

    casino games
    [url=http://bom777casino.com/]online casino[/url]
    casino online
    casino games

  4. 2018年1月3日08:39 | #4

    loans no credit
    payday loans no credit
    loans online
    payday loans online no credit check
    loans online

  5. 2018年1月7日03:40 | #5

    slots casino games
    [url=http://casinobablogames.com/]free slots no download[/url]
    free slot games
    free slots casino games

  6. 2018年1月7日18:09 | #6

    slotomania free slots
    [url=http://casinobablogames.com/]slots casino[/url]
    casino free games
    free slot games

  7. 2018年1月9日05:11 | #7

    free slots no download no registration
    [url=http://casinobablogames.com/]free slots online[/url]
    free slots no download
    free casino slot games

  8. 2018年1月11日15:32 | #8

    Does your site have a contact page? I’m having a tough time locating it but, I’d like to shoot you an email.
    I’ve got some recommendations for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it improve over time.

  9. 2018年1月14日10:48 | #9

    casino games
    [url=http://casinobablogames.com/]casino online[/url]
    online casino
    online slots

  10. 2018年1月14日11:02 | #10

    payday loans no credit
    payday loans no credit check
    payday loans no credit check
    loans no credit check
    payday loans no credit check

  11. 2018年1月15日00:10 | #11

    Hi, I believe your blog might be having internet browser compatibility issues.
    Whenever I look at your website in Safari, it looks
    fine however when opening in IE, it’s got some overlapping issues.
    I simply wanted to provide you with a quick heads up! Apart
    from that, excellent website!

  12. 2018年1月16日00:13 | #12

    online casino
    [url=http://casinobablogames.com/]real money casino[/url]
    online slots
    casino games

  13. 2018年1月16日00:23 | #13

    loans no credit
    [url=http://paydayhjkfg.com/]payday loans online no credit check[/url]
    payday loans no credit check
    payday loans online no credit check

  14. 2018年1月16日22:28 | #14

    online casino
    [url=http://casinobablogames.com/]real money casino[/url]
    casino online
    casino games

  15. 2018年1月18日11:24 | #15

    real money casino
    [url=http://casinobablogames.com/]casino online[/url]
    online slots
    online casino

  16. 2018年1月18日22:39 | #16

    payday loans no credit check
    payday loans
    payday loans online
    payday loans online
    payday loans no credit check

评论分页
1 ... 4 5 6 108
订阅评论
2+5= (必填)