More robust code

This commit is contained in:
Laurent Destailleur 2021-02-19 18:12:15 +01:00
parent 069cf46f16
commit 3d1dfccc1d
2 changed files with 2 additions and 2 deletions

View File

@ -598,7 +598,7 @@ if (!defined('NOLOGIN'))
if ($test && GETPOST("username", "alpha", 2) && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) && !isset($_SESSION['dol_bypass_antispam'])) if ($test && GETPOST("username", "alpha", 2) && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) && !isset($_SESSION['dol_bypass_antispam']))
{ {
$sessionkey = 'dol_antispam_value'; $sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'none'))));
// Check code // Check code
if (!$ok) if (!$ok)

View File

@ -146,7 +146,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('add', 'alpha')) {
// Check Captcha code if is enabled // Check Captcha code if is enabled
if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
$sessionkey = 'dol_antispam_value'; $sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'none'))));
if (!$ok) { if (!$ok) {
$error++; $error++;
array_push($object->errors, $langs->trans("ErrorBadValueForCode")); array_push($object->errors, $langs->trans("ErrorBadValueForCode"));