Some support/help for Akismet

I think the best WordPress Plugin is Akismet, without this useful tool every WP blog owner need to review all comments to select the good comments. There is a lot of work to do for this weblog, more then 100 “spammy” comments a day, and strange enough most of them are coming via the same IP addresses.

Thanks Akismet, you’re doing a really good job!

Ok, next action was to block these IP addresses via .htaccess, but this doesn’t work for me. I guess the reason is that most of the spam is send via the trackback URL and it looks like that .htaccess will not work (at least on the server where this blog is hosted, regular access blocking via .htaccess works fine). Maybe these spammer connect the trackback URL via a proxy?

I didn’t like that some comments from our blog readers become trashed because of the big amount of spam on the internet, so I checked once a week >1000 spam messages. But enough is enough, there is a way to block this guys which posting spam via the trackback URL without disabling this important feature. Just add this code to your wp-config.php file:

$blocked_ips = array("82.146.53.67", "72.232.173.170", "209.200.238.182", "64.111.117.7", "67.159.5.246", "82.146.53.67");
if (in_array($_SERVER['REMOTE_ADDR'], $blocked_ips)) {
header('HTTP/1.0 404 Not Found');
exit;
}

The array $blocked_ips is the “container” of all IP addresses where spam was caught by Akismet or a not recognized comment has reached your Inbox. After every repeating spam attack from one IP address you should at the IP address to this array.

Very useful for people with several weblogs is to host one file which holds all IP addresses from the spam posts from all your blog(s). Just replace the array declaration with this code:


$blocked_ips = array_map('rtrim', file('http://your.host.com/all_ip_addresses.txt'));
// changed the regular file command to remove the line ends from the array

Of course this is very time intensive but very effective, btw. the owner of each IP address is also blocked to access your website. I found this list of IP addresses from WordPress Spammers and have also a look on this project.

 

Related posts

Comments

Trackback URL for this post: http://www.web-development-blog.com/archives/some-supporthelp-for-akismet/trackback/

Akismet is also availble for Drupal
http://drupal.org/project/akismet

The same trick can be applied with the blocked IP’s as well ;)

Though Drupal users may wish to look at Troll as an alternative to hacking their config file
http://drupal.org/project/troll

In case you are using the
$blocked_ips = file(‘http://your.host.com/all_ip_addresses.txt’);
, you need to trim the results, or add a new line to the ip. Eg.

if (in_array($_SERVER['REMOTE_ADDR'].”\\n”, $blocked_ips))
……

Tim, what do you mean with

The same trick can be applied with the blocked IP’s as well

You can do the same little hack you use here with Drupal as well as wordpress, though I would go with the troll module as it has more features and options

…sure this is not the best way to block spammers, but it’s very frustrating if your site get spammed by one IP address 20-30 times a day (and this way its over with them ;) )

@Nick,

are you sure about the “new line” character? the file function converts every row separated by the “new link” character into an array (I think you’re are thing therms of using cURL)

@Nick, you’re right, from the manual:

Each line in the resulting array will include the line ending, so you still need to use rtrim() if you do not want the line ending present.

bad days… :(

only 8 days since the last clean up there are again 859 spammy comments, thats 100 a day!

Ok, this clean-up was about blocking another 50 IP addresses and I hope it takes now a little bit longer until the next 1000 spam comments about phentermine (almost belive that these spammer wants me to loose weight) lol

BTW, thats a lot of traffic 15KB a comment * 1000 = ~15MB/week, between 50-100MB for one blog site!

… still not the result I have accepted, this time (one week later) there are ~800 messages by just one IP address (plus a several others):

81.95.146.227

(you need top block this address a.s.a.p.) :D

It looks like that my membership at blogcatalog.com is one of the reasons that this blog is spammed much more then 2 month before…

Ban Ip address or a range of ip addresses…

How to ban an ip address or a range of ip addresses?
Here is a quick script that will allow you to ban an ip address. Example 12.345.67.89.
$my_ip_add = $_SERVER['REMOTE_ADDR'];
if ($my_ip_add == ‘12.345.67.89′) {
echo (“banned”);
mysql_close;
ex…

Hi, just read your tutorial about how-to ban some IP addresses, you should check the MySQL function INET_ATON or the PHP function ip2long to for better performance.

Comment spam is still a problem, using AJAX comment forms are not the solution and banning some IP’s helps but there are still a lot of them.

A nice tool to find the biggest spammer is Greasemonkey’s Akismet Auntie Spam Script

You can also block IP based on CIDR blocks using Iptables for example. Check out http://www.ipdeny.com

Sorry, the comment form is closed at this time.