Sindbad~EG File Manager
<?php
require_once '../../config/config.php';
checkLogin();
// Only superusers and area/district/assembly level users can access
if (!isSuperuser() && !in_array(getAccessLevel(), ['area', 'district', 'assembly'])) {
redirect('../../dashboard.php');
}
$pageTitle = "Audit Logs - " . APP_NAME;
$auditLog = new AuditLog();
$filters = [];
if (isset($_GET['user_id']) && !empty($_GET['user_id'])) {
$filters['user_id'] = $_GET['user_id'];
}
if (isset($_GET['module']) && !empty($_GET['module'])) {
$filters['module'] = $_GET['module'];
}
if (isset($_GET['action']) && !empty($_GET['action'])) {
$filters['action'] = $_GET['action'];
}
$logs = $auditLog->getLogs($filters, 100);
include '../../includes/header.php';
?>
<?php include '../../includes/sidebar.php'; ?>
<!-- Main Content -->
<main class="flex-1 md:ml-64 mt-16">
<div class="container mx-auto px-4 py-8">
<div class="mb-6">
<h1 class="text-3xl font-bold text-gray-800">
<i class="fas fa-shield-alt mr-2 text-blue-500"></i>Audit Logs
</h1>
<p class="text-gray-600 mt-2">Track all system activities and changes</p>
</div>
<!-- Filter Section -->
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
<form method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Module</label>
<select name="module" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
<option value="">All Modules</option>
<option value="users">Users</option>
<option value="members">Members</option>
<option value="areas">Areas</option>
<option value="districts">Districts</option>
<option value="assemblies">Assemblies</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Action</label>
<select name="action" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
<option value="">All Actions</option>
<option value="create">Create</option>
<option value="update">Update</option>
<option value="delete">Delete</option>
<option value="login">Login</option>
<option value="logout">Logout</option>
</select>
</div>
<div class="md:col-span-2 flex items-end space-x-2">
<button type="submit" class="bg-blue-500 text-white px-6 py-2 rounded-lg hover:bg-blue-600">
<i class="fas fa-filter mr-2"></i>Filter
</button>
<a href="index.php" class="bg-gray-500 text-white px-6 py-2 rounded-lg hover:bg-gray-600">
<i class="fas fa-redo mr-2"></i>Reset
</a>
</div>
</form>
</div>
<!-- Audit Logs Table -->
<div class="bg-white rounded-lg shadow-lg overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gradient-to-r from-blue-500 to-blue-600">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-white uppercase">Timestamp</th>
<th class="px-6 py-3 text-left text-xs font-medium text-white uppercase">User</th>
<th class="px-6 py-3 text-left text-xs font-medium text-white uppercase">Action</th>
<th class="px-6 py-3 text-left text-xs font-medium text-white uppercase">Module</th>
<th class="px-6 py-3 text-left text-xs font-medium text-white uppercase">IP Address</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<?php if (empty($logs)): ?>
<tr>
<td colspan="5" class="px-6 py-12 text-center text-gray-500">
<i class="fas fa-clipboard-list text-5xl mb-4 text-gray-300"></i>
<p>No audit logs found</p>
</td>
</tr>
<?php else: ?>
<?php foreach ($logs as $log): ?>
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
<?php echo formatDate($log['created_at'], 'M d, Y H:i:s'); ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<div class="font-semibold text-gray-800">
<?php echo htmlspecialchars($log['full_name'] ?? 'System'); ?>
</div>
<div class="text-gray-500">
<?php echo htmlspecialchars($log['username'] ?? 'N/A'); ?>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 py-1 text-xs font-semibold rounded-full <?php
echo $log['action'] === 'create' ? 'bg-green-100 text-green-800' :
($log['action'] === 'update' ? 'bg-blue-100 text-blue-800' :
($log['action'] === 'delete' ? 'bg-red-100 text-red-800' :
'bg-gray-100 text-gray-800'));
?>">
<?php echo ucfirst($log['action']); ?>
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
<?php echo ucfirst($log['module']); ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600 font-mono">
<?php echo htmlspecialchars($log['ip_address']); ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</main>
<?php include '../../includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists