Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class poke_adminsmc
- {
- private static $eventName = 'poke_adminsmc';
- private static $config;
- private static $simpleConfig = [];
- private static $cacheNames = ['help_clients' => 'messaged_client'];
- private static function loadConfig()
- {
- global $lang;
- $cfg = getEventConfigValue(self::$eventName);
- if ($cfg != false)
- {
- self::$config = $cfg;
- }
- else
- {
- self::$config = self::$simpleConfig;
- echo ": > [".self::$eventName."]: ".$lang->getConsoleLanguage('SIMPLE_CONFIGURATION')."\n";
- }
- return true;
- }
- public static function onRegister()
- {
- global $cache;
- self::loadConfig();
- $cache->setCache(self::$cacheNames['help_clients'], []);
- return true;
- }
- private static function checkGroups($invokerid, $cid)
- {
- if (isset(self::$config['groups_poke'][$cid]))
- {
- $clientGroups = explode(',',$invokerid['client_servergroups']);
- foreach ($clientGroups as $clientGroup)
- {
- if (in_array($clientGroup, self::$config['groups_poke'][$cid]) == true)
- {
- return true;
- }
- }
- }
- return false;
- }
- private static function isClientInGroup($group, $clientGroups)
- {
- foreach ($clientGroups as $checkGroup)
- {
- if ($group == $checkGroup)
- {
- return $group;
- }
- }
- return false;
- }
- public static function adminsData($config)
- {
- global $ts;
- $i = 0;
- $admins = [];
- $servergroups = $ts->getElement($ts->getServerGroupList(),'data');
- foreach ($ts->getElement($ts->getClientList('-groups -uid -away -voice -times'),'data') as $client)
- {
- $clientGroups = explode(',',$client['client_servergroups']);
- foreach ($config as $checkThisGroup)
- {
- if(in_array($checkThisGroup, $clientGroups))
- {
- $admins[] = '[URL=client://' . $client['clid'] . '/' . $client['client_unique_identifier'] . '~'.urlencode($client['client_nickname']).']' . $client['client_nickname'] . '[/URL]';
- $i++;
- }
- }
- }
- return ['admins' => implode(',', $admins), 'count' => $i];
- }
- private static function isAdminOnChannel($clientsData)
- {
- foreach ($clientsData as $user)
- {
- if (self::checkGroups($user, $user['cid']) == true && in_array($user['cid'], self::$config['onClientAreOnChannel']) == true)
- {
- return true;
- }
- }
- return false;
- }
- public static function onClientAreOnChannel($clid = null, $cid = null, $invokerid = null, $clientsData = null)
- {
- global $ts, $kernel, $lang, $cache;
- $client = $ts->getElement($ts->getClientInfo($clid),'data');
- if (self::checkGroups($client, $client['cid']) == false && $client['client_is_talker'] == 0 && self::isAdminOnChannel($clientsData) == false)
- {
- if ($client['client_away'] != 0 or $client['client_input_muted'] != 0 or $client['client_output_muted'] != 0 or $client['client_output_hardware'] != 1)
- {
- $ts->sendMessage(1, $clid, $lang->getLanguage('PA_KICK_MSG'));
- $ts->kickClient($clid, $lang->getLanguage('PA_KICK_MSG'), 'channel');
- return true;
- }
- $pokes = 0;
- foreach ($clientsData as $aclient)
- {
- if (self::checkGroups($aclient, $client['cid']) == true && $aclient['client_away'] == 0)
- {
- if (!in_array($aclient['cid'], self::$config['ignored_channel']))
- {
- if(self::$config['type'] == 'poke')
- {
- $ts->pokeClient($aclient['clid'],$lang->langReplace('[USER_NAME]',$client['client_nickname'], 'PA_POKE_MSG'));
- $pokes++;
- }
- else if(self::$config['type'] == 'pw')
- {
- $ts->sendMessage(1,$aclient['clid'],$lang->langReplace('[USER_NAME]',$client['client_nickname'], 'PA_POKE_MSG'));
- $pokes++;
- }
- }
- }
- }
- $informations = self::adminsData(self::$config['groups_poke'][$cid]);
- $channelInfo = $ts->getElement($ts->getChannelInfo($client['cid']), 'data');
- if ($pokes > 0)
- {
- $ts->sendMessage(1, $clid, $lang->langReplace(["[COUNT]", "[ADMINS]", "[CH_ID]", "[CH_NAME]"], [$informations['count'], $informations['admins'], $cid, $channelInfo['channel_name']], 'PA_USER_MSG'));
- }
- else
- {
- $ts->sendMessage(1, $clid, $lang->getLanguage('PA_USER_MSG_NOADMINS'));
- }
- }
- return true;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement