]>
Commit | Line | Data |
---|---|---|
ea27475b VP |
1 | <?php |
2 | $conn = NULL; | |
3 | ||
4 | require_once "../../common.php"; | |
5 | require_once "../../header.php"; | |
4225314c | 6 | require_once "SQL/sql.php"; |
4d634d0a | 7 | require_once "SQL/user.php"; |
ea27475b VP |
8 | do_log($_POST); |
9 | ||
ea27475b | 10 | |
4225314c | 11 | |
4225314c | 12 | |
ea27475b | 13 | ?> |
4225314c | 14 | <h4>Panel Access Overview</h4> |
d5316e28 | 15 | <?php |
d72d1923 VP |
16 | if (isset($_POST)) |
17 | { | |
7aad7c29 | 18 | // TODO: Validation and stuff |
d72d1923 VP |
19 | $p = $_POST; |
20 | if (isset($p['delete_user']) && current_user_can(SQLPERM_MANAGE_USERS)) | |
7aad7c29 VP |
21 | { |
22 | $info = []; | |
23 | foreach ($p['userch'] as $id) | |
24 | { | |
25 | $user = new SQLA_User(NULL, $id); | |
f5e3ecee | 26 | $us = unreal_get_current_user(); |
7aad7c29 | 27 | $deleted = delete_user($id, $info); |
f5e3ecee VP |
28 | if ($us->id == $user->id) // if it's the current user |
29 | { | |
30 | session_destroy(); | |
31 | header("Location: " . BASE_URL . "plugins/sql_auth/login.php"); | |
32 | die(); | |
33 | } | |
7aad7c29 VP |
34 | $msg = ($deleted = 1) ? "Message::Success" : "Message::Fail"; |
35 | } | |
36 | $msg($info); | |
37 | unset($info); | |
38 | } | |
39 | ||
d72d1923 VP |
40 | if (isset($p['do_add_user']) && current_user_can(SQLPERM_MANAGE_USERS)) |
41 | { | |
7aad7c29 VP |
42 | $user = []; |
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) | |
50 | { | |
51 | Message::Success("Successfully created user \"" . $user['user_name'] . "\""); | |
52 | } | |
53 | else | |
54 | { | |
55 | Message::Fail("Failed to create user \"" . $user['user_name'] . "\""); | |
56 | } | |
57 | } | |
d72d1923 | 58 | } |
7aad7c29 VP |
59 | $conn = sqlnew(); |
60 | $result = $conn->query("SELECT user_id FROM " . SQL_PREFIX . "users"); | |
61 | $userlist = []; | |
62 | while($row = $result->fetch()) | |
63 | { | |
64 | $userlist[] = new SQLA_User(NULL, $row['user_id']); | |
65 | } | |
66 | ||
67 | if (!$result) // impossible | |
68 | { | |
69 | die("Something went wrong."); | |
70 | } | |
71 | ||
d5316e28 | 72 | ?> |
4225314c VP |
73 | Click on a username to view more information. |
74 | <br><br> | |
75 | <div id="Users"> | |
d72d1923 VP |
76 | <div class="row"> |
77 | <?php if (current_user_can(SQLPERM_MANAGE_USERS)) { ?> | |
78 | <div class="col-sm-3"> | |
79 | <form method="post"> | |
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> | |
83 | </div> | |
84 | <?php } ?> | |
85 | </div> | |
86 | <br> | |
d5316e28 | 87 | </table> |
d72d1923 | 88 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> |
4225314c VP |
89 | <div class="modal-dialog modal-dialog-centered" role="document"> |
90 | <div class="modal-content"> | |
d72d1923 | 91 | <div class="modal-header"> |
4225314c VP |
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"> | |
d72d1923 | 94 | <span aria-hidden="true">×</span></button> |
4225314c VP |
95 | </div> |
96 | <div class="modal-body"> | |
d72d1923 VP |
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> | |
100 | </div> | |
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> | |
104 | </div> | |
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> | |
111 | </div> | |
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> | |
115 | </div> | |
116 | </div> | |
4225314c VP |
117 | |
118 | <div class="modal-footer"> | |
119 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
d5316e28 | 120 | <button type="submit" name="do_add_user" class="btn btn-danger">Add User</button> |
4225314c VP |
121 | |
122 | </div> | |
123 | </div> | |
124 | </div> | |
125 | </div> | |
d72d1923 VP |
126 | </div> |
127 | ||
4225314c VP |
128 | </form> |
129 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
130 | <thead class="table-primary"> | |
131 | <form method="post"> | |
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> | |
d72d1923 VP |
136 | <th scope="col">Created</th> |
137 | <th scope="col">Bio</th> | |
138 | ||
4225314c VP |
139 | </thead> |
140 | <tbody> | |
141 | <?php | |
142 | foreach($userlist as $user) | |
143 | { | |
144 | ||
d5316e28 | 145 | echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id . "' name=\"userch[]\"></td>"; |
4225314c VP |
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>"; | |
d5316e28 VP |
149 | echo "<td scope=\"col\">".$user->created."</td>"; |
150 | echo "<td scope=\"col\">".$user->bio."</td>"; | |
4225314c VP |
151 | echo "</tr>"; |
152 | } | |
153 | ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2"> | |
154 | Delete selected | |
155 | </button></p> | |
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> | |
163 | </button> | |
164 | </div> | |
165 | <div class="modal-body"> | |
166 | Are you sure you want to do this?<br> | |
167 | This cannot be undone. | |
168 | </div> | |
169 | <div class="modal-footer"> | |
170 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
d5316e28 | 171 | <button type="submit" action="post" name="delete_user" class="btn btn-danger">Delete</button> |
4225314c VP |
172 | |
173 | </div> | |
174 | </div> | |
175 | </div> | |
d72d1923 VP |
176 | </div></form></div></div><br></div> |
177 | ||
178 | <h2 style="margin-left: 15px;">Settings</h2> | |
179 | ||
180 | <?php | |
4225314c | 181 | |
d72d1923 VP |
182 | ?> |
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> | |
187 | </div> | |
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> | |
191 | </div> | |
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> | |
195 | </div> | |
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> | |
199 | </div> | |
200 | </div> | |
7aad7c29 | 201 | <?php require_once '../../footer.php'; ?> |