-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddAdmins.php
119 lines (114 loc) · 3.74 KB
/
addAdmins.php
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
include("Meta-PHP.php");
include("myBudgetDataBase.php");
if(!isset($_SESSION['admin']))
redirect("/index.php" );
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href=fonts/DroidSans-Bold.ttf" rel="stylesheet">
<link href=fonts/DroidSans.ttf" rel="stylesheet">
<link href="fonts/Lobster-Regular.ttf" rel="stylesheet">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="datatables.min.css">
<link rel="stylesheet" href="css/styles.css">
<title>Add Admins</title>
</head>
<body>
<?php
include ('NavBar.php');
if(isset($_POST['SetAdmin']))
{
setadmin($_POST['UserID']);
redirect("/AddAdmins.php");
}
if(isset($_POST['DeleteAdmin']))
{
removeadmin($_POST['UserID']);
redirect("/AddAdmins.php");
}
if(isset($_POST['DeleteAccount']))
{
deleteUserByID($_POST['UserID']);
redirect("/AddAdmins.php");
}
$userID = $_SESSION['userID'];
?>
<div class="col-md center-block col-md-offset-1 budgetslist editForAdmins">
<h1 class="text-center changeprofconfirm editForAdminsheader">Add Admins</h1>
<table id="adminsTable" class="table tableincome">
<thead>
<tr>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Age</th>
<th>Data Joined</th>
<th>Authorities</th>
<th>Delete Account</th>
</tr>
</thead>
<tbody>
<?php
$users = getAllUsers();
for ($i=0; $i < sizeof($users); $i++) {
$user = $users[$i];
if($user['ID'] != $userID && $user["isAdmin"] != 2)
{
$userName = $user["Username"];
$firstName = $user["Firstname"];
$lastName = $user["Lastname"];
$email = $user["Email"];
$age = $user["Age"];
$dataJoined = $user["Datejoined"];
$isAdmin = $user["isAdmin"];
echo "
<tr>
<td scope=\"row\">$userName</td>
<td >$firstName</td>
<td>$lastName</td>
<td>$email</td>
<td>$age</td>
<td>$dataJoined</td>
";
echo '<form role= "form" method="POST" action="'.htmlspecialchars($_SERVER["PHP_SELF"]).'">
<td>
<input type="hidden" name="UserID" value="'.$user['ID'].'">';
if($isAdmin)
{
echo '<button type="submit" class="btn btn-default center-block submitbutton" name="DeleteAdmin">Delete Admin</button>';
}
else
{
echo '<button type="submit" class="btn btn-default center-block setbutton submitbutton" name="SetAdmin">Set Admin</button>';
}
echo '</td><td><button type="submit" class="btn btn-default center-block setbutton submitbutton" name="DeleteAccount">Delete</button>';
echo "</form></td></tr>";
}
}
?>
</tbody>
</table>
</div>
<script src = "jquery.js"></script>
<script type="text/javascript" src="datatables.min.js"></script>
<script src="js/html5shiv.min.js"></script>
<script src="js/respond.min.js"></script>
<script src="js/jquery-3.1.1.min.js"> </script>
<script src="js/bootstrap.min.js"></script>
<script src = "jquery.js"></script>
<script type="text/javascript" src="datatables.min.js"></script>
<script>
$(document).ready(function(){
$('#adminsTable').DataTable();
//alert("hii");
});
</script>
</body>
</html>