post.php: use the dynamic_captcha config value to pick from which IP to check for captcha reponsens

This commit is contained in:
Zankaria 2024-07-29 20:46:30 +02:00
parent fccd0a16dd
commit 40475158eb
2 changed files with 7 additions and 3 deletions

View file

@ -329,7 +329,11 @@
'answer' => '4' 'answer' => '4'
); );
*/ */
// The captcha is dynamically injected on the client if the server replies with the `captcha-required` cookie set to 1. /**
* The captcha is dynamically injected on the client if the server replies with the `captcha-required` cookie set
* to 1.
* Use false to disable this configuration, otherwise, set the IP that vichan should check for captcha responses.
*/
$config['dynamic_captcha'] = false; $config['dynamic_captcha'] = false;
// Enable reCaptcha to make spam even harder. Rarely necessary. // Enable reCaptcha to make spam even harder. Rarely necessary.

View file

@ -727,7 +727,7 @@ function handle_post()
if (!$dropped_post) { if (!$dropped_post) {
if ($config['dynamic_captcha'] && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { if ($config['dynamic_captcha'] !== false && $_SERVER['REMOTE_ADDR'] === $config['dynamic_captcha']) {
if ($config['recaptcha']) { if ($config['recaptcha']) {
if (!isset($_POST['g-recaptcha-response'])) { if (!isset($_POST['g-recaptcha-response'])) {
error($config['error']['bot']); error($config['error']['bot']);
@ -747,7 +747,7 @@ function handle_post()
} }
// Check for CAPTCHA right after opening the board so the "return" link is in there. // Check for CAPTCHA right after opening the board so the "return" link is in there.
if (!$config['dynamic_captcha']) { if ($config['dynamic_captcha'] === false) {
if ($config['recaptcha']) { if ($config['recaptcha']) {
if (!isset($_POST['g-recaptcha-response'])) { if (!isset($_POST['g-recaptcha-response'])) {
error($config['error']['bot']); error($config['error']['bot']);