4 require_once "../../common.php";
5 require_once "../../header.php";
6 require_once "SQL/sql.php";
7 require_once "SQL/user.php";
14 <h4
>Panel Access Overview
</h4
>
18 // TODO: Validation and stuff
20 if (isset($p['delete_user']) && current_user_can(SQLPERM_MANAGE_USERS
))
23 foreach ($p['userch'] as $id)
25 $user = new SQLA_User(NULL, $id);
26 $us = unreal_get_current_user();
27 $deleted = delete_user($id, $info);
28 if ($us->id
== $user->id
) // if it's the current user
31 header("Location: " . BASE_URL
. "plugins/sql_auth/login.php");
34 $msg = ($deleted = 1) ? "Message::Success" : "Message::Fail";
40 if (isset($p['do_add_user']) && current_user_can(SQLPERM_MANAGE_USERS
))
43 $user['user_name'] = $p['user_add'];
44 $user['user_pass'] = $p['password'];
45 $user['fname'] = $p['add_first_name'];
46 $user['lname'] = $p['add_last_name'];
47 $user['user_bio'] = $p['user_bio'];
48 create_new_user($user);
49 if (($usr_obj = new SQLA_User($p['user_name'])) && !$usr_obj->id
)
51 Message
::Success("Successfully created user \"" . $user['user_name'] . "\"");
55 Message
::Fail("Failed to create user \"" . $user['user_name'] . "\"");
60 $result = $conn->query("SELECT user_id FROM " . SQL_PREFIX
. "users");
62 while($row = $result->fetch())
64 $userlist[] = new SQLA_User(NULL, $row['user_id']);
67 if (!$result) // impossible
69 die("Something went wrong.");
73 Click on a username to view more information
.
77 <?php
if (current_user_can(SQLPERM_MANAGE_USERS
)) { ?>
78 <div
class="col-sm-3">
80 <div
class="btn btn-sm btn-primary" data
-toggle
="modal" data
-target
="#myModal">Add
New User
</div
>
81 <div
class="btn btn-sm btn-warning" data
-toggle
="modal" data
-target
="#rehash_modal">Delete
</div
>
82 <div
class="btn btn-sm btn-danger" data
-toggle
="modal" data
-target
="#disconnect_modal">Disconnect
</div
>
88 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
89 <div
class="modal-dialog modal-dialog-centered" role
="document">
90 <div
class="modal-content">
91 <div
class="modal-header">
92 <h5
class="modal-title" id
="myModalLabel">Add
new Admin Panel user
</h5
>
93 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
94 <span aria
-hidden
="true">×
;</span
></button
>
96 <div
class="modal-body">
97 <div
class="input-group mb-3">
98 <label
for="name_add" name
="user_add" id
="user_add">Username
99 <input style
="width: 170%;" name
="user_add" id
="user_add" class="form-control curvy" type
="text"></label
>
101 <div
class="input-group mb-3">
102 <label
for="password" id
="user_add">Password
103 <input style
="width: 170%;" name
="password" id
="password" class="form-control curvy" type
="password"></label
>
105 <div
class="input-group mb-3">
106 <label
for="add_first_name" id
="user_add">First Name
107 <input style
="width: 170%;" name
="add_first_name" id
="add_first_name" class="form-control curvy" type
="text"></label
>
108 </div
><div
class="input-group mb-3">
109 <label
for="password" id
="user_add">Last Name
110 <input style
="width: 170%;" name
="add_last_name" id
="add_last_name" class="form-control curvy" type
="text"></label
>
112 <div
class="input-group mb-3">
113 <label
for="password" id
="user_add">Info
/Bio
114 <textarea style
="width: 170%;" name
="user_bio" class="form-control curvy" aria
-label
="With textarea"></textarea
></label
>
118 <div
class="modal-footer">
119 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
120 <button type
="submit" name
="do_add_user" class="btn btn-danger">Add User
</button
>
129 <table
class="container-xxl table table-sm table-responsive caption-top table-striped">
130 <thead
class="table-primary">
132 <th scope
="col"><input type
="checkbox" label
='selectall' onClick
="toggle_tkl(this)" /></th
>
133 <th scope
="col">Username
</th
>
134 <th scope
="col">First Name
</th
>
135 <th scope
="col">Last Name
</th
>
136 <th scope
="col">Created
</th
>
137 <th scope
="col">Bio
</th
>
142 foreach($userlist as $user)
145 echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id
. "' name=\"userch[]\"></td>";
146 echo "<td scope=\"col\">".$user->username
."</td>";
147 echo "<td scope=\"col\">".$user->first_name
."</td>";
148 echo "<td scope=\"col\">".$user->last_name
."</td>";
149 echo "<td scope=\"col\">".$user->created
."</td>";
150 echo "<td scope=\"col\">".$user->bio
."</td>";
153 ?></tbody
></table
><p
><button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2">
156 <div
class="modal fade" id
="myModal2" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
157 <div
class="modal-dialog modal-dialog-centered" role
="document">
158 <div
class="modal-content">
159 <div
class="modal-header">
160 <h5
class="modal-title" id
="myModalLabel">Confirm deletion
</h5
>
161 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
162 <span aria
-hidden
="true">×
;</span
>
165 <div
class="modal-body">
166 Are you sure you want to
do this
?<br
>
167 This cannot be undone
.
169 <div
class="modal-footer">
170 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
171 <button type
="submit" action
="post" name
="delete_user" class="btn btn-danger">Delete
</button
>
176 </div
></form
></div
></div
><br
></div
>
178 <h2 style
="margin-left: 15px;">Settings
</h2
>
183 <div style
="margin-left: 15px;">
184 <div
class="form-check form-switch">
185 <input
class="form-check-input" type
="checkbox" role
="switch" id
="flexSwitchCheckDefault">
186 <label
class="form-check-label" for="flexSwitchCheckDefault">Default switch checkbox input
</label
>
188 <div
class="form-check form-switch">
189 <input
class="form-check-input" type
="checkbox" role
="switch" id
="flexSwitchCheckChecked" checked
>
190 <label
class="form-check-label" for="flexSwitchCheckChecked">Checked
switch checkbox input
</label
>
192 <div
class="form-check form-switch">
193 <input
class="form-check-input" type
="checkbox" role
="switch" id
="flexSwitchCheckDisabled" disabled
>
194 <label
class="form-check-label" for="flexSwitchCheckDisabled">Disabled
switch checkbox input
</label
>
196 <div
class="form-check form-switch">
197 <input
class="form-check-input" type
="checkbox" role
="switch" id
="flexSwitchCheckCheckedDisabled" checked disabled
>
198 <label
class="form-check-label" for="flexSwitchCheckCheckedDisabled">Disabled checked
switch checkbox input
</label
>
201 <?php
require_once '../../footer.php'; ?>