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