]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - index.php
Add beginnings of filtering
[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><br>
8 </div>
9 <script src="js/unrealircd-admin.js" defer></script>
10 <div class="topnav">
11 <a data-tab-target="#overview" class="active" href="#overview">Overview</a>
12 <a data-tab-target="#Users" href="#Users">Users</a>
13 <a data-tab-target="#Channels" href="#Channels">Channels</a>
14 <a data-tab-target="#TKL" href="#TKL">Server Bans</a>
15 <a data-tab-target="#Spamfilter" href="#Spamfilter">Spamfilter</a>
16 <a data-tab-target="#News" href="#News">News</a>
17 </div>
18 <?php
19 define('UPATH', dirname(__FILE__));
20 include "config.php";
21 include "Classes/class-log.php";
22 include "Classes/class-message.php";
23 include "Classes/class-rpc.php";
24 do_log($_POST);
25
26 if (!empty($_POST)) {
27 if (!($bantype = $_POST['bantype'])) {
28
29 } else if (!($users = $_POST["userch"])) {
30 Message::Fail("No user was specified");
31 } else {
32 foreach ($_POST["userch"] as $user) {
33 $user = base64_decode($user);
34 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
35 if (!$bantype)
36 {
37 Message::Fail("An error occured");
38 return;
39 }
40 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
41 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
42 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
43
44 $duration = "";
45 if (!$banlen_d && !$banlen_h && !$banlen_w)
46 $duration .= "0";
47
48 else
49 {
50 if ($banlen_w)
51 $duration .= $banlen_w;
52 if ($banlen_d)
53 $duration .= $banlen_d;
54 if ($banlen_h)
55 $duration .= $banlen_h;
56 }
57
58 $rpc = new RPC();
59 $rpc->set_method("user.get");
60 $rpc->set_params(["nick" => "$user"]);
61 $rpc->execute();
62 $nick = ($rpc->result) ? $rpc->fetch_assoc() : NULL;
63 if (!$nick)
64 {
65 Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?");
66 return;
67 }
68
69 $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for $duration";
70 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
71 if (rpc_tkl_add($user, $bantype, $duration, $reason))
72 {
73 $c = $nick['result']['client'];
74 Message::Success($c['name'] . " (*@".$c['hostname'].") has been $bantype" . "'d $msg_msg: $reason");
75 }
76 }
77 }
78
79 if (!empty($_POST['tklch']))
80 foreach ($_POST as $key => $value) {
81 foreach ($value as $tok) {
82 $tok = explode(",", $tok);
83 if (rpc_tkl_del(base64_decode($tok[0]), base64_decode($tok[1])))
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="">
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 <table class='users_overview'>
148 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
149 <th>Nick</th>
150 <th>UID</th>
151 <th>Host / IP</th>
152 <th>Account</th>
153 <th>Usermodes<a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
154 <th>Oper</th>
155 <th>Secure</th>
156 <th>Connected to</th>
157 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
158
159 <form action="" method="post">
160 <?php
161 foreach(RPC_List::$user as $user)
162 {
163
164 /* Some basic filtering */
165 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
166 strpos(strtolower($user['name']), strtolower($_POST['uf_nick'])) !== 0 &&
167 strpos(strtolower($user['name']), strtolower($_POST['uf_nick'])) == false)
168 continue;
169
170 echo "<tr>";
171 echo "<td><input type=\"checkbox\" value='" . base64_encode($user['id'])."' name=\"userch[]\"></td>";
172 echo "<td>".$user['name']."</td>";
173 echo "<td>".$user['id']."</td>";
174 echo "<td>".$user['hostname']." (".$user['ip'].")</td>";
175 $account = (isset($user['user']['account'])) ? '<span class="label">'.$user['user']['account'].'</span>' : '<span class="label noaccount">No account</span>';
176 echo "<td>".$account."</td>";
177 $modes = (isset($user['user']['modes'])) ? "+" . $user['user']['modes'] : "<none>";
178 echo "<td>".$modes."</td>";
179 $oper = (isset($user['user']['operlogin'])) ? $user['user']['operlogin']." <span class=\"label operclass-label\">".$user['user']['operclass']."</span>" : "";
180 echo "<td>".$oper."</td>";
181 $secure = (isset($user['tls'])) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label noaccount\">Insecure</span>";
182 echo "<td>".$secure."</td>";
183 echo "<td>".$user['user']['servername']."</td>";
184 echo "<td>".$user['user']['reputation']."</td>";
185 }
186 ?></table>
187 <label for="bantype">Apply action: </label><br>
188 <select name="bantype" id="bantype">
189 <option value=""></option>
190 <optgroup label="Bans">
191 <option value="gline">GLine</option>
192 <option value="gzline">GZLine</option>
193 </optgroup>
194 </select>
195 <br>
196 <label for="banlen_w">Duration: </label><br>
197 <select name="banlen_w" id="banlen_w">
198 <?php
199 for ($i = 0; $i <= 56; $i++)
200 {
201 if (!$i)
202 echo "<option value=\"0w\"></option>";
203 else
204 {
205 $w = ($i == 1) ? "week" : "weeks";
206 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
207 }
208 }
209 ?>
210 </select>
211 <select name="banlen_d" id="banlen_d">
212 <?php
213 for ($i = 0; $i <= 31; $i++)
214 {
215 if (!$i)
216 echo "<option value=\"0d\"></option>";
217 else
218 {
219 $d = ($i == 1) ? "day" : "days";
220 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
221 }
222 }
223 ?>
224 </select>
225 <select name="banlen_h" id="banlen_h">
226 <?php
227 for ($i = 0; $i <= 24; $i++)
228 {
229 if (!$i)
230 echo "<option value=\"0d\"></option>";
231 else
232 {
233 $h = ($i == 1) ? "hour" : "hours";
234 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
235 }
236 }
237 ?>
238 </select>
239 <br><label for="ban_reason">Reason:<br></label>
240 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
241 <input class="cute_button" type="submit" value="Apply">
242 </form>
243
244 </div></div>
245
246 <div class="tab-content\">
247 <div id="Channels" data-tab-content>
248 <p></p>
249 <table class='users_overview'>
250 <th>Name</th>
251 <th>Created</th>
252 <th>User count</th>
253 <th>Topic</th>
254 <th>Topic Set</th>
255 <th>Modes</th>
256
257 <?php
258 foreach(RPC_List::$channel as $channel)
259 {
260 echo "<tr>";
261 echo "<td>".$channel['name']."</td>";
262 echo "<td>".$channel['creation_time']."</td>";
263 echo "<td>".$channel['num_users']."</td>";
264 $topic = (isset($channel['topic'])) ? $channel['topic'] : "";
265 echo "<td>".$topic."</td>";
266 $setby = (isset($channel['topic'])) ? "By ".$channel['topic_set_by'] .", at ".$channel['topic_set_at'] : "";
267 echo "<td>".$setby."</td>";
268 $modes = (isset($channel['modes'])) ? "+" . $channel['modes'] : "<none>";
269 echo "<td>".$modes."</td>";
270 }
271 ?></table></div></div>
272
273
274 <div class="tab-content\">
275 <div id="TKL" data-tab-content>
276
277 <table class='users_overview'>
278 <form action="" method="post">
279 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
280 <th>Mask</th>
281 <th>Type</th>
282 <th>Set By</th>
283 <th>Set On</th>
284 <th>Expires</th>
285 <th>Duration</th>
286 <th>Reason</th>
287
288 <?php
289 foreach(RPC_List::$tkl as $tkl)
290 {
291 echo "<tr>";
292 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl['name']).",".base64_encode($tkl['type']) . "' name=\"tklch[]\"></td>";
293 echo "<td>".$tkl['name']."</td>";
294 echo "<td>".$tkl['type_string']."</td>";
295 echo "<td>".$tkl['set_by']."</td>";
296 echo "<td>".$tkl['set_at_string']."</td>";
297 echo "<td>".$tkl['expire_at_string']."</td>";
298 echo "<td>".$tkl['duration_string']."</td>";
299 echo "<td>".$tkl['reason']."</td>";
300 }
301 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
302
303
304 <div class="tab-content\">
305 <div id="Spamfilter" data-tab-content>
306 <p></p>
307 <table class='users_overview'>
308 <form action="" method="post">
309 <th><input type="checkbox" label='selectall' onClick="toggle_sf(this)" />Select all</th>
310 <th>Mask</th>
311 <th>Type</th>
312 <th>Set By</th>
313 <th>Set On</th>
314 <th>Expires</th>
315 <th>Duration</th>
316 <th>Match Type</th>
317 <th>Action</th>
318 <th>Action Duration</th>
319 <th>Target</th>
320 <th>Reason</th>
321
322 <?php
323 foreach(RPC_List::$spamfilter as $sf)
324 {
325 echo "<tr>";
326 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>";
327 echo "<td>".$sf['name']."</td>";
328 echo "<td>".$sf['type_string']."</td>";
329 echo "<td>".$sf['set_by']."</td>";
330 echo "<td>".$sf['set_at_string']."</td>";
331 echo "<td>".$sf['expire_at_string']."</td>";
332 echo "<td>".$sf['duration_string']."</td>";
333 echo "<td>".$sf['match_type']."</td>";
334 echo "<td>".$sf['ban_action']."</td>";
335 echo "<td>".$sf['ban_duration_string']."</td>";
336 for ($i = 0, $targs = ""; ($c = $sf['spamfilter_targets'][$i]); $i++)
337 {
338 if ($c == "c")
339 $targs .= "Channel, ";
340 else if ($c == "p")
341 $targs .= "Private,";
342 else if ($c == "n")
343 $targs .= "Notice, ";
344 else if ($c == "N")
345 $targs .= "Channel notice, ";
346 else if ($c == "P")
347 $targs .= "Part message, ";
348 else if ($c == "q")
349 $targs .= "Quit message, ";
350 else if ($c == "d")
351 $targs .= "DCC filename, ";
352 else if ($c == "a")
353 $targs .= "Away message, ";
354 else if ($c == "t")
355 $targs .= "Channel topic, ";
356 else if ($c == "T")
357 $targs .= "MessageTag, ";
358 else if ($c == "u")
359 $targs .= "Usermask, ";
360
361 $targs = rtrim($targs,", ");
362 }
363 echo "<td>".$targs."</td>";
364 echo "<td>".$sf['reason']."</td>";
365
366 }
367 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
368
369
370
371 <div class="tab-content\">
372 <div id="News" data-tab-content>
373 <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>
374 <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>
375 </div></div>
376
377 </body>