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).
reCAPTCHA tabindex [ngd_recaptcha_tabindex] (v1.1)
Adds a tabindex to the input field, for accessibility goodness

reCAPTCHA lang [ngd_recaptcha_lang] (v1.1)
Set the language for your reCAPTCHA. As of this writing, supported languages are: English, Dutch, French, German, Portuguese, Russian, Spanish, Turkish.
If you need another language you can use custom theming to accomplish that.

reCAPTCHA theme [red | white | blackglass | clean | custom] (v1.1)
The reCAPTCHA theme you would like to use. Defaults to red.

I think they are pretty self-explanatory- red is red, white is white, blackglass is purple with cow images black/grey. The clean theme is transparent. – (btw gTxt turns ‘clean’ into \clean\ at least on my install – I know but want it translatable, so it’s not a bug).
See details on custom theming below.
reCAPTCHA custom theme widget ID [ngd_recaptcha_custom_theme_widget] (v1.1)
A unique DOM id used for display of the widget. Used in conjunction with custom theming (see below)

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.

Custom Theming (v1.1+)

If you don’t like the standard themes, you can now use reCAPTCHA’s custom theme settings to style the display to your site.

Important: If you use a custom theme you must declare a custom theme widget id and call <txp:ngd_recaptcha_get_html /> after that element in your comment.

Details are available on the reCAPTCHA site, so I won’t go into them here, but here’s the basic form you would put into your comment template:

<txp:if_comments_preview>
<div id="recaptcha_tag" style="display:none;">
<div id="recaptcha_image"></div>
<p class="recaptcha_only_if_incorrect_sol" style="color:red"><txp:text item="Incorrect please try again" /></p>
<p>
<span class="recaptcha_only_if_image"><txp:text item="Enter the words above:" /></span>
<span class="recaptcha_only_if_audio"><txp:text item="Enter the numbers you hear:" /></span>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
<br />
 
<span><a href="javascript:Recaptcha.reload()"><txp:text item="Get another CAPTCHA" /></a> &bull; </span>
<span class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')"><txp:text item="Get an audio CAPTCHA" /></a> &bull; </span>
<span class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')"><txp:text item="Get an image CAPTCHA" /></a> &bull; </span>
<span><a href="javascript:Recaptcha.showhelp()"><txp:text item="Help" /></a></span>
</p>
</div>
<txp:ngd_recaptcha_get_html />
</txp:if_comments_preview>

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.

8 Jen - Aug 19, 08:41 AM

Very nice! Exactly what I needed, and worked like a charm.

9 moontan - Sep 8, 10:39 AM

Very smooth indeed. There’s just one thing I’d like to complain about: I cannot customise the position of the reCAPTCHA box. The plugin places it right after the
txpCommentInputMessage class text area which sort of disfigures my layout. Would it be possible to introduce a customisable txp tag here, just like asy_captcha did?

10 Sara Jacobson - Sep 12, 09:12 PM

let me see what i can do

11 Sara Jacobson - Sep 13, 12:43 AM

Okay, I’ve added theming abilities so you can customize things a bit. It may be a bit different than what you expect but I’m working with an outside API.
Try out version 1.1 and let me know what you think before I publish to Txp Resources.

12 Molly - Nov 6, 05:59 AM

Hi Sara—

Thanks for your recaptcha plugin. I have been using it for a few months, and it’s great!

There’s one annoying little #$@! who posts a comment every night on my site, apparently attempting to advertise his site. He’s a human, not a robot, so he passes the recaptcha. I have sent e-mails asking him to stop, but he keeps on posting it. I have tried blocking the IP, but every night it’s a little different.

I am trying to use two other anti-spam plugins to block his URL, but it doesn’t seem to work. Does the recaptcha plugin bypass a process that triggers these other anti spam plugins?

The plugins are mrw_spamkeywords_urlcount and nko_spamurl_blocker.

13 Sara Jacobson - Nov 8, 09:10 AM

I’ll check it out.

14 Sara Jacobson - Nov 8, 01:41 PM

okay. came across another error i am trying to debug but you can change the ‘weight’ on the spam plugin you use to higher than 0.75 on the evaluator and it’ll outweigh the recaptcha one. it’s set at 0.6 now

I’m still checking on another issue (gotta see if I can recreate it)

15 Molly - Nov 11, 08:06 AM

Thank you, Sara. :)

16 YCF.name - Dec 7, 10:57 PM

Using reCAPTCHA,why not to skip comment preview?
Add one option to “skip the comment preview”,thanks.
May help about my request. :-)
http://textpattern.com/faq/82/how-do-i-skip-the-comment-preview
http://rahforum.biz/plugins/rah_comment_form

17 Sara - Jan 11, 09:14 PM

Seems there’s some issue with custom forms-I’ll look into it.

18 Eric Versluys - Feb 4, 11:11 PM

I got the plugin installed and in the right place, but for some reason the actual CAPTCHA words are not showing up. Has anyone seen this, or have any ideas on what might be causing this?

19 Sara - Feb 5, 10:40 PM

@Eric Versluys:
I sent an email for more info. I’ve not heard of just the words being missing.

I know you said ‘actual words’ but I’m one of those silly/annoying types who have to confirm just exactly what’s happening. Is it a) words only – you see the recaptcha box/fields on the comment preview or b) the recaptcha itself.

if b)
To troubleshoot I’d make sure it’s on & turn on debug messages (advanced prefs), add a comment & one the preview use FireBug (or view source) to see if the elements are in place – you should see a script & noscript tag below the comment preview (script tag loads src from api.recaptcha.net).

if a) it might be a glitch in their api or if you are using the custom theming perhaps it’s being overridden (e.g. you are using ‘white on white’ for color/background & the api is using that to generate the image). If you have FF & FireBug you can check to see what styles apply.

20 foo - Apr 10, 05:47 PM

What about a JavaScript free version?

Is that possible at all?

21 Alan Bristow - Jul 21, 07:17 AM

Hi, You don’t have a version of this that can be used with zem_contact_reborn do you? Pretty please? Cheers, -Alan

22 gclub - Apr 3, 11:49 PM

big help, thanks again. this site is very useful
บาคาร่าออนไลน์

23 harry56 - Jul 21, 01:03 AM

thanks

[url=http://interrspace.com][color=#ecf3f7]จีคลับ[/color][/url]

Add Your Comment