Arrow

Version 1.0.6 of Peter’s Random Anti-Spam Image for WordPress

Here’s a spin-off of Peter’s Custom Anti-Spam Image for WordPress that will generate random anti-spam images instead of custom anti-spam images.

I’ll repeat what I wrote in the original post: there are quite a few plugins to combat blog comment spam, and they usually come in two varieties: one that filters and identifies spam posts and another that forces users to identify a random word displayed as an image in order to block spambots that cannot read your image. You can (and should) use both varieties of spam filters in tandem. Spambots are getting smarter and some can read images. Most, however cannot.

The goal of this spin-off plugin is so that webmasters don’t have to create the words themselves (instead the plugin file creates some random text like “2fkt9s”). This plugin aims to keep the readability of the Custom Anti-Spam version, as well as other features like random fonts and colours.

The disadvantage over the Custom Anti-Spam version is that the anti-spam image is not a word, thus making it less user-friendly. To help somewhat, if you click the image it will regenerate some new text (this works for users with JavaScript enabled).

Screenshot of the random anti-spam image

Without further ado…

Version 1.0.6 of Peter’s Random Anti-Spam Image Plugin for WordPress [August 2, 2010: Minor code tweak for WordPress 3.0.]

Download translatable version with Norwegian translation by Øyvind Sæther

Download

Older versions:

Version 1.0.5 [August 2, 2008: Added a setting $ras_wpconfig for the absolute path to wp-config.php for WordPress 2.6+ users who have moved either wp-config.php or the wp-content folder from the default locations.]

Version 1.0.4 [May 31, 2008: Fixed the registration form protection for WordPress 2.5. Pre-WordPress 2.5 users who want to use the registration form protection must use Version 1.0.3 of this plugin or lower.]

Version 1.0.3 [May 24th, 2008: For efficiency reasons, image and audio generation is now run directly through the plugin file.]

Version 1.0.2 [March 13th, 2008: Minor tweak to ensure compatibility with WordPress 2.5.]

Version 1.0.1 [February 10th, 2008: New option to disable random stretching of the wav files. Made the operation to stretch the wav files silent to the server(thanks Angelo!). Blocked indexing of audio file links by search engines (thanks Lucky!).]

Version 1.0.0 [January 20th, 2008: Added registration form protection (WordPress 2.1 and higher required) and a corresponding e-mail blacklist. For registration form protection, set $ras_reg_protection equal to “true”. Also tweaked the audio file generation with wav files to be more robust against spambots.]

