CMS 2.0 - Theme engine, logging, admin improvements

Major changes:
- New ThemeManager with Twig templating and SCSS compilation
- Dynamic themes system (themes/default, themes/demo)
- LogManager with SQLite storage and syslog forwarding
- RequestLogger with static helper methods
- Admin UI overhaul (Bootstrap 5, dark mode)
- Admin config page with logging and theme settings
- Admin logs page with filters and search
- Removed legacy Mustache templates
- Removed test plugin and theme
- Composer dependencies: Twig, scssphp, CommonMark, MaxMind GeoIP
This commit is contained in:
2026-08-08 18:02:14 +02:00
parent cc0e4c19c8
commit a1e5baacac
833 changed files with 108974 additions and 1386 deletions
+72 -110
View File
@@ -1,117 +1,79 @@
<h2 class="mb-4"><i class="bi bi-journal-text"></i> Logs</h2>
<ul class="nav nav-tabs mb-3" id="logTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link <?= $activeTab === 'admin' ? 'active' : '' ?>" id="admin-log-tab" data-bs-toggle="tab" data-bs-target="#admin-log" type="button" role="tab">Activiteiten log</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link <?= $activeTab === 'requests' ? 'active' : '' ?>" id="request-log-tab" data-bs-toggle="tab" data-bs-target="#request-log" type="button" role="tab">Requests log</button>
</li>
</ul>
<div class="tab-content">
<!-- Admin activity log -->
<div class="tab-pane fade <?= $activeTab === 'admin' ? 'show active' : '' ?>" id="admin-log" role="tabpanel">
<div class="d-flex justify-content-between align-items-center mb-2">
<small class="text-muted"><?= count($adminLogs) ?> regels</small>
<div>
<a href="/admin/logs?tab=admin&download=1" class="btn btn-sm btn-outline-secondary"><i class="bi bi-download"></i> Download</a>
<a href="/admin/logs?tab=admin&clear=1" class="btn btn-sm btn-outline-danger" onclick="return confirm('Activiteiten log wissen?')"><i class="bi bi-trash"></i> Wissen</a>
<div class="card shadow-sm mb-4">
<div class="card-body">
<form method="GET" action="/admin/logs" class="row g-3 align-items-end">
<div class="col-md-3">
<label for="filter_event" class="form-label">Gebeurtenis</label>
<select class="form-select" id="filter_event" name="event">
<option value="">Alle</option>
<?php foreach ($eventTypes as $ev): ?>
<option value="<?= $ev ?>" <?= $filterEvent === $ev ? 'selected' : '' ?>><?= ucfirst($ev) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="card shadow-sm">
<div class="card-body p-0" style="max-height: 500px; overflow-y: auto;">
<?php if (empty($adminLogs)): ?>
<p class="text-muted p-3 mb-0">Geen activiteiten geregistreerd.</p>
<?php else: ?>
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Tijd</th>
<th>Niveau</th>
<th>IP</th>
<th>Bericht</th>
</tr>
</thead>
<tbody>
<?php foreach ($adminLogs as $log): ?>
<tr>
<td class="text-nowrap small text-muted"><?= htmlspecialchars($log['time']) ?></td>
<td><span class="badge bg-<?= $log['level'] === 'warning' ? 'warning text-dark' : ($log['level'] === 'error' ? 'danger' : 'info') ?>"><?= htmlspecialchars($log['level']) ?></span></td>
<td><code class="small"><?= htmlspecialchars($log['ip']) ?></code></td>
<td><?= htmlspecialchars($log['message']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="col-md-3">
<label for="filter_level" class="form-label">Niveau</label>
<select class="form-select" id="filter_level" name="level">
<option value="">Alle</option>
<?php foreach ($levelTypes as $lv): ?>
<option value="<?= $lv ?>" <?= $filterLevel === $lv ? 'selected' : '' ?>><?= ucfirst($lv) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-4">
<label for="filter_search" class="form-label">Zoeken</label>
<input type="text" class="form-control" id="filter_search" name="search" value="<?= htmlspecialchars($filterSearch) ?>" placeholder="Zoek in bericht...">
</div>
<div class="col-md-2">
<label for="filter_limit" class="form-label">Aantal</label>
<select class="form-select" id="filter_limit" name="limit">
<?php foreach ([50, 100, 200, 500, 1000] as $n): ?>
<option value="<?= $n ?>" <?= $limit === $n ? 'selected' : '' ?>><?= $n ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-12 d-flex justify-content-between">
<button type="submit" class="btn btn-primary"><i class="bi bi-funnel"></i> Filteren</button>
<div>
<a href="/admin/logs?download=1<?= $filterEvent ? '&event=' . urlencode($filterEvent) : '' ?><?= $filterLevel ? '&level=' . urlencode($filterLevel) : '' ?><?= $filterSearch ? '&search=' . urlencode($filterSearch) : '' ?>" class="btn btn-sm btn-outline-secondary"><i class="bi bi-download"></i> Download</a>
<a href="/admin/logs?clear=1" class="btn btn-sm btn-outline-danger" onclick="return confirm('Log wissen?')"><i class="bi bi-trash"></i> Wissen</a>
</div>
</div>
</form>
</div>
</div>
<!-- Request log -->
<div class="tab-pane fade <?= $activeTab === 'requests' ? 'show active' : '' ?>" id="request-log" role="tabpanel">
<div class="d-flex justify-content-between align-items-center mb-2">
<small class="text-muted"><?= count($requestLogs) ?> regels</small>
<div>
<a href="/admin/logs?tab=requests&download=1" class="btn btn-sm btn-outline-secondary"><i class="bi bi-download"></i> Download</a>
<a href="/admin/logs?tab=requests&clear=1" class="btn btn-sm btn-outline-danger" onclick="return confirm('Requestlog wissen?')"><i class="bi bi-trash"></i> Wissen</a>
</div>
</div>
<div class="card shadow-sm">
<div class="card-body p-0" style="max-height: 500px; overflow-y: auto;">
<?php if (empty($requestLogs)): ?>
<p class="text-muted p-3 mb-0">Geen requests geregistreerd.</p>
<?php else: ?>
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Tijd</th>
<th>IP</th>
<th>Land</th>
<th>Pagina</th>
<th>Type / Gebruiker</th>
<th>Status</th>
<th>Taal</th>
<th>User agent</th>
<th>Referrer</th>
</tr>
</thead>
<tbody>
<?php foreach ($requestLogs as $log): ?>
<tr class="<?= str_starts_with($log['status'] ?? 'ok', 'blocked') ? 'table-danger' : '' ?>">
<td class="text-nowrap small text-muted"><?= htmlspecialchars($log['time']) ?></td>
<td><code class="small"><?= htmlspecialchars($log['ip']) ?></code></td>
<td class="text-nowrap small" title="<?= htmlspecialchars(GeoIP::getCountryName($log['country'] ?: null)) ?>">
<?= GeoIP::getCountryFlagEmoji($log['country'] ?: null) ?>
<span class="text-muted"><?= htmlspecialchars($log['country'] ?: '—') ?></span>
</td>
<td><?= htmlspecialchars($log['page']) ?></td>
<td>
<span class="badge bg-<?= $log['visitor_info']['badge'] ?>">
<i class="bi <?= $log['visitor_info']['icon'] ?>"></i> <?= $log['visitor_info']['label'] ?>
</span>
</td>
<td>
<?php if (str_starts_with($log['status'] ?? 'ok', 'blocked')): ?>
<span class="badge bg-danger" title="<?= htmlspecialchars($log['status']) ?>">
<i class="bi bi-shield-x"></i> Geblokkeerd
</span>
<?php else: ?>
<span class="badge bg-success" title="Toegestaan">
<i class="bi bi-check-circle"></i> OK
</span>
<?php endif; ?>
</td>
<td><?= htmlspecialchars($log['lang']) ?></td>
<td class="small text-muted" title="<?= htmlspecialchars($log['ua']) ?>"><?= htmlspecialchars(substr($log['ua'], 0, 50)) ?><?= strlen($log['ua']) > 50 ? '…' : '' ?></td>
<td class="small text-muted" title="<?= htmlspecialchars($log['referrer']) ?>"><?= htmlspecialchars(substr($log['referrer'], 0, 30)) ?><?= strlen($log['referrer']) > 30 ? '…' : '' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
</div>
<div class="d-flex justify-content-between align-items-center mb-2">
<small class="text-muted"><?= count($logEntries) ?> regels</small>
</div>
<div class="card shadow-sm">
<div class="card-body p-0" style="max-height: 600px; overflow-y: auto;">
<?php if (empty($logEntries)): ?>
<p class="text-muted p-3 mb-0">Geen logregels gevonden.</p>
<?php else: ?>
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Tijd</th>
<th>Gebeurtenis</th>
<th>Niveau</th>
<th>IP</th>
<th>Bericht</th>
</tr>
</thead>
<tbody>
<?php foreach ($logEntries as $log): ?>
<tr>
<td class="text-nowrap small text-muted"><?= htmlspecialchars($log['time']) ?></td>
<td><span class="badge bg-secondary"><?= htmlspecialchars($log['event']) ?></span></td>
<td><span class="badge bg-<?= $log['level'] === 'warning' ? 'warning text-dark' : ($log['level'] === 'error' ? 'danger' : 'info') ?>"><?= htmlspecialchars($log['level']) ?></span></td>
<td><code class="small"><?= htmlspecialchars($log['ip']) ?></code></td>
<td><?= htmlspecialchars($log['message']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
</div>
</div>