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