首页 > 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年12月18日09:15 | #1

    I read this post completely on the topic of the difference of hottest and preceding technologies,
    it’s amazing article.

  2. 2018年12月19日11:42 | #2

    Chain-hyperlink fences are especially price-efficient.

  3. 2018年12月19日22:02 | #3

    I’m contemplating a wooden privacy fence.

  4. 2018年12月20日22:26 | #4

    I’m contemplating a picket privateness fence.

  5. 2018年12月22日14:29 | #5

    The fitting recommendation can save you money and time.

  6. 2018年12月23日01:46 | #6

    The proper advice can save you money and time.

  7. 2018年12月23日10:35 | #7

    The appropriate recommendation can save you money and time.

  8. 2018年12月23日22:41 | #8

    The precise advice can prevent money and time.

  9. 2018年12月24日14:22 | #9

    I pay a quick visit daily some sites and blogs to read content,
    except this webpage offers quality based articles.

  10. 2018年12月24日14:45 | #10

    The precise recommendation can prevent money
    and time.

  11. 2018年12月24日15:22 | #11

    The precise recommendation can prevent time and money.

  12. 2018年12月25日18:25 | #12

    Hey there! I know this is kinda off topic but I was wondering which blog platform are you
    using for this website? I’m getting fed up of WordPress because I’ve had issues with
    hackers and I’m looking at options for another platform. I would be
    fantastic if you could point me in the direction of
    a good platform.

  13. 2018年12月25日19:36 | #13

    The common constructing permit prices about $800.

  14. 2019年1月2日05:51 | #14

    I must thank you for the efforts you’ve put in writing this blog.
    I really hope to view the same high-grade content from you later on as well.
    In fact, your creative writing abilities has motivated me to get my own website now ;)

  15. 2019年1月2日11:36 | #15

    Hello my friend! I want to say that this article is awesome, great written and include approximately all important infos.
    I’d like to peer extra posts like this .

  16. 2019年1月2日19:05 | #16

    Amazing things here. I’m very glad to look your article.
    Thanks so much and I am taking a look forward to touch you.
    Will you kindly drop me a mail?

  17. 2019年1月6日19:16 | #17

    This piece of writing presents clear idea in support of the new viewers of blogging, that
    in fact how to do running a blog.

  18. 2019年1月7日08:19 | #18

    Hiya! Quick question that’s totally off topic. Do you know
    how to make your site mobile friendly? My web site
    looks weird when browsing from my iphone 4. I’m trying to find a template or plugin that might be
    able to fix this issue. If you have any suggestions, please share.
    Cheers!

  19. 2019年1月7日22:51 | #19

    Aw, this was an incredibly good post. Spending some time and
    actual effort to generate a superb article… but
    what can I say… I procrastinate a lot and don’t seem to get nearly anything done.

  20. 2019年1月20日14:28 | #20

    With havin so much content and articles do you ever run into any issues of plagorism or copyright infringement?
    My website has a lot of unique content I’ve either created myself or outsourced but it looks like a lot
    of it is popping it up all over the internet without my authorization.
    Do you know any ways to help stop content from being stolen? I’d certainly
    appreciate it.

  21. 2019年1月25日11:40 | #21

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

  22. 2019年1月29日06:50 | #22

    This is very interesting, You are a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking more of your excellent post.

    Also, I’ve shared your site in my social networks!

  23. 2019年2月24日00:25 | #23

    Howdy! This post could not be written any better! Reading this post
    reminds me of my good old room mate! He always kept chatting about this.
    I will forward this post to him. Fairly certain he will have a good
    read. Thank you for sharing!

  24. 2019年3月2日11:11 | #24

    Keep on working, great job!

  25. 2019年3月21日23:51 | #25

    Hello it’s me, I am also visiting this web page on a regular
    basis, this website is actually good and the visitors are actually
    sharing pleasant thoughts.

  26. 2019年3月22日05:44 | #26

    I do accept as true with all of the concepts you’ve introduced
    for your post. They’re really convincing and will certainly work.

    Still, the posts are too brief for starters. May just you
    please extend them a little from next time? Thank you for
    the post.

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