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):

http://www.utahsysadmin.com/files/bot_javascript.txt

And then have something like this in your perl script:

http://www.utahsysadmin.com/files/bot_perl.txt

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





Please VOTE for this page at: ADD TO DEL.ICIO.US | ADD TO DIGG | ADD TO FURL | ADD TO NEWSVINE | ADD TO NETSCAPE | ADD TO REDDIT | ADD TO STUMBLEUPON | ADD TO TECHNORATI FAVORITES | ADD TO SQUIDOO | ADD TO WINDOWS LIVE | ADD TO YAHOO MYWEB | ADD TO ASK | ADD TO GOOGLE


4 Comments


  1. That’s a cool way to implement it on a non-wordpress site. I’d suspect that it blocks all of the spambots that attempt to post to garbage.

    Posted May 17, 2007, 7:38 am

  2. […] Pendleton, another user, has ported JSSpamBlock to Perl. His version is a bit simpler; it uses a hard-coded value instead of a randomly generated one. In […]

    Posted May 21, 2007, 11:23 am

  3. 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.

    Posted May 21, 2007, 11:27 am

  4. 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).

    Posted May 21, 2007, 12:33 pm

Leave a reply