diff --git a/core/core.php b/core/core.php index 8653a62d..889798b5 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.dev18'; + const ZWII_VERSION = '10.2.00.dev19'; const ZWII_UPDATE_CHANNEL = "v10"; public static $actions = []; @@ -1589,7 +1589,7 @@ class core extends common { // Journalisation $dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; $dataLog .= $_SERVER['REMOTE_ADDR'] . ';' ; - $dataLog .= $this->getUser('id') . ';' ; + $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'visiteur' . ';'; $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 f5ab9fc1..d7bc9440 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -26,7 +26,10 @@ class config extends common { 'updateBaseUrl' => self::GROUP_ADMIN, 'script' => self::GROUP_ADMIN, 'logReset' => self::GROUP_ADMIN, - 'logDownload'=> self::GROUP_ADMIN + 'logDownload'=> self::GROUP_ADMIN, + 'blacklistReset' => self::GROUP_ADMIN, + 'blacklistDownload' => self::GROUP_ADMIN + ]; public static $timezones = [ @@ -603,14 +606,25 @@ class config extends common { */ public function logReset() { - unlink(self::DATA_DIR . 'journal.log'); - // Valeurs en sortie + if ( file_exists(self::DATA_DIR . 'journal.log') ) { + unlink(self::DATA_DIR . 'journal.log'); + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index', + 'notification' => 'Journal réinitialisé avec succès', + 'state' => true + ]); + } else { + // Valeurs en sortie $this->addOutput([ - 'title' => 'Configuration', - 'view' => 'index', - 'notification' => 'Journal réinitialisé avec succès', - 'state' => true - ]); + 'title' => 'Configuration', + 'view' => 'index', + 'notification' => 'Pas de journal à effacer', + 'state' => false + ]); + } + } @@ -619,10 +633,33 @@ class config extends common { * Télécharger le fichier de log */ public function logDownload() { - // Creation du ZIP $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' + ]); + } - // Téléchargement du ZIP + /** + * Tableau des IP blacklistés + */ + public function blacklistDownload () { + $d = $this->getData(['blacklist']); + $data = ''; + foreach ($d as $key => $item) { + $data .= $key . ';' . $item['ip'] . 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)); @@ -631,6 +668,7 @@ class config extends common { $this->addOutput([ 'display' => self::DISPLAY_RAW ]); + unlink(self::TEMP_DIR . 'blacklist.tmp'); // Valeurs en sortie $this->addOutput([ 'title' => 'Configuration', @@ -638,6 +676,31 @@ class config extends common { ]); } + /** + * Réinitialiser les ip blacklistées + */ + + public function blacklistReset() { + if ( file_exists(self::DATA_DIR . 'blacklist.json') ) { + unlink(self::DATA_DIR . 'blacklist.json'); + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index', + 'notification' => 'Liste noire réinitialisée avec succès', + 'state' => true + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'index', + 'notification' => 'Pas de liste à effacer', + 'state' => false + ]); + } + } + /** * Fonction de parcours des données de module diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 0debcd7d..71b4b69f 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -350,7 +350,7 @@