Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Recaptcha on contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Jun 17, 2018
1 parent cf90787 commit 88656de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
11 changes: 3 additions & 8 deletions core/modules/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class Contact extends CodonModule
{
public function index()
{
require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';


if($this->post->submit)
{
if(Auth::LoggedIn() == false)
Expand All @@ -37,13 +34,11 @@ public function index()
}
}

$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
$recaptcha = new \ReCaptcha\ReCaptcha(Config::Get('RECAPTCHA_PRIVATE_KEY'));
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);

// Check the captcha thingy
if(!$resp->is_valid)
if(!$resp->isSuccess())
{
$this->set('captcha_error', $resp->error);
$this->set('message', 'You failed the captcha test!');
Expand Down
7 changes: 4 additions & 3 deletions core/templates/contact_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
<tr>
<td width="1%" nowrap><strong>Captcha</strong></td>
<td>
<?php
echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
?>
<div class="g-recaptcha" data-sitekey="<?php echo Config::Get('RECAPTCHA_PUBLIC_KEY'); ?>"></div>
<script type="text/javascript"
src="https://www.google.com/recaptcha/api.js?hl=en">
</script>
</td>
</tr>

Expand Down

0 comments on commit 88656de

Please sign in to comment.