예제 #1
1
    protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
    {
        $visitor = XenForo_Visitor::getInstance();
        if (XenForo_Permission::hasPermission($visitor['permissions'], 'moturdrn_gw2api', 'verified')) {
            require_once "library/Moturdrn/TS3GW2Auth/Includes/TeamSpeak3/ts3admin.class.php";
            $tsAdmin = new ts3admin(XenForo_Application::getOptions()->ts3gw2auth_ts3server, XenForo_Application::getOptions()->ts3gw2auth_ts3sqport);
            if ($tsAdmin->getElement('success', $tsAdmin->connect())) {
                $tsAdmin->login(XenForo_Application::getOptions()->ts3gw2auth_ts3username, XenForo_Application::getOptions()->ts3gw2auth_ts3password);
                $tsAdmin->selectServer(XenForo_Application::getOptions()->ts3gw2auth_ts3port);
            }
            $ts3server = array();
            $serverinfo = $tsAdmin->serverInfo();
            $ts3server['server_name'] = $serverinfo['data']['virtualserver_name'];
            $ts3server['connected_clients'] = $serverinfo['data']['virtualserver_clientsonline'];
            $channellist = $tsAdmin->channelList("-topic -flags -voice -limits -icon");
            $clientlist = $tsAdmin->clientList("-uid -away -voice -times -groups -info -country -icon -ip -badges");
            foreach ($channellist['data'] as $channelInfo) {
                $ts3server['channellist'][$channelInfo['cid']] = $channelInfo;
            }
            foreach ($clientlist['data'] as $clientInfo) {
                if ($clientInfo['client_type'] == 1) {
                    $this->subtractClient($ts3server['channellist'], $clientInfo['cid']);
                } else {
                    $ts3server['clientlist'][] = $clientInfo;
                }
            }
            $ts3server['channellist'] = $this->buildTree($ts3server['channellist']);
            $ts3server['clientlist'] = $this->array_orderby($ts3server['clientlist'], 'client_talk_power', SORT_DESC, 'client_nickname', SORT_ASC);
            $output = "";
            foreach ($ts3server['channellist'] as $channel) {
                $output .= $this->outputChannel($channel, $ts3server['clientlist']);
            }
            $tsOutput = <<<HTML
<b><a href="https://www.gunnars-hold.eu/resources/gunnars-hold-ts-information.10/" class='tschannellink'>* Connection & Server Details</a></b><br />
<b><a href='ts3server://ts3.gunnars-hold.eu/?port=9987' class='tschannellink'>* Or Click Here To Connect Now!</a></b><br /><br />
{$output}
HTML;
        } else {
            $tsOutput = 'You cannot view this item';
        }
        $renderTemplateObject->setParam('tsOutput', $tsOutput);
        return $renderTemplateObject->render();
    }