WP Plugins and Widgets For Wordpress 2.1+

WP Hashcash Plugin for Spam

May 28th, 2007 by Elliott Back

hashcash.png

What is WP Hashcash?

WP Hashcash is an antispam plugin that eradicates comment spam on Wordpress blogs. It works because your visitors must use obfuscated javascript to submit a proof-of-work that indicates they opened your website in a web browser, not a robot. If the javascript check fails, WP Hashcash now gives you three options; it can either put the comment into moderation (default), put the comment in the akismet queue, or delete it.

Features:

  • Blocks all comment spam, but not real comments
  • Also prevents most trackback / pingback spam
  • Widget support to display spam statistics and edit the configuration
  • Works with IE, Firefox, and Safari
  • 100% standards compliant XHTML 1.1
  • Tested with Wordpres 2.3, Firefox 2, Safari 3, and IE 7
  • Akismet compatibility

Limitations:

  • Javascript is required to submit a comment

WP Hashcash relies on the presence of two hooks in your theme, wp_head and comment_form. If your theme doesn’t include these actions, you will need to add them immediately before the </head> and </form> tags respectively.

Download:

You can download the latest version (4.1) of WP Hashcash from Wordpress Extend: wp-hashcash.zip.

To install WP Hashcash, please download the plugin and unzip it, then copy the wp-hashcash.php file to wp-content/plugins. Activate the plugin and drag into your Widgetized sidebar for public statistics, or visit Options, WP Hashcash from the admin panel to configure options:

hashcash-options.png

Questions & Answers:

I’m having issues with it working.
If you’re installing it over an older version, please disabled then re-enable the plugin. This will reset the preferences.

Do I need widgets to use this?
No, WP Hashcash ships with reasonable defaults, and lets you change them via the standard Wordpress options panel.

How does it prevent comment spam?
By forcing clients submitting comments to additional compute a value from javascript and submit it along with the comment.

How does it prevent trackback spam?
By comparing the IP of the trackback’s url with the senders IP, and by looking in the trackback’s url for a link back to your post.

Testimonials:

  • “One of my favorites” (src)
  • “this is a clever idea that I think might work well” (src)
  • “I haven’t had a single comment spam in my comment moderation queue for over a week now. I’m feeling the love!” (src)
  • “The least annoying one I have found” (src)
  • “this thing was a trivial install” (src)
  • “a fancier technique” (src)
  • “Comment Spam is a thing of the past, and I owe it to Spam Stopgap Extreme. If you use WordPress, I highly recommend installing this plugin. It has completely eliminated the comment spam problem I was having. I no longer need the spammer Tarpit plugin, or anything.” (src)
  • “Why am I not worried about comment spam anymore? Because of my awesome new blog plugin, Spam Stopgap Extreme. This baby blocks any bot trying to post to my blog. No blacklists, no moderation, no “spam points”, no nothing. You won’t even know that it’s working.” (src)
  • “I haven’t had anything to “deal” with in several weeks. That’s a nice thing. I’ve also had a bunch of folks leave legitimate comments that have gotten through. It’s all good.” (src)

Changelog:

WP Hashcash 4.1

  • Added a new options page under Options, Wordpress Hashcash
  • Fixed XHTML standards compliance
  • Added validation options for pingbacks and trackbacks (stolen from here)
  • Added a logging option for moderated comments

WP Hashcash 4.0.5:

  • Added an option for handling comments via moderation, the akismet queue, or deletion
  • Removed database dependencies
  • Removed error message for hash fail
  • Added the noscript tag for users without javascript
  • Corrected the widget formatting
  • Changed zip file format from winrar to 7zip, hopefully it will be more compatible

WP Hashcash 4.0.4:

  • Removed version checking
  • Removed an unnecessary <link> element in the head section

WP Hashcash 4.0.3:

  • Suppress errors on loading remote version by any method
  • Fix typo-bugs everywhere affecting the widget reporting, date checking, etc
  • Strip tags from remote version
  • Try various methods to get remote version, ignore if we can’t open sockets
  • Fix a bug with one of the javascripts

Should you encounter any issues using this widget, please leave a comment. Likewise for improvements, outcry, and other commentary you might have.

Tagged with: , , , , , , , , , , , , , , , , , , ,

