2022-12-30 03:25:40 +00:00
|
|
|
<?php
|
|
|
|
include "partials/header.php";
|
2023-03-07 01:23:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
$current_admin_id = $_SESSION['user-id'];
|
2024-03-29 06:36:56 +00:00
|
|
|
if(!isset($_SESSION['user_is_admin'])){
|
|
|
|
header("location: " . ROOT_URL . "logout.php");
|
|
|
|
//destroy all sessions and redirect user to login page
|
|
|
|
session_destroy();
|
|
|
|
}
|
2023-03-07 01:23:47 +00:00
|
|
|
$query="SELECT id,firstname,lastname,username,is_admin FROM users WHERE NOT id='$current_admin_id'";
|
|
|
|
$users=mysqli_query($connection,$query);
|
2022-12-30 03:25:40 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="dashboard">
|
2023-03-07 01:23:47 +00:00
|
|
|
<?php
|
|
|
|
if(isset($_SESSION['add-user-success'])):
|
|
|
|
?>
|
|
|
|
<div class="alert__message success container">
|
|
|
|
<p>
|
|
|
|
<?= $_SESSION['add-user-success'];
|
|
|
|
unset($_SESSION['add-user-success']);
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
elseif(isset($_SESSION['edit-user'])):
|
|
|
|
?>
|
|
|
|
<div class="alert__message error container">
|
|
|
|
<p>
|
|
|
|
<?= $_SESSION['edit-user'];
|
|
|
|
unset($_SESSION['edit-user']);
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
elseif(isset($_SESSION['edit-user-success'])):
|
|
|
|
?>
|
|
|
|
<div class="alert__message success container">
|
|
|
|
<p>
|
|
|
|
<?= $_SESSION['edit-user-success'];
|
|
|
|
unset($_SESSION['edit-user-success']);
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
elseif(isset($_SESSION['delete-user'])):
|
|
|
|
?>
|
|
|
|
<div class="alert__message error container">
|
|
|
|
<p>
|
|
|
|
<?= $_SESSION['delete-user'];
|
|
|
|
unset($_SESSION['delete-user']);
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
elseif(isset($_SESSION['delete-user-success'])):
|
|
|
|
?>
|
|
|
|
<div class="alert__message success container">
|
|
|
|
<p>
|
|
|
|
<?= $_SESSION['delete-user-success'];
|
|
|
|
unset($_SESSION['delete-user-success']);
|
|
|
|
?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php endif ?>
|
2022-12-30 03:25:40 +00:00
|
|
|
<div class="container dashboard__container">
|
|
|
|
|
|
|
|
<button id="show__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-right-b"></i></button>
|
|
|
|
<button id="hide__sidebar-btn" class="sidebar__toggle"><i class="uil uil-angle-left-b"></i></button>
|
|
|
|
|
|
|
|
<aside>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/add-post.php">
|
|
|
|
<i class="uil uil-pen"></i>
|
|
|
|
<h5>Add Post</h5>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/index.php">
|
2023-01-15 01:22:14 +00:00
|
|
|
<i class="uil uil-postcard"></i>
|
|
|
|
<h5>Manage Posts</h5>
|
2022-12-30 03:25:40 +00:00
|
|
|
</a>
|
|
|
|
</li>
|
2023-01-15 01:22:14 +00:00
|
|
|
<?php if(isset($_SESSION['user_is_admin'])) : ?>
|
2022-12-30 03:25:40 +00:00
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/add-user.php">
|
|
|
|
<i class="uil uil-user-plus"></i>
|
|
|
|
<h5>Add User</h5>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/manage-users.php" class="active">
|
|
|
|
<i class="uil uil-users-alt"></i>
|
|
|
|
<h5>Manage Users</h5>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/add-category.php">
|
|
|
|
<i class="uil uil-edit"></i>
|
|
|
|
<h5>Add Category</h5>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="<?= ROOT_URL ?>admin/manage-categories.php" >
|
|
|
|
<i class="uil uil-list-ul"></i>
|
|
|
|
<h5>Manage Categories</h5>
|
|
|
|
</a>
|
|
|
|
</li>
|
2023-01-15 01:22:14 +00:00
|
|
|
<?php endif ?>
|
|
|
|
|
2022-12-30 03:25:40 +00:00
|
|
|
</ul>
|
|
|
|
</aside>
|
|
|
|
<main>
|
|
|
|
<h2>Manage Users</h2>
|
2023-03-07 01:23:47 +00:00
|
|
|
<?php if(mysqli_num_rows($users)>0): ?>
|
2022-12-30 03:25:40 +00:00
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Username</th>
|
|
|
|
<th>Edit</th>
|
|
|
|
<th>Delete</th>
|
|
|
|
<th>Admin</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2023-03-07 01:23:47 +00:00
|
|
|
<?php while($user=mysqli_fetch_assoc($users)): ?>
|
2022-12-30 03:25:40 +00:00
|
|
|
<tr>
|
2023-03-07 01:23:47 +00:00
|
|
|
<td><?= $user["firstname"] . $user['lastname'] ?></td>
|
|
|
|
<td><?= $user["username"] ?> </td>
|
|
|
|
<td><a href="<?= ROOT_URL ?>admin/edit-user.php?id=<?= $user['id'] ?>" class="btn sm">Edit</a></td>
|
|
|
|
<td><a href="<?= ROOT_URL ?>admin/delete-users.php?id=<?= $user['id'] ?>" class="btn sm danger">Delete</a></td>
|
|
|
|
<td><?= $user["is_admin"] ? 'Yes' : 'No' ?></td>
|
|
|
|
|
2022-12-30 03:25:40 +00:00
|
|
|
|
|
|
|
</tr>
|
2023-03-07 01:23:47 +00:00
|
|
|
<?php endwhile ?>
|
2022-12-30 03:25:40 +00:00
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2023-03-07 01:23:47 +00:00
|
|
|
<?php else : ?>
|
|
|
|
<div class="alert__message error">No users found</div>
|
|
|
|
<?php endif?>
|
2022-12-30 03:25:40 +00:00
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
include "../partials/footer.php";
|
|
|
|
?>
|
|
|
|
|