]>
Commit | Line | Data |
---|---|---|
e98b5a51 | 1 | <?php |
27efe895 | 2 | require_once "../common.php"; |
e77b1514 | 3 | require_once "../connection.php"; |
dd6ce63f | 4 | require_once "../header.php"; |
e98b5a51 | 5 | |
10102cdc VP |
6 | if (!empty($_GET)) |
7 | { | |
8 | if (isset($_GET['account']) && !isset($_POST['uf_account'])) | |
9 | $_POST['uf_account'] = $_GET['account']; | |
10 | ||
11 | if (isset($_GET['operonly']) && !isset($_POST['operonly'])) | |
12 | $_POST['operonly'] = $_GET['operonly']; | |
65a14aac VP |
13 | |
14 | if (isset($_GET['servicesonly']) && !isset($_POST['servicesonly'])) | |
15 | $_POST['servicesonly'] = $_GET['servicesonly']; | |
10102cdc | 16 | } |
6b218bea | 17 | |
65a14aac VP |
18 | if (!empty($_POST)) |
19 | { | |
e98b5a51 | 20 | do_log($_POST); |
c68cfb17 | 21 | $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL; |
65a14aac | 22 | |
d843c1de | 23 | if (isset($_POST['userch'])) { |
65a14aac VP |
24 | foreach ($_POST["userch"] as $user) |
25 | { | |
d843c1de | 26 | $user = $name = base64_decode($user); |
65a14aac VP |
27 | |
28 | if (!$bantype) /* shouldn't happen? */ | |
29 | { | |
e98b5a51 | 30 | Message::Fail("An error occured"); |
65a14aac VP |
31 | } |
32 | ||
33 | else | |
34 | { | |
d843c1de VP |
35 | $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; |
36 | $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; | |
37 | $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; | |
38 | ||
39 | $duration = ""; | |
40 | if (!$banlen_d && !$banlen_h && !$banlen_w) | |
41 | $duration .= "0"; | |
42 | else { | |
43 | if ($banlen_w) | |
44 | $duration .= $banlen_w; | |
45 | if ($banlen_d) | |
46 | $duration .= $banlen_d; | |
47 | if ($banlen_h) | |
48 | $duration .= $banlen_h; | |
49 | } | |
50 | $user = $rpc->user()->get($user); | |
65a14aac | 51 | |
0d846731 | 52 | if (!$user && $bantype !== "qline") { |
d843c1de | 53 | Message::Fail("Could not find that user: User not online"); |
65a14aac VP |
54 | } |
55 | ||
56 | else | |
57 | { | |
d843c1de VP |
58 | $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration); |
59 | $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason"; | |
65a14aac | 60 | |
0d846731 VP |
61 | if ($bantype == "qline") |
62 | $rpc->nameban()->add($name, $reason, $duration); | |
65a14aac | 63 | |
0b546dde VP |
64 | else if ($bantype == "kill") |
65 | { | |
66 | if ($rpc->user()->kill($user->id, $reason)) | |
67 | Message::Success($user->name . "(*@" . $user->hostname . ") has been killed: $reason"); | |
68 | else | |
69 | Message::Fail("Could not kill $user->name: $rpc->error"); | |
70 | } | |
0d846731 | 71 | else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason)) |
d843c1de | 72 | Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason"); |
65a14aac | 73 | |
d843c1de VP |
74 | else |
75 | Message::Fail("Could not add $bantype against $name: $rpc->error"); | |
76 | } | |
e98b5a51 | 77 | } |
e98b5a51 BM |
78 | } |
79 | } | |
80 | } | |
81 | ||
82 | /* Get the user list */ | |
83 | $users = $rpc->user()->getAll(); | |
84 | ?> | |
b111d43c | 85 | <h4>Users Overview</h4> |
d1d9caa9 | 86 | |
62d4ea03 | 87 | Click on a username to view more information. |
e98b5a51 | 88 | |
4fa72795 | 89 | <div class="usertable"> |
d1d9caa9 | 90 | |
e98b5a51 | 91 | <?php |
10102cdc | 92 | |
e98b5a51 BM |
93 | if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick'])) |
94 | Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\""); | |
95 | ||
96 | if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip'])) | |
97 | Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\""); | |
98 | ||
99 | if (isset($_POST['uf_host']) && strlen($_POST['uf_host'])) | |
100 | Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\""); | |
101 | ||
102 | if (isset($_POST['uf_account']) && strlen($_POST['uf_account'])) | |
103 | Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\""); | |
104 | ||
a5400f9a VP |
105 | if (isset($_POST['uf_server']) && strlen($_POST['uf_server'])) |
106 | Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\""); | |
107 | ||
10102cdc | 108 | |
e98b5a51 | 109 | ?> |
75c101fd | 110 | <table class="container-xxl table table-responsive caption-top table-striped"> |
71ef1a7f | 111 | <thead> |
d1d9caa9 | 112 | <form action="" method="post"> |
65a14aac VP |
113 | <tr> |
114 | <th scope="col"><h5>Filter:</h5></th> | |
a9618311 M |
115 | <th scope="col" colspan="2"><input <?php echo (isset($_POST['operonly'])) ? "checked" : ""; ?> name="operonly" type="checkbox" value=""> Opers Only</th> |
116 | <th scope="col" colspan="2"><input <?php echo (isset($_POST['servicesonly'])) ? "checked" : ""; ?> name="servicesonly" type="checkbox" value=""> Services Only</th> | |
65a14aac VP |
117 | </tr> |
118 | <tr> | |
1bad309d VP |
119 | <th scope="col" colspan="2">Nick: <input name="uf_nick" type="text" class="short-form-control"> |
120 | <th scope="col" colspan="2">Host: <input name="uf_host" type="text" class="short-form-control"></th> | |
121 | <th scope="col" colspan="2">IP: <input name="uf_ip" type="text" class="short-form-control"></th> | |
a9618311 | 122 | <th scope="col" colspan="2">Country: <input name="uf_country" type="text" class="short-form-control" placeholder="ca, fr or other"></th> |
1bad309d VP |
123 | <th scope="col" colspan="2">Account: <input name="uf_account" type="text" class="short-form-control"></th> |
124 | <th scope="col" colspan="2">Server: <input name="uf_server" type="text" class="short-form-control"></th> | |
65a14aac VP |
125 | |
126 | <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th> | |
127 | </tr> | |
128 | </form> | |
b111d43c BM |
129 | </thead></table> |
130 | ||
ce3de101 | 131 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> |
b111d43c BM |
132 | <thead class="table-primary"> |
133 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th> | |
d1d9caa9 | 134 | <th scope="col">Nick</th> |
a9618311 | 135 | <th scope="col">Country</th> |
d75f6d14 | 136 | <th class="hostname" scope="col">Host / IP</th> |
898237bd | 137 | <th scope="col"><span data-toggle="tooltip" data-placement="bottom" title="The services account name, if the user identified to services." style="border-bottom: 1px dotted #000000">Account</span></th> |
d1d9caa9 | 138 | <th scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th> |
d75f6d14 VP |
139 | <th class="opercol" scope="col">Oper</th> |
140 | <th class="securecol" scope="col"><span data-toggle="tooltip" data-placement="bottom" title="This shows [Secure] if the user is using SSL/TLS or is on localhost." style="border-bottom: 1px dotted #000000">Secure</span></th> | |
141 | <th class="uplinkcol" scope="col">Connected to</th> | |
898237bd | 142 | <th scope="col"><span data-toggle="tooltip" data-placement="bottom" title="The reputation score gets higher when someone with this IP address has been connected in the past weeks. A low reputation score (like <10) is an indication of a new IP." style="border-bottom: 1px dotted #000000">Reputation</span> <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th> |
2bc4c695 | 143 | </thead> |
e98b5a51 | 144 | |
2bc4c695 | 145 | <tbody> |
27efe895 | 146 | <form method="post"> |
e98b5a51 | 147 | <?php |
a9618311 | 148 | $currentNumberUsers=0; |
d91b75a2 M |
149 | $currentNumberUsersIdentified=0; |
150 | $registrationOfaAllFlags = array(); | |
e98b5a51 BM |
151 | foreach($users as $user) |
152 | { | |
153 | ||
62d4ea03 | 154 | |
e98b5a51 BM |
155 | /* Some basic filtering for NICK */ |
156 | if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) && | |
157 | strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 && | |
158 | strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false) | |
159 | continue; | |
160 | ||
a9618311 M |
161 | /* Some basic filtering for COUNTRY */ |
162 | if (isset($_POST['uf_country']) && strlen($_POST['uf_country']) && | |
163 | @strtolower($user->geoip->country_code) !== strtolower($_POST['uf_country'])) | |
164 | continue; | |
165 | ||
e98b5a51 BM |
166 | /* Some basic filtering for HOST */ |
167 | if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) && | |
168 | strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 && | |
169 | strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false) | |
170 | continue; | |
171 | ||
172 | /* Some basic filtering for IP */ | |
173 | if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) && | |
174 | strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 && | |
175 | strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false) | |
176 | continue; | |
177 | ||
178 | /* Some basic filtering for ACCOUNT */ | |
179 | if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) && | |
0b546dde | 180 | strtolower($user->user->account) !== strtolower($_POST['uf_account'])) |
e98b5a51 BM |
181 | continue; |
182 | ||
0b546dde | 183 | /* Some basic filtering for SERVER */ |
a5400f9a VP |
184 | if (isset($_POST['uf_server']) && strlen($_POST['uf_server']) && |
185 | strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) !== 0 && | |
186 | strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) == false) | |
187 | continue; | |
188 | ||
10102cdc VP |
189 | /* Some basic filtering for OPER */ |
190 | if (isset($_POST['operonly']) && | |
94fd26b9 | 191 | (strpos($user->user->modes, "o") == false || strpos($user->user->modes,"S") !== false)) |
10102cdc VP |
192 | continue; |
193 | ||
65a14aac VP |
194 | /* Some basic filtering for SERVICES */ |
195 | if (isset($_POST['servicesonly']) && | |
196 | (strpos($user->user->modes,"S") == false)) | |
197 | continue; | |
198 | ||
4fa72795 | 199 | echo "\n<tr id=\"$user->id\" value=\"$user->name\" class=\"userselector\">"; |
d1d9caa9 | 200 | echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>"; |
9307bb12 | 201 | $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : ""; |
27efe895 | 202 | echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>"; |
a9618311 | 203 | echo "<td>".(isset($user->geoip->country_code) ? '<img src="https://flagcdn.com/48x36/'.htmlspecialchars(strtolower($user->geoip->country_code)).'.png" width="20" height="15"> '.$user->geoip->country_code : "")."</td>"; |
d75f6d14 | 204 | echo "<td class=\"hostname\">".htmlspecialchars($user->hostname)." (".($user->hostname == $user->ip ? 'the same' : htmlspecialchars($user->ip ?? "None")).")</td>"; |
ea90b321 | 205 | $account = (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>'; |
e98b5a51 BM |
206 | echo "<td>".$account."</td>"; |
207 | $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>"; | |
208 | echo "<td>".$modes."</td>"; | |
9307bb12 | 209 | $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : ""; |
e98b5a51 | 210 | if (!strlen($oper)) |
9307bb12 | 211 | $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : ""; |
d75f6d14 | 212 | echo "<td class=\"opercol\">".$oper."</td>"; |
58478df1 | 213 | |
65a14aac | 214 | $secure = (isset($user->tls) || $user->hostname !== "localhost") ? "<span class=\"badge rounded-pill badge-success\">Secure</span>" : "<span class=\"badge rounded-pill badge-danger\">Insecure</span>"; |
58478df1 VP |
215 | if (strpos($user->user->modes, "S") !== false) |
216 | $secure = ""; | |
d75f6d14 | 217 | echo "<td class=\"securecol\">".$secure."</td>"; |
ea90b321 | 218 | echo "<td class=\"uplinkcol\"><a href=\"".get_config("base_url")."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>"; |
e98b5a51 | 219 | echo "<td>".$user->user->reputation."</td>"; |
f41baac8 | 220 | echo "</tr>"; |
a9618311 | 221 | $currentNumberUsers++; |
d91b75a2 M |
222 | if (isset($user->user->account)) |
223 | $currentNumberUsersIdentified++; | |
224 | if (isset($user->geoip->country_code)) | |
225 | array_push($registrationOfaAllFlags, $user->geoip->country_code); | |
e98b5a51 | 226 | } |
d91b75a2 | 227 | $registrationOfaAllFlags = array_count_values($registrationOfaAllFlags); |
2bc4c695 | 228 | ?> |
d1d9caa9 | 229 | </tbody></table> |
d91b75a2 | 230 | <div id="currentNumberUsers"><?=$currentNumberUsers?> connected users including <?=$currentNumberUsersIdentified?> identified and <?=($currentNumberUsers-$currentNumberUsersIdentified)?> not identified.</div> |
d1d9caa9 VP |
231 | <table class="table table-responsive table-light"> |
232 | <tr> | |
233 | <td colspan="2"> | |
234 | <label for="bantype">Apply action: </label> | |
e98b5a51 BM |
235 | <select name="bantype" id="bantype"> |
236 | <option value=""></option> | |
237 | <optgroup label="Bans"> | |
238 | <option value="gline">GLine</option> | |
239 | <option value="gzline">GZLine</option> | |
0b546dde | 240 | <option value="kill">Kill</option> |
e98b5a51 | 241 | </optgroup> |
d1d9caa9 VP |
242 | </select></td><td colspan="2"> |
243 | <label for="banlen_w">Duration: </label> | |
e98b5a51 BM |
244 | <select name="banlen_w" id="banlen_w"> |
245 | <?php | |
246 | for ($i = 0; $i <= 56; $i++) | |
247 | { | |
248 | if (!$i) | |
249 | echo "<option value=\"0w\"></option>"; | |
250 | else | |
251 | { | |
252 | $w = ($i == 1) ? "week" : "weeks"; | |
253 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
254 | } | |
255 | } | |
256 | ?> | |
257 | </select> | |
258 | <select name="banlen_d" id="banlen_d"> | |
259 | <?php | |
260 | for ($i = 0; $i <= 31; $i++) | |
261 | { | |
262 | if (!$i) | |
263 | echo "<option value=\"0d\"></option>"; | |
264 | else | |
265 | { | |
266 | $d = ($i == 1) ? "day" : "days"; | |
267 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
268 | } | |
269 | } | |
270 | ?> | |
271 | </select> | |
272 | <select name="banlen_h" id="banlen_h"> | |
273 | <?php | |
274 | for ($i = 0; $i <= 24; $i++) | |
275 | { | |
276 | if (!$i) | |
277 | echo "<option value=\"0d\"></option>"; | |
278 | else | |
279 | { | |
280 | $h = ($i == 1) ? "hour" : "hours"; | |
281 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
282 | } | |
283 | } | |
d1d9caa9 | 284 | |
e98b5a51 | 285 | ?> |
0b546dde VP |
286 | </select> |
287 | ||
288 | <br></td><tr><td colspan="3"> | |
d1d9caa9 VP |
289 | |
290 | <label for="ban_reason">Reason: </label> | |
0b546dde | 291 | <input class="form-control" type="text" name="ban_reason" id="ban_reason" value="No reason"> |
d1d9caa9 | 292 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> |
0b546dde | 293 | Apply |
d1d9caa9 VP |
294 | </button></td></table> |
295 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
296 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
297 | <div class="modal-content"> | |
298 | <div class="modal-header"> | |
299 | <h5 class="modal-title" id="myModalLabel">Apply ban</h5> | |
300 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
301 | <span aria-hidden="true">×</span> | |
302 | </button> | |
303 | </div> | |
304 | <div class="modal-body"> | |
305 | Are you sure you want to do this? | |
306 | ||
307 | </div> | |
308 | <div class="modal-footer"> | |
309 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
0b546dde | 310 | <button type="submit" action="post" class="btn btn-danger">Apply</button> |
d1d9caa9 VP |
311 | |
312 | </div> | |
313 | </div> | |
314 | </div> | |
315 | </div> | |
316 | ||
e98b5a51 | 317 | </form> |
d91b75a2 | 318 | |
4fa72795 VP |
319 | <style> |
320 | #rclickmenu { | |
321 | position: fixed; | |
322 | z-index: 10000; | |
323 | width: 250px; | |
324 | background: #1b1a1a; | |
325 | border-radius: 5px; | |
27958eb3 | 326 | display: none; |
4fa72795 VP |
327 | } |
328 | #rclickmenu.visible { | |
329 | display: block; | |
330 | } | |
331 | #rclickmenu .item { | |
332 | padding: 8px 10px; | |
333 | font-size: 15px; | |
334 | color: #eee; | |
335 | cursor: pointer; | |
336 | border-radius: inherit; | |
337 | } | |
338 | #rclickmenu .item:hover { | |
339 | background: #343434; | |
340 | text-decoration: none; | |
341 | } | |
342 | </style> | |
343 | ||
344 | <div id='rclickmenu'> | |
345 | <div id="rclick_opt1" class="item list-group-item-action">View details</div> | |
346 | <div id="rclick_opt2" class="item list-group-item-action">Kill</div> | |
347 | </div> | |
348 | ||
0674e7b5 | 349 | <?php /* ?> |
d91b75a2 M |
350 | <h3>Top country</h3> |
351 | <div id="top-country"> | |
352 | <ul> | |
353 | <?php | |
354 | arsort($registrationOfaAllFlags); | |
355 | foreach($registrationOfaAllFlags as $country_code => $count){ | |
356 | echo '<li> | |
357 | <div class="drag"><img src="https://flagcdn.com/108x81/'.htmlspecialchars(strtolower($country_code)).'.png" width="108" height="81"><br /> | |
358 | '.$country_code . ' | |
359 | </div> | |
360 | <div class="count">' . $count . ' <span>connected</span></div> | |
361 | </li>'; | |
362 | } | |
363 | ?> | |
364 | </ul> | |
365 | </div> | |
0674e7b5 | 366 | <?php */ ?> |
d91b75a2 M |
367 | |
368 | </div> | |
d1d9caa9 VP |
369 | |
370 | <script> | |
371 | ||
372 | $("#myModal").on('shown.bs.modal', function(){ | |
373 | $("#CloseButton").focus(); | |
374 | }); | |
d75f6d14 VP |
375 | |
376 | function resize_check() | |
377 | { | |
378 | var width = window.innerWidth; | |
379 | var elements = document.querySelectorAll('.hostname, .opercol, .uplinkcol, .securecol'); | |
380 | var show = ''; | |
2555518d | 381 | if (width < 900) |
d75f6d14 VP |
382 | show = 'none'; |
383 | ||
384 | for (let i = 0; i < elements.length; i++) | |
385 | elements[i].style.display = show; | |
386 | ||
387 | } | |
388 | resize_check(); | |
389 | window.addEventListener('resize', function() { | |
390 | resize_check(); | |
391 | }); | |
4fa72795 VP |
392 | var rclickmenu = document.getElementById('rclickmenu'); |
393 | var scopes = document.querySelectorAll('.userselector'); | |
394 | var usertable = document.querySelector('body'); | |
395 | usertable.addEventListener("click", (e) => | |
396 | { | |
397 | rclickmenu.classList.remove("visible"); | |
398 | rclickmenu.style.display = 'none'; | |
399 | }); | |
400 | scopes.forEach((scope) => { | |
401 | scope.addEventListener("contextmenu", (event) => | |
402 | { | |
403 | event.preventDefault(); | |
404 | var { clientX: mouseX, clientY: mouseY } = event; | |
405 | var name = $('#' + scope.id).attr('value') | |
406 | document.getElementById("rclick_opt1").innerHTML = '<a style="text-decoration: none" href="<?php echo get_config("base_url"); ?>users/details.php?nick=' + scope.id + '">View details for ' + name + '</a>'; | |
407 | rclickmenu.style.top = `${mouseY}px`; | |
408 | rclickmenu.style.left = `${mouseX}px`; | |
409 | rclickmenu.classList.add("visible"); | |
410 | rclickmenu.style.display = ''; | |
411 | }); | |
412 | ||
413 | }); | |
d1d9caa9 | 414 | </script> |
e98b5a51 | 415 | |
27efe895 | 416 | <?php require_once UPATH.'/footer.php'; ?> |