Fight Comment Spam
-
I’ve been getting a lot of poker comment spam recently, and I cooked up a quick trick to fight it, so I thought I’d share:
I.) In wp-comments-post.php, there are three or four calls to die(), which stop the comment from being posted if there is an error. Somewhere in the line of these, drop in:
if ( commblist($user_ip) )
die( __(‘Registered spambot! JERK!’) );II.) For easy access, next turn to the file you edit most often, which should be index.php or index.html (etc.) for most of us.
When you receive a spam comment, click on the ARIN WHOIS link and look for a line marked in the form of”NetRange: 194.0.0.0 – 194.255.255.255.” This means that the spambot is operating within the 194.*.*.* block of IP addresses. Now you can easily block all comments coming from this block of IP addresses.
function commblist($ipaddy)
{
$segs = explode(‘.’,$ipaddy); // creates an array of the 4 blocks in the IP address.
if($segs[0] == 194)
return true; // $segs[0] refers to the first number in the IP address
if(implode(‘.’,$segs[0],$segs[1],$segs[2])==”192.6.143″)
return true; // to string multiple numbers back together, use implode(‘.’,$segs[0]… however many you need). I used this line to block the IP block of 192.6.143.*
return false;
}
- The topic ‘Fight Comment Spam’ is closed to new replies.