Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class adminsOnline {
- private static $eventName = 'adminsOnline';
- private static $config;
- private static $simpleConfig = array(
- 'write_channel' => 0,
- 'groups' => array()
- );
- 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()
- {
- self::loadConfig();
- return true;
- }
- private static function isClientInGroup($group,$clientGroups) {
- foreach ($clientGroups as $checkGroup) {
- if ($group == $checkGroup) {
- return $group;
- }
- }
- return false;
- }
- private static function format_seconds($seconds)
- {
- $uptime = array();
- $uptime['days']=floor($seconds / 86400);
- $uptime['hours']=floor(($seconds - ($uptime['days'] * 86400)) / 3600);
- $uptime['minutes']=floor(($seconds - (($uptime['days'] * 86400)+($uptime['hours']*3600))) / 60);
- $uptime['seconds']=floor(($seconds - (($uptime['days'] * 86400)+($uptime['hours']*3600)+($uptime['minutes'] * 60))));
- $uptime_text = '';
- if ($uptime['days'] > 0) {
- $uptime_text .= $uptime['days'] . ' ' . ($uptime['days'] == 1 ? 'dnia ' : 'dni ');
- }
- if ($uptime['hours'] > 0) {
- $uptime_text .= $uptime['hours'] . ' ' . ($uptime['hours'] == 1 ? 'godziny ' : 'godzin ');
- }
- if ($uptime['minutes'] > 0) {
- $uptime_text .= $uptime['minutes'] . ' ' . ($uptime['minutes'] == 1 ? 'minuty' : 'minut');
- }
- if ($uptime_text == '') {
- $uptime_text .= $uptime['seconds'] . ' sekund';
- }
- return $uptime_text;
- }
- public static function onThink()
- {
- global $lang, $ts, $whoami;
- $desc = '[center][b][size=15]SpeakCenter.pl[/size][/b]\n[size=10]Status Administracji[/size][/center]\n';
- $i=1;
- $admins = array();
- $channel = $ts->getElement($ts->getChannelList(),'data');
- $servergroups = $ts->getElement($ts->getServerGroupList(),'data');
- foreach ($ts->getElement($ts->getClientList('-groups -uid -away -voice -times'),'data') as $client) {
- $client_info = $ts->getElement($ts->getClientInfo($client['clid']),'data');
- $clientinfos[$client["clid"]] = $client_info['connection_connected_time'];
- if ($client['clid'] != $whoami['client_id']) {
- $clientGroups = explode(',',$client['client_servergroups']);
- foreach (self::$config['groups'] as $checkThisGroup) {
- $group = self::isClientInGroup($checkThisGroup,$clientGroups);
- if (is_numeric($group) == true && in_array($group,self::$config['groups']) == true) {
- $admins[$client['client_nickname']] = array('group' => $group, 'cid' => $client['cid'], 'clid' => $client['clid'], 'unique_id' => $client['client_unique_identifier'], 'idle' => $client['client_idle_time'], 'last_connect'=> $client['client_lastconnected'], 'away' => $client['client_away'], 'mute' => $client['client_output_muted']);
- }
- }
- }
- }
- foreach($channel as $channels){
- $channelname[$channels['cid']] = $channels['channel_name'];
- }
- foreach ($servergroups as $group) {
- if (in_array($group['sgid'],self::$config['groups']) == true) {
- foreach ($admins as $nickname => $values) {
- $status = '[color=green]Online[/color]';
- if ($values['away'] == 1 || $values['mute'] == 1) {
- $status = '[color=orange]Away[/color]';
- }
- if ($values['group'] == $group['sgid']) {
- $desc .= '[center][size=9][color=red][b]'.$group['name'].'[/b][/color] [b]:[/b] [URL=client://' . $values['clid'] . '/' . $values['unique_id'] . '][color=black]' . $nickname . '[/color][/URL]\n Status: [b]'.$status.'[/b]\n KanaĆ: [b][url=channelID://'.$values['cid'].']'.str_replace('[cspacer]', '', $channelname[$values['cid']]).'[/url][/b]\n Aktywny/a od: [b]'.self::format_seconds(time() - $values['last_connect']).'[/b] [/size][/center]\n\n';
- $i++;
- }
- }
- $desc .= '';
- }
- }
- $desc .= '\n[right][size=9][i]Ostatnia aktualizacja:[/i] [b]'.date('H:i', time()).'[/right]';
- $ts->editChannel(512, array(
- 'channel_name' => '[cspacer]Administracja Online: '.($i - 1 ).''
- )
- );
- $ts->editChannel(self::$config['write_channel'], array(
- 'channel_description' => $desc
- )
- );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement