-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminEditUser.php
More file actions
93 lines (71 loc) · 2.52 KB
/
adminEditUser.php
File metadata and controls
93 lines (71 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
session_start();
require_once 'header.php';
require_once 'lib/functions.php';
require_once 'db/db.php';
$stmt = $pdo->prepare("SELECT ID, name, status FROM users where ID = ? ");
$updateStmt = $pdo->prepare('UPDATE users SET status = ? WHERE id = ?');
$thisUser = null;
if (isset($_GET['id'])) {
$thisUser = checkIfAdmin($pdo, $_GET['id']);
}
else if (isset($_SESSION['user_id'])) {
$thisUser = checkIfAdmin($pdo, $_SESSION['user_id']);
}
if ($thisUser == null)
header("Location: index.php");
//Process Admin User Ban
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['activateUser'])) {
$updateStmt->execute([1, $thisUser['ID']]);
$_SESSION['success_message'] = "This User has been activated.";
header('Location: adminEditUser.php?id=' . $thisUser['ID']);
}
}
if (isset($_POST['banUser'])) {
$updateStmt->execute([-1, $thisUser['ID']]);
$_SESSION['success_message'] = "This User has been banned.";
header('Location: adminEditUser.php?id=' . $thisUser['ID']);
}
//Process Admin Photo Removal, Fully deletes photos
?>
<?php
echo echoHeader($thisUser['name'] . '\'s Profile', $thisUser['bio'] ?? '');
$status = $thisUser['status'];
switch ($status) {
case (-1):
echo '<div class="d-flex p-2 bg-danger text-white">This user is Admin Blocked</div>';
break;
case (0):
echo '<div class="d-flex p-2 bg-primary text-white">This user is Deleted</div>';
break;
case (1):
echo '<div class="d-flex p-2 bg-success text-white">This user is Active</div>';
break;
case (3):
echo '<div class="d-flex p-2 bg-warning text-white">This user is a Admin</div>';
break;
}
?>
<!-- Admin Navigation-->
<div class="d-flex flex-row justify-content-between">
<div class="d-flex justify-content-start">
<form method="POST" action="">
<?php
if ($thisUser['status'] == '1') {
echo '
<button name="banUser" type="submit">Ban User Account</button>';
} else if ($thisUser['status'] == '-1') {
echo '
<button name="activateUser" type="submit">Activate User Account</button>';
}
?>
</form>
</div>
<div class="d-flex justify-content-end w-25 align-self-end align-items-end">
<a href="admin.php"><button name="toIndex" type="submit">Back to Admin Dashboard</button></a>
</div>
</div>
<hr>
<?= generateUserAlbum($pdo,$thisUser['ID']); ?>
<?= echoFooter() ?>