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

Commit 88656de

Browse files
committed
Recaptcha on contact page
1 parent cf90787 commit 88656de

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

core/modules/Contact/Contact.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class Contact extends CodonModule
2020
{
2121
public function index()
2222
{
23-
require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';
24-
25-
2623
if($this->post->submit)
2724
{
2825
if(Auth::LoggedIn() == false)
@@ -37,13 +34,11 @@ public function index()
3734
}
3835
}
3936

40-
$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
41-
$_SERVER["REMOTE_ADDR"],
42-
$_POST["recaptcha_challenge_field"],
43-
$_POST["recaptcha_response_field"]);
37+
$recaptcha = new \ReCaptcha\ReCaptcha(Config::Get('RECAPTCHA_PRIVATE_KEY'));
38+
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
4439

4540
// Check the captcha thingy
46-
if(!$resp->is_valid)
41+
if(!$resp->isSuccess())
4742
{
4843
$this->set('captcha_error', $resp->error);
4944
$this->set('message', 'You failed the captcha test!');

core/templates/contact_form.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@
5656
<tr>
5757
<td width="1%" nowrap><strong>Captcha</strong></td>
5858
<td>
59-
<?php
60-
echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
61-
?>
59+
<div class="g-recaptcha" data-sitekey="<?php echo Config::Get('RECAPTCHA_PUBLIC_KEY'); ?>"></div>
60+
<script type="text/javascript"
61+
src="https://www.google.com/recaptcha/api.js?hl=en">
62+
</script>
6263
</td>
6364
</tr>
6465

0 commit comments

Comments
 (0)