This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
administration.php
188 lines (171 loc) · 9.15 KB
/
administration.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($con);
check_admin();
?>
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>Jukebox | Users Console</title>
<link rel="shortcut icon" type="image/png" href="assets/favicon.png">
<link rel="stylesheet" href="/src/users.css">
<link rel="stylesheet" href="/src/tablesorter.css">
<link rel="stylesheet" href="/src/editor.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&family=Work+Sans:ital,wght@0,100;0,200;0,400;0,500;0,600;1,100&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script src="/src/welcome.js"></script>
<script src="/src/tablesort.js"></script>
<script src="/src/users.js"></script>
<style>
.wrapper{
width: 600px;
margin: 0 auto;
}
body {
background-image: url('cdn/background.jpg');
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
font-family: "Roboto",sans-serif;
font-family: 'Work Sans', sans-serif;
overflow:auto;
}
</style>
</head>
<body>
<div class="overlay" id="editorback">
<div class="editor-box" id="editor-box">
<h1><span class="waving">Edit User Information</span></h1>
<form method="post" class="editor-form">
<input name = "fname" type="text" class = "input-box" placeholder= "First Name" id="edit_fname">
<input name = "lname" type="text" class = "input-box" placeholder= "Last Name" id="edit_lname" >
<input name = "username" type="text" class = "input-box" placeholder= "Username" id="edit_uname" readonly>
<input name = "email" type="text" class = "input-box" placeholder= "Email" id="edit_mail">
<input type="hidden" name="id" value="" id="key_field">
<select name="role_select" class = "input-box styleselect" id="edit_role">
<option value="ADMIN">Admin</option>
<option value="ORGANIZER">Organizer</option>
<option value="USER">User</option>
</select><br><br>
<button type="button" class="button" onclick="submitEdits()">Submit</button>
<button type="button" class="button btn-2 repos" onclick="closeEditor()" id="exitbtn">Cancel</button>
<div class="resultBox" id="resBox"><p class="result-msg" id="resMsg"></p></div>
</form>
</div>
</div>
<div class="banner">
<div class="navbar">
<div class="logo">
<a href="index.php"><img src="cdn/logo.png"></a>
</div>
<div class="dropdown">
<button class="dropbtn waving">
<?php
if($_SESSION['user_role'] === "ADMIN"){
echo 'ADMIN';
}elseif($_SESSION['user_role'] === "ORGANIZER"){
echo 'ORGANIZER';
}elseif($_SESSION['user_role'] === "USER"){
echo 'USER';
}else{
echo 'Internal Error';
die;
}
?>
MENU</button>
<div class="dropdown-content">
<?php
if($_SESSION['user_role'] === "ADMIN"){
echo '<a href="administration.php">User Catalog Tools</a>';
}elseif($_SESSION['user_role'] === "ORGANIZER"){
echo '<a href="organizer.php">Organizer Tools</a>';
}elseif($_SESSION['user_role'] === "USER"){
echo '<a href="concerts.php">Concerts</a>';
echo '<a href="favorites.php">Favorites</a>';
}else{
echo 'Internal Error';
die;
}
?>
<a href="mailto:admin@jukebox.com">Report a problem</a>
</div>
</div>
<div>
<button id="logoutBtn" type="button" class="logoutbtn" title="Sign out from <?php echo $_SESSION['uname'];?>">
<img src="assets/logout.png" alt="Logout">
</button>
</div>
<div>
<span> <img src="/assets/user.png" alt="User icon" class = "userico">
<p class="userinfo">
<?php
printf("%s %s (%s)",$_SESSION['last_name'],$_SESSION['first_name'], $_SESSION['user_role']);
?>
</p>
</span>
</div>
</div>
<div class="content">
<div><h1><span>Users of Jukebox | Administrator Console</span></h1></div>
<?php
// Include config file
require_once "connection.php";
$sql = "SELECT * FROM users";
if($result = mysqli_query($con, $sql)){
if(mysqli_num_rows($result) > 0){
echo '<table class="content-table table-sortable">';
echo "<thead>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>First Name</th>";
echo "<th>Last Name</th>";
echo "<th>Username</th>";
echo "<th>Email</th>";
echo "<th>Role</th>";
echo "<th>Confirmed</th>";
echo "<th>Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr id=row_".$row['id'].">";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";
echo "<td id=uname_".$row['id'].">". $row['username'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['role'] . "</td>";
if($row['confirmed'] == 1){
echo "<td id=status_".$row['id']." style=\"color:green;\">" . 'Confirmed' . "</td>";
}else{
echo "<td id=status_".$row['id']." style=\"color:red;\">" . 'Deactivated' . "</td>";
}
echo "<td>";
echo '<a href="javascript:statusUser('.$row['id'].');"><img class = "conf-ico" src="/assets/activate.png" alt="change confirmed"></a>';
echo '<a href="javascript:editUser('. $row['id'] .');"><img class = "conf-ico" src="/assets/editing.png" alt="change confirmed"></a>';
echo '<a href="javascript:delUser('.$row['id'].');"><img class = "conf-ico" src="/assets/bin.png" alt="change confirmed"></a>';
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
}
} else{
echo "Something went wrong. Please try again later.";
}
?>
</div>
<div class="divider">
</div>
</div>
</body>