Fix stats
This commit is contained in:
21
index.php
21
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);
|
||||
|
||||
Reference in New Issue
Block a user