]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - index.php
Make ban durations work
[irc/unrealircd/unrealircd-webpanel.git] / index.php
CommitLineData
896b6cdc 1<!DOCTYPE html>
26971737 2<link rel="icon" type="image/x-icon" href="/img/favicon.ico">
46b1c955 3<link href="css/unrealircd-admin.css" rel="stylesheet">
26971737 4<body class="body-for-sticky">
82f5bcbf 5<div id="headerContainer">
26971737 6<h2><a href="">UnrealIRCd</a> <small>Administration Panel</small></h2><br>
82f5bcbf 7</div>
709b97f3
VP
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>
26971737 15 <a data-tab-target="#News" href="#News">News</a>
709b97f3
VP
16</div>
17<?php
26971737
VP
18define('UPATH', dirname(__FILE__));
19include "config.php";
20include "Classes/class-log.php";
21include "Classes/class-message.php";
709b97f3 22include "Classes/class-rpc.php";
26971737 23do_log($_POST);
709b97f3 24
26971737 25if (!empty($_POST)) {
b063b4b2 26 if (!($bantype = $_POST['bantype'])) {
26971737
VP
27
28 } else if (!($users = $_POST["userch"])) {
29 Message::Fail("No user was specified");
30 } else {
31 foreach ($_POST["userch"] as $user) {
32 $user = base64_decode($user);
b063b4b2
VP
33 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
34 if (!$bantype)
35 {
36 Message::Fail("An error occured");
37 return;
38 }
39 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
40 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
41 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
42
43 $duration = "";
44 if (!$banlen_d && !$banlen_h && !$banlen_w)
45 $duration .= "0";
46
47 else
48 {
49 if ($banlen_w)
50 $duration .= $banlen_w;
51 if ($banlen_d)
52 $duration .= $banlen_d;
53 if ($banlen_h)
54 $duration .= $banlen_h;
55 }
56
57 $rpc = new RPC();
58 $rpc->set_method("user.get");
59 $rpc->set_params(["nick" => "$user"]);
60 $rpc->execute();
61 $nick = ($rpc->result) ? $rpc->fetch_assoc() : NULL;
62 if (!$nick)
63 {
64 Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?");
65 return;
66 }
67
68 $msg_msg = ($duration == 0) ? "permanently" : "for $duration";
69
70 if (rpc_tkl_add($user, $bantype, $duration, "You have been banned lol"))
71 {
72 $c = $nick['result']['client'];
73 Message::Success($c['name'] . " (*@".$c['hostname'].") has been $bantype" . "'d $msg_msg");
74 }
76200e36
VP
75 }
76 }
77
26971737
VP
78 if (!empty($_POST['tklch']))
79 foreach ($_POST as $key => $value) {
80 foreach ($value as $tok) {
81 $tok = explode(",", $tok);
b063b4b2
VP
82 if (rpc_tkl_del(base64_decode($tok[0]), base64_decode($tok[1])))
83 Message::Success(base64_decode($tok[1])." has been removed for ".base64_decode($tok[0]));
26971737
VP
84 }
85 }
86
87 if (!empty($_POST['sf']))
88 foreach ($_POST as $key => $value) {
89 foreach ($value as $tok) {
90 $tok = explode(",", $tok);
91 rpc_sf_del(base64_decode($tok[0]), base64_decode($tok[1]), base64_decode($tok[2]), base64_decode($tok[3]));
b063b4b2 92 Message::Success(base64_decode($tok[1])." has been added for ".base64_decode($tok[0]));
26971737
VP
93 }
94 }
95}
96
b063b4b2 97rpc_pop_lists();
709b97f3 98?>
82f5bcbf
VP
99
100<div class="tab-content\">
101<div id="overview" data-tab-content class="active">
896b6cdc
VP
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>
26971737 112 <form action="" method="post">
ef866d8c
VP
113 <div class="tab-content\">
114 <div id="Users" data-tab-content>
896b6cdc
VP
115 <p></p>
116 <table class='users_overview'>
26971737 117 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
896b6cdc
VP
118 <th>Nick</th>
119 <th>UID</th>
ef866d8c 120 <th>Host / IP</th>
896b6cdc
VP
121 <th>Account</th>
122 <th>Usermodes</th>
123 <th>Oper</th>
124 <th>Secure</th>
125 <th>Connected to</th>
26971737 126 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score">ℹī¸</a></th>
896b6cdc
VP
127
128 <?php
129 foreach(RPC_List::$user as $user)
130 {
131 echo "<tr>";
26971737 132 echo "<td><input type=\"checkbox\" value='" . base64_encode($user['id'])."' name=\"userch[]\"></td>";
896b6cdc
VP
133 echo "<td>".$user['name']."</td>";
134 echo "<td>".$user['id']."</td>";
135 echo "<td>".$user['hostname']." (".$user['ip'].")</td>";
76200e36 136 $account = (isset($user['user']['account'])) ? $user['user']['account'] : "";
896b6cdc
VP
137 echo "<td>".$account."</td>";
138 $modes = (isset($user['user']['modes'])) ? "+" . $user['user']['modes'] : "<none>";
139 echo "<td>".$modes."</td>";
140 $oper = (isset($user['user']['operlogin'])) ? $user['user']['operlogin']." (".$user['user']['operclass'].")" : "";
141 echo "<td>".$oper."</td>";
142 $secure = (isset($user['tls'])) ? "✅" : "❌";
143 echo "<td>".$secure."</td>";
144 echo "<td>".$user['user']['servername']."</td>";
145 echo "<td>".$user['user']['reputation']."</td>";
146 }
26971737
VP
147 ?></table>
148
149 <label for="bantype">Apply action:
150 <select name="bantype" id="bantype">
151 <option value=""></option>
152 <optgroup label="Bans">
153 <option value="gline">GLine</option>
154 <option value="gzline">GZLine</option>
155 </optgroup>
156 </select>
157 <br>
158 <label for="banlen_w">Duration:
159 <select name="banlen_w" id="banlen_w">
160 <?php
161 for ($i = 0; $i <= 56; $i++)
162 {
163 if (!$i)
164 echo "<option value=\"0w\"></option>";
165 else
166 {
167 $w = ($i == 1) ? "week" : "weeks";
168 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
169 }
170 }
171 ?>
172 </select>
173 <select name="banlen_d" id="banlen_d">
174 <?php
175 for ($i = 0; $i <= 31; $i++)
176 {
177 if (!$i)
178 echo "<option value=\"0d\"></option>";
179 else
180 {
181 $d = ($i == 1) ? "day" : "days";
182 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
183 }
184 }
185 ?>
186 </select>
187 <select name="banlen_h" id="banlen_h">
188 <?php
189 for ($i = 0; $i <= 24; $i++)
190 {
191 if (!$i)
192 echo "<option value=\"0d\"></option>";
193 else
194 {
195 $h = ($i == 1) ? "hour" : "hours";
196 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
197 }
198 }
199 ?>
200 </select>
201 <br>
202 <input type="submit" value="Apply">
203 </form>
204
205 </div></div>
82f5bcbf 206
ef866d8c
VP
207 <div class="tab-content\">
208 <div id="Channels" data-tab-content>
209 <p></p>
210 <table class='users_overview'>
211 <th>Name</th>
212 <th>Created</th>
213 <th>User count</th>
214 <th>Topic</th>
215 <th>Topic Set</th>
216 <th>Modes</th>
217
218 <?php
219 foreach(RPC_List::$channel as $channel)
220 {
221 echo "<tr>";
222 echo "<td>".$channel['name']."</td>";
223 echo "<td>".$channel['creation_time']."</td>";
224 echo "<td>".$channel['num_users']."</td>";
225 $topic = (isset($channel['topic'])) ? $channel['topic'] : "";
226 echo "<td>".$topic."</td>";
227 $setby = (isset($channel['topic'])) ? "By ".$channel['topic_set_by'] .", at ".$channel['topic_set_at'] : "";
228 echo "<td>".$setby."</td>";
229 $modes = (isset($channel['modes'])) ? "+" . $channel['modes'] : "<none>";
230 echo "<td>".$modes."</td>";
231 }
232 ?></table></div></div>
233
234
235 <div class="tab-content\">
236 <div id="TKL" data-tab-content>
76200e36 237
ef866d8c 238 <table class='users_overview'>
76200e36 239 <form action="" method="post">
26971737 240 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
ef866d8c
VP
241 <th>Mask</th>
242 <th>Type</th>
243 <th>Set By</th>
244 <th>Set On</th>
245 <th>Expires</th>
246 <th>Duration</th>
247 <th>Reason</th>
248
249 <?php
250 foreach(RPC_List::$tkl as $tkl)
251 {
252 echo "<tr>";
76200e36 253 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl['name']).",".base64_encode($tkl['type']) . "' name=\"tklch[]\"></td>";
ef866d8c
VP
254 echo "<td>".$tkl['name']."</td>";
255 echo "<td>".$tkl['type_string']."</td>";
256 echo "<td>".$tkl['set_by']."</td>";
257 echo "<td>".$tkl['set_at_string']."</td>";
258 echo "<td>".$tkl['expire_at_string']."</td>";
259 echo "<td>".$tkl['duration_string']."</td>";
260 echo "<td>".$tkl['reason']."</td>";
261 }
76200e36 262 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
ef866d8c
VP
263
264
265 <div class="tab-content\">
266 <div id="Spamfilter" data-tab-content>
267 <p></p>
268 <table class='users_overview'>
26971737
VP
269 <form action="" method="post">
270 <th><input type="checkbox" label='selectall' onClick="toggle_sf(this)" />Select all</th>
ef866d8c
VP
271 <th>Mask</th>
272 <th>Type</th>
273 <th>Set By</th>
274 <th>Set On</th>
275 <th>Expires</th>
276 <th>Duration</th>
277 <th>Match Type</th>
278 <th>Action</th>
279 <th>Action Duration</th>
280 <th>Target</th>
281 <th>Reason</th>
282
283 <?php
284 foreach(RPC_List::$spamfilter as $sf)
285 {
286 echo "<tr>";
26971737 287 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>";
ef866d8c
VP
288 echo "<td>".$sf['name']."</td>";
289 echo "<td>".$sf['type_string']."</td>";
290 echo "<td>".$sf['set_by']."</td>";
291 echo "<td>".$sf['set_at_string']."</td>";
292 echo "<td>".$sf['expire_at_string']."</td>";
293 echo "<td>".$sf['duration_string']."</td>";
294 echo "<td>".$sf['match_type']."</td>";
295 echo "<td>".$sf['ban_action']."</td>";
296 echo "<td>".$sf['ban_duration_string']."</td>";
297 for ($i = 0, $targs = ""; ($c = $sf['spamfilter_targets'][$i]); $i++)
298 {
299 if ($c == "c")
300 $targs .= "Channel, ";
301 else if ($c == "p")
302 $targs .= "Private,";
303 else if ($c == "n")
304 $targs .= "Notice, ";
305 else if ($c == "N")
306 $targs .= "Channel notice, ";
307 else if ($c == "P")
308 $targs .= "Part message, ";
309 else if ($c == "q")
310 $targs .= "Quit message, ";
311 else if ($c == "d")
312 $targs .= "DCC filename, ";
313 else if ($c == "a")
314 $targs .= "Away message, ";
315 else if ($c == "t")
316 $targs .= "Channel topic, ";
317 else if ($c == "T")
318 $targs .= "MessageTag, ";
319 else if ($c == "u")
320 $targs .= "Usermask, ";
321
322 $targs = rtrim($targs,", ");
323 }
324 echo "<td>".$targs."</td>";
325 echo "<td>".$sf['reason']."</td>";
326
327 }
26971737
VP
328 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
329
330
331
332 <div class="tab-content\">
333 <div id="News" data-tab-content>
334 <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>
335 <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>
336 </div></div>
ef866d8c 337
896b6cdc 338</body>