<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $page = max(1, (int)($_GET['page'] ?? 1)); $limit = 100; $offset = ($page - 1) * $limit; $catFilter = $_GET['cat'] ?? ''; $where = ''; $params = [':lim' => $limit, ':off' => $offset]; if ($catFilter !== '' && is_numeric($catFilter)) { $where = 'WHERE category = :cat'; $params[':cat'] = (int)$catFilter; } $events = []; $totalEvents = 0; try { $totalEvents = (int)Database::scalar("SELECT COUNT(*) FROM events $where", array_diff_key($params, [':lim' => 1, ':off' => 1])); $events = Database::fetchAll("SELECT * FROM events $where ORDER BY created_at DESC LIMIT :lim OFFSET :off", $params); } catch (\Throwable $e) {} $maxPage = max(1, (int)ceil($totalEvents / $limit)); $categories = ['' => 'All', '1' => 'Create', '2' => 'Read', '3' => 'Modify', '4' => 'Delete', '5' => 'Security', '6' => 'Fleet']; $catLabels = [1 => 'CREATE', 2 => 'READ', 3 => 'MODIFY', 4 => 'DELETE', 5 => 'SECURITY', 6 => 'FLEET']; $catColors = [1 => 'success', 2 => 'info', 3 => 'warning', 4 => 'danger', 5 => 'danger', 6 => 'info']; 