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

Commit 6a45090

Browse files
Nabeel Shahzadnabeelio
authored andcommitted
Changes for recaptcha
1 parent fdcb8e2 commit 6a45090

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ ed
77
phpvms.iml
88
core/local.config.php
99
*.iml
10+
core/cache/

core/app.config.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,12 @@
222222
Config::Set('VACENTRAL_NEWS_FEED', 'http://feeds.feedburner.com/vacentral');
223223
Config::Set('GEONAME_API_SERVER', 'http://ws.geonames.org');
224224

225-
/* Keys for recaptcha, you can change these if you want to your own but it's
226-
a global key so it should just work */
227-
Config::Set('RECAPTCHA_PUBLIC_KEY', '6LcklAsAAAAAAJqmghmMPOACeJrAxW3sJulSboxx');
228-
Config::Set('RECAPTCHA_PRIVATE_KEY', '6LcklAsAAAAAAMeQy5ZBoDu8JOMTP-UL7ek1GedO');
225+
# Add to the end of local.config.php
226+
# You need to get the keys from here: https://www.google.com/recaptcha/admin
227+
# Put the "Site Key" in RECAPTCHA_PUBLIC_KEY
228+
# Put the "Secret Key" in RECAPTCHA_PRIVATE_KEY
229+
Config::Set('RECAPTCHA_PUBLIC_KEY', '');
230+
Config::Set('RECAPTCHA_PRIVATE_KEY', '');
229231

230232
/* Whether you have the /admin/maintenance.php script added into cron.
231233
If you do, set this to true. This saves many DB calls since phpVMS will

core/bootstrap.inc.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
1717
*/
1818

19+
require_once CORE_PATH.'/lib/recaptcha/autoload.php';
20+
1921
function pre_module_load()
2022
{
2123
if(is_dir(CORE_PATH.'/local.config.php'))
@@ -150,4 +152,4 @@ function fileurl($path)
150152
function html_url($title, $url)
151153
{
152154
return '<a href="'.url($url).'" >'.$title.'</a>';
153-
}
155+
}

core/modules/Registration/Registration.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public function HTMLHead()
3131

3232
public function index()
3333
{
34-
require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';
35-
3634
if(Auth::LoggedIn()) // Make sure they don't over-ride it
3735
{
3836
$this->render('login_already.tpl');
@@ -167,13 +165,10 @@ protected function ProcessRegistration()
167165
protected function VerifyData()
168166
{
169167
$error = false;
168+
$recaptcha = new \ReCaptcha\ReCaptcha(Config::Get('RECAPTCHA_PRIVATE_KEY'));
169+
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
170170

171-
$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
172-
$_SERVER["REMOTE_ADDR"],
173-
$_POST["recaptcha_challenge_field"],
174-
$_POST["recaptcha_response_field"]);
175-
176-
if(!$resp->is_valid)
171+
if(!$resp->isSuccess())
177172
{
178173
$error = true;
179174
$this->set('captcha_error', $resp->error);
@@ -256,4 +251,4 @@ protected function VerifyData()
256251

257252
return true;
258253
}
259-
}
254+
}

core/templates/registration_mainform.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@
9090

9191
<dt>reCaptcha</dt>
9292
<dd>
93-
<?php
94-
echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
95-
?>
93+
<div class="g-recaptcha" data-sitekey="<?php echo Config::Get('RECAPTCHA_PUBLIC_KEY'); ?>"></div>
94+
<script type="text/javascript"
95+
src="https://www.google.com/recaptcha/api.js?hl=en">
96+
</script>
9697
</dd>
9798

9899
<dt></dt>

0 commit comments

Comments
 (0)