Files
server-manager/views/admin/audit.php
Agent c3009fbbf7 Add views directory and UI improvements
- Add all view templates (servers, auth, dashboard, admin, layouts, errors, terminal)
- Fix SSH double decryption bug in SSHService
- Fix router parameter type casting for strict_types
- Add missing error views (401, 403, 404)
- Add nginx manager with file editing
- Add SSL certificates management
- Add database manager with phpMyAdmin-like interface
- Add sidebar server accordion
2026-06-06 17:59:13 -04:00

91 lines
4.5 KiB
PHP
Executable File

<?php
$logs = $logs ?? [];
$action = $action ?? '';
$userId = $userId ?? '';
?>
<div class="page-header">
<h1 class="page-title">Audit Logs</h1>
<p class="page-subtitle">Comprehensive activity tracking and security monitoring</p>
</div>
<div class="card">
<div class="card-header">
<div class="card-filters">
<select id="actionFilter" class="form-select" onchange="applyFilters()">
<option value="">All Actions</option>
<option value="login_success" <?= $action === 'login_success' ? 'selected' : '' ?>>Login Success</option>
<option value="login_failed" <?= $action === 'login_failed' ? 'selected' : '' ?>>Login Failed</option>
<option value="server_created" <?= $action === 'server_created' ? 'selected' : '' ?>>Server Created</option>
<option value="server_deleted" <?= $action === 'server_deleted' ? 'selected' : '' ?>>Server Deleted</option>
<option value="credential_access" <?= $action === 'credential_access' ? 'selected' : '' ?>>Credential Access</option>
<option value="command_executed" <?= $action === 'command_executed' ? 'selected' : '' ?>>Command Executed</option>
<option value="user_created" <?= $action === 'user_created' ? 'selected' : '' ?>>User Created</option>
<option value="user_deleted" <?= $action === 'user_deleted' ? 'selected' : '' ?>>User Deleted</option>
</select>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Time</th>
<th>User</th>
<th>Action</th>
<th>Entity</th>
<th>Details</th>
<th>IP Address</th>
</tr>
</thead>
<tbody>
<?php foreach ($logs['data'] as $log): ?>
<tr class="audit-row <?= str_contains($log['action'] ?? '', 'failed') ? 'audit-row-danger' : '' ?>">
<td><?= htmlspecialchars($log['created_at'] ?? '') ?></td>
<td><?= htmlspecialchars($log['actor_name'] ?? $log['username'] ?? 'System') ?></td>
<td>
<span class="badge badge-<?= match(true) {
str_contains($log['action'] ?? '', 'failed') => 'danger',
str_contains($log['action'] ?? '', 'success') => 'success',
str_contains($log['action'] ?? '', 'deleted') => 'danger',
str_contains($log['action'] ?? '', 'created') => 'success',
default => 'info',
} ?>">
<?= htmlspecialchars(str_replace('_', ' ', $log['action'] ?? '')) ?>
</span>
</td>
<td><?= htmlspecialchars(($log['entity_type'] ?? '') . ' #' . ($log['entity_id'] ?? '')) ?></td>
<td>
<?php if ($log['details'] ?? false): ?>
<pre class="audit-details"><?= htmlspecialchars($log['details']) ?></pre>
<?php else: ?>
-
<?php endif; ?>
</td>
<td><code><?= htmlspecialchars($log['ip_address'] ?? '') ?></code></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php if ($logs['total_pages'] > 1): ?>
<div class="pagination">
<?php for ($i = 1; $i <= $logs['total_pages']; $i++): ?>
<a href="?page=<?= $i ?>&action=<?= urlencode($action) ?>&user_id=<?= urlencode($userId) ?>"
class="page-link <?= $i === ($logs['page'] ?? 1) ? 'active' : '' ?>">
<?= $i ?>
</a>
<?php endfor; ?>
</div>
<?php endif; ?>
</div>
</div>
<script>
function applyFilters() {
const action = document.getElementById('actionFilter').value;
window.location.href = '/admin/audit?action=' + encodeURIComponent(action);
}
</script>