欢迎光临 MathCai
我们一直在努力

WordPress 防止垃圾评论算术验证码安装手记

Math Comment Spam Protection Plugin

This plugin for WordPress 2.9 and 3.0+ asks the visitor making the comment to answer a simple math question. This is intended to prove that the visitor is a human being and not a spam robot.

Example of such question:
Example of spam protection question

This plugin does not require JavaScript or cookies. It uses a special encryption function; the result of the question is being passed via a hidden field. The result is being compared with the value entered by the visitor – after encrypring this value as well.

Downloads

Installation

This plugin can be installed in 4 easy steps:

  1. Download the plugin (see “Downloads” above), decompress the .zip archive and put the files into your plugins directory (/wp-content/plugins/) or into a sub directory of the plugins directory.
  2. Enable the plugin in the WordPress Plugins admin page.
  3. Go to Options > Math Comment Spam, adjust the options and save.
  4. Adding the HTML code to your theme by using way a, b, or c:
    1. The new field for the math question will be added automatically when the option ‘Add math question field automatically’ is activated. This works well for the standard WordPress 3 theme (Twenty Ten), but may not work for some other (and older) themes. In this case use way b or c.
    2. If ‘Add math question field automatically’ does not work for your theme, you can also deactivate this option and add the following code to the comments.php of your theme for example right after the field for the website URL:
      <?php if ( function_exists('mcsp_html') )  mcsp_html(); ?>

      mcsp_html()will output the HTML code from the plugin option ‘HTML code for the math question field’.

    3. Furthermore, you can also add the HTML code directly to your comments.php by using for example the following code:
      <?php if ( function_exists('math_comment_spam_protection') ) {
      $mcsp_info = math_comment_spam_protection();
      ?> <p><input type="text" name="<?php echo $mcsp_info['fieldname_answer'] ?>" id="<?php echo $mcsp_info['fieldname_answer'] ?>" value="" size="22" tabindex="4" />
      <label for="<?php echo $mcsp_info['fieldname_answer'] ?>">Spam protection: Sum of <?php echo $mcsp_info['operand1'] . ' + ' . $mcsp_info['operand2'] . ' ?' ?></label>
      <input type="hidden" name="<?php echo $mcsp_info['fieldname_hash'] ?>" value="<?php echo $mcsp_info['result']; ?>" />
      </p>
      <?php } // if function_exists... ?>

Frequently Asked Questions

  1. Question: I’ve installed this plugin but still get spammed, why?
    Answer: Are you sure that you get comment spam, isn’t it trackback spam? In case of trackback spam consider installing a plugin like Simple Trackback Validation Plugin.

Other Plugins for Spam Protection

I recommend to use the following 3 plugins for protecting your weblog from spam:

  • Simple Trackback Validation Plugin: Eliminates spam trackbacks by retrieving the web page located at the URL used in the trackback and checking if the page contains a link to your blog: if not, the trackback is placed into comment moderation queue.
  • Math Comment Spam Protection (this plugin)
  • Akismet: additional protection in case of attacks by human spammers or trackback spammers that use the permalink on the web page located at the trackback’s URL.

Related Plugins

I got the idea for this plugin from Steven Herod’s plugin Did You Pass Math?. However, the code of the Math Comment Spam Protection Plugin is completely differently. While Did You Pass Math? provides a one-click-installation which works for standard themes only, my plugin requires you to place the form in the comments.php on your own. But this has one big advantage: You can add the field whereever you want and JavaScript is not needed for positioning it. So you can use this plugin in every theme. Furthermore, it is not necessary that the visitor has enabled cookies in his/her browser. In addition, I have seen that when using the Did You Pass Math plugin and if you entered a wrong or no answer and press the back button in your browser, the comment is no more available! This is not the case when using the Math Comment Spam Protection Plugin.
Any ways: if you are afraid of modifying the source code of your theme, I recommend that you go for the Did You Pass Math? plugin.

From:http://sw-guide.de/wordpress/plugins/math-comment-spam-protection/

未经允许不得转载:MathCai » WordPress 防止垃圾评论算术验证码安装手记
分享到: 更多 (0)

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址