Another spam protection for WordPress
Despite the fact this blog has not so many visitors, spam-protect plugin (akismet) catch 50-70 spam-commends daily. Most of them contain something like [url=http://jxfbvjhdfv.com]. Since wordpress don’t understand bbcode I consider a good practice to delete such comments. But there is no reason to blacklist these “words” using wordpress due to blacklisted comments will be marked as spam instead deleting.
Here is my solution. I think it is quite good and have one important advantage: spam processed before putting to MySQL thereby reduced CPU load.
I add this kode to askimet.php, but you free to put in any suitable place :)
Please don’t forget to make backup.
wp-content/plugins/akismet/akismet.php has funktion akismet_auto_check_comment. It called every time comment submitted.
(changes are bold):
global $akismet_api_host, $akismet_api_port;
$comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
if (strpos(strtolower($comment[’comment_content’]),”[url”) !== FALSE ) { //found
print “‘url’ spam found! you IP will be banned”;
die;
}
$comment[’user_agent’] = $_SERVER[’HTTP_USER_AGENT’];
strtolower() - it’s for case insensitive. If you have php 5 you may do this:
if (stripos($comment[’comment_content’],”[url”) !== FALSE ) { //found
That’s all.
If you read carefully you could see I threaten that bad guys will be banned but this code just delete spam comment without banning.
Where IP of spammers will be stored? How you can filter them? It is subject of next post. Now I have my own (maybe unique:) ) spamtrap that work nice! I already have 9610 banned IP’s.
Now I think this project ready to general public so I propose to test this service for everyone freely.
Detailed instructions will ready in few days.
If you interested in this service you can leave a commend (with subscription) or subscribe to RSS on this blog.
ps: I know, my English may look crazy but I hope I’m understandable :)
Any corrections will be greatly appreciated. Thank you.