44 Responses

  1. Ian

    I love the changes you’ve made to Hashcash, E. Hashcash is back on my page to stay now. Thanks!

  2. David Pascoe

    I love WP_HashCash, here is a short article I wrote praising it.

    http://my.opera.com/djp/blog/show.dml/1570265

  3. Populara

    i tested the plugin and i like it! thx! i really hate spam!!

  4. dante

    like it!! thanks! i really work and hate spam in 99%!!

  5. aqua

    Hashcash is back on my page

  6. Brook

    I’m amazed at how well your plugin works. I’ve never been happy with the others I’ve tired. You’re a genius!

  7. Pearl

    Excellent tool. Thank you. Spam went from 200 to 1 in moderation. Wonderful accurate filter.

  8. Dave Miller

    v4.1 is much easier to use, thanks!

  9. Austin

    Dang! that’s the killer I wanted for spam! ;)

    Thank you for making such an awesome plugin and sharing it with the community.

    Cheers!

  10. Tim McCormack

    What does it mean for a comment to be “put [into] the akismet queue”? Does that mean that I need to check the Akismet queue for comments from users with Javascript disabled?

    Ideally, it would first whitelist any comment that passes the hash test, let Akismet put anything it doesn’t like into the spam queue, and drop everything else into moderation. Is there a way of using Hashcash that way?

  11. Elliott Back

    Yeah I can’t think of an easy way to do that generically, especially given that Wordpress Hashcash can’t whitelist anything, only banlist things it thinks are bad. It would be possible to add this as a special option, though, to drop failing comments into akismet and let it sort it out…

  12. Rick Beckman

    Any word on WordPress 2.5 compatibility? I noticed it’s not listed anywhere in this list:

    http://codex.wordpress.org/Plugins/Plugin_Compatibility/2.5

  13. Elliott Back

    I haven’t tried WP 2.5 yet, but feel free to try yourself. I don’t /think/ anything will break, but you never know right?

  14. Ian

    Since installing the new version of hashcash, it’s started blocking *all* comments by users on my site again. Where can I view the comments blocked (since it’s storing them somewhere) and either approve or delete them?

  15. Elliott Back

    Ian, by default they go to moderation or Akismet if it is installed. However, the problem is that your theme doesn’t have the wp_head hook in it. You need to add a call to wp_head(); inside your template.

  16. Ian

    Okay, will do. Will consult the documentation on where I need to put that. :-)

    Thanks again, Elliott!

  17. Ian

    Okay, that seemed to fix it. Apparently the theme author had commented it out. I uncommented it and it hashcash works as advertised. :-)

    Thanks!

  18. Ian

    Oh, and it works with WP 2.5 just fine.

  19. Christian

    How about making a contact form plugin with Hash-Cash? I want a contact form plugin, but I don’t want spam or captchas.

  20. kelly

    Am gonna try! :) 10Q for the plugin!

  21. Mike

    After having problems with HashCash working, Elliot suggested I sent him my theme files so he could see what was going on.

    It turned out to be my theme and some javascript that I had added that was causing the problems. Elliot re-wrote the javascript and sorted out my php!

    Many many thanks Elliot!

  22. Jeff

    Small note: on line 302, if you change it to

    echo "addLoadEvent(function(){var el=document.getElementById('wphc_value'); if(el){el.value=wphc();}});\n";

    it will not error on pages which are lacking a comment form despite being a post.

  23. test

    testcase

  24. dizi izle

    thank you for this great plugin

  25. Sean

    I’ve got Hash Cash on a WP2.5 site with the wp_head and comment_form hooks present in the theme. Every comment is being held for moderation, even my own comments when I’m logged in as admin. Here is the error that is logged:

    [WORDPRESS HASHCASH] The poster sent us ‘0 which is not a hashcash value.

  26. Elliott Back

    It’s because you’ve manually overloaded body.onLoad aka window.onLoad in your html. Instead of body onload=”Init()” you should just put in the js window.onload=Init.

  27. blu3man

    Whats wrong with the default wordpress askimnet antispam?

  28. lazarus

    For those of us new to WP, etc, can you provide exactly the code to include “the hooks” and exactly which file(s) to place them in?

    Thanks

  29. Constantin

    Could it be, that trackbacks doesn’t work with that plugin?

    Greets

  30. Wes

    Great I will try this - Thanks soo much
    :-)

  31. Hecker

    Firebug says wphc took 0.465ms to execute. This is a nice check to make sure the client has JavaScript but it sure isn’t hashcash.

  32. TB

    Looks like Hashcash thinks comments with an OpenId enabled website are spam (using the WP-OpenID plugin). Disabling the WP-OpenID plugin or not entering an OpenID website during comment submission seems to be OK with WP-Hashcash.

  33. Dominic Desbiens

    Nice plugin. I will use it and hope it will work well.

  34. Joe.H

    Couldn’t this be worked around by using a webBrowser object then figuring out how to reach the form using tabs etc. then using sendKeys to send it anyway? This way the user would technically be using a webBrowser

  35. Jason Wohlford

    Elliott, thanks for the WP plugin!

    Do you by know of a way to do this in straight PHP without Wordpress? I have some contact forms I’d like to Hashcashify, but can’t find a solution.

  36. Rayed

    Thanks Elliott for this nice plugin, I really love it.

    I got a tiny bug, when I get a trackback from a page without any links I get this error:

    Warning: Invalid argument supplied for foreach() in …/wp-hashcash.php on line 491

  37. rap dinle

    ohw. thanks! i really work and hate spam in 99%!!

  38. GJ

    I’ll certainly try this! Thanks.

  39. ilahi

    Since installing the new version of hashcash, it’s started blocking *all* comments by users on my site again.

  40. rap

    the hooks” and exactly which file(s) to place them in ? ? ?

  41. Joe Kissell

    This plugin was working brilliantly until I upgraded to WP 2.5; now I’m experiencing the same problem as Sean: every comment, including ones I post myself while logged in, get this error:

    [WORDPRESS HASHCASH] The poster sent us ‘0 which is not a hashcash value.

    I don’t have body onload=”Init()” anywhere in my code…any other suggestions?

    Thanks kindly!

  42. ilahi dinle

    Wonderful accurate filter.

  43. Soft

    Very interesting plugin.

  44. Kelson

    Maybe I’m being pedantic, but claiming that it “Blocks all comment spam, but not real comments” seems to be stretching the truth a bit. A hashcash solution won’t block manually submitted spam (and yes, I’ve seen it!), just the automated types. And just a few lines later, you mention that it does block real comments by people who have JavaScript turned off.

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Powered by WP Hashcash