]> jfr.im git - irc/unrealircd/unrealircd-webpanel-plugins.git/blame - mute/index.php
Merge pull request #2 from ValwareIRC/main
[irc/unrealircd/unrealircd-webpanel-plugins.git] / mute / index.php
CommitLineData
dc618640
VL
1<?php
2
3require_once "../../inc/common.php";
4require_once "../../inc/header.php";
5require_once "../../inc/connection.php";
6
7global $rpc;
8if (!$rpc)
9{
10 Message::Fail("No RPC");
11 require_once "../../inc/footer.php";
12 return;
13}
14$unmuted = [];
15$e_unmuted = [];
16if (isset($_GET['unmute']))
17{
18 if ($_GET['unmute'] == "*")
19 {
20 $users = $rpc->query("mute.list")->list;
21 foreach($users as $user)
22 {
23 if ($rpc->query("mute.remove", ["nick" => $user->name]))
24 $unmuted[] = $user->name;
25 else
26 $e_unmuted[] = $user->name;
27 }
28 }
29 else
30 {
31 if ($rpc->query("mute.remove", ["nick" => $_GET['unmute']]))
32 $unmuted[] = $_GET['unmute'];
33 else
34 $e_unmuted[] = $_GET['unmute'];
35 }
36 if (!empty($unmuted))
37 Message::Success("Unmuted ".count($unmuted)." users");
38 if (!empty($e_unmuted))
39 Message::Fail("Could not unmute ".count($e_unmuted)." users");
40}
41function get_mute_version() : float|NULL
42{
43 global $rpc;
44 if (!$rpc)
45 return NULL;
46 $mods = $rpc->server()->module_list()->list;
47 foreach ($mods as $m)
48 {
49 if ($m->name != "third/mute2" && $m->name != "third/mute")
50 continue;
51
52 return (float)$m->version;
53 }
54 return NULL;
55}
56
57$users = $rpc->query("mute.list");
58if (get_mute_version() < 1.4)
59 Message::Fail("Need to be using module third/mute version 1.4 or later for this plugin to work");
60?>
61<h2>Muted Users</h2>
62A list of muted users (third/mute)
63<form>
64 <table class="mt-4 ml-3 table-sm table-primary table-striped">
65 <thead>
66 <th><button name='unmute' value='*' type='submit' class='mr-2 btn-sm btn-danger'>Clear All</button></th>
67 <th>Nick</th>
68 <th>Host/IP</th>
69 <th>Security Groups</th>
70 </thead>
71 <tbody>
72 <?php
73 foreach($users->list as $user)
74 {
75 $securitygroups = "";
76 foreach ($user->user->{"security-groups"} as $sg)
77 {
78 $securitygroups .= "<span class='mr-1 badge rounded-pill text-white bg-primary'>$sg</span>";
79 }
80 echo "<tr>
81 <td><button name='unmute' value='$user->id' type='submit' class='mr-2 btn-sm btn-danger'><b>Remove</b></button></td>
82 <td><a href=\"".get_config("base_url")."users/details.php?nick=".$user->id."\"><b>".$user->name."</b></a></td>
83 <td><a href=\"".get_config("base_url")."tools/ip-whois.php?ip=".$user->ip."\">".$user->ip."</a></td>
84 <td>$securitygroups</td>
85 </tr>";
86 }
87 ?>
88 </tbody>
89 </table>
90</form>
91<?php
92
93require_once "../../inc/footer.php";