« Back to History
activity.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/../includes/bootstrap.php'; require_once __DIR__ . '/../includes/header.php'; require_once __DIR__ . '/../includes/sidebar.php'; $search = trim($_GET['search'] ?? ''); $module_filter = trim($_GET['module'] ?? 'all'); $page = max(1, (int)($_GET['page'] ?? 1)); $limit = 25; $offset = ($page - 1) * $limit; $whereClause = " WHERE 1=1 "; $params = []; if (!empty($search)) { $whereClause .= " AND (username LIKE ? OR action_performed LIKE ? OR ip_address LIKE ?) "; $searchWildcard = "%$search%"; array_push($params, $searchWildcard, $searchWildcard, $searchWildcard); } if ($module_filter !== 'all') { $whereClause .= " AND module_name = ? "; $params[] = $module_filter; } try { // Unique modules fetch list for dynamic filter parameters dropdown mapping $mod_stmt = $pdo->query("SELECT DISTINCT module_name FROM activity_logs WHERE module_name IS NOT NULL AND module_name != '' ORDER BY module_name ASC"); $modules = $mod_stmt->fetchAll(PDO::FETCH_COLUMN); // Filter count execution context $countStmt = $pdo->prepare("SELECT COUNT(*) FROM activity_logs $whereClause"); $countStmt->execute($params); $totalRecords = $countStmt->fetchColumn(); $totalPages = ceil($totalRecords / $limit); // Fetch tracking list dataset records stream $dataStmt = $pdo->prepare("SELECT * FROM activity_logs $whereClause ORDER BY id DESC LIMIT $limit OFFSET $offset"); $dataStmt->execute($params); $logs = $dataStmt->fetchAll(); } catch (PDOException $e) { $logs = []; $modules = []; $totalPages = 1; } // Function helper to break down and extract clean browser definitions from user agent string block maps function get_clean_browser_name($user_agent) { if (empty($user_agent)) return 'Unknown'; if (strpos($user_agent, 'Opera') !== false || strpos($user_agent, 'OPR') !== false) return 'Opera'; if (strpos($user_agent, 'Edge') !== false || strpos($user_agent, 'Edg') !== false) return 'Edge'; if (strpos($user_agent, 'Chrome') !== false) return 'Chrome'; if (strpos($user_agent, 'Safari') !== false) return 'Safari'; if (strpos($user_agent, 'Firefox') !== false) return 'Firefox'; if (strpos($user_agent, 'MSIE') !== false || strpos($user_agent, 'Trident') !== false) return 'Internet Explorer'; return 'Unknown Browser / Bot'; } ?> <div class="container-fluid p-0"> <div class="d-flex justify-content-between align-items-center mb-4"> <h4 class="m-0 fw-bold text-dark">Security & Activity Audit Trail</h4> <span class="badge bg-secondary px-3 py-2 small">Read Only Audit Access Mode</span> </div> <div class="card border-0 shadow-sm p-3 mb-4 bg-white"> <form method="GET" action="activity.php" class="row g-2 align-items-center"> <div class="col-12 col-md-5"> <input type="text" name="search" class="form-control form-control-sm" placeholder="Search operator user, action description sequence, IP address..." value="<?= htmlspecialchars($search) ?>"> </div> <div class="col-12 col-md-3"> <select name="module" class="form-select form-select-sm text-capitalize"> <option value="all" <?= $module_filter === 'all' ? 'selected' : '' ?>>All Operational Modules</option> <?php foreach ($modules as $mod): ?> <option value="<?= htmlspecialchars($mod) ?>" <?= $module_filter === $mod ? 'selected' : '' ?>><?= htmlspecialchars(ucfirst($mod)) ?></option> <?php endforeach; ?> </select> </div> <div class="col-12 col-md-2"> <button type="submit" class="btn btn-sm btn-secondary w-100">Filter Trail</button> </div> </form> </div> <div class="card border-0 shadow-sm bg-white"> <div class="table-responsive"> <table class="table table-hover align-middle mb-0 text-nowrap small"> <thead class="table-light"> <tr> <th style="width: 15%;">Timestamp (Date)</th> <th>Target Scope Module</th> <th>User Identity Node</th> <th>Executed Action Descriptor Context</th> <th>Network IP Context</th> <th>Client Browser</th> </tr> </thead> <tbody> <?php if (empty($logs)): ?> <tr><td colspan="6" class="text-center py-4 text-muted">No security framework transactional operations mapped into the log parameters registry ledger indices.</td></tr> <?php else: ?> <?php foreach ($logs as $row): ?> <tr> <td class="text-secondary font-monospace"><?= $row['log_date'] ?></td> <td> <span class="badge bg-light text-dark border text-uppercase font-monospace style-module-tag" style="font-size: 0.72rem;"> <?= htmlspecialchars($row['module_name']) ?: 'SYSTEM' ?> </span> </td> <td class="fw-bold text-dark"><?= htmlspecialchars($row['username']) ?></td> <td class="text-wrap style-action-desc text-secondary" style="max-width: 400px; font-size: 0.85rem;"><?= htmlspecialchars($row['action_performed']) ?></td> <td><code class="text-danger"><?= htmlspecialchars($row['ip_address']) ?></code></td> <td class="text-muted"> <span title="<?= htmlspecialchars($row['user_agent']) ?>"> 🌐 <?= get_clean_browser_name($row['user_agent']) ?> </span> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> <?php if ($totalPages > 1): ?> <div class="card-footer bg-white border-0 py-3"> <nav> <ul class="pagination pagination-sm justify-content-end m-0"> <?php for ($i = 1; $i <= $totalPages; $i++): ?> <li class="page-item <?= $page === $i ? 'active' : '' ?>"> <a class="page-link" href="activity.php?page=<?= $i ?>&search=<?= urlencode($search) ?>&module=<?= urlencode($module_filter) ?>"><?= $i ?></a> </li> <?php endfor; ?> </ul> </nav> </div> <?php endif; ?> </div> </div> <?php require_once __DIR__ . '/../includes/footer.php'; ?>