Simple anti-comment spam measure

Thanks to Patrick Strang who pointed me to Steven Geen’s simple anti-comment spam measure for MovableType, I managed to stem the current flow of “Please approve this comment” emails flooding my inbox. This has been happening since last Saturday! Argh! Why are they doing this even when everything goes into the moderation queue?

Anyway, it’s so simple to get this into WordPress - just edit wp-comments.php and wp-comments-post.php to add the field to the comment form (see below) and die() when the correct “letter of the day” isn’t entered. (Though die()ing isn’t the most elegant way, but WordPress does this for the other fields as well.)

Screenshot of anti-spam field


Check out the comment form if the picture above is too small. Sorry to have to put you commentors through this, but it’s really for my sanity. At least it isn’t one of those randomly-generated graphical thingies that really ensures you are human (or an equivalent intelligent lifeform).

14 Comments & TrackBacks ()

Paper doll icon
Tijs's Gravatar

Why not simply rename wp-comments-post.php? solves you problem right away without bothering any of your visitors…

Posted by: Tijs on November 5, 2004 6pm

Paper doll icon
Cheah Chu Yeow's Gravatar

Well, that is a good idea, but I doubt it will solve the problem since spammers seem to be hitting me by actually posting. At least, that’s what my access logs seem to tell me. Or maybe I’m totally off-base. I’ll find out for sure if and when another steady stream of comment spam arrives. I’m pretty sure this is only stop-gap. If it gets worse, I’ll get down to business ;).

Posted by: Cheah Chu Yeow on November 5, 2004 6pm

Paper doll icon
Terry Orio's Gravatar

Isn’t this better? http://james.seng.cc/archives/000145.html

Posted by: Terry Orio on November 5, 2004 7pm

Paper doll icon
nick's Gravatar

I just renamed the file and then edited the one of the other comment files to go along with the renamed file and that solved ALL my problems.

Posted by: nick on November 5, 2004 9pm

Paper doll icon
test's Gravatar

test

Posted by: test on November 5, 2004 9pm

Paper doll icon
Bernie Zimmermann's Gravatar

Another thing to keep in mind is that for a popular site like yours, spammers might be willing to do a quick scrape of your source to determine what the “letter of the day” is before they automatically fill out your form and post. I think this is why using a graphic might be more appropriate. A spammer then has to either look at the graphic, or figure out what your naming scheme is for the images you use for the “letters of the day.”

I’ve been thinking about options to use on my site (yes, even though it’s not very popular and I use my own CMS I still get spammed) and have yet to decide on anything definitive. I’m leaning toward creating a bunch of graphics that contain random words (not as predictable as the 26 letters of the alphabet) and having the commenter type the word in a text field. Once a month or so I could then rename the files and update my authentication accordingly so I can always keep the spammers guessing.

Believe it or not, the work involved would be much less time consuming than scouring my blog for spam and then removing it.

Posted by: Bernie Zimmermann on November 5, 2004 10pm

Paper doll icon
minghong's Gravatar

If the spammer program is smart enough, it can get the XHTML file, then get the “secret letters” by using something like DOM.

Of course little spammer programs will do so…

Posted by: minghong on November 6, 2004 12am

Paper doll icon
Patrick's Gravatar

When it was at its worst I got 10-16 spam comments a day from spam robots. But since I installed the extra text field I haven’t received any. So far it’s working - the day it gets defeated I’ll probably enhance it further.

Posted by: Patrick on November 6, 2004 1am

Paper doll icon
CarLBanks's Gravatar

I like this idea.

Posted by: CarLBanks on November 8, 2004 10pm

Paper doll icon
CarLBanks's Gravatar

Hmm it’s giving me the wrong letter in the error message. It’s telling me today’s anti-spam letter is R but the error message says please put in C.

Posted by: CarLBanks on November 8, 2004 10pm

Paper doll icon
CarLBanks's Gravatar

Sorry for triple commenting but what code do I add?

Posted by: CarLBanks on November 8, 2004 10pm

Paper doll icon
Nathan Wong's Gravatar

My goal: Keep my site completely reader-less so that nobody spams it. Yay! :) Working well so far.

Posted by: Nathan Wong on November 10, 2004 11am

Paper doll icon
CarLBanks's Gravatar

What do I add back again? I accidentlly overwrote comments-post.php and now spam is rampant again.

Posted by: CarLBanks on December 17, 2004 5am

Paper doll icon
fernando's Gravatar

I adore this hack!

However, it’s admiration from a far…

can you write up ecatly what code you added where? i, for one, and definitely too stupid to figure out what to do exactly…

and yet, the solution is exquisite and i would seriously dig having it on my site instead of the fiercer measures which can inadvertantly ban people who are only trying to add something.

Posted by: fernando on December 19, 2004 8am

You can subscribe to the RSS feed for comments on this post.

Sorry, this entry is no longer accepting comments. If you have something you really want to say, you can write me.