diff --git a/core/core.php b/core/core.php index 5d34da72..303ab0c3 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.dev24'; + const ZWII_VERSION = '10.2.00.dev25'; const ZWII_UPDATE_CHANNEL = "v10"; public static $actions = []; @@ -1313,6 +1313,9 @@ class common { if (file_exists(self::DATA_DIR . 'theme.css')) { unlink(self::DATA_DIR . 'theme.css'); } + // Créer les en-têtes du journal + $d = 'Date;Heure;Id;Action' . PHP_EOL; + file_put_contents(self::DATA_DIR . 'journal.log',$d); $this->setData(['core', 'dataVersion', 10200]); } } @@ -1586,7 +1589,7 @@ class core extends common { } // Journalisation $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; - $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'visiteur' . ';'; + $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';'; $dataLog .= $this->getUrl(); $dataLog .= PHP_EOL; if ($this->getData(['config','connect','log'])) { diff --git a/core/module/config/config.php b/core/module/config/config.php index 9fb94533..e77878c2 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -608,6 +608,9 @@ class config extends common { public function logReset() { if ( file_exists(self::DATA_DIR . 'journal.log') ) { unlink(self::DATA_DIR . 'journal.log'); + // Créer les en-têtes des journaux + $d = 'Date;Heure;Id;Action' . PHP_EOL; + file_put_contents(self::DATA_DIR . 'journal.log',$d); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'config', @@ -618,7 +621,7 @@ class config extends common { // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'config', - 'notification' => 'Pas de journal à effacer', + 'notification' => 'Aucun journal à effacer', 'state' => false ]); } @@ -632,47 +635,67 @@ class config extends common { */ public function logDownload() { $fileName = self::DATA_DIR . 'journal.log'; - 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' - ]); + if (file_exists($fileName)) { + 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' + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => 'Aucun fichier journal à télécharger', + 'state' => false + ]); + } } /** * Tableau des IP blacklistés */ public function blacklistDownload () { - $d = $this->getData(['blacklist']); - $data = ''; - foreach ($d as $key => $item) { - $data .= $key . ';' . $item['ip'] . ';' . strftime('%d/%m/%y',$item['lastFail']) . ';' ; - $data .= strftime('%R',$item['lastFail']) . ';' . $item['connectFail'] . PHP_EOL; - } $fileName = self::TEMP_DIR . 'blacklist.log'; - file_put_contents($fileName,$data); - 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 - ]); - unlink(self::TEMP_DIR . 'blacklist.log'); - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Configuration', - 'view' => 'index' - ]); + $d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL; + file_put_contents($fileName,$d); + if ( file_exists($fileName) ) { + $d = $this->getData(['blacklist']); + $data = ''; + foreach ($d as $key => $item) { + $data .= strftime('%d/%m/%y',$item['lastFail']) . strftime('%R',$item['lastFail']) . ';' ; + $data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL; + } + file_put_contents($fileName,$data,FILE_APPEND); + 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 + ]); + unlink(self::TEMP_DIR . 'blacklist.log'); + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index' + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'config', + 'notification' => 'Aucune liste noire à télécharger', + 'state' => false + ]); + } } /** diff --git a/core/vendor/filemanager/dialog.php b/core/vendor/filemanager/dialog.php old mode 100644 new mode 100755 diff --git a/core/vendor/jquery/jquery.min.js b/core/vendor/jquery/jquery.min.js old mode 100644 new mode 100755