From b4e7a0f5f48b53024a2faabccd439894b2e44d7c Mon Sep 17 00:00:00 2001 From: Prof Langues Date: Thu, 8 Oct 2020 15:16:01 +0200 Subject: [PATCH 1/4] =?UTF-8?q?erreur=20login=20captcha=20erron=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/user/user.php | 191 +++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 95 deletions(-) diff --git a/core/module/user/user.php b/core/module/user/user.php index 279c23ba..4f88d863 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -337,118 +337,119 @@ class user extends common { // Check la captcha if( $this->getData(['config','connect','captcha']) - //$this->getInput('userLoginCaptcha', helper::FILTER_INT) !== $this->getInput('userLoginCaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('userLoginCaptchaSecondNumber', helper::FILTER_INT)) + AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false ) { self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; - } + } else { - // Lire Id du compte - $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); + // Lire Id du compte + $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); - /** - * Aucun compte existant - */ - if ( !$this->getData(['user', $userId])) { - //Stockage de l'IP - $this->setData([ - 'blacklist', - $userId, - [ - 'connectFail' => $this->getData(['blacklist',$userId,'connectFail']) + 1, - 'lastFail' => time(), - 'ip' => helper::getIp() - ] - ]); - // Verrouillage des IP - $ipBlackList = helper::arrayCollumn($this->getData(['blacklist']), 'ip'); - if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt']) - AND in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) { - // Valeurs en sortie - $this->addOutput([ - 'notification' => 'Trop de tentatives, compte verrouillé', - 'redirect' => helper::baseUrl(), - 'state' => false + /** + * Aucun compte existant + */ + if ( !$this->getData(['user', $userId])) { + //Stockage de l'IP + $this->setData([ + 'blacklist', + $userId, + [ + 'connectFail' => $this->getData(['blacklist',$userId,'connectFail']) + 1, + 'lastFail' => time(), + 'ip' => helper::getIp() + ] ]); - } else { - // Valeurs en sortie - $this->addOutput([ - 'notification' => 'Identifiant ou mot de passe incorrect' - ]); - } - /** - * Le compte existe - */ - } else { - // Cas 4 : le délai de blocage est dépassé et le compte est au max - Réinitialiser - if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() - AND $this->getData(['user',$userId,'connectFail']) === $this->getData(['config', 'connect', 'attempt']) ) { - $this->setData(['user',$userId,'connectFail',0 ]); - $this->setData(['user',$userId,'connectTimeout',0 ]); - } - // Check la présence des variables et contrôle du blocage du compte si valeurs dépassées - // Vérification du mot de passe et du groupe - if ( - ( $this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) ) < time() - AND $this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt']) - AND password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password'])) - AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER - ) { - // Expiration - $expire = $this->getInput('userLoginLongTime') ? strtotime("+1 year") : 0; - $c = $this->getInput('userLoginLongTime', helper::FILTER_BOOLEAN) === true ? 'true' : 'false'; - setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false) , '', helper::isHttps(), true); - setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', helper::isHttps(), true); - setcookie('ZWII_USER_LONGTIME', $c, $expire, helper::baseUrl(false, false), '', helper::isHttps(), true); - // Accès multiples avec le même compte - $this->setData(['user',$userId,'accessCsrf',$_SESSION['csrf']]); - // Valeurs en sortie lorsque le site est en maintenance et que l'utilisateur n'est pas administrateur - if( - $this->getData(['config', 'maintenance']) - AND $this->getData(['user', $userId, 'group']) < self::GROUP_ADMIN - ) { + // Verrouillage des IP + $ipBlackList = helper::arrayCollumn($this->getData(['blacklist']), 'ip'); + if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt']) + AND in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) { + // Valeurs en sortie $this->addOutput([ - 'notification' => 'Seul un administrateur peut se connecter lors d\'une maintenance', + 'notification' => 'Trop de tentatives, compte verrouillé', 'redirect' => helper::baseUrl(), 'state' => false ]); } else { // Valeurs en sortie $this->addOutput([ - 'notification' => 'Connexion réussie', - 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), - 'state' => true + 'notification' => 'Identifiant ou mot de passe incorrect' ]); } - // Sinon notification d'échec - } else { - $notification = 'Identifiant ou mot de passe incorrect'; - // Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec - if ($this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) { - $this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); + /** + * Le compte existe + */ + } else { + // Cas 4 : le délai de blocage est dépassé et le compte est au max - Réinitialiser + if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() + AND $this->getData(['user',$userId,'connectFail']) === $this->getData(['config', 'connect', 'attempt']) ) { + $this->setData(['user',$userId,'connectFail',0 ]); + $this->setData(['user',$userId,'connectTimeout',0 ]); } - // Cas 2 la limite du nombre de connexion est atteinte : placer le timer - if ( $this->getdata(['user',$userId,'connectFail']) == $this->getData(['config', 'connect', 'attempt']) ) { - $this->setData(['user',$userId,'connectTimeout', time()]); + // Check la présence des variables et contrôle du blocage du compte si valeurs dépassées + // Vérification du mot de passe et du groupe + if ( + ( $this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) ) < time() + AND $this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt']) + AND password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password'])) + AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER + ) { + // Expiration + $expire = $this->getInput('userLoginLongTime') ? strtotime("+1 year") : 0; + $c = $this->getInput('userLoginLongTime', helper::FILTER_BOOLEAN) === true ? 'true' : 'false'; + setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false) , '', helper::isHttps(), true); + setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', helper::isHttps(), true); + setcookie('ZWII_USER_LONGTIME', $c, $expire, helper::baseUrl(false, false), '', helper::isHttps(), true); + // Accès multiples avec le même compte + $this->setData(['user',$userId,'accessCsrf',$_SESSION['csrf']]); + // Valeurs en sortie lorsque le site est en maintenance et que l'utilisateur n'est pas administrateur + if( + $this->getData(['config', 'maintenance']) + AND $this->getData(['user', $userId, 'group']) < self::GROUP_ADMIN + ) { + $this->addOutput([ + 'notification' => 'Seul un administrateur peut se connecter lors d\'une maintenance', + 'redirect' => helper::baseUrl(), + 'state' => false + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'notification' => 'Connexion réussie', + 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), + 'state' => true + ]); + } + // Sinon notification d'échec + } else { + $notification = 'Identifiant ou mot de passe incorrect'; + // Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec + if ($this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) { + $this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); + } + // Cas 2 la limite du nombre de connexion est atteinte : placer le timer + if ( $this->getdata(['user',$userId,'connectFail']) == $this->getData(['config', 'connect', 'attempt']) ) { + $this->setData(['user',$userId,'connectTimeout', time()]); + } + // Cas 3 le délai de bloquage court + if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() ) { + $notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; + } + // Journalisation + $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; + $dataLog .= helper::getIp() . ';'; + $dataLog .= $userId . ';' ; + $dataLog .= $this->getUrl() .';' ; + $dataLog .= 'échec de connexion' ; + $dataLog .= PHP_EOL; + if ($this->getData(['config','connect','log'])) { + file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); + } + // Valeurs en sortie + $this->addOutput([ + 'notification' => $notification + ]); } - // Cas 3 le délai de bloquage court - if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() ) { - $notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; - } - // Journalisation - $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; - $dataLog .= helper::getIp() . ';'; - $dataLog .= $userId . ';' ; - $dataLog .= $this->getUrl() .';' ; - $dataLog .= 'échec de connexion' ; - $dataLog .= PHP_EOL; - if ($this->getData(['config','connect','log'])) { - file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); - } - // Valeurs en sortie - $this->addOutput([ - 'notification' => $notification - ]); } } } From 00a3243d8730dbe8cc739253da28eb73794512ce Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 8 Oct 2020 20:47:57 +0200 Subject: [PATCH 2/4] gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 7707a26e..8a247dc6 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Fichiers temporaires site/tmp/*.zip site/tmp/*.gz +site/tmp/*.png # Sauvegardes site/backup/* @@ -35,3 +36,9 @@ site/data/journal.log .DS_Store site/.DS_Store site/file/.DS_Store +site/tmp/5f7f5e998762c.png +site/tmp/5f7f5e9987628.png +site/tmp/5f7f5ea3e983b.png +site/tmp/5f7f5ea3e9837.png +site/tmp/5f7f5ea20d5eb.png +site/tmp/5f7f5ea20d5ee.png From 2e929d142b3d866ac37b366a06498d816fada3a6 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 9 Oct 2020 08:44:05 +0200 Subject: [PATCH 3/4] espaces en trop + supprimer = --- core/class/template.class.php | 2 +- core/module/user/user.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/class/template.class.php b/core/class/template.class.php index 225ad92a..f7384a10 100644 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -64,7 +64,7 @@ class template { $html = '
'; // Label $html .= self::label($attributes['id'], - '' . template::ico('plus') . ' = en chiffres ?', [ + '' . template::ico('plus') . ' en chiffres ?', [ 'help' => $attributes['help'] ]); // Notice diff --git a/core/module/user/user.php b/core/module/user/user.php index 4f88d863..f1c8aeef 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -337,15 +337,12 @@ class user extends common { // Check la captcha if( $this->getData(['config','connect','captcha']) - AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false ) { self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; } else { - // Lire Id du compte $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); - /** * Aucun compte existant */ From 339241383f3d8459e54222388bb3f01af3ee90f4 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 10 Oct 2020 19:36:09 +0200 Subject: [PATCH 4/4] changes --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 1097e39b..8134da32 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - Modifications : - Nouvelles images de captcha. - Option de configuration, captcha demandé à la connexion. + - Méthode d'encodage UTF8. ## version 10.3.01 - Corrections :