How to effectively intercept and filter spam reviews

Source: Internet
Author: User

For those who use technical means, such as GET, post, etc. do not fill in the foreground form, directly read the background program file spam, only the shield IP to alleviate the same offensive, other what verification code, sliding unlock and so on are useless.

You can add the following in the. htaccess file:Some IP access is forbidden.
123
Order deny,allow  deny from xxx.xxx.xxx.xx  deny from xxx.xxx.xxx.xx

Effectively intercept comment and trackback (pingback) with no Chinese characters in the content

123456789
/* refused spam *  /function refused_spam_comments ($comment _data) {  $pattern = '/[one-calls]/u ';  if (!preg_match ($pattern, $comment _data[' comment_content ')) {  Wp_die (' comments must contain Chinese! ');  }  Return ($comment _data);  }  Add_filter (' preprocess_comment ', ' refused_spam_comments ');

The code rejects the spam comment directly put the following code in front of the last?> of the topic's functions.php file:

Spam comment interception class Anti_spam {function Anti_spam () {if (!current_user_can (' level_0 ')) {add_action (' template_redirect '), Array ($this, ' W_tb '), 1), add_action (' init ', array ($this, ' Gate '), 1), add_action (' Preprocess_comment ', Array ($this, ' Sink '), 1);}} function W_tb () {if (Is_singular ()) {Ob_start (create_function (' $input ', ' Return Preg_replace ("#textarea (. *?) Name= ([\ "\ ']) comment ([\" \ ']) (. +)/textarea># "," Textarea$1name=$2w$3$4/textarea><textarea name=\ "comment \ "Cols=\" 100%\ "rows=\" 4\ "style=\" display:none\ "></textarea>", $input); ') );}} Function Gate () {if (!empty ($_post[' W ')) && empty ($_post[' comment ')) {$_post[' comment '] = $_post[' W '];} else {$ Request = $_server[' Request_uri '; $referer = isset ($_server[' http_referer '])? $_server[' http_referer ': ' concealment '; $IP = Isset ($_server["http_x_forwarded_for"])? $_server["Http_x_forwarded_for"]. ' (through proxy) ': $_server["REMOTE_ADDR"]; $way = isset ($_post[' W '))?              ' Manual operation '         : ' Non-comment form '; $spamcom = isset ($_post[' comment ')? $_post[' comment ': null;$_post[' spam_confirmed '] = "Request:". $request. "\ nthe route:". $referer. "\nip:". $IP. "\ n Way:". $way. "\ n content:". $spamcom. "\ n--record success--";}} function Sink ($comment) {if (!empty ($_post[' spam_confirmed ')) {if (In_array ($comment [' Comment_type '], array (' Pingba CK ', ' trackback ')) return $comment;//Method one: Block directly, will die (); the front two slashes can be removed. Die (); //Method Two: Marked as spam, left in the database to check for false positives. //add_filter (' pre_comment_approved ', create_function (', ' return ' spam '; ')); //$comment [' comment_content '] = "[small wall judging this is spam!] \ n ". $_post[' spam_confirmed ');} return $comment;}} $anti _spam = new Anti_spam ();   

How to effectively intercept and filter spam reviews

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.