diff --git a/imgboard.php b/imgboard.php index c1dbb9d..8c5c86e 100644 --- a/imgboard.php +++ b/imgboard.php @@ -66,11 +66,11 @@ if (!defined('TINYIB_LOCALE') || TINYIB_LOCALE == '') { $translator->register(); } -if ((TINYIB_CAPTCHA === 'hcaptcha' || TINYIB_MANAGECAPTCHA === 'hcaptcha') && (TINYIB_HCAPTCHA_SITE == '' || TINYIB_HCAPTCHA_SECRET == '')) { +if ((TINYIB_CAPTCHA === 'hcaptcha' || TINYIB_REPLYCAPTCHA === 'hcaptcha' || TINYIB_MANAGECAPTCHA === 'hcaptcha') && (TINYIB_HCAPTCHA_SITE == '' || TINYIB_HCAPTCHA_SECRET == '')) { fancyDie(__('TINYIB_HCAPTCHA_SITE and TINYIB_HCAPTCHA_SECRET must be configured.')); } -if ((TINYIB_CAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') && (TINYIB_RECAPTCHA_SITE == '' || TINYIB_RECAPTCHA_SECRET == '')) { +if ((TINYIB_CAPTCHA === 'recaptcha' || TINYIB_REPLYCAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') && (TINYIB_RECAPTCHA_SITE == '' || TINYIB_RECAPTCHA_SECRET == '')) { fancyDie(__('TINYIB_RECAPTCHA_SITE and TINYIB_RECAPTCHA_SECRET must be configured.')); } @@ -269,11 +269,6 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) fancyDie(__('Posting is currently disabled.
Please try again in a few moments.')); } - if (!$loggedin) { - checkCAPTCHA(TINYIB_CAPTCHA); - checkFlood(); - } - $staffpost = isStaffPost(); $capcode = ''; if (!$staffpost) { @@ -282,6 +277,11 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) $post = newPost(setParent()); + if (!$loggedin) { + checkCAPTCHA($post['parent'] == TINYIB_NEWTHREAD ? TINYIB_CAPTCHA : TINYIB_REPLYCAPTCHA); + checkFlood(); + } + if (!$loggedin) { if ($post['parent'] == TINYIB_NEWTHREAD && TINYIB_DISALLOWTHREADS != '') { fancyDie(TINYIB_DISALLOWTHREADS); diff --git a/inc/defines.php b/inc/defines.php index 9c0b96e..a280493 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -64,6 +64,9 @@ if (!defined('TINYIB_NOFILEOK')) { if (!defined('TINYIB_CAPTCHA')) { define('TINYIB_CAPTCHA', ''); } +if (!defined('TINYIB_REPLYCAPTCHA')) { + define('TINYIB_REPLYCAPTCHA', TINYIB_CAPTCHA); +} if (!defined('TINYIB_REPORTCAPTCHA')) { define('TINYIB_REPORTCAPTCHA', ''); } diff --git a/inc/html.php b/inc/html.php index a078c33..818b5a2 100644 --- a/inc/html.php +++ b/inc/html.php @@ -13,10 +13,10 @@ function pageHeader() { } $js_captcha = ''; - if (TINYIB_CAPTCHA === 'hcaptcha' || TINYIB_MANAGECAPTCHA === 'hcaptcha') { + if (TINYIB_CAPTCHA === 'hcaptcha' || TINYIB_REPLYCAPTCHA === 'hcaptcha' || TINYIB_MANAGECAPTCHA === 'hcaptcha') { $js_captcha .= ''; } - if (TINYIB_CAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') { + if (TINYIB_CAPTCHA === 'recaptcha' || TINYIB_REPLYCAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') { $js_captcha .= ''; } @@ -196,14 +196,16 @@ EOF; $embed_input_html = ''; $unique_posts_html = ''; + $captcha_setting = $parent == TINYIB_NEWTHREAD ? TINYIB_CAPTCHA : TINYIB_REPLYCAPTCHA; + $captcha_html = ''; - if (TINYIB_CAPTCHA && !$staff_post) { - if (TINYIB_CAPTCHA === 'hcaptcha') { + if ($captcha_setting && !$staff_post) { + if ($captcha_setting === 'hcaptcha') { $captcha_inner_html = '
'; - } else if (TINYIB_CAPTCHA === 'recaptcha') { + } else if ($captcha_setting === 'recaptcha') { $captcha_inner_html = '
diff --git a/settings.default.php b/settings.default.php index eb7e1d8..c91b503 100644 --- a/settings.default.php +++ b/settings.default.php @@ -26,7 +26,8 @@ define('TINYIB_BOARD', 'b'); // Unique identifier for this board using define('TINYIB_BOARDDESC', 'TinyIB'); // Displayed below logo in page headers define('TINYIB_BOARDTITLE', ''); // Title of board pages. When blank, defaults to TINYIB_BOARDDESC (when set) or "TinyIB" define('TINYIB_ALWAYSNOKO', false); // Redirect to thread after posting -define('TINYIB_CAPTCHA', ''); // Reduce spam by requiring users to pass a CAPTCHA when posting: simple / hcaptcha / recaptcha ['' to disable] +define('TINYIB_CAPTCHA', ''); // Reduce spam by requiring users to pass a CAPTCHA when posting a new thread: simple / hcaptcha / recaptcha ['' to disable] +define('TINYIB_REPLYCAPTCHA', ''); // Reduce spam by requiring users to pass a CAPTCHA when posting a reply: simple / hcaptcha / recaptcha ['' to disable] define('TINYIB_REPORTCAPTCHA', ''); // Reduce invalid reports by requiring users to pass a CAPTCHA when reporting: simple / hcaptcha / recaptcha ['' to disable] define('TINYIB_MANAGECAPTCHA', ''); // Improve security by requiring users to pass a CAPTCHA when logging in to the management panel: simple / hcaptcha / recaptcha ['' to disable] define('TINYIB_REPORT', false); // Allow users to report posts @@ -119,11 +120,11 @@ define('TINYIB_MAXH', 250); // Height define('TINYIB_TRIPSEED', ''); // Enter some random text (used when generating secure tripcodes, hashing passwords and hashing IP addresses) // CAPTCHA - hCaptcha / reCAPTCHA -// The following settings apply when TINYIB_CAPTCHA is set to hcaptcha +// The following settings only apply when using hcaptcha // For API keys visit https://dashboard.hcaptcha.com/signup define('TINYIB_HCAPTCHA_SITE', ''); // Site key define('TINYIB_HCAPTCHA_SECRET', ''); // Secret key -// The following settings apply when TINYIB_CAPTCHA is set to recaptcha +// The following settings only apply when using recaptcha // For API keys visit https://www.google.com/recaptcha define('TINYIB_RECAPTCHA_SITE', ''); // Site key define('TINYIB_RECAPTCHA_SECRET', '');// Secret key