mirror of
https://github.com/hybula/whmcs-turnstile.git
synced 2025-12-19 14:59:24 +00:00
Merge pull request #17 from pplulee/main
feat: support captcha on reset page
This commit is contained in:
@@ -38,7 +38,7 @@ const hybulaTurnstileSite = '';
|
||||
const hybulaTurnstileSecret = '';
|
||||
const hybulaTurnstileTheme = 'auto';
|
||||
const hybulaTurnstileError = 'Something went wrong with your captcha challenge!';
|
||||
const hybulaTurnstileLocations = ['login', 'register', 'checkout', 'ticket', 'contact'];
|
||||
const hybulaTurnstileLocations = ['login', 'register', 'checkout', 'ticket', 'contact', 'reset'];
|
||||
```
|
||||
|
||||
Final notes: Due to some limitations, the captcha will **NOT** be shown when there is an active admin session. If you want to test it, open up your WHMCS in a private window.
|
||||
|
||||
@@ -23,11 +23,16 @@ if (!defined('WHMCS')) {
|
||||
if (! isset($_SESSION['adminid'])) {
|
||||
if (! empty($_POST) && (! isset($_SESSION['uid']) && hybulaTurnstileExcludeLogin)) {
|
||||
$pageFile = basename($_SERVER['SCRIPT_NAME'], '.php');
|
||||
if ((($pageFile == 'index' && isset($_POST['username']) && isset($_POST['password']) && in_array('login', hybulaTurnstileLocations)) ||
|
||||
if (hybulaTurnstileEnabled &&
|
||||
(
|
||||
($pageFile == 'index' && isset($_POST['username']) && isset($_POST['password']) && in_array('login', hybulaTurnstileLocations)) ||
|
||||
($pageFile == 'register' && in_array('register', hybulaTurnstileLocations)) ||
|
||||
($pageFile == 'contact' && in_array('contact', hybulaTurnstileLocations)) ||
|
||||
($pageFile == 'submitticket' && isset($_POST['subject']) && in_array('ticket', hybulaTurnstileLocations)) ||
|
||||
($pageFile == 'cart' && $_GET['a'] == 'checkout' && in_array('checkout', hybulaTurnstileLocations))) && hybulaTurnstileEnabled) {
|
||||
($pageFile == 'cart' && $_GET['a'] == 'checkout' && in_array('checkout', hybulaTurnstileLocations)) ||
|
||||
($pageFile == 'index' && isset($_POST['email']) && in_array('reset', hybulaCapLocations))
|
||||
)
|
||||
) {
|
||||
if (! isset($_POST['cf-turnstile-response'])) {
|
||||
unset($_SESSION['uid']);
|
||||
die('Missing captcha response in POST data!');
|
||||
@@ -67,11 +72,14 @@ if (!isset($_SESSION['adminid'])) {
|
||||
return '';
|
||||
}
|
||||
$pageFile = basename($_SERVER['SCRIPT_NAME'], '.php');
|
||||
if ((in_array('login', hybulaTurnstileLocations) && $vars['pagetitle'] == $vars['LANG']['login']) ||
|
||||
if (
|
||||
(in_array('login', hybulaTurnstileLocations) && $vars['pagetitle'] == $vars['LANG']['login']) ||
|
||||
(in_array('register', hybulaTurnstileLocations) && $pageFile == 'register') ||
|
||||
(in_array('contact', hybulaTurnstileLocations) && $pageFile == 'contact') ||
|
||||
(in_array('ticket', hybulaTurnstileLocations) && $pageFile == 'submitticket') ||
|
||||
(in_array('checkout', hybulaTurnstileLocations) && $pageFile == 'cart' && $_GET['a'] == 'checkout')) {
|
||||
(in_array('checkout', hybulaTurnstileLocations) && $pageFile == 'cart' && $_GET['a'] == 'checkout') ||
|
||||
(in_array('reset', hybulaCapLocations) && $vars['pagetitle'] == $vars['LANG']['pwreset'])
|
||||
) {
|
||||
return '<script>
|
||||
var turnstileDiv = document.createElement("div");
|
||||
turnstileDiv.innerHTML = \'<div class="cf-turnstile" data-sitekey="' . hybulaTurnstileSite . '" data-callback="javascriptCallback" data-theme="' . hybulaTurnstileTheme . '"></div>' . (hybulaTurnstileCredits ? '<a href="https://github.com/hybula/whmcs-turnstile" target="_blank"><small class="text-muted text-uppercase">Captcha integration by Hybula</small></a>' : '<!-- Captcha integration by Hybula (https://github.com/hybula/whmcs-turnstile) -->') . '<br><br>\';
|
||||
|
||||
Reference in New Issue
Block a user