Stripped down JSSpamBlock

So a friend of mine mentioned in his blog that he used Paul Butler’s JSSpamBlock plug-in with his WordPress blog to prevent spam. I thought it was a great idea, but I wanted to apply it to a script I had written previously that was just a basic guestbook page (not WordPress). I was getting a lot of bots hitting it and trying to post their links. I blocked all links in my code, but I still ended up getting a bunch of random hits with no links. So I took a look at his code (originally written in php) and stripped it down to two small simple sections. One is the actual JavaScript that he uses and then some simple perl on the backend parsing script to check for it.

Here’s the JavaScript section, put it within your form code (slightly modified variable names keep the bots from automating any fixes for this):

And then have something like this in your perl script:

(Sorry, not sure how to get WordPress to not show the actual code and not run it)

4 thoughts on “Stripped down JSSpamBlock

  1. Thanks for the post Kevin, I posted a link here from my blog.

    One comment on the code itself, line 5 of the perl code: ($botblockcheck ne “8989890” || $bothash ne “TRyAg41n”). Won’t this always evaluate to true? I haven’t used Perl in a while so maybe the operators act different than I am used to.

  2. The code is correct. If either one of the fields (||) is not what it should be or what the script expects it to be (ne) then the comment is not allowed (not_allowed).

Leave a Comment