requireAdmin(); I18n::init(); $db = Database::getInstance(); $appTitle = $db->getSetting('app_title', 'UniFi Voucher System'); $filterAction = trim($_GET['action'] ?? ''); $filterUser = trim($_GET['user_id'] ?? ''); $page = max(1, (int)($_GET['page'] ?? 1)); $perPage = 50; $offset = ($page - 1) * $perPage; $where = []; $params = []; if ($filterAction !== '') { $where[] = 'a.action = ?'; $params[] = $filterAction; } if ($filterUser !== '') { $where[] = 'a.user_id = ?'; $params[] = (int)$filterUser; } $whereStr = $where ? 'WHERE ' . implode(' AND ', $where) : ''; $total = (int)$db->fetchOne("SELECT COUNT(*) as c FROM audit_log a $whereStr", $params)['c']; $pages = max(1, (int)ceil($total / $perPage)); $logs = $db->fetchAll( "SELECT a.*, u.name as user_name, u.email as user_email FROM audit_log a LEFT JOIN users u ON a.user_id = u.id $whereStr ORDER BY a.created_at DESC LIMIT ? OFFSET ?", array_merge($params, [$perPage, $offset]) ); // Distinct actions for filter $actions = $db->fetchAll("SELECT DISTINCT action FROM audit_log ORDER BY action"); // User list for filter $users = $db->fetchAll("SELECT id, name FROM users WHERE is_active = 1 ORDER BY name"); $currentPage = 'audit_log'; $adminBase = ''; // Aktionsnamen uebersetzt anzeigen; unbekannte Aktionen bleiben technisch. $actionLabels = []; foreach (['voucher_created', 'voucher_bulk', 'user_login', 'user_logout', 'user_created', 'user_updated', 'user_deleted', 'site_added', 'site_updated', 'site_deleted', 'settings_saved', 'password_reset', 'template_created', 'template_updated', 'template_deleted'] as $action) { $actionLabels[$action] = __('audit_action_' . $action); } ?>
= __('audit_subtitle') ?>
= __('audit_none') ?>
| = __('audit_time') ?> | = __('audit_action') ?> | = __('audit_user') ?> | = __('audit_entity') ?> | = __('audit_details') ?> | = __('audit_ip') ?> |
|---|---|---|---|---|---|
|
= date('d.m.Y', strtotime($log['created_at'])) ?> = date('H:i:s', strtotime($log['created_at'])) ?> |
= htmlspecialchars($actionLabels[$log['action']] ?? $log['action']) ?> |
= htmlspecialchars($log['user_name']) ?> = htmlspecialchars($log['user_email'] ?? '') ?> = __('audit_system_anon') ?> |
= htmlspecialchars($log['entity_type']) ?>:= htmlspecialchars($log['entity_id'] ?? '') ?>
-
|
= htmlspecialchars(mb_strimwidth($log['details'] ?? '-', 0, 80, '…')) ?> | = htmlspecialchars($log['ip_address'] ?? '-') ?> |