diff --git a/core/core.php b/core/core.php index 2bddd446..be86bc56 100755 --- a/core/core.php +++ b/core/core.php @@ -39,7 +39,7 @@ class common { const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '10.2.00.dev14'; + const ZWII_VERSION = '10.2.00.dev16'; const ZWII_UPDATE_CHANNEL = "v10"; public static $actions = []; @@ -1312,6 +1312,7 @@ class common { $this->deleteData(['admin','colorButtonText']); $this->setData(['config', 'connect', 'attempt',3]); $this->setData(['config', 'connect', 'timeout',360]); + $this->setData(['config', 'connect', 'log',false]); $this->setData(['core', 'dataVersion', 10200]); } } @@ -1581,6 +1582,15 @@ class core extends common { header('Location:' . helper::baseUrl() . 'install'); exit(); } + // Journalisation + $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; + $dataLog .= $_SERVER['REMOTE_ADDR'] . ';' ; + $dataLog .= $this->getUser('id') . ';' ; + $dataLog .= $this->getUrl(); + $dataLog .= PHP_EOL; + if ($this->getData(['config','connect','log'])) { + file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); + } // Force la déconnexion des membres bannis ou d'une seconde session if ( $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') @@ -1661,7 +1671,6 @@ class core extends common { $this->setData(['user',$this->getuser('id'),'accessUrl',$this->getUrl()]); $this->setData(['user',$this->getuser('id'),'accessTimer',time()]); } - // Breadcrumb $title = $this->getData(['page', $this->getUrl(0), 'title']); if (!empty($this->getData(['page', $this->getUrl(0), 'parentPageId'])) && diff --git a/core/module/config/config.php b/core/module/config/config.php index 7a3a683f..944dcb36 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -24,7 +24,9 @@ class config extends common { 'index' => self::GROUP_ADMIN, 'manage' => self::GROUP_ADMIN, 'updateBaseUrl' => self::GROUP_ADMIN, - 'script' => self::GROUP_ADMIN + 'script' => self::GROUP_ADMIN, + 'logReset' => self::GROUP_ADMIN, + 'logDownload'=> self::GROUP_ADMIN ]; public static $timezones = [ @@ -457,6 +459,7 @@ class config extends common { 'connect' => [ 'attempt' => $this->getInput('configConnectAttempt',helper::FILTER_INT), 'timeout' => $this->getInput('configConnectTimeout',helper::FILTER_INT), + 'log' => $this->getInput('configConnectLog',helper::FILTER_BOOLEAN) ] ] ]); @@ -597,6 +600,47 @@ class config extends common { ]); } + /** + * Vider le fichier de log + */ + + public function logReset() { + unlink(self::DATA_DIR . 'journal.log'); + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index', + 'notification' => 'Journal réinitialisé avec succès', + 'state' => true + ]); + } + + + + /** + * Télécharger le fichier de log + */ + public function logDownload() { + // Creation du ZIP + $fileName = self::DATA_DIR . 'journal.log'; + + // Téléchargement du ZIP + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="' . $fileName . '"'); + header('Content-Length: ' . filesize($fileName)); + readfile( $fileName); + // Valeurs en sortie + $this->addOutput([ + 'display' => self::DISPLAY_RAW + ]); + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index' + ]); + } + + /** * Fonction de parcours des données de module * @param string $find donnée à rechercher diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 5bf40523..2730e342 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -148,7 +148,6 @@
'buttonRed', 'ico' => 'download-cloud', 'href' => helper::baseUrl() . 'install/update', 'value' => 'Mise à jour manuelle', @@ -286,27 +285,6 @@
-
-
-
-

Connexion

-
-
- 'Echecs avant blocage', - 'selected' => $this->getData(['config', 'connect', 'attempt']) - ]); ?> -
-
- 'Durée du blocage', - 'selected' => $this->getData(['config', 'connect', 'timeout']) - ]); ?> -
-
-
-
-
@@ -374,7 +352,21 @@

Options avancées

