| Server IP : 213.255.246.8 / Your IP : 216.73.217.2 Web Server : Apache System : Linux dublin.stapolin.com 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64 User : stapolin ( 1019) PHP Version : 8.4.24 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/stapolin/public_html/dash.stapolin.com/ |
Upload File : |
<?php
/**
* All Activity Page
* Shows all activity (Users, Plugins, Themes, Core, Posts, Attachments, etc.) filterable by website, user, type, action.
*/
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/auth.php';
$filterWebsite = isset($_GET['website']) ? (int)$_GET['website'] : 0;
$filterUser = isset($_GET['user']) ? trim($_GET['user']) : '';
$filterType = isset($_GET['type']) ? trim($_GET['type']) : '';
$filterAction = isset($_GET['action']) ? trim($_GET['action']) : '';
$websiteId = ($filterWebsite > 0) ? $filterWebsite : null;
try {
$activity = getAllActivity($websiteId, $filterUser ?: null, $filterType ?: null, $filterAction ?: null, 500);
$websites = getWebsites();
$objectTypes = getActivityObjectTypes();
$actions = getActivityActions($filterType ?: null);
} catch (Exception $e) {
$activity = [];
$websites = [];
$objectTypes = [];
$actions = [];
}
$pageTitle = 'All Activity';
require_once __DIR__ . '/includes/header.php';
?>
<div class="flex items-center justify-between mb-6">
<div>
<h2 class="text-2xl font-semibold mb-1" data-testid="text-page-title">All Activity</h2>
<p class="text-muted-foreground">All activity across sites — filter by website, user, type, or action</p>
</div>
</div>
<!-- Filters -->
<div class="card rounded-lg p-4 mb-6">
<form method="GET" class="flex flex-wrap items-end gap-4">
<div class="flex-1 min-w-[180px]">
<label class="block text-sm font-medium mb-1">Website</label>
<select name="website" class="w-full px-3 py-2 rounded-md text-sm" data-testid="select-filter-website">
<option value="">All Websites</option>
<?php foreach ($websites as $site): ?>
<option value="<?= (int)$site['website_id'] ?>" <?= $filterWebsite === (int)$site['website_id'] ? 'selected' : '' ?>>
<?= sanitize($site['website_url']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex-1 min-w-[180px]">
<label class="block text-sm font-medium mb-1">User</label>
<input type="text" name="user" value="<?= sanitize($filterUser) ?>" placeholder="Username or target..."
class="w-full px-3 py-2 rounded-md text-sm" data-testid="input-filter-user">
</div>
<div class="flex-1 min-w-[180px]">
<label class="block text-sm font-medium mb-1">Activity Type</label>
<select name="type" class="w-full px-3 py-2 rounded-md text-sm" data-testid="select-filter-type">
<option value="">All Types</option>
<?php foreach ($objectTypes as $ot): ?>
<option value="<?= sanitize($ot['object_type']) ?>" <?= $filterType === $ot['object_type'] ? 'selected' : '' ?>>
<?= sanitize($ot['object_type']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex-1 min-w-[180px]">
<label class="block text-sm font-medium mb-1">Action</label>
<select name="action" class="w-full px-3 py-2 rounded-md text-sm" data-testid="select-filter-action">
<option value="">All Actions</option>
<?php foreach ($actions as $act): ?>
<option value="<?= sanitize($act['action']) ?>" <?= $filterAction === $act['action'] ? 'selected' : '' ?>>
<?= sanitize($act['action']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex gap-2">
<button type="submit" class="btn-primary px-4 py-2 rounded-md text-sm font-medium" data-testid="button-apply-filter">Apply</button>
<?php if ($filterWebsite || $filterUser !== '' || $filterType !== '' || $filterAction !== ''): ?>
<a href="activity.php" class="btn-secondary px-4 py-2 rounded-md text-sm font-medium" data-testid="button-clear-filter">Clear</a>
<?php endif; ?>
</div>
</form>
</div>
<!-- Table -->
<div class="card rounded-lg overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-muted/50 border-b">
<tr>
<th class="px-4 py-3 text-left font-medium">Time</th>
<th class="px-4 py-3 text-left font-medium">Website</th>
<th class="px-4 py-3 text-left font-medium">Type</th>
<th class="px-4 py-3 text-left font-medium">Action</th>
<th class="px-4 py-3 text-left font-medium">What</th>
<th class="px-4 py-3 text-left font-medium">Who</th>
<th class="px-4 py-3 text-left font-medium">IP</th>
</tr>
</thead>
<tbody class="divide-y">
<?php if (empty($activity)): ?>
<tr>
<td colspan="7" class="px-4 py-8 text-center text-muted-foreground">No activity found. Adjust filters or wait for new events.</td>
</tr>
<?php else: ?>
<?php foreach ($activity as $row): ?>
<tr class="table-row">
<td class="px-4 py-2 whitespace-nowrap text-muted-foreground"><?= date('M j, Y H:i', (int)$row['hist_time']) ?></td>
<td class="px-4 py-2">
<a href="website-detail.php?id=<?= (int)$row['website_id'] ?>" class="text-primary hover:underline truncate max-w-[200px] block" title="<?= sanitize($row['website_url']) ?>">
<?= sanitize($row['website_url']) ?>
</a>
</td>
<td class="px-4 py-2">
<span class="badge badge-secondary"><?= sanitize($row['object_type']) ?></span>
</td>
<td class="px-4 py-2 font-mono"><?= sanitize($row['action']) ?></td>
<td class="px-4 py-2 max-w-[220px] truncate" title="<?= sanitize($row['object_name'] . ($row['object_subtype'] ? ' (' . $row['object_subtype'] . ')' : '')) ?>">
<?= sanitize($row['object_name']) ?>
<?php if (!empty($row['object_subtype'])): ?>
<span class="text-muted-foreground">(<?= sanitize($row['object_subtype']) ?>)</span>
<?php endif; ?>
</td>
<td class="px-4 py-2"><?= sanitize($row['username'] ?? '—') ?></td>
<td class="px-4 py-2 font-mono text-muted-foreground"><?= sanitize($row['hist_ip'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<?php if (!empty($activity)): ?>
<div class="px-4 py-2 border-t text-sm text-muted-foreground">
Showing <?= count($activity) ?> record(s). Max 500 per load.
</div>
<?php endif; ?>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>