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