+
+ 'Tentatives de logins', + 'selected' => $this->getData(['config', 'connect', 'attempt']) + ]); ?> +
+ 'Durée du blocage', + 'selected' => $this->getData(['config', 'connect', 'timeout']) + ]); ?> +
+
+
+
'Saisissez l\'ID de suivi.', 'label' => 'Google Analytics', @@ -382,21 +374,43 @@ 'value' => $this->getData(['config', 'analyticsId']) ]); ?>
-
- + helper::baseUrl() . 'config/script/head', - 'value' => 'Script inséré dans head', + 'value' => 'Script dans head', 'ico' => 'pencil' ]); ?>
-
- + helper::baseUrl() . 'config/script/body', - 'value' => 'Script inséré dans body', + 'value' => 'Script dans body', 'ico' => 'pencil' ]); ?>
+
+
+ $this->getData(['config', 'connect', 'log']) + ]); ?> +
+
+ helper::baseUrl() . 'config/logDownload', + 'value' => 'Téléchargement du journal', + 'ico' => 'download' + ]); ?> +
+
+ 'buttonRed', + 'href' => helper::baseUrl() . 'config/logReset', + 'value' => 'Réinitialisation du journal', + 'ico' => 'cancel' + ]); ?> +
+
diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 4ceef5ac..a45bdfb7 100755 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -31,7 +31,8 @@ class init extends common { ], "connect" => [ "timeout" => 360, - "attempt" => 3 + "attempt" => 3, + 'log' => false ] ], 'core' => [ diff --git a/core/module/user/user.php b/core/module/user/user.php index ba90fa56..4fae53f3 100755 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -332,22 +332,17 @@ class user extends common { // Soumission du formulaire if($this->isPost()) { $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); - // Contrôle du time out - if ( $this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() && - $this->getData(['user',$userId,'connectFail']) > $this->getData(['config', 'connect', 'attempt']) ) { - $this->addOutput([ - 'notification' => 'Accès bloqué pour ' . $this->getData(['config', 'connect', 'timeout']) . ' minutes' - ]); - } + // Contrôle du time out pas de vérification du mot de passe si le temps est dépassé. // Connexion si les informations sont correctes - if( + if( $this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() && + $this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt']) && password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password'])) AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER ) { $expire = $this->getInput('userLoginLongTime') ? strtotime("+1 year") : 0; setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false)); setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false)); - // Accès multiples avec le m$eme compte + // 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( @@ -363,7 +358,7 @@ class user extends common { else { // RAZ compteur échec connexion $this->setData(['user',$userId,'connectFail',0 ]); - // Valeurs en sortie en cas de réussite + // Valeurs en sortie $this->addOutput([ 'notification' => 'Connexion réussie', 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), @@ -377,9 +372,9 @@ class user extends common { if ( is_array($this->getdata(['user',$userId])) ) { $this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); } - // Mettre à jour le timer + // Mettre à jour le timer et notifier if ( $this->getdata(['user',$userId,'connectFail']) > $this->getData(['config', 'connect', 'attempt'])) { - $notification = 'Trop de tentatives, accès bloqué durant ' . $this->getData(['config', 'connect', 'timeout']) . ' minutes.'; + $notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; // Ne pas incrémenter le timer si actif if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() ) { $this->setData(['user',$userId,'connectTimeout', time()]); @@ -387,6 +382,16 @@ class user extends common { } else { $notification = 'Identifiant ou mot de passe incorrect'; } + // Journalisation + $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; + $dataLog .= $_SERVER['REMOTE_ADDR'] . ';' ; + $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 diff --git a/module/blog/view/index/index.php b/module/blog/view/index/index.php index 3d03bb18..3734b479 100755 --- a/module/blog/view/index/index.php +++ b/module/blog/view/index/index.php @@ -1,10 +1,10 @@
- $article): ?> + $article): ?>
- -
+
diff --git a/site/file/source/screenshot.png b/site/file/source/screenshot.png old mode 100644 new mode 100755