Version 0.2.6 [November 20th, 2007: Minor code tweak to the image and audio generation code so that full page generation doesn't occur unnecessarily (thanks Steve!).]

Version 0.2.5 [November 11th, 2007: Made a few minor efficiency and display tweaks, and switched up the fonts.]

Version 0.2.4 [October 13th, 2007: Tweaked a database command to be more compatible, allowed a site address override (over the WordPress site URL value), and removed some redundant code.]

Version 0.2.3 [September 30th, 2007: Fixed a bug that was blocking trackbacks and pingbacks for the past few versions (a stupid oversight on my part in the order of some code.]

Version 0.2.2 [September 26th, 2007: Fixed minor CSS detail, allowed for different folder names for the plugin, and renamed mp3 class to avoid the possibility of clashes with other class names.]

Version 0.2.1 [September 10th, 2007: Fixed a bug whereby the audio files weren’t generating in all Internet Explorer setups. Fixed a bug with the "don't force registered users to enter the anti-spam word" setting. Changed table creation method so that PHP installations with low memory allocated to scripts will still be able to create the necessary tables. Also, made all display strings more easily customizable, to enhance translation support.]

Version 0.2.0 [September 3rd, 2007: The plugin now uses a database for truly random words and can generate mp3 audio files of the words. Clicking on the image now generates an audio file, and you can generate new text by clicking a link next to the image.]

Version 0.1 [July 28th, 2007: First version!]

Unzip the entire folder random-anti-spam to your plugins directory, so that the path is wp-content/plugins/random-anti-spam/. Then activate the plugin via your WordPress admin section. The plugin should work directly “out of the box”, but all instructions for customization are found by editing the plugin file (in your WordPress control panel, go to Plugins > Edit Plugins).

Forum for Peter’s Random Anti-Spam Image

Forum/Topic Started Last post Posts

Note: this blog uses the Custom Anti-Spam version of this plugin. To see the Random Anti-Spam version of this plugin in action, check out highinterestsavings.ca.

Arrow

51 Responses to “Version 1.0.6 of Peter’s Random Anti-Spam Image for WordPress”


  1. WirelessGuru says:

    No single anti-spam method will get rid of all spam. But I’ve found that using Peter’s Captcha plug-in, along with other methods has helped to eliminate all of my spam.


  2. Rui Cruz says:

    I dont mean to offend you, but using a captcha with the alt tag “Anti-Spam Image” leave any visual empaired or blind user withnot any access to blog commands.
    If you kindly have an idea to add sound to it, I will look forward to use your plugin and to invite my friends to use it too, and ofcourse to spread the word, because I never saw a plugin with web acessibility in mind.

    I hope you consider this request.

    Thanks,
    Rui


  3. bebek says:

    i have difficulty on installing the plugins, it shows this error message :

    open_basedir
    Your server has an open_basedir restriction on. Make sure you edit the $ras_abspath value in the plugin file to set the absolute server path to your blog (something like /home/peter/public_html/blog/).

    and i’ve change my path to : /home/myusername/public_html/

    but it won’t work.

    could you jelp me on this?


  4. Peter says:

    To check the server path, create a PHP file in the root of your blog with this code:

    <?php
    print $_SERVER['DOCUMENT_ROOT'];
    ?>


  5. Cy says:

    hey there, great plugin! it really works for me. The only thing I’d like to ask is: how do I change the position of the script? I have activated the plugin and nothing else, but the security verification appears AFTER the submit button. I’d like to place it before.

    Thanks a lot!


  6. Peter says:

    Hi, there’s some instructions on the Custom Anti-Spam Version for positioning the script:

    http://www.theblog.ca/wp-content/uploads/2007/01/do_action.htm


  7. Cy says:

    thanks a lot for the fast reply. Im on it =)


  8. Cy says:

    Sorry to bother you again with all these questions, but I need to place the image verification first and then the text form (horizontally align, I mean). Is that possible?

    And one more thing: if I change the height of the image, I just see the half of the picture. The word is not resized to the image height. Do I need to change something else?

    Thanks!


  9. Peter says:

    Those changes are certainly possible, but a bit more difficult. The height resizes… up to a certain extent, so there’s a bit more to change: see here


  10. Nico Nemil | Web Developer | Web Designer | Graphics Artist » WordPress Plugin Releases for 7/29 says:

    [...] Peter’s Anti-spam Image generates random anti-spam images instead of custom anti-spam images. [...]


  11. Patrice says:

    I did not find a setting/variable to specify maximum length of random string. IMHO, the default lenght (7) is probably too long. How can I reduce it? –Thanks


  12. Peter says:

    It’s a bit buried in the code in two places:

    Change the 7:

    // Validate the input values
    $ras_antiselect = substr( $_GET['antiselect'], 0, 10 );
    $ras_antispam = substr(md5($ras_antiselect . $ras_key), 0, 7);

    Change the 7:

    // Figure out what the field should match
    $final_check = substr( md5( strtolower( $matchthis ) . $ras_key), 0, 7 );

    I’ll add that as an easy option whenever I get around to making the next version.


  13. Patrice says:

    Thanks Peter for the hack. It\’s working. I agree, a param would be a good idea.


  14. Pirate’s Cove » >>Americans Never Quit » Plugin Roundup-Ajax And New Bad Behavior says:

    [...] (which does not like some comments), and Peter’s Custom Anti Spam Image (you can also try his newer one, which generates a random code), which cover quite a bit of the spam. Bad Behavior was in place to [...]


  15. Matt Belitsky \ mattbelitsky.com » Blog Archive » Past, Present & Future says:

    [...] but until then I am using the default “Kubrick” template while installing plugins left and right—mostly for comment spam [...]


  16. Dubi’s Blog » Blog Archive » I discriminate against spammers says:

    [...] installed an anti spam plugin on this blog. There are many plugins available for wordpress and Peter’s Random Anti-Spam Image for WordPress was the easiest one to Install , no configuration or signing up anywhere. truly plug and play. I [...]


  17. Kunal says:

    Thank you very much for this awesome plugin.


  18. Gary says:

    I saw a nice looking ‘antispam security word’ system at http://aldianprakoso.com/how-to-write-unique-articles-yourself/ so I wrote to him. He said it was from you. And it looks like I just found it…

    Thanks!

    Gary


  19. James says:

    This is great Peter! I just put it onto my site and now I can feel that anyone can comment without having to register anymore. Thanks a lot!


  20. James says:

    This has problems on IE? Any suggestions?


  21. Peter says:

    I would suggest trying the manual insert, as described here.

    I don’t know of any specific problems with IE at all, but just make sure you’re not logged in when testing and try the manual insert. If there is a different problem, please let me know with some more specifics :D


  22. Gijet says:

    Hi…..

    Peter, I used your “Custom Anti-Spam Image” on my WordPress 2.2.2 blog.

    The picture box, only shown seven characters. I wanna change that so that the box can displaying more than seven characters. So please tell me the way !.

    Thanks


  23. Peter says:

    Hi, the very first setting in the plugin file (go to Plugins > Plugin Editor in the WordPress admin panel) controls how many letters to show:

    // Set this to how many letters you want the anti-spam word to be
    $ras_length = 7;

    To increase the size of the box itself, find this setting:

    // Set the anti-spam image width and height.
    // You may need to increase these sizes for longer words and/or bigger fonts.
    $ras_imgwidth = 160;
    $ras_imgheight = 50;


  24. Kenny says:

    Dear Peter

    Surely, i dislike the “up-right” position of the spam image. So, please tell me how to set the output to fully horizontal position?

    Cheers


  25. Peter says:

    You mean the slant in the image? Find this piece of code and set the value to 0:

    $cas_angle = 4; // Degrees to tilt the text


  26. thesuperstar says:

    very nice plugin, thanks.


  27. Leonard says:

    I need this at my blog.

    Thanks.


  28. Wordpress MU secure form » Patrick Chia says:

    [...] image to the signup form anf login form. This plugin don’t use session and modified based on Peter’s Custom Anti-Spam. This plugin currently run on blogates.com signup page and will be release on coming [...]


  29. Matt says:

    I have the plugin installed but it does not display, what does it ‘hook’ into?


  30. Peter says:

    Hi Matt, do you mean the anti-spam field does not display at all or there is a broken image?

    If the anti-spam field does not display at all, make sure you have logged out first, because by default it does not display to registered users (although you can change that with the $ras_forcereg setting). Failing that, try the manual insert method (as described for the custom anti-spam version).

    If it displays a broken image, check that you have the necessary libraries installed (FreeType and GD Library). Otherwise, send me a link to your site and I’ll check it out.


  31. Matt says:

    Hi Peter,

    Nothing displays at all. I did try logging out and checking but still nothing.

    My site is www.christiandrummers.net

    I will try that manual insert. I was using this plugin before (well, the other one I think) and it worked fine. But that was with the K2 theme, which I am no longer using.

    Thank you for your response, your assistance is greatly appreciated.


  32. Peter says:

    Ah, looks like you got it to work. What did the trick?


  33. Matt says:

    Thank you so much, I had to manually insert the code into my comments.php file and that worked. It is a great plugin! Thanks again!


  34. Stop Comment Spam on Your WordPress Blog | The Design Junkie says:

    [...] time reading images on screen which may or may not be an issue for you. On my blog I’m using Version 0.2.4 of Peter’s Random Anti-Spam Image for WordPress. It has some nice features that avoid creating accessibility issues. (Thanks [...]


  35. Bel says:

    Hey Peter,

    thanks for the great plugin. I was really looking forward to a plugin that would prevent me from getting hundreds of spam comments.

    Anyway, I installed the plugin and apparently it worked, I logged off wp as you mentioned to do to see it working, and well, what did I get? On my comments page I can’t get to see the code, just the sound, what do I have to do? I tried gazillion things but it doesn’t seem to work.

    Any help would be appreciated!

    Thanks! :D


  36. Peter says:

    Hi Bel, there are a few possible causes:

    Did you make sure that the fonts were uploaded in binary mode, instead of ASCII mode (in your FTP program)?
    Are the permissions correct on the font files? Try giving them 777 permissions (in your FTP program).
    Is FreeType enabled? Check Manage > Random anti-spam in your WordPress admin section.


  37. Stefan Hoehn says:

    Just thanks! One day, all of a sudden, I had spam comments on my blog. I searched a plugin, found yours, it worked immediately and since then: Silence! Thanks for your work!


  38. Lucky Hariadi says:

    Thanx for the great plugins.. it works well on my site..

    The problem is search engine (eg. Google) kept indexing all the pages of “*site.com/x?audioselect=*” which saying “anti-spam number is no longer valid.” and its really annoying seeing many this kind of page links in the search results.

    Temporary fixes that i do is editing the plugin:

    adding “rel=nofollow” attribute so search engine bots (like: Google, Yahoo, MSN) will not follow this link and index it.


    if ($ras_mp3) echo( '<a href="' . $ras_myurl . '?audioselect=' . $ras_rowid . '" title="Hear an audio file of the anti-spam image" rel="nofollow" rel="nofollow">' );

    and

    changing the invalid page that generates by the plugin to add meta tags to instruct the robots not to index the page and redirect in 5 seconds to back to last page / the homepage / 404 error page. I do this coz not all search engine bots support “rel:nofollow” attribute.


    // Error message when trying to generate an audio file and the anti-spam image has already been used
    $ras_displaytext['not_valid'] = 'Security code no longer valid.';

    Comment also posted here: http://www.tmk.co.id/downloads/unindex-antispam-image-wp-plugin.txt


  39. Peter says:

    Hi Lucky,

    This is a great idea and I will have to implement it in the next version of all of the anti-spam plugins (math, random and custom). Thanks a lot for your suggestion.

    Edit: this has now been implemented in version 1.0.1


  40. Lucky Hariadi says:

    Hi, Peter..

    So glad knowing that my suggestion turns out to be useful and were implemented on version 1.0.1

    Again thanks for the great anti-spam plugins..
    Keep up the good works.. ;)


  41. Bob V says:

    Hi,

    This plug in was working fine for awhile…but now the anti spam image hangs when the page loads. I tried uninstalling and install again, tried downloading different ones, but the anti spam image will not load.

    See it here:

    http://www.chappellmccullar.com/notes


  42. Peter says:

    Hi Bob, if you read this forum post, your problem sounds quite similar. Your host might have re-compiled PHP or done something funny related to the compilation of the FreeType library. The technical details at the point are a bit over my head, but you should be able to ask your host to fix the FreeType library (and/or GD Library) compilation.


  43. Mukarram says:

    Thanks a million buddy for developing a cool plugin……thanks


  44. Vaelek says:

    After recently upgrading to WP2.7, the image box now always shows ***INVALID*** and I’m not sure why. Any light to shed on this? If I cannot resolve I will have to go with another plugin as this has effectively disabled unregistered comments entirely.


  45. Peter says:

    Hi Vaelek, are you running the latest version of the plugin? I know of no reason why the plugin would stop working after you upgrade to WP 2.7.


  46. Vaelek says:

    Oh crap, it’s only 0.2.1!!! It didn’t offer auto-update so I assumed it was the latest. I’ll give the new one a shot. Thanks!


  47. Alvin says:

    Hi Peter,

    I used the automatic option bu it didn’t so i tried including the code you specified in my teamplate’s comments.php file and it worked, but it keeps saying "invalid data" when I key in all the required fields correctly.

    Pls see here:
    http://www.teambuildingspecialist.com/?page_id=5

    thank you very much!

    Reply from Peter: Looks like that error is caused by another plugin: http://wordpress.org/support/topic/175344


  48. Alvin says:

    Dear Peter,

    Thank you very much for the prompt response.
    Yes, disabling the "WP Captcha Free" plugin solved my problem!

    YOU ROCK!


  49. johanericka says:

    thanks for the great plugin
    you save my life :D

    and the sound is so great, but i have to disable it because of limited bandwidth :(


  50. Sharon says:

    Hi Peter! First off, thanks so much for this. It is the only one I can find anywhere that does exactly what I want.

    That being said, I do have one problem, and I can’t seem to fix it.
    On my blog, it works perfectly for Internet Explorer, but not for Firefox!?!

    I’ve logged out, and even rebooted just to be sure… but it will NOT work for Firefox. I get the following error message:

    Error: Please enter the anti-spam text.
    Copy your comment in case this site forces a page reload whenever you press the Back button:

    I love that it gives you the comment to copy BTW!
    So, can you help me? Have you seen this problem before? Works like a charm on IE, but not FireFox… it’s stumped me. (BTW I’m on the most recent version of FF 3.5.5)

    Thanks!!

    PS: If you want to test it, the site is www.sharonmcleod.ca/blog

    Reply from Peter: Did you make any modifications to the plugin? Looks like you left an <a> tag unclosed.


  51. bicevap says:

    Peter.. I wanna ask, how can we change the listening sound ?

    Reply from Peter: There is a “sounds” folder containing files for each letter of the English alphabet and each number. You can replace any of all of those files with your own recording.

Speak your mind

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word