]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | /** | |
3 | * RPC Functionality for UnrealIRCd Admin Webpanel | |
4 | * License: GPLv3 or later | |
5 | * Author: ValwareIRC | |
6 | * GitHub URI: ValwareIRC/unrealircd-webpanel | |
7 | * 2023 | |
8 | */ | |
9 | ||
10 | if (!defined('UPATH')) | |
11 | die("Access denied"); | |
12 | ||
13 | require UPATH . '/vendor/autoload.php'; | |
14 | ||
15 | use UnrealIRCd\Connection; | |
16 | use UnrealIRCd\User; | |
17 | use UnrealIRCd\Channel; | |
18 | ||
19 | class RPC_List | |
20 | { | |
21 | static $user = []; | |
22 | static $channel = []; | |
23 | static $tkl = []; | |
24 | static $spamfilter = []; | |
25 | static $server = []; | |
26 | static $nameban = []; | |
27 | static $exception = []; | |
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 | { | |
37 | GLOBAL $rpc; | |
38 | ||
39 | /* Get the user list */ | |
40 | $ret = $rpc->user()->getAll(); | |
41 | // TODO: error checking | |
42 | ||
43 | foreach($ret as $r) | |
44 | { | |
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++; | |
50 | } | |
51 | ||
52 | /* Get the channels list */ | |
53 | $ret = $rpc->channel()->getAll(); | |
54 | foreach($ret as $r) | |
55 | { | |
56 | RPC_List::$channel[] = $r; | |
57 | if ($r->num_users > RPC_List::$channel_pop_count) | |
58 | { | |
59 | RPC_List::$channel_pop_count = $r->num_users; | |
60 | RPC_List::$most_populated_channel = $r->name; | |
61 | } | |
62 | } | |
63 | ||
64 | /* Get the tkl list */ | |
65 | $ret = $rpc->serverban()->getAll(); | |
66 | foreach($ret as $r) | |
67 | RPC_List::$tkl[] = $r; | |
68 | ||
69 | /* Get the spamfilter list */ | |
70 | $ret = $rpc->spamfilter()->getAll(); | |
71 | foreach($ret as $r) | |
72 | RPC_List::$spamfilter[] = $r; | |
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; | |
82 | } | |
83 | ||
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 | ||
95 | } |