]>
Commit | Line | Data |
---|---|---|
180b8ec1 VP |
1 | <?php |
2 | $conn = NULL; | |
3 | ||
4 | require_once "../common.php"; | |
5 | require_once "../header.php"; | |
6 | do_log($_POST); | |
7 | ||
8 | ||
9 | ||
10 | ||
11 | ?> | |
12 | <h4>Panel Settings Overview</h4> | |
13 | ||
14 | <?php | |
15 | ||
16 | if (isset($_POST)) | |
17 | { | |
18 | $p = $_POST; | |
19 | if (isset($p['delete_user']) && current_user_can(PERMISSION_MANAGE_USERS)) | |
20 | { | |
21 | $info = []; | |
22 | foreach ($p['userch'] as $id) | |
23 | { | |
24 | $user = new PanelUser(NULL, $id); | |
25 | $us = unreal_get_current_user(); | |
26 | $deleted = delete_user($id, $info); | |
27 | if ($us->id == $user->id) // if it's the current user | |
28 | { | |
29 | session_destroy(); | |
ea90b321 | 30 | header("Location: " . get_config("base_url") . "plugins/sql_auth/login.php"); |
180b8ec1 VP |
31 | die(); |
32 | } | |
33 | $msg = ($deleted = 1) ? "Message::Success" : "Message::Fail"; | |
34 | } | |
35 | $msg($info); | |
36 | unset($info); | |
37 | } | |
38 | ||
39 | if (isset($p['do_add_user']) && current_user_can(PERMISSION_MANAGE_USERS)) | |
40 | { | |
41 | $user = []; | |
42 | $user['user_name'] = $p['user_add']; | |
43 | $user['user_pass'] = $p['password']; | |
44 | $user['fname'] = $p['add_first_name']; | |
45 | $user['lname'] = $p['add_last_name']; | |
9a674833 | 46 | $user['user_email'] = $p['user_email']; |
180b8ec1 VP |
47 | $user['user_bio'] = $p['user_bio']; |
48 | $user['err'] = ""; | |
49 | if (!create_new_user($user)) | |
50 | { | |
51 | Message::Fail("Failed to create user: " . $user['user_name'] . " " . $user['err']); | |
52 | } | |
53 | else if (($usr_obj = new PanelUser($user['user_name'])) && isset($usr_obj->id)) | |
54 | { | |
55 | Message::Success("Successfully created user \"" . $user['user_name'] . "\""); | |
56 | } | |
57 | else | |
58 | { | |
59 | Message::Fail("Failed to create user \"" . $user['user_name'] . "\""); | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | $userlist = []; | |
65 | Hook::run(HOOKTYPE_GET_USER_LIST, $userlist); | |
66 | ||
67 | ?> | |
68 | <br> | |
69 | <h5>Panel Access</h5> | |
70 | Click on a username to view more information. | |
71 | <br><br> | |
72 | <div id="Users"> | |
73 | <div class="row"> | |
74 | <?php if (current_user_can(PERMISSION_MANAGE_USERS)) { ?> | |
75 | <div class="col-sm-3"> | |
76 | <form method="post"> | |
77 | <div class="btn btn-primary" data-toggle="modal" data-target="#myModal">Add New User</div> | |
78 | <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">Delete selected</button> | |
79 | </div> | |
80 | <?php } ?> | |
81 | </div> | |
82 | <br> | |
83 | </table> | |
84 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
85 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
86 | <div class="modal-content"> | |
87 | <div class="modal-header"> | |
88 | <h5 class="modal-title" id="myModalLabel">Add new Admin Panel user</h5> | |
89 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
90 | <span aria-hidden="true">×</span></button> | |
91 | </div> | |
92 | <div class="modal-body"> | |
93 | <div class="input-group mb-3"> | |
94 | <label for="name_add" name="user_add" id="user_add">Username | |
95 | <input style="width: 170%;" name="user_add" id="user_add" class="form-control curvy" type="text"></label> | |
96 | </div> | |
97 | <div class="input-group mb-3"> | |
98 | <label for="password" id="user_add">Password | |
99 | <input style="width: 170%;" name="password" id="password" class="form-control curvy" type="password"></label> | |
100 | </div> | |
9a674833 VP |
101 | <div class="input-group mb-3"> |
102 | <label for="user_email" id="user_add">Email | |
103 | <input style="width: 170%;" name="user_email" id="user_email" class="form-control curvy" type="text"></label> | |
104 | </div> | |
180b8ec1 VP |
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> | |
9a674833 VP |
108 | </div> |
109 | <div class="input-group mb-3"> | |
180b8ec1 VP |
110 | <label for="password" id="user_add">Last Name |
111 | <input style="width: 170%;" name="add_last_name" id="add_last_name" class="form-control curvy" type="text"></label> | |
112 | </div> | |
113 | <div class="input-group mb-3"> | |
114 | <label for="password" id="user_add">Info /Bio | |
115 | <textarea style="width: 170%;" name="user_bio" class="form-control curvy" aria-label="With textarea"></textarea></label> | |
116 | </div> | |
117 | </div> | |
118 | ||
119 | <div class="modal-footer"> | |
120 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
121 | <button type="submit" name="do_add_user" class="btn btn-danger">Add User</button> | |
122 | ||
123 | </div> | |
124 | </div> | |
125 | </div> | |
126 | </div> | |
127 | </div> | |
128 | ||
129 | </form> | |
130 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
131 | <thead class="table-primary"> | |
132 | <form method="post"> | |
133 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th> | |
134 | <th scope="col">Username</th> | |
135 | <th scope="col">First Name</th> | |
136 | <th scope="col">Last Name</th> | |
9a674833 | 137 | <th scope="col">Email</th> |
180b8ec1 VP |
138 | <th scope="col">Created</th> |
139 | <th scope="col">Bio</th> | |
140 | <th scope="col">Last login</th> | |
141 | ||
142 | </thead> | |
143 | <tbody> | |
144 | <?php | |
145 | foreach($userlist as $user) | |
146 | { | |
147 | ||
148 | echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id . "' name=\"userch[]\"></td>"; | |
ea90b321 | 149 | echo "<td scope=\"col\"><a href=\"".get_config("base_url")."settings/user-edit.php?id=$user->id\">$user->username</a></td>"; |
180b8ec1 VP |
150 | echo "<td scope=\"col\">".$user->first_name."</td>"; |
151 | echo "<td scope=\"col\">".$user->last_name."</td>"; | |
9a674833 | 152 | echo "<td scope=\"col\"><a href=\"mailto:$user->email\">$user->email</a></td>"; |
2d62c85d | 153 | echo "<td scope=\"col\"><code>".$user->created."</code></td>"; |
180b8ec1 | 154 | echo "<td scope=\"col\">".$user->bio."</td>"; |
2d62c85d VP |
155 | $last = (isset($user->user_meta['last_login'])) ? "<code>".$user->user_meta['last_login'] . "</code> <span class=\"badge rounded-pill badge-dark\">".how_long_ago($user->user_meta['last_login'])."</span>" : "none"; |
156 | echo "<td scope=\"col\">$last</td>"; | |
e9996356 | 157 | echo "</tr>\n"; |
180b8ec1 | 158 | } |
e9996356 VP |
159 | ?></tbody></table> |
160 | <?php if (current_user_can(PERMISSION_MANAGE_USERS)) { ?> | |
161 | <p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2"> | |
180b8ec1 VP |
162 | Delete selected |
163 | </button></p> | |
e9996356 | 164 | <?php } ?> |
180b8ec1 VP |
165 | <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> |
166 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
167 | <div class="modal-content"> | |
168 | <div class="modal-header"> | |
169 | <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5> | |
170 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
171 | <span aria-hidden="true">×</span> | |
172 | </button> | |
173 | </div> | |
174 | <div class="modal-body"> | |
175 | Are you sure you want to do this?<br> | |
176 | This cannot be undone. | |
177 | </div> | |
178 | <div class="modal-footer"> | |
179 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
180 | <button type="submit" action="post" name="delete_user" class="btn btn-danger">Delete</button> | |
181 | ||
182 | </div> | |
183 | </div> | |
184 | </div> | |
185 | </div></form></div></div><br></div> | |
186 | <?php | |
187 | require_once '../footer.php'; ?> |