From 989e817926586e628f8f970aee54f81a14789a12 Mon Sep 17 00:00:00 2001 From: leosw Date: Sat, 27 Dec 2025 19:00:19 +0100 Subject: [PATCH] Fix stats --- index.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 6438e03..291e440 100644 --- a/index.php +++ b/index.php @@ -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);