Add request log to dashboard, update guides with logging docs

This commit is contained in:
2026-07-28 14:59:18 +02:00
parent 28c8e895c5
commit 99a4c20e97
4 changed files with 100 additions and 2 deletions
+19
View File
@@ -218,6 +218,25 @@ function handleDashboard(AdminAuth $auth, array $config): void
$recentLogs = array_reverse($recentLogs);
}
// Load recent request log
$requestLogFile = $config['request_log'];
$recentRequests = [];
if (file_exists($requestLogFile)) {
$lines = file($requestLogFile);
$lines = array_slice($lines, -20);
foreach ($lines as $line) {
if (preg_match('/^\[([^\]]+)\] \[([^\]]+)\] \[([^\]]+)\] \[([^\]]*)\] \[([^\]]+)\] \[([^\]]*)\] \[([^\]]*)\]$/', trim($line), $m)) {
$recentRequests[] = [
'time' => $m[1],
'ip' => $m[2],
'page' => $m[5],
'ua' => $m[6],
];
}
}
$recentRequests = array_reverse($recentRequests);
}
require __DIR__ . '/../admin/templates/layout.php';
}