Fix captchas
This commit is contained in:
+11
-6
@@ -2,12 +2,17 @@
|
||||
$result = get_post_data(TRUE, TRUE);
|
||||
extract($result[0], EXTR_OVERWRITE);
|
||||
|
||||
if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
|
||||
include_once('../lib/recaptchalib.inc.php');
|
||||
$privatekey = config('RECAPTCHA_SECRET');
|
||||
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"],
|
||||
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
|
||||
if (!$resp->is_valid) {
|
||||
if (isset($_POST['g-recaptcha-response'])) {
|
||||
$captcha = $_POST['g-recaptcha-response'];
|
||||
if (! $captcha) {
|
||||
$validate['captcha'] = 'Invalid captcha. Please try again.';
|
||||
include('./write.inc.php');
|
||||
return;
|
||||
}
|
||||
$captcha_resp = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".urlencode(config('RECAPTCHA_SECRET'))."&response=".
|
||||
$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
|
||||
var_dump($captcha_resp);
|
||||
if ($captcha_resp.success==false) {
|
||||
$validate['captcha'] = 'The words you typed in the captcha were not correct. Please try again.';
|
||||
include('./write.inc.php');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user