1 <?php 2 require_once __DIR__ . '/../includes/bootstrap.php'; 3 must_admin(); 4 $PAGE_TITLE = 'Users'; 5 $ADMIN_PAGE = 'users'; 6 7 $q = get('q'); 8 $page = max(1,(int)get('page','1')); 9 $pp = 30; 10 $off = ($page-1)*$pp; 11 $like = '%'.$q.'%'; 12 $where = $q ? "WHERE username LIKE ? OR email LIKE ?" : ""; 13 $params = $q ? [$like,$like] : []; 14 $users = DB::rows("SELECT * FROM users $where ORDER BY joined_at DESC LIMIT $pp OFFSET $off", $params); 15 $total = (int)DB::val("SELECT COUNT(*) FROM users $where", $params); 16 $pages = max(1,(int)ceil($total/$pp)); 17 18 include __DIR__ . '/../views/partials/admin_layout.php'; 19 ?> 20 <div class="admin-toolbar"> 21 <form method="GET" class="at-form"> 22 <input type="text" name="q" value="<?= e($q) ?>" placeholder="Search users…" class="fi at-fi"> 23 <button type="submit" class="btn-primary">Search</button> 24 <?php if ($q): ?><a href="<?= u('admin/users.php') ?>" class="btn-ghost">Clear</a><?php endif; ?> 25 </form> 26 </div> 27 <div class="acard"> 28 <table class="atable"> 29 <thead><tr><th>User</th><th>Email</th><th>Role</th><th>Posts</th><th>Status</th><th>Joined</th><th></th></tr></thead> 30 <tbody> 31 <?php foreach ($users as $u): ?> 32 <tr> 33 <td>@<?= e($u['username']) ?></td> 34 <td><?= e($u['email']) ?></td> 35 <td><span class="role-tag role-<?= e($u['role']) ?>"><?= e($u['role']) ?></span></td> 36 <td><?= $u['post_count'] ?></td> 37 <td> 38 <?php if ($u['suspended']): ?><span class="stag suspended">Suspended</span> 39 <?php elseif ($u['silenced']): ?><span class="stag silenced">Silenced</span> 40 <?php else: ?><span class="stag active">Active</span><?php endif; ?> 41 </td> 42 <td><span class="ago" data-ts="<?= e($u['joined_at']) ?>"></span></td> 43 <td><a href="<?= u('admin/user.php?id='.$u['id']) ?>" class="btn-ghost btn-sm">Manage</a></td> 44 </tr> 45 <?php endforeach; ?> 46 <?php if (!$users): ?><tr><td colspan="7" style="text-align:center;padding:2rem;color:#6b7280">No users found.</td></tr><?php endif; ?> 47 </tbody> 48 </table> 49 </div> 50 <?php if ($pages>1): ?> 51 <nav class="pager"> 52 <?php for($i=1;$i<=$pages;$i++): ?> 53 <a href="?page=<?= $i ?>&q=<?= urlencode($q) ?>" class="pg-btn <?= $i===$page?'active':'' ?>"><?= $i ?></a> 54 <?php endfor; ?> 55 </nav> 56 <?php endif; ?> 57 <?php include __DIR__ . '/../views/partials/admin_layout_end.php'; ?>