From ad3731ec67f09c958dbaba9d1527c2de1b6d6779 Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Sat, 16 Sep 2023 01:27:20 -0700 Subject: [PATCH 1/3] add hCaptcha support --- post.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/post.php b/post.php index b3d3203a..e2585a36 100644 --- a/post.php +++ b/post.php @@ -410,6 +410,31 @@ if (isset($_POST['delete'])) { error($config['error']['captcha']); } } + // hCaptcha + if ($config['hcaptcha']) { + if (!isset($_POST['h-captcha-response'])) { + error($config['error']['bot']); + } + + $data = array( + 'secret' => $config['hcaptcha_private'], + 'response' => $_POST['h-captcha-response'], + 'remoteip' => $_SERVER['REMOTE_ADDR'] + ); + + $hcaptchaverify = curl_init(); + curl_setopt($hcaptchaverify, CURLOPT_URL, "https://hcaptcha.com/siteverify"); + curl_setopt($hcaptchaverify, CURLOPT_POST, true); + curl_setopt($hcaptchaverify, CURLOPT_POSTFIELDS, http_build_query($data)); + curl_setopt($hcaptchaverify, CURLOPT_RETURNTRANSFER, true); + $hcaptcharesponse = curl_exec($hcaptchaverify); + + $resp = json_decode($hcaptcharesponse, true); // Decoding $hcaptcharesponse instead of $response + + if (!$resp['success']) { + error($config['error']['captcha']); + } + } // Same, but now with our custom captcha provider if (($config['captcha']['enabled']) || (($post['op']) && ($config['new_thread_capt'])) ) { $ch = curl_init($config['domain'].'/'.$config['captcha']['provider_check'] . "?" . http_build_query([ From f396204e44563d414308801a041afb3f98755642 Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Sat, 16 Sep 2023 01:31:02 -0700 Subject: [PATCH 2/3] add hcaptcha support --- inc/config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/config.php b/inc/config.php index 545d8c1c..e85407ed 100644 --- a/inc/config.php +++ b/inc/config.php @@ -295,6 +295,7 @@ 'raw', 'embed', 'g-recaptcha-response', + 'h-captcha-response', 'captcha_cookie', 'captcha_text', 'spoiler', @@ -313,6 +314,10 @@ $config['recaptcha_public'] = '6LcXTcUSAAAAAKBxyFWIt2SO8jwx4W7wcSMRoN3f'; $config['recaptcha_private'] = '6LcXTcUSAAAAAOGVbVdhmEM1_SyRF4xTKe8jbzf_'; + // Public and private key pair for using hCaptcha. + $config['hcaptcha_public'] = '7a4b21e0-dc53-46f2-a9f8-91d2e74b63a0'; + $config['hcaptcha_private'] = '0x4e9A01bE637b51dC41a7Ea9865C3fDe4aB72Cf17'; + // Enable Custom Captcha you need to change a couple of settings //Read more at: /inc/captcha/readme.md $config['captcha'] = array(); From 5e26d5f09e10b45c69eb25793656430e7a98b7a4 Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Sat, 16 Sep 2023 01:32:01 -0700 Subject: [PATCH 3/3] add hcaptcha support --- templates/post_form.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/templates/post_form.html b/templates/post_form.html index 0febce44..80e4e1ca 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -84,6 +84,18 @@ {% endif %} + {% if config.hcaptcha %} + + + {% trans %}Verification{% endtrans %} + {{ antibot.html() }} + + +
+ {{ antibot.html() }} + + + {% endif %} {% if config.captcha.enabled %}