function preFilter() { parent::preFilter(); $host = $this->request->get('host'); $port = $this->request->get('port'); $service = new \DedicatedManager\Services\ServerService(); try { $this->server = $service->get($host, $port); $this->server->fetchDetails(); } catch (\Exception $e) { $this->session->set('error', _('The server is unreachable, maybe it is closed')); $this->request->redirectArgList('/'); } if (!$this->isAdmin) { $service = new \DedicatedManager\Services\ManagerService(); if (!$service->isAllowed($host, $port, $this->session->login)) { $this->session->set('error', _('You\'re not allowed to edit this server.')); $this->request->redirectArgList('/'); } } $rm = new \ReflectionMethod($this, $this->request->getAction('index')); $comment = $rm->getDocComment(); if ($this->server->isRelay && $comment && preg_match('/@norelay/u', $comment)) { $this->session->set('error', _('Unauthorized action on a relay.')); if ($this->request->getReferer() == $this->request->createLink()) { $this->request->redirectArgList('..'); } else { $this->request->redirectToReferer(); } } $mapDirectory = \DedicatedManager\Config::getInstance()->dedicatedPath . 'UserData/Maps/'; if (!in_array($this->server->rpcHost, array('127.0.0.1', 'localhost')) && $this->server->connection->getMapsDirectory() != $mapDirectory) { if (preg_match('/@local/u', $comment)) { $this->session->set('error', _('Unauthorized action on a distant server.')); if ($this->request->getReferer() == $this->request->createLink()) { $this->request->redirectArgList('..'); } else { $this->request->redirectToReferer(); } } $this->response->isLocal = false; } else { $this->response->isLocal = true; } if (!$comment || !preg_match('/@redirect/u', $comment)) { $this->request->registerReferer(); $this->players = $this->server->connection->getPlayerList(-1, 0); $this->options = $this->server->connection->getServerOptions(); $this->currentMap = $this->server->connection->getCurrentMapInfo(); if (!$this->server->isRelay) { $this->nextMap = $this->server->connection->getNextMapInfo(); } } }
function preFilter() { if (!$this->session->get('server')) { try { $service = new \DedicatedManager\Services\ServerService(); $server = $service->get($this->request->get('host'), $this->request->get('port')); $server->fetchDetails(); $this->session->set('server', $server); } catch (\Exception $e) { $this->session->set('error', _('You cannot start ManiaLive: unknown server')); $this->request->redirectArgList('/'); } } }
function status($host, $port) { $service = new \DedicatedManager\Services\ServerService(); try { $server = $service->get($host, $port); $this->connection = \Maniaplanet\DedicatedServer\Connection::factory($server->rpcHost, $server->rpcPort, 5, 'SuperAdmin', $server->rpcPassword); $info = $this->connection->getSystemInfo(); $this->response->running = $info->serverLogin; } catch (\Exception $e) { $this->response->running = 0; } }