Browse Source

Add TINYIB_REPLYCAPTCHA

This allows different CAPTCHA settings for new threads and replies.

Resolves #131.
sqlitefix
Trevor Slocum 2 months ago
parent
commit
c09278028d
  1. 14
      imgboard.php
  2. 3
      inc/defines.php
  3. 12
      inc/html.php
  4. 7
      settings.default.php

14
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.<br>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);

3
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', '');
}

12
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 .= '<script src="https://www.hcaptcha.com/1/api.js" async defer></script>';
}
if (TINYIB_CAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') {
if (TINYIB_CAPTCHA === 'recaptcha' || TINYIB_REPLYCAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha') {
$js_captcha .= '<script src="https://www.google.com/recaptcha/api.js" async defer></script>';
}
@ -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 = '
<div style="min-height: 82px;">
<div class="h-captcha" data-sitekey="' . TINYIB_HCAPTCHA_SITE . '"></div>
</div>';
} else if (TINYIB_CAPTCHA === 'recaptcha') {
} else if ($captcha_setting === 'recaptcha') {
$captcha_inner_html = '
<div style="min-height: 80px;">
<div class="g-recaptcha" data-sitekey="' . TINYIB_RECAPTCHA_SITE . '"></div>

7
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

Loading…
Cancel
Save