]>
Commit | Line | Data |
---|---|---|
709b97f3 | 1 | <?php |
26971737 VP |
2 | /** |
3 | * RPC Functionality for UnrealIRCd Admin Webpanel | |
4 | * License: GPLv3 or later | |
02c4da66 VP |
5 | * Author: ValwareIRC |
6 | * GitHub URI: ValwareIRC/unrealircd-webpanel | |
26971737 VP |
7 | * 2023 |
8 | */ | |
9 | ||
709b97f3 | 10 | if (!defined('UPATH')) |
3e57758a | 11 | die("Access denied"); |
709b97f3 | 12 | |
03ddd26b | 13 | require UPATH . '/vendor/autoload.php'; |
709b97f3 | 14 | |
03ddd26b | 15 | use UnrealIRCd\Connection; |
0d0013bb BM |
16 | use UnrealIRCd\User; |
17 | use UnrealIRCd\Channel; | |
709b97f3 VP |
18 | |
19 | class RPC_List | |
20 | { | |
3e57758a VP |
21 | static $user = []; |
22 | static $channel = []; | |
23 | static $tkl = []; | |
24 | static $spamfilter = []; | |
c1ce40a2 VP |
25 | static $server = []; |
26 | static $nameban = []; | |
27 | static $exception = []; | |
709b97f3 VP |
28 | |
29 | static $opercount = 0; | |
30 | static $services_count = 0; | |
31 | static $most_populated_channel = NULL; | |
32 | static $channel_pop_count = 0; | |
33 | } | |
34 | ||
35 | function rpc_pop_lists() | |
36 | { | |
03ddd26b | 37 | GLOBAL $rpc; |
709b97f3 VP |
38 | |
39 | /* Get the user list */ | |
0d0013bb | 40 | $ret = $rpc->user()->getAll(); |
03ddd26b | 41 | // TODO: error checking |
709b97f3 | 42 | |
17311eb0 | 43 | foreach($ret as $r) |
709b97f3 | 44 | { |
03ddd26b BM |
45 | RPC_List::$user[] = $r; |
46 | if (strpos($r->user->modes,"o") !== false && strpos($r->user->modes,"S") == false) | |
47 | RPC_List::$opercount++; | |
48 | elseif (strpos($r->user->modes,"S") !== false) | |
49 | RPC_List::$services_count++; | |
709b97f3 VP |
50 | } |
51 | ||
52 | /* Get the channels list */ | |
0d0013bb | 53 | $ret = $rpc->channel()->getAll(); |
17311eb0 | 54 | foreach($ret as $r) |
709b97f3 | 55 | { |
03ddd26b BM |
56 | RPC_List::$channel[] = $r; |
57 | if ($r->num_users > RPC_List::$channel_pop_count) | |
709b97f3 | 58 | { |
03ddd26b BM |
59 | RPC_List::$channel_pop_count = $r->num_users; |
60 | RPC_List::$most_populated_channel = $r->name; | |
709b97f3 | 61 | } |
709b97f3 VP |
62 | } |
63 | ||
709b97f3 | 64 | /* Get the tkl list */ |
0d0013bb | 65 | $ret = $rpc->serverban()->getAll(); |
17311eb0 | 66 | foreach($ret as $r) |
03ddd26b | 67 | RPC_List::$tkl[] = $r; |
709b97f3 | 68 | |
03ddd26b | 69 | /* Get the spamfilter list */ |
6cfe0ee0 | 70 | $ret = $rpc->spamfilter()->getAll(); |
17311eb0 | 71 | foreach($ret as $r) |
03ddd26b | 72 | RPC_List::$spamfilter[] = $r; |
c1ce40a2 VP |
73 | |
74 | foreach ($rpc->nameban()->getAll() as $r) | |
75 | RPC_List::$nameban[] = $r; | |
76 | ||
77 | foreach ($rpc->serverbanexception()->getAll() as $r) | |
78 | RPC_List::$exception[] = $r; | |
79 | ||
80 | foreach ($rpc->server()->getAll() as $r) | |
81 | RPC_List::$server[] = $r; | |
76200e36 VP |
82 | } |
83 | ||
ffd01497 VP |
84 | /** Convert the duration_string */ |
85 | function rpc_convert_duration_string($str) | |
86 | { | |
87 | $tok = explode("w", $str); | |
88 | $weeks = $tok[0]; | |
89 | $tok = explode("d", $tok[1]); | |
90 | $days = $tok[0]; | |
91 | $tok = explode("h", $tok[1]); | |
92 | $hours = $tok[0]; | |
93 | return "$weeks weeks, $days days and $hours hours"; | |
94 | ||
709b97f3 | 95 | } |