Jump to content

[not doable - ignore this post]reCapture update


Morgan

Recommended Posts

https://www.google.com/recaptcha/intro/index.html

Than put the below code in your local.config.php and replace with your keys.

/* Keys for recaptcha, you can change these if you want to your own but it's a global key so it should just work */
Config::Set('RECAPTCHA_PUBLIC_KEY', 'key 1');
Config::Set('RECAPTCHA_PRIVATE_KEY', 'key 2');

Link to comment
Share on other sites

  • 2 weeks later...

thanks will try

https://www.google.c...ntro/index.html

Than put the below code in your local.config.php and replace with your keys.

/* Keys for recaptcha, you can change these if you want to your own but it's a global key so it should just work */
Config::Set('RECAPTCHA_PUBLIC_KEY', 'key 1');
Config::Set('RECAPTCHA_PRIVATE_KEY', 'key 2');

I already told you how to do it.

Link to comment
Share on other sites

Easiest solution, upgrade to this

https://github.com/D...rk/phpvms_5.5.x

Otherwise

1. Re-add these files to the location https://github.com/D...e/lib/recaptcha

specifically this file https://github.com/D...ecaptchalib.php but try the rest as well

add them to core/lib/recaptcha

2. https://www.google.c...ntro/index.html get your API Keys

3. Add this code to your local.config.php (Make sure it's not already in there otherwise it will cause issues)

/* Keys for recaptcha, you can change these if you want to your own but it's
a global key so it should just work */
Config::Set('RECAPTCHA_PUBLIC_KEY', 'YOUR PUBLIC API KEY');
Config::Set('RECAPTCHA_PRIVATE_KEY', 'YOUR PRIVATE API KEY');

4. Go into your registration_mainform.tpl file and find this

<?php
//Put this in a seperate template. Shows the Custom Fields for registration
Template::Show('registration_customfields.tpl');
?>
<dt>reCaptcha</dt>
<dd>
<?php
echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
?>
</dd>

And replace it with this

<?php

//Put this in a seperate template. Shows the Custom Fields for registration
Template::Show('registration_customfields.tpl');

?>

<dt>reCaptcha</dt>
<dd>
<?php if(isset($captcha_error)){echo '<p class="error">'.$captcha_error.'</p>';} ?>
<div class="g-recaptcha" data-sitekey="<?php echo $sitekey;?>"></div>
<script type="text/javascript" src="[url="https://www.google.com/recaptcha/api.js?hl=<?php"]https://www.google.c...api.js?hl=<?php[/url] echo $lang;?>">
</script>
</dd>

5. Then in core/modules/Registration/Registration.php find this function

protected function VerifyData()

And in there you will find this

$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(!$resp->is_valid)
{
$error = true;
$this->set('captcha_error', $resp->error);
}
else
$this->set('captcha_error', '');

replace it with this

//Google reCaptcha
//updated to Google noCaptcha 1/15
$resp = null;
$reCaptcha = new ReCaptcha(RECAPTCHA_PRIVATE_KEY);
// Was there a reCAPTCHA response?
if ($_POST["g-recaptcha-response"]) {
 $resp = $reCaptcha->verifyResponse(
 $_SERVER["REMOTE_ADDR"],
 $_POST["g-recaptcha-response"]
);
}
//check if reCaptcha response was valid
if ($resp == null) {
 $error = true;
 $this->set('captcha_error', 'reCaptcha Validation Error');
}

And that should work.

Remember that anything (within reason) is doable, but sometimes you have to look hard to find the answers.

Edited by web541
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...