10.2.dev25 en-têtes des logs + permissions des nouveaux fichiers

This commit is contained in:
Fred Tempez 2020-06-03 10:06:11 +02:00
parent 508cd838df
commit 5151f64beb
4 changed files with 63 additions and 37 deletions

View File

@ -39,7 +39,7 @@ class common {
const ACCESS_TIMER = 1800; const ACCESS_TIMER = 1800;
// Numéro de version // Numéro de version
const ZWII_VERSION = '10.2.00.dev24'; const ZWII_VERSION = '10.2.00.dev25';
const ZWII_UPDATE_CHANNEL = "v10"; const ZWII_UPDATE_CHANNEL = "v10";
public static $actions = []; public static $actions = [];
@ -1313,6 +1313,9 @@ class common {
if (file_exists(self::DATA_DIR . 'theme.css')) { if (file_exists(self::DATA_DIR . 'theme.css')) {
unlink(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]); $this->setData(['core', 'dataVersion', 10200]);
} }
} }
@ -1586,7 +1589,7 @@ class core extends common {
} }
// Journalisation // Journalisation
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; $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 .= $this->getUrl();
$dataLog .= PHP_EOL; $dataLog .= PHP_EOL;
if ($this->getData(['config','connect','log'])) { if ($this->getData(['config','connect','log'])) {

View File

@ -608,6 +608,9 @@ class config extends common {
public function logReset() { public function logReset() {
if ( file_exists(self::DATA_DIR . 'journal.log') ) { if ( file_exists(self::DATA_DIR . 'journal.log') ) {
unlink(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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -618,7 +621,7 @@ class config extends common {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
'notification' => 'Pas de journal à effacer', 'notification' => 'Aucun journal à effacer',
'state' => false 'state' => false
]); ]);
} }
@ -632,47 +635,67 @@ class config extends common {
*/ */
public function logDownload() { public function logDownload() {
$fileName = self::DATA_DIR . 'journal.log'; $fileName = self::DATA_DIR . 'journal.log';
header('Content-Type: application/octet-stream'); if (file_exists($fileName)) {
header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($fileName)); header('Content-Disposition: attachment; filename="' . $fileName . '"');
readfile( $fileName); header('Content-Length: ' . filesize($fileName));
// Valeurs en sortie readfile( $fileName);
$this->addOutput([ // Valeurs en sortie
'display' => self::DISPLAY_RAW $this->addOutput([
]); 'display' => self::DISPLAY_RAW
// Valeurs en sortie ]);
$this->addOutput([ // Valeurs en sortie
'title' => 'Configuration', $this->addOutput([
'view' => 'index' '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 * Tableau des IP blacklistés
*/ */
public function blacklistDownload () { 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'; $fileName = self::TEMP_DIR . 'blacklist.log';
file_put_contents($fileName,$data); $d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL;
header('Content-Type: application/octet-stream'); file_put_contents($fileName,$d);
header('Content-Disposition: attachment; filename="' . $fileName . '"'); if ( file_exists($fileName) ) {
header('Content-Length: ' . filesize($fileName)); $d = $this->getData(['blacklist']);
readfile( $fileName); $data = '';
// Valeurs en sortie foreach ($d as $key => $item) {
$this->addOutput([ $data .= strftime('%d/%m/%y',$item['lastFail']) . strftime('%R',$item['lastFail']) . ';' ;
'display' => self::DISPLAY_RAW $data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL;
]); }
unlink(self::TEMP_DIR . 'blacklist.log'); file_put_contents($fileName,$data,FILE_APPEND);
// Valeurs en sortie header('Content-Type: application/octet-stream');
$this->addOutput([ header('Content-Disposition: attachment; filename="' . $fileName . '"');
'title' => 'Configuration', header('Content-Length: ' . filesize($fileName));
'view' => 'index' 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
]);
}
} }
/** /**

0
core/vendor/filemanager/dialog.php vendored Normal file → Executable file
View File

0
core/vendor/jquery/jquery.min.js vendored Normal file → Executable file
View File