]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - index.php
Users Tab: Remove some labels which were too much
[irc/unrealircd/unrealircd-webpanel.git] / index.php
1 <!DOCTYPE html>
2 <title>UnrealIRCd Panel</title>
3 <link rel="icon" type="image/x-icon" href="/img/favicon.ico">
4 <link href="css/unrealircd-admin.css" rel="stylesheet">
5 <body class="body-for-sticky">
6 <div id="headerContainer">
7 <h2><a href="">UnrealIRCd <small>Administration Panel</small></a></h2></div>
8 <script src="js/unrealircd-admin.js" defer></script>
9 <div class="topnav">
10 <a data-tab-target="#overview" class="active" href="#overview">Overview</a>
11 <a data-tab-target="#Users" href="#Users">Users</a>
12 <a data-tab-target="#Channels" href="#Channels">Channels</a>
13 <a data-tab-target="#TKL" href="#TKL">Server Bans</a>
14 <a data-tab-target="#Spamfilter" href="#Spamfilter">Spamfilter</a>
15 <a data-tab-target="#News" href="#News">News</a>
16 </div>
17 <?php
18 define('UPATH', dirname(__FILE__));
19 require_once "config.php";
20 require_once UPATH . '/vendor/autoload.php';
21 require_once "connection.php";
22 require_once "Classes/class-log.php";
23 require_once "Classes/class-message.php";
24 require_once "Classes/class-rpc.php";
25
26 do_log($_POST);
27
28 if (!empty($_POST)) {
29 if (!($bantype = $_POST['bantype'])) {
30
31 } else if (!($users = $_POST["userch"])) {
32 Message::Fail("No user was specified");
33 } else {
34 foreach ($_POST["userch"] as $user) {
35 $user = base64_decode($user);
36 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
37 if (!$bantype)
38 {
39 Message::Fail("An error occured");
40 return;
41 }
42 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
43 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
44 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
45
46 $duration = "";
47 if (!$banlen_d && !$banlen_h && !$banlen_w)
48 $duration .= "0";
49
50 else
51 {
52 if ($banlen_w)
53 $duration .= $banlen_w;
54 if ($banlen_d)
55 $duration .= $banlen_d;
56 if ($banlen_h)
57 $duration .= $banlen_h;
58 }
59
60 $nick = $rpc->user()->get($user);
61 if (!$nick)
62 {
63 Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?");
64 return;
65 }
66
67 $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
68 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
69 if ($rpc->serverban()->add($user, $bantype, $duration, $reason))
70 {
71 $c = $nick->client;
72 Message::Success($c->name . " (*@".$c->hostname.") has been $bantype" . "d $msg_msg: $reason");
73 }
74 }
75 }
76
77 if (!empty($_POST['tklch']))
78 foreach ($_POST as $key => $value) {
79 foreach ($value as $tok) {
80 $tok = explode(",", $tok);
81 $ban = base64_decode($tok[0]);
82 $type = base64_decode($tok[1]);
83 if ($rpc->serverban()->delete($ban, $type))
84 Message::Success("$type has been removed for $ban");
85 else
86 Message::Fail("Unable to remove $type on $ban: $rpc->error");
87 }
88 }
89
90 if (!empty($_POST['sf']))
91 foreach ($_POST as $key => $value) {
92 foreach ($value as $tok) {
93 $tok = explode(",", $tok);
94 $name = base64_decode($tok[0]);
95 $match_type = base64_decode($tok[1]);
96 $spamfilter_targets = base64_decode($tok[2]);
97 $ban_action = base64_decode($tok[3]);
98 if ($rpc->spamfilter()->delete($name, $match_type, $spamfilter_targets, $ban_action))
99 Message::Success("Spamfilter on $name has been removed");
100 else
101 Message::Fail("Unable to remove spamfilter on $name: $rpc->error");
102 }
103 }
104 }
105
106 rpc_pop_lists();
107 ?>
108
109 <div class="tab-content\">
110 <div id="overview" data-tab-content class="active">
111 <table class='unrealircd_overview'>
112 <th>Chat Overview</th><th></th>
113 <tr><td><b>Users</b></td><td><?php echo count(RPC_List::$user); ?></td></tr>
114 <tr><td><b>Opers</b></td><td><?php echo RPC_List::$opercount; ?></td></tr>
115 <tr><td><b>Services</b></td><td><?php echo RPC_List::$services_count; ?></td></tr>
116 <tr><td><b>Most popular channel</b></td><td><?php echo RPC_List::$most_populated_channel; ?> (<?php echo RPC_List::$channel_pop_count; ?> users)</td></tr>
117 <tr><td><b>Channels</b></td><td><?php echo count(RPC_List::$channel); ?></td></tr>
118 <tr><td><b>Server bans</b></td><td><?php echo count(RPC_List::$tkl); ?></td></tr>
119 <tr><td><b>Spamfilter entries</b></td><td><?php echo count(RPC_List::$spamfilter); ?></td></tr></th>
120 </table></div></div>
121
122 <div class="tab-content\">
123 <div id="Users" data-tab-content>
124 <table class='users_filter'>
125 <th class="thuf">Filter by: </th>
126 <th>
127 <form action="" method="post">
128 Nick: <input name="uf_nick" id="uf_nick" type="text">
129 <input class="cute_button2" type="submit" value="Search">
130 </form>
131 </th>
132 <th>
133 <form action="" method="post">
134 Hostname: <input name="uf_host" id="uf_host" type="text">
135 <input class="cute_button2" type="submit" value="Search">
136 </form>
137 </th>
138 <th>
139 <form action="" method="post">
140 IP: <input name="uf_ip" id="uf_ip" type="text">
141 <input class="cute_button2" type="submit" value="Search">
142 </form>
143 </th>
144 <th class="thuffer">
145 <form action="" method="post">
146 Account: <input name="uf_account" id="uf_account" type="text">
147 <input class="cute_button2" type="submit" value="Search">
148 </form>
149 </th>
150 </form>
151 </table>
152 <?php
153 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
154 Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
155
156 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
157 Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
158
159 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
160 Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
161
162 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
163 Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
164
165 ?>
166 <table class='users_overview'>
167 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
168 <th>Nick</th>
169 <th>UID</th>
170 <th>Host / IP</th>
171 <th>Account</th>
172 <th>Usermodes<a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
173 <th>Oper</th>
174 <th>Secure</th>
175 <th>Connected to</th>
176 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
177
178 <form action="" method="post">
179 <?php
180 foreach(RPC_List::$user as $user)
181 {
182
183 /* Some basic filtering for NICK */
184 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
185 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
186 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
187 continue;
188
189 /* Some basic filtering for HOST */
190 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
191 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
192 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
193 continue;
194
195 /* Some basic filtering for IP */
196 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
197 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
198 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
199 continue;
200
201 /* Some basic filtering for ACCOUNT */
202 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
203 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
204 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
205 continue;
206
207 echo "<tr>";
208 echo "<td><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></td>";
209 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="label">Bot</span>' : "";
210 echo "<td>".$user->name.$isBot.'</td>';
211 echo "<td>".$user->id."</td>";
212 echo "<td>".$user->hostname." (".$user->ip.")</td>";
213 $account = (isset($user->user->account)) ? $user->user->account : '<span class="label noaccount">None</span>';
214 echo "<td>".$account."</td>";
215 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
216 echo "<td>".$modes."</td>";
217 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"label operclass-label\">".$user->user->operclass."</span>" : "";
218 if (!strlen($oper))
219 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
220 echo "<td>".$oper."</td>";
221 $secure = (isset($user->tls)) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label noaccount\">Insecure</span>";
222 echo "<td>".$secure."</td>";
223 echo "<td>".$user->user->servername."</td>";
224 echo "<td>".$user->user->reputation."</td>";
225 }
226 ?></table>
227 <label for="bantype">Apply action: </label><br>
228 <select name="bantype" id="bantype">
229 <option value=""></option>
230 <optgroup label="Bans">
231 <option value="gline">GLine</option>
232 <option value="gzline">GZLine</option>
233 </optgroup>
234 </select>
235 <br>
236 <label for="banlen_w">Duration: </label><br>
237 <select name="banlen_w" id="banlen_w">
238 <?php
239 for ($i = 0; $i <= 56; $i++)
240 {
241 if (!$i)
242 echo "<option value=\"0w\"></option>";
243 else
244 {
245 $w = ($i == 1) ? "week" : "weeks";
246 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
247 }
248 }
249 ?>
250 </select>
251 <select name="banlen_d" id="banlen_d">
252 <?php
253 for ($i = 0; $i <= 31; $i++)
254 {
255 if (!$i)
256 echo "<option value=\"0d\"></option>";
257 else
258 {
259 $d = ($i == 1) ? "day" : "days";
260 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
261 }
262 }
263 ?>
264 </select>
265 <select name="banlen_h" id="banlen_h">
266 <?php
267 for ($i = 0; $i <= 24; $i++)
268 {
269 if (!$i)
270 echo "<option value=\"0d\"></option>";
271 else
272 {
273 $h = ($i == 1) ? "hour" : "hours";
274 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
275 }
276 }
277 ?>
278 </select>
279 <br><label for="ban_reason">Reason:<br></label>
280 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
281 <input class="cute_button" type="submit" value="Apply">
282 </form>
283
284 </div></div>
285
286 <div class="tab-content\">
287 <div id="Channels" data-tab-content>
288 <p></p>
289 <table class='users_overview'>
290 <th>Name</th>
291 <th>Created</th>
292 <th>User count</th>
293 <th>Topic</th>
294 <th>Topic Set</th>
295 <th>Modes</th>
296
297 <?php
298 foreach(RPC_List::$channel as $channel)
299 {
300 echo "<tr>";
301 echo "<td>".$channel->name."</td>";
302 echo "<td>".$channel->creation_time."</td>";
303 echo "<td>".$channel->num_users."</td>";
304 $topic = (isset($channel->topic)) ? $channel->topic : "";
305 echo "<td>".$topic."</td>";
306 $setby = (isset($channel->topic)) ? "By ".$channel->topic_set_by .", at ".$channel->topic_set_at : "";
307 echo "<td>".$setby."</td>";
308 $modes = (isset($channel->modes)) ? "+" . $channel->modes : "<none>";
309 echo "<td>".$modes."</td>";
310 }
311 ?></table></div></div>
312
313
314 <div class="tab-content\">
315 <div id="TKL" data-tab-content>
316 <div class="tkl_add_boxheader">
317 Add Server Ban
318 </div>
319 <div class="tkl_add_form">
320
321 <form action="" method="post">
322 <div class="align_label">IP / Host:</div><input class="input_text" type="text" id="tkl_add" name="tkl_add"><br>
323 <div class="align_label">Ban Type:</div><select name="bantype" id="bantype">
324 <option value=""></option>
325 <optgroup label="Bans">
326 <option value="kline">Kill Line (KLine)</option>
327 <option value="gline">Global Kill Line (GLine)</option>
328 <option value="zline">Zap Line (ZLine)</option>
329 <option value="gzline">Global Zap Line (GZLine)</option>
330
331 </optgroup>
332 <optgroup label="Restrictions">
333 <option value="local-qline">Reserve Nick Locally(QLine)</option>
334 <option value="qline">Reserve Nick Globally (QLine)</option>
335 <option value="shun">Shun</option>
336
337 </optgroup>
338 <optgroup label="Settings">
339 <option value="except">Global Exception (ELine)</option>
340 <option value="local-exception">Local Exception (ELine)</option>
341 </optgroup>
342 </select><br>
343 <div class="align_label"><label for="banlen_w">Duration: </label></div>
344 <select name="banlen_w" id="banlen_w">
345 <?php
346 for ($i = 0; $i <= 56; $i++)
347 {
348 if (!$i)
349 echo "<option value=\"0w\"></option>";
350 else
351 {
352 $w = ($i == 1) ? "week" : "weeks";
353 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
354 }
355 }
356 ?>
357 </select>
358 <select name="banlen_d" id="banlen_d">
359 <?php
360 for ($i = 0; $i <= 31; $i++)
361 {
362 if (!$i)
363 echo "<option value=\"0d\"></option>";
364 else
365 {
366 $d = ($i == 1) ? "day" : "days";
367 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
368 }
369 }
370 ?>
371 </select>
372 <select name="banlen_h" id="banlen_h">
373 <?php
374 for ($i = 0; $i <= 24; $i++)
375 {
376 if (!$i)
377 echo "<option value=\"0d\"></option>";
378 else
379 {
380 $h = ($i == 1) ? "hour" : "hours";
381 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
382 }
383 }
384 ?>
385 </select>
386 <br><div class="align_label"><label for="ban_reason">Reason: </label></div>
387 <input class="input_text" type="text" id="ban_reason" name="ban_reason"><br>
388 <div class="align_right_button_tkl_add"><input class="cute_button" type="submit" id="submit" value="Submit"></div>
389 </form>
390 </div>
391 <table class='users_overview'>
392 <form action="" method="post">
393 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
394 <th>Mask</th>
395 <th>Type</th>
396 <th>Set By</th>
397 <th>Set On</th>
398 <th>Expires</th>
399 <th>Duration</th>
400 <th>Reason</th>
401
402 <?php
403 foreach(RPC_List::$tkl as $tkl)
404 {
405 echo "<tr>";
406 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
407 echo "<td>".$tkl->name."</td>";
408 echo "<td>".$tkl->type_string."</td>";
409 echo "<td>".$tkl->set_by."</td>";
410 echo "<td>".$tkl->set_at_string."</td>";
411 echo "<td>".$tkl->expire_at_string."</td>";
412 echo "<td>".$tkl->duration_string."</td>";
413 echo "<td>".$tkl->reason."</td>";
414 }
415 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
416
417
418 <div class="tab-content\">
419 <div id="Spamfilter" data-tab-content>
420 <p></p>
421 <table class='users_overview'>
422 <form action="" method="post">
423 <th><input type="checkbox" label='selectall' onClick="toggle_sf(this)" />Select all</th>
424 <th>Mask</th>
425 <th>Type</th>
426 <th>Set By</th>
427 <th>Set On</th>
428 <th>Expires</th>
429 <th>Duration</th>
430 <th>Match Type</th>
431 <th>Action</th>
432 <th>Action Duration</th>
433 <th>Target</th>
434 <th>Reason</th>
435
436 <?php
437 foreach(RPC_List::$spamfilter as $sf)
438 {
439 echo "<tr>";
440 echo "<td><input type=\"checkbox\" value='" . base64_encode($sf->name).",".base64_encode($sf->match_type).",".base64_encode($sf->spamfilter_targets).",".base64_encode($sf->ban_action) . "' name=\"sf[]\"></td>";
441 echo "<td>".$sf->name."</td>";
442 echo "<td>".$sf->type_string."</td>";
443 echo "<td>".$sf->set_by."</td>";
444 echo "<td>".$sf->set_at_string."</td>";
445 echo "<td>".$sf->expire_at_string."</td>";
446 echo "<td>".$sf->duration_string."</td>";
447 echo "<td>".$sf->match_type."</td>";
448 echo "<td>".$sf->ban_action."</td>";
449 echo "<td>".$sf->ban_duration_string."</td>";
450 for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
451 {
452 $c = $sf->spamfilter_targets[$i];
453 if ($c == "c")
454 $targs .= "Channel, ";
455 else if ($c == "p")
456 $targs .= "Private,";
457 else if ($c == "n")
458 $targs .= "Notice, ";
459 else if ($c == "N")
460 $targs .= "Channel notice, ";
461 else if ($c == "P")
462 $targs .= "Part message, ";
463 else if ($c == "q")
464 $targs .= "Quit message, ";
465 else if ($c == "d")
466 $targs .= "DCC filename, ";
467 else if ($c == "a")
468 $targs .= "Away message, ";
469 else if ($c == "t")
470 $targs .= "Channel topic, ";
471 else if ($c == "T")
472 $targs .= "MessageTag, ";
473 else if ($c == "u")
474 $targs .= "Usermask, ";
475 }
476 $targs = rtrim($targs,", ");
477 echo "<td>".$targs."</td>";
478 echo "<td>".$sf->reason."</td>";
479
480 }
481 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
482
483
484
485 <div class="tab-content\">
486 <div id="News" data-tab-content>
487 <iframe style="border:none;" height="1000" width="600" data-tweet-url="https://twitter.com/Unreal_IRCd" src="data:text/html;charset=utf-8,%3Ca%20class%3D%22twitter-timeline%22%20href%3D%22https%3A//twitter.com/Unreal_IRCd%3Fref_src%3Dtwsrc%255Etfw%22%3ETweets%20by%20Unreal_IRCd%3C/a%3E%0A%3Cscript%20async%20src%3D%22https%3A//platform.twitter.com/widgets.js%22%20charset%3D%22utf-8%22%3E%3C/script%3E%0A%3Cstyle%3Ehtml%7Boverflow%3Ahidden%20%21important%3B%7D%3C/style%3E"></iframe>
488 <iframe style="border:none;" height="1000" width="600" data-tweet-url="https://twitter.com/irc_stats" src="data:text/html;charset=utf-8,%3Ca%20class%3D%22twitter-timeline%22%20href%3D%22https%3A//twitter.com/irc_stats%3Fref_src%3Dtwsrc%255Etfw%22%3ETweets%20by%20IRC%20Stats%3C/a%3E%0A%3Cscript%20async%20src%3D%22https%3A//platform.twitter.com/widgets.js%22%20charset%3D%22utf-8%22%3E%3C/script%3E%0A%3Cstyle%3Ehtml%7Boverflow%3Ahidden%20%21important%3B%7D%3C/style%3E"></iframe>
489 </div></div>
490
491 </body>