Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something weird after replacing ReCaptcha #201

Open
rotenbaron opened this issue Jan 14, 2016 · 0 comments
Open

Something weird after replacing ReCaptcha #201

rotenbaron opened this issue Jan 14, 2016 · 0 comments

Comments

@rotenbaron
Copy link

I have replaced old ReCaptcha with new NoCaptcha ReCaptcha wich is look like that:

old code
post.php:198-208

if ($config['recaptcha']) {
    if (!isset($_POST['recaptcha_challenge_field']) || !isset($_POST['recaptcha_response_field']))
        error($config['error']['bot']);
    // Check what reCAPTCHA has to say...
    $resp = recaptcha_check_answer($config['recaptcha_private'],
        $_SERVER['REMOTE_ADDR'],
        $_POST['recaptcha_challenge_field'],
        $_POST['recaptcha_response_field']);
    if (!$resp->is_valid) {
        error($config['error']['captcha']);
    }
}

new code
post.php:198-211

if ($config['recaptcha']) {
    if (!isset($_POST['g-recaptcha-response'])) {
    // Check what reCAPTCHA has to say...
        error($config['error']['bot']);
    } else {
        $captcha=$_POST['g-recaptcha-response'];
    }

    $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$config['recaptcha_private']."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    $decoded_response = json_decode($response, true);

    if($decoded_response["success"] == false) {
        error($config['error']['captcha']);
    }
}

After that flood checker (post.php:229-232) ends up with an error no matter what you typing. Which has no sense to me.

if (!$post['mod']) {
    $post['antispam_hash'] = checkSpam(array($board['uri'], isset($post['thread']) && !($config['quick_reply'] && isset($_POST['quick-reply'])) ? $post['thread'] : ($config['try_smarter'] && isset($_POST['page']) ? 0 - (int)$_POST['page'] : null)));
    if ($post['antispam_hash'] === true)
        error($config['error']['spam']);
}

Anyone has any ideas? BTW new ReCaptcha working just fine if delete this flood checker all together.

19-25-12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant