Thwart the Comment Spammers...
Well the comment spammers have pissed me off enough to actually do something about it.
I have written the first half of a script that will allow me to encumber thier progress some. Basically I added a table to my database that stores IP's that I wish to ban, then I created a script that queries the client attempting to connect to this site and if the IP is listed in the database they get a nasty message. If they are not then the actual content of the site is loaded.
My next step is to write a hack for my blogging software that will allow me to add IP' to the database with one click from the admin panel, then I am going to automate the updating of the database by finding website that hosts a list of the IP's and adding any new ones each night to my database.
If you want some measure of protection now, and don't mind manually adding the IP's to your database, the here is the code that you need to include in your pages:
print "You smell and your momma dresses you funny! Get out of my site!" ;
And here is the script you need to add the appropriate table to your DB:
CREATE TABLE banip (
ID int(12) NOT NULL auto_increment,
IP varchar(25) NOT NULL default '',
PRIMARY KEY (ID)
Now this example is written for my blogging software of choice Wordpress so you will have to adapt it to what you use.
So that is it, pretty vanilla stuff really. I have mine set up as index.php, it then includes content.php if it passes the check, so none of my functions are broken, since it is technically still index.php.
More on this later, as I refine the script and add the missing components.
Enjoyed this article? Follow me on Twitter.