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