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