]>
Commit | Line | Data |
---|---|---|
e98b5a51 | 1 | <?php |
27efe895 | 2 | require_once "../common.php"; |
dd6ce63f | 3 | require_once "../header.php"; |
e98b5a51 | 4 | |
10102cdc VP |
5 | if (!empty($_GET)) |
6 | { | |
7 | if (isset($_GET['account']) && !isset($_POST['uf_account'])) | |
8 | $_POST['uf_account'] = $_GET['account']; | |
9 | ||
10 | if (isset($_GET['operonly']) && !isset($_POST['operonly'])) | |
11 | $_POST['operonly'] = $_GET['operonly']; | |
65a14aac VP |
12 | |
13 | if (isset($_GET['servicesonly']) && !isset($_POST['servicesonly'])) | |
14 | $_POST['servicesonly'] = $_GET['servicesonly']; | |
10102cdc | 15 | } |
6b218bea | 16 | |
65a14aac VP |
17 | if (!empty($_POST)) |
18 | { | |
e98b5a51 | 19 | do_log($_POST); |
c68cfb17 | 20 | $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL; |
65a14aac | 21 | |
d843c1de | 22 | if (isset($_POST['userch'])) { |
65a14aac VP |
23 | foreach ($_POST["userch"] as $user) |
24 | { | |
d843c1de | 25 | $user = $name = base64_decode($user); |
65a14aac VP |
26 | |
27 | if (!$bantype) /* shouldn't happen? */ | |
28 | { | |
e98b5a51 | 29 | Message::Fail("An error occured"); |
65a14aac VP |
30 | } |
31 | ||
32 | else | |
33 | { | |
d843c1de VP |
34 | $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; |
35 | $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; | |
36 | $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; | |
37 | ||
38 | $duration = ""; | |
39 | if (!$banlen_d && !$banlen_h && !$banlen_w) | |
40 | $duration .= "0"; | |
41 | else { | |
42 | if ($banlen_w) | |
43 | $duration .= $banlen_w; | |
44 | if ($banlen_d) | |
45 | $duration .= $banlen_d; | |
46 | if ($banlen_h) | |
47 | $duration .= $banlen_h; | |
48 | } | |
49 | $user = $rpc->user()->get($user); | |
65a14aac | 50 | |
0d846731 | 51 | if (!$user && $bantype !== "qline") { |
d843c1de | 52 | Message::Fail("Could not find that user: User not online"); |
65a14aac VP |
53 | } |
54 | ||
55 | else | |
56 | { | |
d843c1de VP |
57 | $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration); |
58 | $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason"; | |
65a14aac | 59 | |
0d846731 VP |
60 | if ($bantype == "qline") |
61 | $rpc->nameban()->add($name, $reason, $duration); | |
65a14aac | 62 | |
0b546dde VP |
63 | else if ($bantype == "kill") |
64 | { | |
65 | if ($rpc->user()->kill($user->id, $reason)) | |
66 | Message::Success($user->name . "(*@" . $user->hostname . ") has been killed: $reason"); | |
67 | else | |
68 | Message::Fail("Could not kill $user->name: $rpc->error"); | |
69 | } | |
0d846731 | 70 | else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason)) |
d843c1de | 71 | Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason"); |
65a14aac | 72 | |
d843c1de VP |
73 | else |
74 | Message::Fail("Could not add $bantype against $name: $rpc->error"); | |
75 | } | |
e98b5a51 | 76 | } |
e98b5a51 BM |
77 | } |
78 | } | |
79 | } | |
80 | ||
81 | /* Get the user list */ | |
82 | $users = $rpc->user()->getAll(); | |
83 | ?> | |
b111d43c | 84 | <h4>Users Overview</h4> |
d1d9caa9 | 85 | |
62d4ea03 | 86 | Click on a username to view more information. |
e98b5a51 | 87 | |
1e6ffd06 | 88 | <div id="Users"> |
d1d9caa9 | 89 | |
e98b5a51 | 90 | <?php |
10102cdc | 91 | |
e98b5a51 BM |
92 | if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick'])) |
93 | Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\""); | |
94 | ||
95 | if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip'])) | |
96 | Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\""); | |
97 | ||
98 | if (isset($_POST['uf_host']) && strlen($_POST['uf_host'])) | |
99 | Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\""); | |
100 | ||
101 | if (isset($_POST['uf_account']) && strlen($_POST['uf_account'])) | |
102 | Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\""); | |
103 | ||
a5400f9a VP |
104 | if (isset($_POST['uf_server']) && strlen($_POST['uf_server'])) |
105 | Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\""); | |
106 | ||
10102cdc | 107 | |
e98b5a51 | 108 | ?> |
75c101fd | 109 | <table class="container-xxl table table-responsive caption-top table-striped"> |
71ef1a7f | 110 | <thead> |
d1d9caa9 | 111 | <form action="" method="post"> |
65a14aac VP |
112 | <tr> |
113 | <th scope="col"><h5>Filter:</h5></th> | |
114 | <th scope="col" colspan="2"><input <?php echo (isset($_POST['operonly'])) ? "checked" : ""; ?> name="operonly" type="checkbox" value=""> Opers Only</th> | |
115 | <th scope="col" colspan="2"><input <?php echo (isset($_POST['servicesonly'])) ? "checked" : ""; ?> name="servicesonly" type="checkbox" value=""> Services Only</th> | |
116 | </tr> | |
117 | <tr> | |
1bad309d VP |
118 | <th scope="col" colspan="2">Nick: <input name="uf_nick" type="text" class="short-form-control"> |
119 | <th scope="col" colspan="2">Host: <input name="uf_host" type="text" class="short-form-control"></th> | |
120 | <th scope="col" colspan="2">IP: <input name="uf_ip" type="text" class="short-form-control"></th> | |
121 | <th scope="col" colspan="2">Account: <input name="uf_account" type="text" class="short-form-control"></th> | |
122 | <th scope="col" colspan="2">Server: <input name="uf_server" type="text" class="short-form-control"></th> | |
65a14aac VP |
123 | |
124 | <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th> | |
125 | </tr> | |
126 | </form> | |
b111d43c BM |
127 | </thead></table> |
128 | ||
ce3de101 | 129 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> |
b111d43c BM |
130 | <thead class="table-primary"> |
131 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th> | |
d1d9caa9 | 132 | <th scope="col">Nick</th> |
d1d9caa9 | 133 | <th scope="col">Host / IP</th> |
898237bd | 134 | <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 VP |
135 | <th scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th> |
136 | <th scope="col">Oper</th> | |
898237bd | 137 | <th 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> |
d1d9caa9 | 138 | <th scope="col">Connected to</th> |
898237bd | 139 | <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 | 140 | </thead> |
e98b5a51 | 141 | |
2bc4c695 | 142 | <tbody> |
27efe895 | 143 | <form method="post"> |
e98b5a51 | 144 | <?php |
d1d9caa9 | 145 | |
e98b5a51 BM |
146 | foreach($users as $user) |
147 | { | |
148 | ||
62d4ea03 | 149 | |
e98b5a51 BM |
150 | /* Some basic filtering for NICK */ |
151 | if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) && | |
152 | strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 && | |
153 | strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false) | |
154 | continue; | |
155 | ||
156 | /* Some basic filtering for HOST */ | |
157 | if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) && | |
158 | strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 && | |
159 | strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false) | |
160 | continue; | |
161 | ||
162 | /* Some basic filtering for IP */ | |
163 | if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) && | |
164 | strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 && | |
165 | strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false) | |
166 | continue; | |
167 | ||
168 | /* Some basic filtering for ACCOUNT */ | |
169 | if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) && | |
0b546dde | 170 | strtolower($user->user->account) !== strtolower($_POST['uf_account'])) |
e98b5a51 BM |
171 | continue; |
172 | ||
0b546dde | 173 | /* Some basic filtering for SERVER */ |
a5400f9a VP |
174 | if (isset($_POST['uf_server']) && strlen($_POST['uf_server']) && |
175 | strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) !== 0 && | |
176 | strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) == false) | |
177 | continue; | |
178 | ||
10102cdc VP |
179 | /* Some basic filtering for OPER */ |
180 | if (isset($_POST['operonly']) && | |
94fd26b9 | 181 | (strpos($user->user->modes, "o") == false || strpos($user->user->modes,"S") !== false)) |
10102cdc VP |
182 | continue; |
183 | ||
65a14aac VP |
184 | /* Some basic filtering for SERVICES */ |
185 | if (isset($_POST['servicesonly']) && | |
186 | (strpos($user->user->modes,"S") == false)) | |
187 | continue; | |
188 | ||
9307bb12 | 189 | echo "\n<tr>"; |
d1d9caa9 | 190 | echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>"; |
9307bb12 | 191 | $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : ""; |
27efe895 | 192 | echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>"; |
4ee7eb56 | 193 | echo "<td>".htmlspecialchars($user->hostname)." (".htmlspecialchars($user->ip ?? "None").")</td>"; |
65a14aac | 194 | $account = (isset($user->user->account)) ? "<a href=\"".BASE_URL."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>'; |
e98b5a51 BM |
195 | echo "<td>".$account."</td>"; |
196 | $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>"; | |
197 | echo "<td>".$modes."</td>"; | |
9307bb12 | 198 | $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : ""; |
e98b5a51 | 199 | if (!strlen($oper)) |
9307bb12 | 200 | $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : ""; |
e98b5a51 | 201 | echo "<td>".$oper."</td>"; |
58478df1 | 202 | |
65a14aac | 203 | $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 |
204 | if (strpos($user->user->modes, "S") !== false) |
205 | $secure = ""; | |
e98b5a51 | 206 | echo "<td>".$secure."</td>"; |
f2b064ad | 207 | echo "<td><a href=\"".BASE_URL."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>"; |
e98b5a51 | 208 | echo "<td>".$user->user->reputation."</td>"; |
f41baac8 | 209 | echo "</tr>"; |
e98b5a51 | 210 | } |
2bc4c695 | 211 | ?> |
d1d9caa9 VP |
212 | </tbody></table> |
213 | <table class="table table-responsive table-light"> | |
214 | <tr> | |
215 | <td colspan="2"> | |
216 | <label for="bantype">Apply action: </label> | |
e98b5a51 BM |
217 | <select name="bantype" id="bantype"> |
218 | <option value=""></option> | |
219 | <optgroup label="Bans"> | |
220 | <option value="gline">GLine</option> | |
221 | <option value="gzline">GZLine</option> | |
0b546dde | 222 | <option value="kill">Kill</option> |
e98b5a51 | 223 | </optgroup> |
d1d9caa9 VP |
224 | </select></td><td colspan="2"> |
225 | <label for="banlen_w">Duration: </label> | |
e98b5a51 BM |
226 | <select name="banlen_w" id="banlen_w"> |
227 | <?php | |
228 | for ($i = 0; $i <= 56; $i++) | |
229 | { | |
230 | if (!$i) | |
231 | echo "<option value=\"0w\"></option>"; | |
232 | else | |
233 | { | |
234 | $w = ($i == 1) ? "week" : "weeks"; | |
235 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
236 | } | |
237 | } | |
238 | ?> | |
239 | </select> | |
240 | <select name="banlen_d" id="banlen_d"> | |
241 | <?php | |
242 | for ($i = 0; $i <= 31; $i++) | |
243 | { | |
244 | if (!$i) | |
245 | echo "<option value=\"0d\"></option>"; | |
246 | else | |
247 | { | |
248 | $d = ($i == 1) ? "day" : "days"; | |
249 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
250 | } | |
251 | } | |
252 | ?> | |
253 | </select> | |
254 | <select name="banlen_h" id="banlen_h"> | |
255 | <?php | |
256 | for ($i = 0; $i <= 24; $i++) | |
257 | { | |
258 | if (!$i) | |
259 | echo "<option value=\"0d\"></option>"; | |
260 | else | |
261 | { | |
262 | $h = ($i == 1) ? "hour" : "hours"; | |
263 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
264 | } | |
265 | } | |
d1d9caa9 | 266 | |
e98b5a51 | 267 | ?> |
0b546dde VP |
268 | </select> |
269 | ||
270 | <br></td><tr><td colspan="3"> | |
d1d9caa9 VP |
271 | |
272 | <label for="ban_reason">Reason: </label> | |
0b546dde | 273 | <input class="form-control" type="text" name="ban_reason" id="ban_reason" value="No reason"> |
d1d9caa9 | 274 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> |
0b546dde | 275 | Apply |
d1d9caa9 VP |
276 | </button></td></table> |
277 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
278 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
279 | <div class="modal-content"> | |
280 | <div class="modal-header"> | |
281 | <h5 class="modal-title" id="myModalLabel">Apply ban</h5> | |
282 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
283 | <span aria-hidden="true">×</span> | |
284 | </button> | |
285 | </div> | |
286 | <div class="modal-body"> | |
287 | Are you sure you want to do this? | |
288 | ||
289 | </div> | |
290 | <div class="modal-footer"> | |
291 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
0b546dde | 292 | <button type="submit" action="post" class="btn btn-danger">Apply</button> |
d1d9caa9 VP |
293 | |
294 | </div> | |
295 | </div> | |
296 | </div> | |
297 | </div> | |
298 | ||
e98b5a51 BM |
299 | </form> |
300 | ||
d1d9caa9 VP |
301 | </div> |
302 | ||
303 | <script> | |
304 | ||
305 | $("#myModal").on('shown.bs.modal', function(){ | |
306 | $("#CloseButton").focus(); | |
307 | }); | |
308 | </script> | |
e98b5a51 | 309 | |
27efe895 | 310 | <?php require_once UPATH.'/footer.php'; ?> |