This repository has been archived by the owner on May 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathusermanager.php
151 lines (128 loc) · 3.65 KB
/
usermanager.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
<?php
include 'includes/header.php';
require 'includes/config.php';
?>
<body>
<?php
if($_SESSION['status'] == "admin")
{
?>
<div class="container">
<?php
$page='usermanager';
include 'includes/navbar.php';
include 'includes/file-nav.php';
?>
<div class="sub-page-main">
<div class="display-menu">
<!-- Or delete just the button if no buttons on the page -->
<form action="/createnewuser">
<button class="btn-display-menu" type='submit'><i class="fas fa-user-plus"></i> Create new user</button>
</form>
</div>
<div class="main">
<?php
echo "<h3>User list:</h3>";
$sqlReadAllUsers = "SELECT * FROM Users ORDER BY lastLogged DESC";
$resultReadAllUsers = mysqli_query($conn, $sqlReadAllUsers);
echo "<form method='POST'>";
echo "<table>";
echo "<tr>"; //nick, status, suspension, last connected
echo "<th>Nick</th>";
echo "<th>Status</th>";
echo "<th>Is active</th>";
echo "<th>Last connection</th>";
echo "<th>Edit</th>";
echo "<th>Delete</th>";
echo "<th>View Files</th>";
echo "</tr>";
while($row = mysqli_fetch_assoc($resultReadAllUsers))
{
echo "<tr>";
echo "<td>".$row['nick']."</td>";
echo "<td>".$row['status']."</td>";
if($row['suspended'] == "0")
echo "<td>Active</td>";
else
echo "<td>Suspended</td>";
if("0000-00-00 00:00:00" == $row['lastLogged'])
echo "<td>Never</td>";
else
echo "<td>".$row['lastLogged']."</td>";
if($_SESSION['nick'] == $row['nick'])
echo "<td>Edit</td>";
else
echo "<td><button class='butonas' name='edit".$row['id']."'>Edit</button></td>";
if($_SESSION['nick'] == $row['nick'])
echo "<td>X</td>";
else
echo "<td><button class='butonas1' type='button' name='".$row['nick']."' id='".$row['id']."' >X</button></td></td>";
if($_SESSION['nick'] == $row['nick'])
echo "<td>View</td>";
else
echo "<td><button class='butonas' name='view".$row['id']."'>View</button></td>";
echo "</tr>";
if(isset($_POST['edit'.$row['id']]))
{
$_SESSION['editableUser'] = $row['id'];
echo '<meta http-equiv="refresh" content="0; url=./edituser" />';
}
if(isset($_POST['view'.$row['id']]))
{
$_SESSION['viewingFiles'] = $row['nick'];
$_SESSION['specAccesToViewFile'] = "2000-01-01 00:00:00";
echo '<meta http-equiv="refresh" content="0; url=./viewfiles" />';
}
}
echo "</table>";
echo "</form>";
?>
</div>
</div> <?php
}
else
{
echo "You are not authorised to view this page!<br>";
echo '<meta http-equiv="refresh" content="0; url=./errorAuthorization.shtml" />';
}
?>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
$(".butonas1").click(function() {
var idid = this.id;
var nicknick = this.name;
var varData = 'id=' + idid + '&nick=' + nicknick;
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this user!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal("User has been deleted!", {
icon: "success",
});
$.ajax({
type: 'POST',
url: 'includes/userdelete',
data: varData,
success: function() {
console.log("deleted succesfully!");
}
});
location.reload(true);
}
});
});
});
</script>
</div>
</body>
</html>