function __construct()
 {
     $this->setTitle('Network Graph');
     $this->barsFrame = new Frame();
     $this->barsFrame->setLayout(new Line());
     $this->addComponent($this->barsFrame);
     $this->linesFrame = new Frame();
     $this->addComponent($this->linesFrame);
     $heightStep = ($this->sizeY - 6) / 4;
     for ($i = 1; $i <= 4; ++$i) {
         $ui = new Frame();
         $ui->setPosition(0, $i * $heightStep);
         $line = new Quad();
         $line->setBgcolor('fff');
         $line->setSize($this->sizeX - 2, 0.2);
         $ui->addComponent($line);
         $text = new Label();
         $text->setText('$fff0 kb/s');
         $text->setPosition(3, 3.5);
         $ui->addComponent($text);
         $this->linesFrame->addComponent($ui);
         $this->lines[] = array($line, $text, $ui);
     }
     Dispatcher::register(MonitorEvent::getClass(), $this, MonitorEvent::ON_NEW_NETWORK_VALUE);
 }
 function __construct()
 {
     $this->setTitle('Speed Graph');
     $this->barsFrame = new Frame(1, 1 - $this->sizeY, new Line());
     $this->addComponent($this->barsFrame);
     $this->criticalLineFrame = new Frame(0, 1 + self::RESPONSE_MINIMAL * ($this->sizeY - 6) / self::RESPONSE_OPTIMAL - $this->sizeY);
     $text = new Label(75, 3);
     $text->setTextColor('fff');
     $text->setText('Critical Response Time (1/' . self::RESPONSE_MINIMAL . ' Second)');
     $text->setPosition(3, 3.5);
     $text->setTextSize(2);
     $this->criticalLineFrame->addComponent($text);
     $this->criticalLine = new Quad($this->sizeX - 2, 0.2);
     $this->criticalLine->setBgcolor('a00');
     $this->criticalLine->setPosX(1);
     $this->criticalLine->setValign('center');
     $this->criticalLineFrame->addComponent($this->criticalLine);
     $this->addComponent($this->criticalLineFrame);
     $this->optimalLineFrame = new Frame(0, -5);
     $text = new Label(75, 3);
     $text->setTextColor('fff');
     $text->setText('Optimal Response Time (1/' . self::RESPONSE_OPTIMAL . ' Second)');
     $text->setPosition(3, 3.5);
     $text->setTextSize(2);
     $this->optimalLineFrame->addComponent($text);
     $this->optimalLine = new Quad($this->sizeX - 2, 0.2);
     $this->optimalLine->setBgcolor('0a0');
     $this->optimalLine->setPosX(1);
     $this->optimalLine->setValign('bottom');
     $this->optimalLineFrame->addComponent($this->optimalLine);
     $this->addComponent($this->optimalLineFrame);
     Dispatcher::register(MonitorEvent::getClass(), $this, MonitorEvent::ON_NEW_CPU_VALUE);
 }
