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