Fix stats
This commit is contained in:
27
index.php
27
index.php
@@ -160,27 +160,30 @@ if ($action === 'admin_generate_stats') {
|
||||
// Emplacement du rapport généré
|
||||
$report = __DIR__ . "/stats.html";
|
||||
|
||||
$files = glob('/var/log/nginx/materiel.org-access.log*.gz');
|
||||
// Récupérer tous les logs gzip
|
||||
$gz_files = glob('/var/log/nginx/materiel.org-access.log*.gz');
|
||||
|
||||
$parts = [];
|
||||
// Construire la commande
|
||||
$cmd = "/bin/bash -c '(";
|
||||
|
||||
if (!empty($files)) {
|
||||
$parts[] = 'zcat ' . implode(' ', array_map('escapeshellarg', $files));
|
||||
// 1. Logs compressés
|
||||
if (!empty($gz_files)) {
|
||||
$cmd .= "zcat " . implode(' ', array_map('escapeshellarg', $gz_files)) . " ; ";
|
||||
}
|
||||
|
||||
// 2. Log d’hier
|
||||
if (file_exists('/var/log/nginx/materiel.org-access.log.1')) {
|
||||
$parts[] = 'cat /var/log/nginx/materiel.org-access.log.1';
|
||||
$cmd .= "cat /var/log/nginx/materiel.org-access.log.1 ; ";
|
||||
}
|
||||
|
||||
$parts[] = 'cat /var/log/nginx/materiel.org-access.log';
|
||||
// 3. Log du jour
|
||||
$cmd .= "cat /var/log/nginx/materiel.org-access.log";
|
||||
|
||||
// Commande GoAccess
|
||||
$cmd = '/bin/bash -c \'(' . implode(' && ', $parts) . ')'
|
||||
. ' | goaccess --log-format=COMBINED --no-progress -o '
|
||||
. escapeshellarg($report)
|
||||
. ' -\' 2>&1';
|
||||
$cmd .= ") | goaccess --log-format=COMBINED --no-progress -o "
|
||||
. escapeshellarg($report)
|
||||
. " -' 2>&1";
|
||||
|
||||
// Exécuter la commande
|
||||
// Exécuter
|
||||
$output = shell_exec($cmd);
|
||||
|
||||
// Vérifier si le fichier a été généré
|
||||
|
||||
Reference in New Issue
Block a user