Fix stats

This commit is contained in:
leosw
2025-12-27 19:00:19 +01:00
parent 3e0d26aa19
commit 989e817926

View File

@@ -160,10 +160,25 @@ 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');
$parts = [];
if (!empty($files)) {
$parts[] = 'zcat ' . implode(' ', array_map('escapeshellarg', $files));
}
if (file_exists('/var/log/nginx/materiel.org-access.log.1')) {
$parts[] = 'cat /var/log/nginx/materiel.org-access.log.1';
}
$parts[] = 'cat /var/log/nginx/materiel.org-access.log';
// Commande GoAccess
$cmd = "goaccess /var/log/nginx/materiel.kabano.org-access.log "
. "--log-format=COMBINED "
. "-o " . escapeshellarg($report) . " 2>&1";
$cmd = '/bin/bash -c \'(' . implode(' && ', $parts) . ')'
. ' | goaccess --log-format=COMBINED --no-progress -o '
. escapeshellarg($report)
. ' -\' 2>&1';
// Exécuter la commande
$output = shell_exec($cmd);