]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - index.php
Updates to use latest unrealircd-rpc-php.
[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 $a = base64_decode($tok[0]);
82 $b = base64_decode($tok[1]);
83 if ($rpc->serverban()->delete($a, $b))
84 Message::Success(base64_decode($tok[1])." has been removed for ".base64_decode($tok[0]));
85 }
86 }
87
88 if (!empty($_POST['sf']))
89 foreach ($_POST as $key => $value) {
90 foreach ($value as $tok) {
91 $tok = explode(",", $tok);
92 rpc_sf_del(base64_decode($tok[0]), base64_decode($tok[1]), base64_decode($tok[2]), base64_decode($tok[3]));
93 }
94 }
95 }
96
97 rpc_pop_lists();
98 ?>
99
100 <div class="tab-content\">
101 <div id="overview" data-tab-content class="active">
102 <table class='unrealircd_overview'>
103 <th>Chat Overview</th><th></th>
104 <tr><td><b>Users</b></td><td><?php echo count(RPC_List::$user); ?></td></tr>
105 <tr><td><b>Opers</b></td><td><?php echo RPC_List::$opercount; ?></td></tr>
106 <tr><td><b>Services</b></td><td><?php echo RPC_List::$services_count; ?></td></tr>
107 <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>
108 <tr><td><b>Channels</b></td><td><?php echo count(RPC_List::$channel); ?></td></tr>
109 <tr><td><b>Server bans</b></td><td><?php echo count(RPC_List::$tkl); ?></td></tr>
110 <tr><td><b>Spamfilter entries</b></td><td><?php echo count(RPC_List::$spamfilter); ?></td></tr></th>
111 </table></div></div>
112
113 <div class="tab-content\">
114 <div id="Users" data-tab-content>
115 <table class='users_filter'>
116 <th class="thuf">Filter by: </th>
117 <th>
118 <form action="" method="post">
119 Nick: <input name="uf_nick" id="uf_nick" type="text">
120 <input class="cute_button2" type="submit" value="Search">
121 </form>
122 </th>
123 <th>
124 <form action="" method="post">
125 Hostname: <input name="uf_host" id="uf_host" type="text">
126 <input class="cute_button2" type="submit" value="Search">
127 </form>
128 </th>
129 <th>
130 <form action="" method="post">
131 IP: <input name="uf_ip" id="uf_ip" type="text">
132 <input class="cute_button2" type="submit" value="Search">
133 </form>
134 </th>
135 <th class="thuffer">
136 <form action="" method="post">
137 Account: <input name="uf_account" id="uf_account" type="text">
138 <input class="cute_button2" type="submit" value="Search">
139 </form>
140 </th>
141 </form>
142 </table>
143 <?php
144 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
145 Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
146
147 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
148 Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
149
150 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
151 Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
152
153 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
154 Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
155
156 ?>
157 <table class='users_overview'>
158 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
159 <th>Nick</th>
160 <th>UID</th>
161 <th>Host / IP</th>
162 <th>Account</th>
163 <th>Usermodes<a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
164 <th>Oper</th>
165 <th>Secure</th>
166 <th>Connected to</th>
167 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
168
169 <form action="" method="post">
170 <?php
171 foreach(RPC_List::$user as $user)
172 {
173
174 /* Some basic filtering for NICK */
175 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
176 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
177 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
178 continue;
179
180 /* Some basic filtering for HOST */
181 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
182 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
183 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
184 continue;
185
186 /* Some basic filtering for IP */
187 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
188 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
189 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
190 continue;
191
192 /* Some basic filtering for ACCOUNT */
193 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
194 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
195 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
196 continue;
197
198 echo "<tr>";
199 echo "<td><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></td>";
200 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="label">Bot</span>' : "";
201 echo "<td>".$user->name.$isBot.'</td>';
202 echo "<td>".$user->id."</td>";
203 echo "<td>".$user->hostname." (".$user->ip.")</td>";
204 $account = (isset($user->user->account)) ? '<span class="label">'.$user->user->account.'</span>' : '<span class="label noaccount">None</span>';
205 echo "<td>".$account."</td>";
206 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
207 echo "<td>".$modes."</td>";
208 $oper = (isset($user->user->operlogin)) ? '<span class="label">'.$user->user->operlogin."</span> <span class=\"label operclass-label\">".$user->user->operclass."</span>" : "";
209 if (!strlen($oper))
210 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
211 echo "<td>".$oper."</td>";
212 $secure = (isset($user->tls)) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label noaccount\">Insecure</span>";
213 echo "<td>".$secure."</td>";
214 echo "<td>".$user->user->servername."</td>";
215 echo "<td>".$user->user->reputation."</td>";
216 }
217 ?></table>
218 <label for="bantype">Apply action: </label><br>
219 <select name="bantype" id="bantype">
220 <option value=""></option>
221 <optgroup label="Bans">
222 <option value="gline">GLine</option>
223 <option value="gzline">GZLine</option>
224 </optgroup>
225 </select>
226 <br>
227 <label for="banlen_w">Duration: </label><br>
228 <select name="banlen_w" id="banlen_w">
229 <?php
230 for ($i = 0; $i <= 56; $i++)
231 {
232 if (!$i)
233 echo "<option value=\"0w\"></option>";
234 else
235 {
236 $w = ($i == 1) ? "week" : "weeks";
237 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
238 }
239 }
240 ?>
241 </select>
242 <select name="banlen_d" id="banlen_d">
243 <?php
244 for ($i = 0; $i <= 31; $i++)
245 {
246 if (!$i)
247 echo "<option value=\"0d\"></option>";
248 else
249 {
250 $d = ($i == 1) ? "day" : "days";
251 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
252 }
253 }
254 ?>
255 </select>
256 <select name="banlen_h" id="banlen_h">
257 <?php
258 for ($i = 0; $i <= 24; $i++)
259 {
260 if (!$i)
261 echo "<option value=\"0d\"></option>";
262 else
263 {
264 $h = ($i == 1) ? "hour" : "hours";
265 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
266 }
267 }
268 ?>
269 </select>
270 <br><label for="ban_reason">Reason:<br></label>
271 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
272 <input class="cute_button" type="submit" value="Apply">
273 </form>
274
275 </div></div>
276
277 <div class="tab-content\">
278 <div id="Channels" data-tab-content>
279 <p></p>
280 <table class='users_overview'>
281 <th>Name</th>
282 <th>Created</th>
283 <th>User count</th>
284 <th>Topic</th>
285 <th>Topic Set</th>
286 <th>Modes</th>
287
288 <?php
289 foreach(RPC_List::$channel as $channel)
290 {
291 echo "<tr>";
292 echo "<td>".$channel->name."</td>";
293 echo "<td>".$channel->creation_time."</td>";
294 echo "<td>".$channel->num_users."</td>";
295 $topic = (isset($channel->topic)) ? $channel->topic : "";
296 echo "<td>".$topic."</td>";
297 $setby = (isset($channel->topic)) ? "By ".$channel->topic_set_by .", at ".$channel->topic_set_at : "";
298 echo "<td>".$setby."</td>";
299 $modes = (isset($channel->modes)) ? "+" . $channel->modes : "<none>";
300 echo "<td>".$modes."</td>";
301 }
302 ?></table></div></div>
303
304
305 <div class="tab-content\">
306 <div id="TKL" data-tab-content>
307
308 <table class='users_overview'>
309 <form action="" method="post">
310 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
311 <th>Mask</th>
312 <th>Type</th>
313 <th>Set By</th>
314 <th>Set On</th>
315 <th>Expires</th>
316 <th>Duration</th>
317 <th>Reason</th>
318
319 <?php
320 foreach(RPC_List::$tkl as $tkl)
321 {
322 echo "<tr>";
323 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
324 echo "<td>".$tkl->name."</td>";
325 echo "<td>".$tkl->type_string."</td>";
326 echo "<td>".$tkl->set_by."</td>";
327 echo "<td>".$tkl->set_at_string."</td>";
328 echo "<td>".$tkl->expire_at_string."</td>";
329 echo "<td>".$tkl->duration_string."</td>";
330 echo "<td>".$tkl->reason."</td>";
331 }
332 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
333
334
335 <div class="tab-content\">
336 <div id="Spamfilter" data-tab-content>
337 <p></p>
338 <table class='users_overview'>
339 <form action="" method="post">
340 <th><input type="checkbox" label='selectall' onClick="toggle_sf(this)" />Select all</th>
341 <th>Mask</th>
342 <th>Type</th>
343 <th>Set By</th>
344 <th>Set On</th>
345 <th>Expires</th>
346 <th>Duration</th>
347 <th>Match Type</th>
348 <th>Action</th>
349 <th>Action Duration</th>
350 <th>Target</th>
351 <th>Reason</th>
352
353 <?php
354 foreach(RPC_List::$spamfilter as $sf)
355 {
356 echo "<tr>";
357 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>";
358 echo "<td>".$sf->name."</td>";
359 echo "<td>".$sf->type_string."</td>";
360 echo "<td>".$sf->set_by."</td>";
361 echo "<td>".$sf->set_at_string."</td>";
362 echo "<td>".$sf->expire_at_string."</td>";
363 echo "<td>".$sf->duration_string."</td>";
364 echo "<td>".$sf->match_type."</td>";
365 echo "<td>".$sf->ban_action."</td>";
366 echo "<td>".$sf->ban_duration_string."</td>";
367 for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
368 {
369 $c = $sf->spamfilter_targets[$i];
370 if ($c == "c")
371 $targs .= "Channel, ";
372 else if ($c == "p")
373 $targs .= "Private,";
374 else if ($c == "n")
375 $targs .= "Notice, ";
376 else if ($c == "N")
377 $targs .= "Channel notice, ";
378 else if ($c == "P")
379 $targs .= "Part message, ";
380 else if ($c == "q")
381 $targs .= "Quit message, ";
382 else if ($c == "d")
383 $targs .= "DCC filename, ";
384 else if ($c == "a")
385 $targs .= "Away message, ";
386 else if ($c == "t")
387 $targs .= "Channel topic, ";
388 else if ($c == "T")
389 $targs .= "MessageTag, ";
390 else if ($c == "u")
391 $targs .= "Usermask, ";
392 }
393 $targs = rtrim($targs,", ");
394 echo "<td>".$targs."</td>";
395 echo "<td>".$sf->reason."</td>";
396
397 }
398 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
399
400
401
402 <div class="tab-content\">
403 <div id="News" data-tab-content>
404 <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>
405 <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>
406 </div></div>
407
408 </body>