From e59927290be2b820f01d352093022f51c2b0fa21 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Tue, 13 Apr 2021 22:40:31 -0700 Subject: [PATCH] Add TINYIB_REPORTCAPTCHA Resolves #187. --- imgboard.php | 60 ++++++++++++++++++++++++++++++++++++++++++-- inc/defines.php | 3 +++ settings.default.php | 1 + 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/imgboard.php b/imgboard.php index 3dae738..d83b9e1 100644 --- a/imgboard.php +++ b/imgboard.php @@ -38,7 +38,8 @@ while (ob_get_level() > 0) { ob_end_flush(); } -function fancyDie($message) { +function fancyDie($message) +{ $back = 'Click here to go back'; if (function_exists('__')) { $back = __('Click here to go back'); @@ -54,7 +55,8 @@ require 'inc/defines.php'; global $tinyib_capcodes, $tinyib_embeds, $tinyib_hidefields, $tinyib_hidefieldsop; if (!defined('TINYIB_LOCALE') || TINYIB_LOCALE == '') { - function __($string) { + function __($string) + { return $string; } } else { @@ -574,6 +576,60 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) fancyDie(__('You have already submitted a report for that post.')); } + if (TINYIB_REPORTCAPTCHA != '') { + if (isset($_GET['verify'])) { + checkCAPTCHA(TINYIB_REPORTCAPTCHA); + } else { + if (TINYIB_REPORTCAPTCHA === 'hcaptcha') { + $captcha = ' +
+
+
+


'; + } else if (TINYIB_REPORTCAPTCHA === 'recaptcha') { + $captcha = ' +
+
+
+ +


'; + } else { // Simple CAPTCHA + $captcha = ' +
+  ' . __('(enter the text below)') . '
+CAPTCHA

'; + } + + $txt_report = __('Please complete a CAPTCHA to submit your report'); + $txt_submit = __('Submit'); + $body = << +
+$txt_report + +
+ +EOF; + + echo pageHeader() . $body . pageFooter(); + die(); + } + } + $report = array('ip' => $_SERVER['REMOTE_ADDR'], 'post' => $post['id']); insertReport($report); diff --git a/inc/defines.php b/inc/defines.php index 8554e8c..2d640dc 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -61,6 +61,9 @@ if (!defined('TINYIB_NOFILEOK')) { if (!defined('TINYIB_CAPTCHA')) { define('TINYIB_CAPTCHA', ''); } +if (!defined('TINYIB_REPORTCAPTCHA')) { + define('TINYIB_REPORTCAPTCHA', ''); +} if (!defined('TINYIB_MANAGECAPTCHA')) { define('TINYIB_MANAGECAPTCHA', ''); } diff --git a/settings.default.php b/settings.default.php index badca7f..04b95bb 100644 --- a/settings.default.php +++ b/settings.default.php @@ -25,6 +25,7 @@ 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_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 define('TINYIB_REQMOD', ''); // Require moderation before displaying posts: files / all ['' to disable]