ngd_recaptcha plugin for TextPattern

If you don’t know what a reCAPTCHA is or the difference from a regular CAPTCHA and want all the details, visit http://recaptcha.net/.

[…waits while you do that…]

All clear? Great!

This plugin implements reCAPTCHA for TextPattern comments. When a visitor submits a comment they’ll have to solve a reCAPTCHA on the comments preview. If the preview is not solved after the maximum number of attempts, then the comment is sent to the comment moderation queue.

Installation

Click here to get your reCAPTCHA keys if you need them.

If you want to use the Mailhide functions, click here to get your reCAPTCHA Mailhide keys if you need them.

Install the plugin and turn it on.

Go to your advanced preferences tab (admin -> preferences -> advanced preferences).
At the bottom you’ll see a section labeled ‘reCAPTCHA’. Fill in the values as follows:

reCAPTCHA for comments enabled [ngd_recaptcha_enabled]
Select yes to enable reCAPTCHA for comments. This allows you to disable reCAPTCHA without taking all the tags out of your code. This does not affect the Mailhide functions.
reCAPTCHA max tries [ngd_recaptcha_max_tries]
Maximum validation attempts. Defaults to 3.
reCAPTCHA failure action [ngd_recaptcha_max_try_action]
Failed comments are sent to the moderation queue. Set to SPAM to additionally mark them as spam.
reCAPTCHA public key [ngd_recaptcha_publickey]
The public key for your site that you got a few steps back.
reCAPTCHA private key [ngd_recaptcha_privatekey]
Ditto, but strike public, insert private.
reCAPTCHA Mailhide public key [ngd_recaptcha_mailhide_publickey]
The reCAPTCHA Mailhide public key. Only needed if want to you want to use the Mailhide functions.
reCAPTCHA Mailhide private key [ngd_recaptcha_mailhide_privatekey]
Ditto, but strike public, insert private.
Display reCAPTCHA debug messages [ngd_recaptcha_debug]
Turn this off for production sites, but if you are having issues, this will print out a debug message where the reCAPTCHA image or Mailhide should show (missing lib, keys, etc). Note: Incorrect keys will cause an error to display regardless of these settings. If anyone reallllly has a problem with that, let me know (not promising to do anything about it tho).

Save your preferences and test it out. If it doesn’t work, try turning the debug option on. If you still cannot get it to work, disable it and report the problems.

That’s it! Enjoy your newfound security and the warm fuzzy that comes with helping a good cause.

Mailhide function

You can find out more about the reCAPTCHA Mailhide here.

Usage: <txp:ngd_recaptcha_mailhide>youremail@yourdomain.com</txp:ngd_recaptcha_mailhide>

Attributes:

link
0: returns the url only.
1: returns a link (default).
privatekey
You can also pass the privatekey along here if you prefer.
publickey
You can also pass the publickey along here if you prefer.

Issues

The only known issue is if you want to totally uninstall the plugin. This plugin adds some records to your txp_prefs table. If you don’t care if they stay there and you still see the reCAPTCHA settings in your preferences, do nothing. Otherwise, use PHPMyAdmin or the Textpattern db_manager plugin or whatever other program you like and run this query: DELETE FROM txp_prefs WHERE name LIKE ‘ngd_recaptcha_%’ (you may need to add your table prefix if you use one). If that sentence made no sense to you, I suggest you just live with the change rather than attempt something you aren’t familiar with-leaving the records does no harm.

Credit

I used the asy_captcha plugin by Sencer Yurdagul as a model.


Comments

1 Morgan Aldridge - Jan 17, 02:31 PM

I’ll have to give this a try!

I’ve been working on/using my own reCAPTCHA plug-in for Textpattern since somewhere around December of 2006. I had planned to do an initial release in July of 2007, but Manfre posted a reCAPTCHA plug-in then so I held off and just kept using mine.

Two weekends ago I talked to Manfre on IRC and tweaked mine to release, but hadn’t gotten a chance to provide documentation, so held off releasing again. So now, as things seem to go with my reCAPTCHA plug-in, all my effort was for naught… you’ve released yours!

Actually, it was a very good for the expansion of my Textpattern plug-in development skills, but I must be jinxed!

How actively are you looking and supporting yours? I may send you some code & fixes to merge bits of my functionality in if you like or don’t mind.

2 Sara Jacobson - Jan 18, 09:44 PM

@Morgan:

Thank you. This is my first ‘official’ contribution to TextPattern (about time since I’ve been using it for two years now!). I’ve many others ‘in the works’ but this is the first I’ve managed to finish and publish.

I didn’t see Manfre’s until after I’d almost finished it, and since they do different things figured it would still be a worthwhile effort to continue.

I think it is pretty stable but there is always room for improvement. Right now it only activates on comments-if there’s a need I’ll flesh it out more.

Given my track history I’d welcome any collaboration on your part. There’s a wonderful plugin diff contribution that is very helpful if you find things to improve upon.

-Ng_

3 chris - Jun 11, 03:31 AM

Hi – i’m struggling to implement this.

When I fill in the words and hit enter, do I also need to hit Submit on my comment or not? Also, how can I position the Recaptcha widget within my sites structure?

4 Sara Jacobson - Jun 11, 09:50 AM

It’s been a while so I test in the easiest manner – by adding a comment. :0

5 Sara Jacobson - Jun 11, 10:21 AM

Mkay- the answer is…mixed.

I just hit the [enter] key directly after typing. Doing either should submit the form (which is all you are doing). There may be some variance browser to browser (Safari may require you to hit ‘submit’) but so long as your comment preview form is standard (‘submit’ being the default action rather than cancel or otherelse) it should work in both cases.

As to the position-it’s appended to the end of the form automagically. The id for the primary container div is “recaptcha_widget_div” – you could use some CSS magic to apply some styling. There are a couple other id’s too (just view the source to see them).

Please clarify if I’m misunderstanding.

6 Locum tenes job - Jun 15, 11:53 PM

So is it better than the regular? i wanted to switch to the RedCaptcha also

7 Sara Jacobson - Jun 16, 12:57 AM

Better? Well, the function is the same as a regular captcha, and effectiveness likely the same as well. However the recaptcha uses 2 real words, which are easier to type than the nonsense strings generated by normal captchas, plus there’s the altruistic hook of helping to digitize books.

Add Your Comment




Textile Help