Exemple #3
0
 protected function __construct()
 {
     $this->identifier = 'ManiaLive ' . \ManiaLiveApplication\Version;
     $config = Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
     Dispatcher::register(Event::getClass(), $this, Event::ON_ECHO);
 }
 public function onLoad()
 {
     $this->enableDedicatedEvents();
     \ManiaLive\Event\Dispatcher::register(\ManiaLivePlugins\NadeoLive\XmlRpcScript\Event::getClass(), $this);
     $this->connection->setModeScriptSettings(array('S_UseScriptCallbacks' => true));
     $this->postTwitterMessage(sprintf('Now following %s', $this->storage->server->name));
 }
 protected function __construct()
 {
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_PLAYER_CHAT);
     $command = new Command('help', 0);
     $command->addLoginAsFirstParameter = true;
     $command->log = false;
     $command->help = 'Display all visible commands to a player it takes no parameter';
     $command->callback = array($this, 'help');
     $this->register($command);
     $command = new Command('man', 1);
     $command->addLoginAsFirstParameter = true;
     $command->help = 'Display help for every commands you give as parameter' . "\n" . 'exemple of usage: /man man';
     $command->isPublic = true;
     $command->log = false;
     $command->callback = array($this, 'man');
     $this->register($command);
     $command = new Command('man', 2);
     $command->addLoginAsFirstParameter = true;
     $command->help = 'Display help for the command with the corresponding parameters' . "\n" . 'exemple of usage: /man man 2';
     $command->isPublic = true;
     $command->log = false;
     $command->callback = array($this, 'man');
     $this->register($command);
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
 }
 function __construct()
 {
     $this->setTitle('Memory Graph');
     $this->memoryLimit = intval(str_replace('M', 1024 * 1024, ini_get('memory_limit')));
     if ($this->memoryLimit == -1) {
         $this->memoryLimit = Profiler::MEM_DEFAULT;
     }
     $this->barsFrame = new Frame();
     $this->barsFrame->setLayout(new Line());
     $this->addComponent($this->barsFrame);
     $this->linesFrame = new Frame();
     $this->addComponent($this->linesFrame);
     $heightStep = ($this->sizeY - 6) / 4;
     for ($i = 1; $i <= 4; ++$i) {
         $ui = new Frame();
         $ui->setPosition(0, $i * $heightStep);
         $line = new Quad();
         $line->setBgcolor('fff');
         $line->setSize($this->sizeX - 2, 0.2);
         $ui->addComponent($line);
         $text = new Label();
         $text->setText('$fff0% of total');
         $text->setPosition(3, 3.5);
         $ui->addComponent($text);
         $this->linesFrame->addComponent($ui);
         $this->lines[] = array($line, $text, $ui);
     }
     Dispatcher::register(MonitorEvent::getClass(), $this, MonitorEvent::ON_NEW_MEMORY_VALUE);
 }
 protected function __construct($lobbyLogin, $scriptName, $titleIdString)
 {
     $config = \ManiaLive\Database\Config::getInstance();
     $this->db = Connection::getConnection($config->host, $config->username, $config->password, $config->database, $config->type, $config->port);
     Dispatcher::register(Event::getClass(), $this, Event::ON_PLAYER_ALLIES_CHANGED | Event::ON_PLAYER_CONNECT | Event::ON_PLAYER_DISCONNECT);
     $this->lobbyLogin = $lobbyLogin;
     $this->scriptName = $scriptName;
     $this->titleIdString = $titleIdString;
     $this->createTable();
 }
 function start()
 {
     $this->running = true;
     $this->loopStart = microtime(true);
     $this->loopCount = 0;
     $this->tickCount = 0;
     $this->lastNetwork = array(Client::$received, Client::$sent);
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_PRE_LOOP);
     Dispatcher::register(TickEvent::getClass(), $this);
 }
 function open()
 {
     $config = Config::getInstance();
     try {
         $this->server = TeamSpeak3::factory('serverquery://' . $config->queryLogin . ':' . $config->queryPassword . '@' . $config->queryHost . ':' . $config->queryPort . '/?server_port=' . $config->voicePort . '&blocking=0#no_query_clients');
         $this->server->execute('instanceedit', array('serverinstance_serverquery_flood_commands' => 20, 'serverinstance_serverquery_flood_time' => 1, 'serverinstance_serverquery_flood_ban_time' => 1));
     } catch (\Exception $e) {
         $this->server = null;
         return;
     }
     // Threading is really useful for this plugin !!!
     $this->processHandler = ThreadHandler::getInstance();
     $this->processId = $this->processHandler->launchThread();
     // Enable events (from ML and from TS)
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_PRE_LOOP);
     Dispatcher::register(TickEvent::getClass(), $this);
     $this->server->notifyRegister('channel');
     // Find players group id or create a new group for privilege keys
     foreach ($this->server->serverGroupList() as $group) {
         if ($group['name'] == 'ManiaPlanet Player') {
             $this->playersGroupId = $group['sgid'];
             break;
         }
     }
     $this->server->serverGroupListReset();
     if (!$this->playersGroupId) {
         $this->playersGroupId = $this->server->serverGroupCreate('ManiaPlanet Player');
         foreach ($config->groupPermissions as $permission => $value) {
             $this->server->serverGroupPermAssign($this->playersGroupId, $permission, $value);
         }
     } else {
         // Find existing tokens to avoid duplicates
         try {
             foreach ($this->server->privilegeKeyList() as $token => $tokenInfo) {
                 if (!$tokenInfo['token_type'] && $tokenInfo['token_id1'] == $this->playersGroupId && preg_match('/`([a-z\\._-]{1,25})`$/', $tokenInfo['token_description'], $matches)) {
                     $this->privilegeKeys[$matches[1]] = $token;
                 }
             }
         } catch (\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception $e) {
             /* thanks for launching exception instead of just returning an empty array... */
         }
     }
     // Populate
     foreach ($this->server->channelList() as $channel) {
         new Channel($channel, $this->getChannelPermissionList($channel));
     }
     foreach ($this->server->clientList() as $client) {
         new Client($client, $this->getCustomInfo($client));
     }
     // Handle default channels
     $this->createChannelsIFN();
 }
 protected function __construct()
 {
     $this->modalBg = new Bgs1(340, 200);
     $this->modalBg->setSubStyle(Bgs1::BgDialogBlur);
     $this->modalBg->setAlign('center', 'center');
     $this->modalBg->setPosZ(Window::Z_MODAL);
     $this->modalBg->setScriptEvents();
     $this->nextLoop = microtime(true);
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ALL & ~AppEvent::ON_POST_LOOP);
     Dispatcher::register(PlayerEvent::getClass(), $this, PlayerEvent::ON_PLAYER_CHANGE_SIDE);
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT);
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
 }
 protected function __construct()
 {
     $this->enabled = extension_loaded('mysql') && Config::getInstance()->enabled;
     if ($this->enabled) {
         $this->setUpDatabase();
         $this->setData('config', \ManiaLive\Config\Config::getInstance());
         $this->setData('wsapi', \ManiaLive\Features\WebServices\Config::getInstance());
         $this->setData('manialive', \ManiaLive\Application\Config::getInstance());
         $this->setData('server', \ManiaLive\DedicatedApi\Config::getInstance());
         $this->setData('threading', \ManiaLive\Threading\Config::getInstance());
     } else {
         Logger::debug('Application started with threading disabled!', true, array('Process #' . getmypid()));
         $this->buffers[0] = array();
     }
     Dispatcher::register(TickEvent::getClass(), $this);
 }
 protected function connect($database)
 {
     // Connection
     try {
         $this->connection = mysql_connect($this->host, $this->user, $this->password);
     } catch (\ErrorException $err) {
         throw new ConnectionException($err->getMessage(), $err->getCode());
     }
     // Success ?
     if (!$this->connection) {
         throw new ConnectionException();
     }
     $this->select($database);
     // Default Charset : UTF8
     $this->setCharset('utf8');
     Dispatcher::register(TickEvent::getClass(), $this);
 }
