stop-spam

Akismet is a proven way to prevent comment spam in wordpress powered blogs. It does a great job of sifting spam comments and redirecting them to the spam folder.

There is still a problem with this. Though spam get redirected to the appropriate folder but it unnecessarily clogs our MYSQL database. Moreover there is always a chance that among the hundreds of spam comments there is one good comment and unknowingly you might end up deleting that good comment as well, while cleaning up the folder.

I did some analysis on my spam comments (wordpress dashboard > comments > spam) and found that they mostly originate from 2-3 common IP’s. If I can get some way to automatically delete comments coming through those IP’s my problem would be partially solved(other spammers would still be there…grrr).

Here is a simple SQL script I wrote to do this:
[source:sql]
DELETE FROM `wp_comments`
where `comment_author_IP` = ‘66.159.18.9’ OR
`comment_author_IP` = ‘84.19.188.218’;
[/source]

Keep on adding the spammers IP’s that you see from your wordpress dashboard.

Now you can set up a  cron job that runs every night or every week or every fortnight (depending on your requrements). All your spam comments would get deleted automatically at a given interval.

Gozar!

Pin It on Pinterest

Share This