118 lines
4.5 KiB
PHP
118 lines
4.5 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
|
|
header('Location: admin_login.php');
|
|
exit;
|
|
}
|
|
|
|
$users = [];
|
|
try {
|
|
$db = db();
|
|
$stmt = $db->query('SELECT id, username, created_at FROM users ORDER BY created_at DESC');
|
|
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
$error = "Error fetching users: " . $e->getMessage();
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>User Management - Admin</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<style>
|
|
.sidebar {
|
|
width: 280px;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100vh;
|
|
background-color: #1E1E1E;
|
|
padding-top: 20px;
|
|
}
|
|
.main-content {
|
|
margin-left: 280px;
|
|
padding: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="sidebar d-flex flex-column p-3">
|
|
<h3 class="text-white text-center mb-4">Admin Panel</h3>
|
|
<ul class="nav nav-pills flex-column mb-auto">
|
|
<li class="nav-item">
|
|
<a href="admin.php" class="nav-link text-white"><i class="bi bi-speedometer2 me-2"></i>Dashboard</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_users.php" class="nav-link active text-white"><i class="bi bi-people-fill me-2"></i>Users</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_content.php" class="nav-link text-white"><i class="bi bi-tv-fill me-2"></i>Premium Content</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_settings.php" class="nav-link text-white"><i class="bi bi-gear-fill me-2"></i>App Settings</a>
|
|
</li>
|
|
</ul>
|
|
<hr>
|
|
<div class="dropdown">
|
|
<a href="?action=logout" class="d-flex align-items-center text-white text-decoration-none">
|
|
<i class="bi bi-box-arrow-right me-2"></i>
|
|
<strong>Sign out</strong>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<main class="main-content">
|
|
<h1 class="mb-4">User Management</h1>
|
|
|
|
<?php if (isset($error)): ?>
|
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Registered Users</h5>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Username</th>
|
|
<th>Registration Date</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($users)): ?>
|
|
<tr>
|
|
<td colspan="4" class="text-center">No users found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($users as $user): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($user['id']); ?></td>
|
|
<td><?php echo htmlspecialchars($user['username']); ?></td>
|
|
<td><?php echo htmlspecialchars($user['created_at']); ?></td>
|
|
<td>
|
|
<button class="btn btn-sm btn-primary disabled" title="Coming Soon"><i class="bi bi-pencil-fill"></i></button>
|
|
<button class="btn btn-sm btn-danger disabled" title="Coming Soon"><i class="bi bi-trash-fill"></i></button>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
</body>
|
|
</html>
|