api = $api; } public function getConfig(): array { return [ 'title' => 'Logs', 'viewable' => false, 'type' => 'system', ]; } public function getAdminMenu(): array { return [ [ 'plugin' => 'Logs', 'route' => 'logs', 'label' => 'Logs', 'icon' => 'bi-journal-text', 'section' => 'general', ], ]; } public function handleAdminRoute(string $action): ?string { $tab = $_GET['tab'] ?? 'admin'; $logDir = dirname(__DIR__, 2) . '/admin/storage/logs'; $logFile = $tab === 'requests' ? $logDir . '/requests.log' : $logDir . '/admin.log'; $logs = []; if (file_exists($logFile)) { $lines = file($logFile) ?: []; $lines = array_slice($lines, -100); foreach ($lines as $line) { if (preg_match('/^\[([^\]]+)\] \[([^\]]+)\] \[([^\]]+)\] (.+)$/', trim($line), $m)) { $logs[] = [ 'time' => $m[1], 'level' => strtolower($m[2]), 'ip' => $m[3], 'message' => $m[4], ]; } } $logs = array_reverse($logs); } ob_start(); ?>
| Tijd | Level | IP | Bericht |
|---|---|---|---|
| Geen logs gevonden. | |||
| = htmlspecialchars($log['time']) ?> | = htmlspecialchars($log['level']) ?> | = htmlspecialchars($log['ip']) ?> |
= htmlspecialchars($log['message']) ?> |