From cfac4034a30e88bd5b15229a3bf1d5e6f7e5e6bb Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 23 Apr 2023 18:51:37 +0200 Subject: [PATCH] 12400 logs --- CHANGES.md | 5 +++++ core/class/router.class.php | 11 +++-------- core/core.php | 16 ++++++++++++++++ core/module/user/user.php | 10 +--------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ed9fa752..4c034db5 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changelog +## Version 12.4.00 +# Améliorations +- Gestion des groupes de profils d'utilisateurs. +- Améliore la gestion de la base de données et la génération du fichier de journalisation. + ## Version 12.3.08 - Amélioration du code liée à la traduction du contenu du CMS. - Implémentation d'un message d'avertissement de suppression d'une langue de site ou de contenu. diff --git a/core/class/router.class.php b/core/class/router.class.php index 7886159f..4af5a6b1 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -474,15 +474,10 @@ class core extends common header('Location:' . helper::baseUrl() . 'install'); exit(); } + // Journalisation - $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time()); - $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; - $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';'; - $dataLog .= $this->getUrl(); - $dataLog .= PHP_EOL; - if ($this->getData(['config', 'connect', 'log'])) { - file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); - } + $this->saveLog(); + // Force la déconnexion des membres bannis ou d'une seconde session if ( $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') diff --git a/core/core.php b/core/core.php index 47b93cce..0405647a 100644 --- a/core/core.php +++ b/core/core.php @@ -1315,4 +1315,20 @@ class common } $zip->close(); } + + + /** + * Journalisation + */ + public function saveLog($message = '') { + // Journalisation + $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time()); + $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; + $dataLog .= empty($this->getUser('id')) ? 'visitor;' : $this->getUser('id') . ';'; + $dataLog .= $message ? $this->getUrl() . ';'. $message : $this->getUrl(); + $dataLog .= PHP_EOL; + if ($this->getData(['config', 'connect', 'log'])) { + file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); + } + } } \ No newline at end of file diff --git a/core/module/user/user.php b/core/module/user/user.php index 711256e2..3e10cc3f 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -701,15 +701,7 @@ class user extends common } } // Journalisation - $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time()); - $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; - $dataLog .= empty($this->getInput('userLoginId')) ? ';' : $this->getInput('userLoginId', helper::FILTER_ID) . ';'; - $dataLog .= $this->getUrl() . ';'; - $dataLog .= $logStatus; - $dataLog .= PHP_EOL; - if ($this->getData(['config', 'connect', 'log'])) { - file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); - } + $this->saveLog($logStatus); // Régénère la session session_regenerate_id();