Skip to main content
[ADDON] ReCAPTCHA Started by Ant59 · · Read 9995 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

[ADDON] ReCAPTCHA

I've written an reCaptcha addon for Elkarte using the v2 Google reCaptcha service which uses a checkbox instead of verification text for most uses it deems to be likely human.

Grab the addon: https://github.com/Xydre/elkarte-recaptcha


Re: [ADDON] ReCAPTCHA

Reply #1

Nice to see new ways to fight spam! :D
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] ReCAPTCHA

Reply #2

Got a few errors for each person that tries to register:

QuoteGuest
Today at 07:22:42 PM
Type of error: General
8: Trying to get property of non-object
URL /index.php?action=register2
File: /sources/subs/reCaptcha.class.php
Line: 65
      
Guest
Today at 07:22:42 PM
Type of error: Undefined
8: Undefined variable: resp
URL /index.php?action=register2
File: /sources/subs/reCaptcha.class.php
Line: 65
      
Guest
Today at 07:22:42 PM
Type of error: Undefined
8: Undefined index: g-recaptcha-response
URL /index.php?action=register2
File: /sources/subs/reCaptcha.class.php
Line: 58

Here is my reCaptcha.class.php file, too.

Re: [ADDON] ReCAPTCHA

Reply #3

I would change the block:
Code: [Select]
	
public function doTest()
{
$this->_recaptcha = new ReCaptcha($this->_secret_key);

if ($_POST["g-recaptcha-response"]) {
$resp = $this->_recaptcha->verifyResponse (
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}

if (!$resp->success)
return 'wrong_verification_code';

return true;
}

to:
Code: [Select]
	public function doTest()
{
$this->_recaptcha = new ReCaptcha($this->_secret_key);

if ($_POST["g-recaptcha-response"]) {
$resp = $this->_recaptcha->verifyResponse (
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
if (!$resp->success)
return 'wrong_verification_code';
}
else
return 'wrong_verification_code';

return true;
}
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] ReCAPTCHA

Reply #4

Still getting 2 errors for line 58:

Code: [Select]
if ($_POST["g-recaptcha-response"]) {

1 error per person, so we almost there.  ;D

 

Re: [ADDON] ReCAPTCHA

Reply #5

I guess:
Code: [Select]
if (!empty($_POST["g-recaptcha-response"])) {
:D
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] ReCAPTCHA

Reply #6

That did the trick, it seems. At least, for test account I just did. :)

Re: [ADDON] ReCAPTCHA

Reply #7

A bump!

I made a few updates to this package and put it on the addon site http://addons.elkarte.net/security/reCaptcha.html

This update allows you to specify the language code (from google) and uses ElkArtes functions for posting the form data back to Google, and loads as a deferred/async script.

Re: [ADDON] ReCAPTCHA

Reply #8

Hi Spuds -
Just installed the package. On the page you referenced, there is a screenshot showing where to enable/disable this package and to add the key pair .  However, I don't see a way to get to this screen from the install.  How do you get to that screen?

Re: [ADDON] ReCAPTCHA

Reply #9

It should be under 
Admin -> Security and Moderation -> Anti Spam 
on that screen, at the bottom is where it should show up ... if not then I made a mistake when I put the package together !

Re: [ADDON] ReCAPTCHA

Reply #10

@billwill

it's in Configuration > Security and Moderation > Anti Spam.
192.MY.ID: Forum ISP Indonesia.

Re: [ADDON] ReCAPTCHA

Reply #11

And there it is.  Thanks kucing!

Re: [ADDON] ReCAPTCHA

Reply #12

Great! A new way to prevent spam. Please keep improving on this.
Sorry in advance for bad english, stupid comments and links. A useful one can be found below:
Forum support - have a look here


Re: [ADDON] ReCAPTCHA

Reply #14

Thanks Spuds I needed that  8)