|
Server IP : 2a02:4780:2b:1556:0:9c6:43c4:d / Your IP : 216.73.216.229 Web Server : LiteSpeed System : Linux us-bos-web1456.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64 User : u163988420 ( 163988420) PHP Version : 8.5.4 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail, proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u163988420/domains/../domains/acmajmer.in/public_html/AACSITE/../AACSITE/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include("../includes/auth.php");
include("../includes/db.php");
if (!isset($_SESSION['admin'])) {
header("Location: login.php");
exit;
}
/*
|--------------------------------------------------------------------------
| Only Super Admin Can Access
|--------------------------------------------------------------------------
*/
if ($_SESSION['admin_role'] != "super_admin") {
?>
<!DOCTYPE html>
<html>
<head>
<title>Access Restricted</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 p-0">
<?php include("navbar.php"); ?>
</div>
<div class="col-md-10 p-5">
<div class="alert alert-danger">
<h3>Access Restricted</h3>
<p>
Only the <strong>Super Admin</strong> can access this page.
</p>
<a href="dashboard.php" class="btn btn-primary">
Back to Dashboard
</a>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
exit;
}
$id = (int)$_GET['id'];
$res = mysqli_query($conn, "SELECT * FROM admins WHERE id='$id'");
if (mysqli_num_rows($res) == 0) {
header("Location: manage_admin.php");
exit;
}
$row = mysqli_fetch_assoc($res);
if (isset($_POST['update'])) {
$fullname = mysqli_real_escape_string($conn, $_POST['fullname']);
$username = mysqli_real_escape_string($conn, $_POST['username']);
$role = $_POST['role'];
$password = trim($_POST['password']);
/*
----------------------------------------------------
Prevent Super Admin from changing own role
----------------------------------------------------
*/
if ($id == $_SESSION['admin_id']) {
$role = "super_admin";
}
if (!empty($password)) {
$hashed_password = password_hash(
$password,
PASSWORD_DEFAULT
);
$sql = "UPDATE admins SET
fullname='$fullname',
username='$username',
password='$hashed_password',
role='$role'
WHERE id='$id'";
} else {
$sql = "UPDATE admins SET
fullname='$fullname',
username='$username',
role='$role'
WHERE id='$id'";
}
mysqli_query($conn, $sql);
header("Location: manage_admin.php");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 p-0">
<?php include("navbar.php"); ?>
</div>
<div class="col-md-10 p-4">
<h2>Edit Admin</h2>
<form method="POST">
<div class="mb-3">
<label>Full Name</label>
<input
type="text"
name="fullname"
value="<?php echo htmlspecialchars($row['fullname']); ?>"
class="form-control"
required>
</div>
<div class="mb-3">
<label>Username</label>
<input
type="text"
name="username"
value="<?php echo htmlspecialchars($row['username']); ?>"
class="form-control"
required>
</div>
<div class="mb-3">
<label>New Password</label>
<input
type="password"
name="password"
class="form-control">
<small class="text-muted">
Leave blank if you don't want to change the password.
</small>
</div>
<div class="mb-3">
<label>Role</label>
<select
name="role"
class="form-select">
<option
value="admin"
<?php if ($row['role'] == "admin") echo "selected"; ?>>
Admin
</option>
<option
value="super_admin"
<?php if ($row['role'] == "super_admin") echo "selected"; ?>>
Super Admin
</option>
</select>
<?php if ($id == $_SESSION['admin_id']) { ?>
<small class="text-danger">
Your account will always remain <strong>Super Admin</strong>.
</small>
<?php } ?>
</div>
<button
type="submit"
name="update"
class="btn btn-success">
Update Admin
</button>
<a
href="manage_admin.php"
class="btn btn-secondary">
Cancel
</a>
</form>
</div>
</div>
</div>
</body>
</html>