Fix captchas

This commit is contained in:
tim
2015-11-22 00:22:34 +02:00
parent 602d644181
commit 925a8572d0
11 changed files with 18 additions and 662 deletions
+11 -6
View File
@@ -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;