首页 > 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年9月11日17:50 | #1

    You really make it appear so easy along with your presentation but I to find this topic
    to be actually something which I believe I’d by no means understand.
    It sort of feels too complicated and very vast for
    me. I am taking a look forward for your next publish, I’ll attempt to get the dangle of
    it!

  2. 2018年9月13日05:20 | #2

    Wonderful beat ! I wish to apprentice at the same time as you amend your website, how could i subscribe for a blog site?
    The account helped me a acceptable deal. I were tiny bit familiar of this
    your broadcast offered bright transparent idea

  3. 2018年9月13日19:03 | #3

    Hi to every single one, it’s in fact a nice for me to visit this website,
    it includes precious Information.

  4. 2018年9月16日01:49 | #4

    I am in fact thankful to the owner of this web page who has shared this enormous paragraph at here.

  5. 2018年9月17日08:11 | #5

    It’s hard to come by experienced people in this particular topic, however, you seem like you know what you’re
    talking about! Thanks

  6. 2018年9月17日16:06 | #6

    Heya just wanted to give you a brief heads up and let you know a few of
    the pictures aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same outcome.

  7. 2018年9月20日03:06 | #7

    Hi! I’ve been reading your site for a while now and finally
    got the courage to go ahead and give you a shout out from Atascocita Tx!
    Just wanted to mention keep up the fantastic work!

  8. 2018年9月20日15:57 | #8
  9. 2018年9月21日23:07 | #9

    Today, while I was at work, my cousin stole my iPad and tested
    to see if it can survive a twenty five foot drop,
    just so she can be a youtube sensation. My iPad is now broken and she
    has 83 views. I know this is completely off topic but I had to
    share it with someone!

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