0) { $conditions[] = 'a.user_id = ?'; $params[] = $actorId; } if ($from !== '') { $conditions[] = 'a.created_at >= ?'; $params[] = $from . ' 00:00:00'; } if ($to !== '') { $conditions[] = 'a.created_at <= ?'; $params[] = $to . ' 23:59:59'; } $where = $conditions ? 'WHERE ' . implode(' AND ', $conditions) : ''; $countStmt = db()->prepare("SELECT COUNT(*) FROM audit_log a $where"); $countStmt->execute($params); $total = (int) $countStmt->fetchColumn(); $perPage = 50; $pageCount = max(1, (int) ceil($total / $perPage)); $page = min($pageCount, max(1, (int) ($_GET['page'] ?? 1))); $stmt = db()->prepare( "SELECT a.*, u.discord_id FROM audit_log a LEFT JOIN users u ON u.id = a.user_id $where ORDER BY a.created_at DESC, a.id DESC LIMIT $perPage OFFSET " . (($page - 1) * $perPage) ); $stmt->execute($params); $entries = $stmt->fetchAll(); // Anzahl je Bereich (fuer die Chips) und der Name der gefilterten Person $areaCounts = db()->query('SELECT area, COUNT(*) FROM audit_log GROUP BY area')->fetchAll(PDO::FETCH_KEY_PAIR); $actorName = ''; if ($actorId > 0) { $nameStmt = db()->prepare("SELECT actor_name FROM audit_log WHERE user_id = ? AND actor_name <> '' ORDER BY id DESC LIMIT 1"); $nameStmt->execute([$actorId]); $actorName = (string) ($nameStmt->fetchColumn() ?: 'Konto #' . $actorId); } $filtered = $query !== '' || $area !== '' || $tone !== '' || $actorId > 0 || $from !== '' || $to !== ''; /** Link mit den aktuellen Filtern, einzelne Werte ueberschrieben ('' = weglassen). */ $auditUrl = static function (array $overrides = []) use ($query, $area, $tone, $actorId, $from, $to): string { $params = array_merge(['q' => $query, 'area' => $area, 'tone' => $tone, 'user' => $actorId ?: '', 'from' => $from, 'to' => $to], $overrides); $params = array_filter($params, static fn ($value): bool => $value !== '' && $value !== null && $value !== 0); return '/admin/audit.php?' . ($params ? http_build_query($params) . '&' : ''); }; $pageTitle = 'Audit-Log'; $containerWide = true; include __DIR__ . '/../includes/header.php'; ?>
Alle Verwaltungsaktionen und Sicherheitsereignisse der Website - dieselben Einträge wie im Discord-Log, aber dauerhaft gespeichert und hier nicht lösch- oder änderbar.
= $filtered ? 'Kein Eintrag passt zu Suche und Filter.' : 'Noch keine Einträge.' ?>