]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | require_once "../inc/common.php"; | |
3 | require_once "../inc/connection.php"; | |
4 | require_once "../inc/header.php"; | |
5 | ||
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']; | |
13 | ||
14 | if (isset($_GET['servicesonly']) && !isset($_POST['servicesonly'])) | |
15 | $_POST['servicesonly'] = $_GET['servicesonly']; | |
16 | } | |
17 | ||
18 | if (!empty($_POST)) | |
19 | { | |
20 | do_log($_POST); | |
21 | $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL; | |
22 | ||
23 | if (isset($_POST['userch'])) { | |
24 | foreach ($_POST["userch"] as $user) | |
25 | { | |
26 | $user = $name = base64_decode($user); | |
27 | ||
28 | if (!$bantype) /* shouldn't happen? */ | |
29 | { | |
30 | Message::Fail("An error occured"); | |
31 | } | |
32 | ||
33 | else | |
34 | { | |
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); | |
51 | ||
52 | if (!$user && $bantype !== "qline") { | |
53 | Message::Fail("Could not find that user: User not online"); | |
54 | } | |
55 | ||
56 | else | |
57 | { | |
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"; | |
60 | ||
61 | if ($bantype == "qline") | |
62 | $rpc->nameban()->add($name, $reason, $duration); | |
63 | ||
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 | } | |
71 | else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason)) | |
72 | Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason"); | |
73 | ||
74 | else | |
75 | Message::Fail("Could not add $bantype against $name: $rpc->error"); | |
76 | } | |
77 | } | |
78 | } | |
79 | } | |
80 | } | |
81 | ||
82 | /* Get the user list */ | |
83 | $users = $rpc->user()->getAll(); | |
84 | ?> | |
85 | <h4>Users Overview</h4> | |
86 | ||
87 | Click on a username to view more information. | |
88 | ||
89 | <div class="usertable"> | |
90 | ||
91 | <?php | |
92 | ||
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 | ||
105 | if (isset($_POST['uf_server']) && strlen($_POST['uf_server'])) | |
106 | Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\""); | |
107 | ||
108 | ||
109 | ?> | |
110 | <table class="container-xxl table table-responsive caption-top table-striped"> | |
111 | <thead> | |
112 | <form action="" method="post"> | |
113 | <tr> | |
114 | <th scope="col"><h5>Filter:</h5></th> | |
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> | |
117 | </tr> | |
118 | <tr> | |
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> | |
122 | <th scope="col" colspan="2">Country: <input name="uf_country" type="text" class="short-form-control" placeholder="ca, fr or other"></th> | |
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> | |
125 | ||
126 | <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th> | |
127 | </tr> | |
128 | </form> | |
129 | </thead></table> | |
130 | ||
131 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
132 | <thead class="table-primary"> | |
133 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th> | |
134 | <th scope="col">Nick</th> | |
135 | <th class="countrycol" scope="col">Country</th> | |
136 | <th class="hostname" scope="col">Host / IP</th> | |
137 | <th class="accountcol" 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> | |
138 | <th class="umodescol" scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th> | |
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> | |
142 | <th class="reputationcol" scope="col"><span id="reputationheader" 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">Rep.</span> <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th> | |
143 | </thead> | |
144 | ||
145 | <tbody> | |
146 | <form method="post"> | |
147 | <?php | |
148 | $currentNumberUsers=0; | |
149 | $currentNumberUsersIdentified=0; | |
150 | $registrationOfaAllFlags = array(); | |
151 | foreach($users as $user) | |
152 | { | |
153 | ||
154 | ||
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 | ||
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 | ||
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']) && | |
180 | strtolower($user->user->account) !== strtolower($_POST['uf_account'])) | |
181 | continue; | |
182 | ||
183 | /* Some basic filtering for SERVER */ | |
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 | ||
189 | /* Some basic filtering for OPER */ | |
190 | if (isset($_POST['operonly']) && | |
191 | (strpos($user->user->modes, "o") == false || strpos($user->user->modes,"S") !== false)) | |
192 | continue; | |
193 | ||
194 | /* Some basic filtering for SERVICES */ | |
195 | if (isset($_POST['servicesonly']) && | |
196 | (strpos($user->user->modes,"S") == false)) | |
197 | continue; | |
198 | ||
199 | echo "\n<tr id=\"$user->id\" value=\"$user->name\" class=\"userselector\">"; | |
200 | echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>"; | |
201 | $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : ""; | |
202 | echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>"; | |
203 | echo "<td class=\"countrycol\">".(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>"; | |
204 | if ($user->hostname == $user->ip) | |
205 | $hostip = $user->ip; | |
206 | else if ($user->ip == null) | |
207 | $hostip = $user->hostname; | |
208 | else | |
209 | $hostip = $user->hostname . " (".$user->ip.")"; | |
210 | echo "<td class=\"hostname\">".htmlspecialchars($hostip)."</td>"; | |
211 | $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>'; | |
212 | echo "<td class=\"accountcol\">".$account."</td>"; | |
213 | $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>"; | |
214 | echo "<td class=\"umodescol\">".$modes."</td>"; | |
215 | $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : ""; | |
216 | if (!strlen($oper)) | |
217 | $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : ""; | |
218 | echo "<td class=\"opercol\">".$oper."</td>"; | |
219 | ||
220 | $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>"; | |
221 | if (strpos($user->user->modes, "S") !== false) | |
222 | $secure = ""; | |
223 | echo "<td class=\"securecol\">".$secure."</td>"; | |
224 | echo "<td class=\"uplinkcol\"><a href=\"".get_config("base_url")."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>"; | |
225 | echo "<td class=\"reputationcol\">".$user->user->reputation."</td>"; | |
226 | echo "</tr>"; | |
227 | $currentNumberUsers++; | |
228 | if (isset($user->user->account)) | |
229 | $currentNumberUsersIdentified++; | |
230 | if (isset($user->geoip->country_code)) | |
231 | array_push($registrationOfaAllFlags, $user->geoip->country_code); | |
232 | } | |
233 | $registrationOfaAllFlags = array_count_values($registrationOfaAllFlags); | |
234 | ?> | |
235 | </tbody></table> | |
236 | <div id="currentNumberUsers"><?=$currentNumberUsers?> connected users including <?=$currentNumberUsersIdentified?> identified and <?=($currentNumberUsers-$currentNumberUsersIdentified)?> not identified.</div> | |
237 | <table class="table table-responsive table-light"> | |
238 | <tr> | |
239 | <td colspan="2"> | |
240 | <label for="bantype">Apply action: </label> | |
241 | <select name="bantype" id="bantype"> | |
242 | <option value=""></option> | |
243 | <optgroup label="Bans"> | |
244 | <option value="gline">GLine</option> | |
245 | <option value="gzline">GZLine</option> | |
246 | <option value="kill">Kill</option> | |
247 | </optgroup> | |
248 | </select></td><td colspan="2"> | |
249 | <label for="banlen_w">Duration: </label> | |
250 | <select name="banlen_w" id="banlen_w"> | |
251 | <?php | |
252 | for ($i = 0; $i <= 56; $i++) | |
253 | { | |
254 | if (!$i) | |
255 | echo "<option value=\"0w\"></option>"; | |
256 | else | |
257 | { | |
258 | $w = ($i == 1) ? "week" : "weeks"; | |
259 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
260 | } | |
261 | } | |
262 | ?> | |
263 | </select> | |
264 | <select name="banlen_d" id="banlen_d"> | |
265 | <?php | |
266 | for ($i = 0; $i <= 31; $i++) | |
267 | { | |
268 | if (!$i) | |
269 | echo "<option value=\"0d\"></option>"; | |
270 | else | |
271 | { | |
272 | $d = ($i == 1) ? "day" : "days"; | |
273 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
274 | } | |
275 | } | |
276 | ?> | |
277 | </select> | |
278 | <select name="banlen_h" id="banlen_h"> | |
279 | <?php | |
280 | for ($i = 0; $i <= 24; $i++) | |
281 | { | |
282 | if (!$i) | |
283 | echo "<option value=\"0d\"></option>"; | |
284 | else | |
285 | { | |
286 | $h = ($i == 1) ? "hour" : "hours"; | |
287 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
288 | } | |
289 | } | |
290 | ||
291 | ?> | |
292 | </select> | |
293 | ||
294 | <br></td><tr><td colspan="3"> | |
295 | ||
296 | <label for="ban_reason">Reason: </label> | |
297 | <input class="form-control" type="text" name="ban_reason" id="ban_reason" value="No reason"> | |
298 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> | |
299 | Apply | |
300 | </button></td></table> | |
301 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
302 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
303 | <div class="modal-content"> | |
304 | <div class="modal-header"> | |
305 | <h5 class="modal-title" id="myModalLabel">Apply ban</h5> | |
306 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
307 | <span aria-hidden="true">×</span> | |
308 | </button> | |
309 | </div> | |
310 | <div class="modal-body"> | |
311 | Are you sure you want to do this? | |
312 | ||
313 | </div> | |
314 | <div class="modal-footer"> | |
315 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
316 | <button type="submit" action="post" class="btn btn-danger">Apply</button> | |
317 | ||
318 | </div> | |
319 | </div> | |
320 | </div> | |
321 | </div> | |
322 | ||
323 | </form> | |
324 | ||
325 | <style> | |
326 | #rclickmenu { | |
327 | position: fixed; | |
328 | z-index: 10000; | |
329 | width: 250px; | |
330 | background: #1b1a1a; | |
331 | border-radius: 5px; | |
332 | transform: scale(0); | |
333 | transform-origin: top left; | |
334 | } | |
335 | #rclickmenu.visible { | |
336 | transform: scale(1); | |
337 | transition: transform 120ms ease-in-out; | |
338 | } | |
339 | #rclickmenu .item { | |
340 | padding: 8px 10px; | |
341 | font-size: 15px; | |
342 | color: #eee; | |
343 | cursor: pointer; | |
344 | border-radius: inherit; | |
345 | } | |
346 | #rclickmenu .item:hover { | |
347 | background: #343434; | |
348 | text-decoration: none; | |
349 | } | |
350 | </style> | |
351 | ||
352 | <div id='rclickmenu' class="nav-item list-group"> | |
353 | <div id="rclick_opt1" class="item list-group-item-action">View details</div> | |
354 | <div id="rclick_opt2" class="item list-group-item-action">Kill</div> | |
355 | <div id="rclick_opt3" class="item list-group-item-action">Copy | |
356 | </div> | |
357 | ||
358 | <?php /* ?> | |
359 | <h3>Top country</h3> | |
360 | <div id="top-country"> | |
361 | <ul> | |
362 | <?php | |
363 | arsort($registrationOfaAllFlags); | |
364 | foreach($registrationOfaAllFlags as $country_code => $count){ | |
365 | echo '<li> | |
366 | <div class="drag"><img src="https://flagcdn.com/108x81/'.htmlspecialchars(strtolower($country_code)).'.png" width="108" height="81"><br /> | |
367 | '.$country_code . ' | |
368 | </div> | |
369 | <div class="count">' . $count . ' <span>connected</span></div> | |
370 | </li>'; | |
371 | } | |
372 | ?> | |
373 | </ul> | |
374 | </div> | |
375 | <?php */ ?> | |
376 | ||
377 | </div> | |
378 | ||
379 | <script> | |
380 | function resize_check() | |
381 | { | |
382 | var width = window.innerWidth; | |
383 | var show_elements = ''; | |
384 | var hide_elements = ''; | |
385 | if (width < 500) | |
386 | { | |
387 | show_elements = ''; | |
388 | hide_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol, .countrycol'; | |
389 | } else | |
390 | if (width < 600) | |
391 | { | |
392 | show_elements = '.countrycol'; | |
393 | hide_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol'; | |
394 | } else | |
395 | if (width < 700) | |
396 | { | |
397 | show_elements = '.umodescol, .countrycol'; | |
398 | hide_elements = '.hostname, .opercol, .uplinkcol, .securecol'; | |
399 | } else | |
400 | if (width < 768) | |
401 | { | |
402 | show_elements = '.securecol, .umodescol, .countrycol'; | |
403 | hide_elements = '.hostname, .opercol, .uplinkcol'; | |
404 | } else | |
405 | if (width < 875) | |
406 | { | |
407 | // left nav kicks in at 768+ so need to drop one column between 768..875 | |
408 | show_elements = '.umodescol, .countrycol'; | |
409 | hide_elements = '.hostname, .opercol, .uplinkcol, .securecol'; | |
410 | } else if (width < 1000) | |
411 | { | |
412 | show_elements = '.securecol, .umodescol, .countrycol'; | |
413 | hide_elements = '.hostname, .uplinkcol, .opercol'; | |
414 | } else if (width < 1200) | |
415 | { | |
416 | show_elements = '.opercol, .securecol, .umodescol, .countrycol'; | |
417 | hide_elements = '.hostname, .uplinkcol'; | |
418 | } else if (width < 1550) | |
419 | { | |
420 | show_elements = '.opercol, .uplinkcol, .securecol, .umodescol, .countrycol'; | |
421 | hide_elements = '.hostname'; | |
422 | } else if (width < 1750) | |
423 | { | |
424 | show_elements = '.hostname, .opercol, .securecol, .umodescol, .countrycol'; | |
425 | hide_elements = '.uplinkcol'; | |
426 | } else { | |
427 | show_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol, .countrycol'; | |
428 | hide_elements = ''; | |
429 | } | |
430 | ||
431 | if (show_elements != '') | |
432 | { | |
433 | show_elements=document.querySelectorAll(show_elements); | |
434 | for (let i = 0; i < show_elements.length; i++) | |
435 | show_elements[i].style.display = ''; | |
436 | } | |
437 | ||
438 | if (hide_elements != '') | |
439 | { | |
440 | hide_elements=document.querySelectorAll(hide_elements); | |
441 | for (let i = 0; i < hide_elements.length; i++) | |
442 | hide_elements[i].style.display = 'none'; | |
443 | } | |
444 | } | |
445 | resize_check(); | |
446 | window.addEventListener('resize', function() { | |
447 | resize_check(); | |
448 | }); | |
449 | var rclickmenu = document.getElementById('rclickmenu'); | |
450 | var scopes = document.querySelectorAll('.userselector'); | |
451 | document.addEventListener("click", (e) => | |
452 | { | |
453 | if (e.target.offsetParent != rclickmenu) | |
454 | { | |
455 | rclickmenu.classList.remove("visible"); | |
456 | } | |
457 | }); | |
458 | scopes.forEach((scope) => { | |
459 | scope.addEventListener("contextmenu", (event) => | |
460 | { | |
461 | event.preventDefault(); | |
462 | var { clientX: mouseX, clientY: mouseY } = event; | |
463 | var name = $('#' + scope.id).attr('value') | |
464 | document.getElementById("rclick_opt1").innerHTML = 'View details for ' + name; | |
465 | rclickmenu.style.top = `${mouseY}px`; | |
466 | rclickmenu.style.left = `${mouseX}px`; | |
467 | rclickmenu.classList.remove("visible"); | |
468 | setTimeout(() => { rclickmenu.classList.add("visible"); }); | |
469 | }); | |
470 | }); | |
471 | document.addEventListener('keydown', (event) => { | |
472 | if (event.key === 'Escape') | |
473 | { | |
474 | rclickmenu.classList.remove("visible"); | |
475 | } | |
476 | }); | |
477 | </script> | |
478 | ||
479 | <?php require_once UPATH.'/inc/footer.php'; ?> |