From aa90f3b43b1eb33e403a133c98e81b0ad8ae7472 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 18 Mar 2015 19:27:47 -0700 Subject: [PATCH] Remove ReCAPTCHA from remaining pages --- create.php | 53 +++++++++---------------------------- dnsbls_bypass.php | 35 +++++++++++------------- templates/8chan/create.html | 5 ++-- templates/8chan/dnsbls.html | 1 + templates/mod/settings.html | 2 +- 5 files changed, 32 insertions(+), 64 deletions(-) diff --git a/create.php b/create.php index 59134bd8..309ac9eb 100644 --- a/create.php +++ b/create.php @@ -1,35 +1,17 @@ '._('Game').'' . $ayah->getPublisherHTML() . ''; -} - -if (!$cbRecaptcha){ - $recapcha_html = ''; -} else { - $recapcha_html = 'reCaptcha' . recaptcha_get_html($config['recaptcha_public'], NULL, TRUE) . ''; -} - +include '8chan-captcha/functions.php'; $password = base64_encode(openssl_random_pseudo_bytes(9)); -$body = Element("8chan/create.html", array("config" => $config, "password" => $password, "game_html" => $game_html, "recapcha_html" => $recapcha_html)); +$captcha = generate_captcha($config['captcha']['extra']); + +$body = Element("8chan/create.html", array("config" => $config, "password" => $password, "captcha" => $captcha)); echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Create your board"), "subtitle" => _("before someone else does"))); } @@ -41,26 +23,13 @@ $subtitle = $_POST['subtitle']; $username = $_POST['username']; $password = $_POST['password']; - $resp = ($cbRecaptcha) ? recaptcha_check_answer ($config['recaptcha_private'], - $_SERVER["REMOTE_ADDR"], - $_POST["recaptcha_challenge_field"], - $_POST["recaptcha_response_field"]):false; +$resp = file_get_contents($config['captcha']['provider_check'] . "?" . http_build_query([ + 'mode' => 'check', + 'text' => $_POST['captcha_text'], + 'extra' => $config['captcha']['extra'], + 'cookie' => $_POST['captcha_cookie'] +])); -if ($resp != false){ -$passedCaptcha = $resp->is_valid; -} else { -$passedCaptcha = true; -} - -if (!$ayah){ -$score = true; -} else { -$score = $ayah->scoreResult(); -} -if (!$score) - error(_('You failed the game')); -if (!$passedCaptcha) - error(_('You failed to enter the reCaptcha correctly')); if (!preg_match('/^[a-z0-9]{1,30}$/', $uri)) error(_('Invalid URI')); if (!(strlen($title) < 40)) @@ -69,6 +38,8 @@ if (!(strlen($subtitle) < 200)) error(_('Invalid subtitle')); if (!preg_match('/^[a-zA-Z0-9._]{1,30}$/', $username)) error(_('Invalid username')); +if ($resp !== '1') + error($config['error']['captcha']); foreach (listBoards() as $i => $board) { if ($board['uri'] == $uri) diff --git a/dnsbls_bypass.php b/dnsbls_bypass.php index a37f1ca0..cf289b67 100644 --- a/dnsbls_bypass.php +++ b/dnsbls_bypass.php @@ -1,31 +1,26 @@ array('8.8.8.8'))); -$result = $dns->query(RECAPTCHA_VERIFY_SERVER, "A"); -if ($result and $result->answer[0]) { - $RECAPTCHA_VERIFY_SERVER_IP = $result->answer[0]->address; -} else { - $RECAPTCHA_VERIFY_SERVER_IP = RECAPTCHA_VERIFY_SERVER; -} +include '8chan-captcha/functions.php'; if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $ayah_html = recaptcha_get_html($config['recaptcha_public'], NULL, TRUE); - $body = Element("8chan/dnsbls.html", array("config" => $config, "ayah_html" => $ayah_html)); + $captcha = generate_captcha($config['captcha']['extra']); + + $html = "{$captcha['html']}
+ +
"; + + $body = Element("8chan/dnsbls.html", array("config" => $config, "ayah_html" => $html)); echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Bypass DNSBL"), "subtitle" => _("Post even if blocked"))); } else { - $score = recaptcha_check_answer($config['recaptcha_private'], - $_SERVER["REMOTE_ADDR"], - $_POST["recaptcha_challenge_field"], - $_POST["recaptcha_response_field"], - array(), - $RECAPTCHA_VERIFY_SERVER_IP); + $resp = file_get_contents($config['captcha']['provider_check'] . "?" . http_build_query([ + 'mode' => 'check', + 'text' => $_POST['captcha_text'], + 'extra' => $config['captcha']['extra'], + 'cookie' => $_POST['captcha_cookie'] + ])); - if ($score->is_valid) { + if ($resp === '1') { $tor = checkDNSBL($_SERVER['REMOTE_ADDR']); if (!$tor) { $query = prepare('INSERT INTO ``dnsbl_bypass`` VALUES(:ip, NOW()) ON DUPLICATE KEY UPDATE `created`=NOW()'); diff --git a/templates/8chan/create.html b/templates/8chan/create.html index b6470709..be0cf4b7 100644 --- a/templates/8chan/create.html +++ b/templates/8chan/create.html @@ -7,8 +7,9 @@ Subtitle {% trans %}(must be < 200 chars){% endtrans %} {% trans %}Username{% endtrans %} {% trans %}(must contain only alphanumeric, periods and underscores){% endtrans %} {% trans %}Password{% endtrans %} {% trans %}(write this down){% endtrans %} -{{ game_html }} -{{ recapcha_html }} +{% trans %}CAPTCHA{% endtrans %}{{ captcha['html'] }}
+ +
diff --git a/templates/8chan/dnsbls.html b/templates/8chan/dnsbls.html index 49c54efc..0e346a00 100644 --- a/templates/8chan/dnsbls.html +++ b/templates/8chan/dnsbls.html @@ -1,5 +1,6 @@

{% trans %}Your IP is listed in our DNSBL. To stop attackers, we require users who use certain IP ranges to pass a test which proves they are human every 24 hours.{% endtrans %}

+

{% trans %}Tor users need to fill out the CAPTCHA every 3 hours or 5 posts.{% endtrans %}

{% trans %}It is also possible that the site is currently under attack and we are requiring everyone to pass the test right now. Sorry for the inconvenience.{% endtrans %}

diff --git a/templates/mod/settings.html b/templates/mod/settings.html index 4c4a5cfa..c0f43ced 100644 --- a/templates/mod/settings.html +++ b/templates/mod/settings.html @@ -53,7 +53,7 @@ {% trans %}Public action log{% endtrans %}
{% trans %}Displays all actions to the public{% endtrans %}{% for i in range(2, 25) %}{% endfor %} {% trans %}Bump limit{% endtrans %} - {% trans %}Language{% endtrans %}
{% trans %}To contribute translations, register at Transifex{% endtrans %} + {% trans %}Language{% endtrans %}
{% trans %}Read this page for more information about contributing translations:
Translation tutorial or use Transifex{% endtrans %}