Exemple #13
0
 function __construct()
 {
     $this->setTitle('Overview');
     $this->memoryLimit = str_replace('M', 1024 * 1024, ini_get('memory_limit'));
     if ($this->memoryLimit < 0) {
         $this->memoryLimit = Profiler::MEM_DEFAULT;
     }
     $this->leftLabel = new Label();
     $this->leftLabel->setStyle(Label::TextCardSmallScores2Rank);
     $this->leftLabel->enableAutonewline();
     $this->leftLabel->setPosition(1, -1);
     $this->addComponent($this->leftLabel);
     $this->rightLabel = new Label();
     $this->rightLabel->setStyle(Label::TextCardSmallScores2Rank);
     $this->rightLabel->enableAutonewline();
     $this->addComponent($this->rightLabel);
     Dispatcher::register(MonitorEvent::getClass(), $this, MonitorEvent::ON_NEW_CPU_VALUE);
 }
 function __construct()
 {
     $this->setTitle('Plugins');
     $this->pluginItems = array();
     $this->managerButton = new Button();
     $this->managerButton->setHalign('center');
     $this->managerButton->setStyle(Button::CardButtonSmallWide);
     $this->managerButton->setText('click here to manage your plugins');
     $this->managerButton->setAction(ActionHandler::getInstance()->createAction(array($this, 'showPluginManager')));
     $this->addComponent($this->managerButton);
     $this->pluginsPager = new Pager();
     $this->pluginsPager->setStretchContentX(true);
     $this->addComponent($this->pluginsPager);
     foreach (PluginHandler::getInstance()->getLoadedPluginsList() as $plugin) {
         $this->onPluginLoaded($plugin);
     }
     Dispatcher::register(PluginEvent::getClass(), $this);
 }
Exemple #15
0
 /**
  * Start listen for plugin events like
  * onPluginLoaded and onPluginUnloaded
  */
 protected final function enablePluginEvents($events = PluginEvent::ALL)
 {
     $this->restrictIfUnloaded();
     Dispatcher::register(PluginEvent::getClass(), $this, $events & ~$this->eventsPlugins);
     $this->eventsPlugins |= $events;
 }
 protected function __construct()
 {
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_PLAYER_MANIALINK_PAGE_ANSWER);
 }
