Add request log to dashboard, update guides with logging docs
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user