transfert du résultat dans un champ cahcé et hashé

This commit is contained in:
Prof Langues 2020-10-01 15:50:19 +02:00
parent 0216e0c1e1
commit 175dd51a18
5 changed files with 18 additions and 4 deletions

View File

@ -53,6 +53,8 @@ class template {
$letters = array('u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a'); $letters = array('u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a');
$firstNumber = rand ( 0 , count($letters)-1 ); $firstNumber = rand ( 0 , count($letters)-1 );
$secondNumber = rand ( 0 , count($letters)-1 ); $secondNumber = rand ( 0 , count($letters)-1 );
$result = $firstNumber + $secondNumber;
$result = password_hash($result, PASSWORD_BCRYPT);
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
@ -72,7 +74,13 @@ class template {
'<input type="text" %s>', '<input type="text" %s>',
helper::sprintAttributes($attributes) helper::sprintAttributes($attributes)
); );
// Champ résultat caché
$html .= self::hidden($attributes['id'] . 'Result', [
'value' => $result,
'before' => false
]);
// Champs cachés contenant les nombres // Champs cachés contenant les nombres
/*
$html .= self::hidden($attributes['id'] . 'FirstNumber', [ $html .= self::hidden($attributes['id'] . 'FirstNumber', [
'value' => $firstNumber, 'value' => $firstNumber,
'before' => false 'before' => false
@ -81,6 +89,7 @@ class template {
'value' => $secondNumber, 'value' => $secondNumber,
'before' => false 'before' => false
]); ]);
*/
// Fin du wrapper // Fin du wrapper
$html .= '</div>'; $html .= '</div>';
// Retourne le html // Retourne le html

View File

@ -1368,8 +1368,10 @@ th.col12 {
padding-left: 10px; padding-left: 10px;
padding-right: 10px; padding-right: 10px;
} }
#userLoginCaptcha, #userLoginCaptcha,
#formcaptcha { #formcaptcha,
#blogArticlecaptcha {
width: 20%; width: 20%;
text-align: center; text-align: center;
margin: auto; margin: auto;

View File

@ -336,7 +336,8 @@ class user extends common {
if($this->isPost()) { if($this->isPost()) {
// Check la captcha // Check la captcha
if( if(
$this->getInput('userLoginCaptcha', helper::FILTER_INT) !== $this->getInput('userLoginCaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('userLoginCaptchaSecondNumber', helper::FILTER_INT)) //$this->getInput('userLoginCaptcha', helper::FILTER_INT) !== $this->getInput('userLoginCaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('userLoginCaptchaSecondNumber', helper::FILTER_INT))
password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false )
{ {
self::$inputNotices['blogArticlecaptcha'] = 'Incorrect'; self::$inputNotices['blogArticlecaptcha'] = 'Incorrect';
} }

View File

@ -342,7 +342,8 @@ class blog extends common {
// Check la captcha // Check la captcha
if( if(
$this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
AND $this->getInput('blogArticlecaptcha', helper::FILTER_INT) !== $this->getInput('blogArticlecaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('blogArticlecaptchaSecondNumber', helper::FILTER_INT)) //AND $this->getInput('blogArticlecaptcha', helper::FILTER_INT) !== $this->getInput('blogArticlecaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('blogArticlecaptchaSecondNumber', helper::FILTER_INT))
AND password_verify($this->getInput('blogArticlecaptcha', helper::FILTER_INT), $this->getInput('blogArticlecaptchaResult') ) === false )
{ {
self::$inputNotices['blogArticlecaptcha'] = 'Incorrect'; self::$inputNotices['blogArticlecaptcha'] = 'Incorrect';
} }

View File

@ -282,7 +282,8 @@ class form extends common {
// Check la captcha // Check la captcha
if( if(
$this->getData(['module', $this->getUrl(0), 'config', 'captcha']) $this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
AND $this->getInput('formcaptcha', helper::FILTER_INT) !== $this->getInput('formcaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('formcaptchaSecondNumber', helper::FILTER_INT)) // AND $this->getInput('formcaptcha', helper::FILTER_INT) !== $this->getInput('formcaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('formcaptchaSecondNumber', helper::FILTER_INT))
AND password_verify($this->getInput('formcaptcha', helper::FILTER_INT), $this->getInput('formcaptchaResult') ) === false )
{ {
self::$inputNotices['formcaptcha'] = 'Incorrect'; self::$inputNotices['formcaptcha'] = 'Incorrect';