Exemple #17
0
 /**
  * Set the time before the interface will be hidden
  * @param $seconds
  */
 public function setTimeout($seconds)
 {
     $this->timeout = time() + $seconds;
     Dispatcher::register(TickEvent::getClass(), $this);
 }
 protected function __construct()
 {
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_INIT | AppEvent::ON_TERMINATE);
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_SERVER_START | ServerEvent::ON_SERVER_STOP);
 }
Exemple #19
0
 protected function __construct()
 {
     $this->lastDisplayed = 0;
     Dispatcher::register(TickEvent::getClass(), $this);
 }
 function onLoad()
 {
     //Check if Lobby is not running with the match plugin
     if ($this->isPluginLoaded('\\ManiaLivePlugins\\MatchMakingLobby\\Match\\Plugin')) {
         throw new \Exception('Lobby and match cannot be one the same server.');
     }
     $this->enableDedicatedEvents(ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT | ServerEvent::ON_MODE_SCRIPT_CALLBACK | ServerEvent::ON_BEGIN_MAP);
     $this->enableStorageEvents(StorageEvent::ON_PLAYER_CHANGE_SIDE | StorageEvent::ON_PLAYER_JOIN_GAME);
     /** Register to Ally Service Event */
     \ManiaLive\Event\Dispatcher::register(Services\AllyEvent::getClass(), $this);
     $matchSettingsClass = $this->config->getMatchSettingsClassName($this->scriptName);
     /* @var $matchSettings \ManiaLivePlugins\MatchMakingLobby\MatchSettings\MatchSettings */
     if (!class_exists($matchSettingsClass)) {
         throw new \Exception(sprintf("Can't find class %s. You should set up the config : ManiaLivePlugins\\MatchMakingLobby\\Config.matchSettingsClassName", $matchSettingsClass));
     }
     $this->titleIdString = $this->connection->getSystemInfo()->titleId;
     $this->backLink = $this->storage->serverLogin . ':' . $this->storage->server->password . '@' . $this->titleIdString;
     $this->registerLobby();
     $this->setLobbyInfo();
     $partySize = $this->matchMaker->getNumberOfTeam() ? (int) $this->matchMaker->getPlayersPerMatch() / $this->matchMaker->getNumberOfTeam() : 1;
     $this->gui->createWaitingScreen(\ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerReady')), $this->scriptName, $partySize, $this->config->rulesManialink, $this->config->logoURL, $this->config->logoLink);
     $this->gui->configurePlayerList($partySize > 1 ? true : false);
     foreach (array_merge($this->storage->players, $this->storage->spectators) as $login => $obj) {
         //Simulate player connection
         $this->onPlayerConnect($login, null);
     }
     $this->updatePlayerList = true;
     $matchSettings = new $matchSettingsClass();
     $settings = $matchSettings->getLobbyScriptSettings();
     $this->connection->setModeScriptSettings($settings);
     $this->enableTickerEvent();
     $this->connection->setCallVoteRatiosEx(false, array(new Structures\VoteRatio('SetModeScriptSettingsAndCommands', -1.0), new Structures\VoteRatio('NextMap', -1.0), new Structures\VoteRatio('JumpToMapIndex', -1.0), new Structures\VoteRatio('SetNextMapIndex', -1.0), new Structures\VoteRatio('RestartMap', -1.0)));
     $this->updateLobbyWindow();
     //$this->gui->showHelp($this->scriptName);
     if ($this->config->showMasters) {
         $this->gui->createMasterList();
         $this->updateMasterList();
     }
     $this->connection->disableServiceAnnounces(true);
     $this->registerChatCommand('setAllReady', 'onSetAllReady', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('kickNonReady', 'onKickNotReady', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('resetPenalty', 'onResetPenalty', 1, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('resetAllPenalties', 'onResetAllPenalties', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('maintenance', 'onMaintenance', 1, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->connection->restartMap();
     $this->setLocalAllyAction = \ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerSetLocalAlly'));
     $this->unsetLocalAllyAction = \ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerUnsetLocalAlly'));
 }
Exemple #21
0
 protected function __construct()
 {
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_INIT | AppEvent::ON_POST_LOOP);
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ALL);
 }
Exemple #22
0
 function __construct()
 {
     $this->time = time();
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_PRE_LOOP);
 }