savetheinternet / Tinyboard

The better imageboard software
http://tinyboard.org
Other
368 stars 311 forks source link

Something weird after replacing ReCaptcha #201

Open rotenbaron opened 8 years ago

rotenbaron commented 8 years ago

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