1
This commit is contained in:
parent
14c0118747
commit
ac58933e42
36
index.php
36
index.php
@ -10,41 +10,7 @@ if ($_SESSION['role'] !== 'admin') {
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="sidebar">
|
||||
<h4 class="px-3">TankMon</h4>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">
|
||||
<i data-feather="home"></i>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="users"></i>
|
||||
Users
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="database"></i>
|
||||
Tanks
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="hard-drive"></i>
|
||||
IoT Devices
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="settings"></i>
|
||||
Settings
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php include 'sidebar.php'; ?>
|
||||
|
||||
<div class="main-content">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
|
||||
35
sidebar.php
Normal file
35
sidebar.php
Normal file
@ -0,0 +1,35 @@
|
||||
<div class="sidebar">
|
||||
<h4 class="px-3">TankMon</h4>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="index.php">
|
||||
<i data-feather="home"></i>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="users.php">
|
||||
<i data-feather="users"></i>
|
||||
Users
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="database"></i>
|
||||
Tanks
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="hard-drive"></i>
|
||||
IoT Devices
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i data-feather="settings"></i>
|
||||
Settings
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
68
users.php
Normal file
68
users.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
require_once 'header.php';
|
||||
|
||||
// Check if user is logged in and is an admin
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'admin') {
|
||||
echo '<div class="container">
|
||||
<div class="alert alert-danger mt-5" role="alert">
|
||||
You are not authorized to view this page. Please <a href="login.php">login</a> as an admin.
|
||||
</div>
|
||||
</div>';
|
||||
require_once 'footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch users from the database
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query('SELECT id, name, email, role, created_at FROM users ORDER BY created_at DESC');
|
||||
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
include 'sidebar.php';
|
||||
?>
|
||||
|
||||
<div class="main-content">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>User Management</h2>
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="me-3">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?>!</span>
|
||||
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Registered At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($users)): ?>
|
||||
<tr>
|
||||
<td colspan="5" 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['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($user['email']); ?></td>
|
||||
<td><?php echo htmlspecialchars($user['role']); ?></td>
|
||||
<td><?php echo htmlspecialchars(date('Y-m-d H:i', strtotime($user['created_at']))); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once 'footer.php';
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user