Example #1
0
 function config($configFile = '')
 {
     $service = new \DedicatedManager\Services\ConfigFileService();
     if ($configFile) {
         list($options, $account, $system, $authLevel) = $service->get($configFile);
         $this->session->set('configFile', $configFile);
         $this->session->set('options', $options);
         $this->session->set('account', $account);
         $this->session->set('system', $system);
         $this->session->set('authLevel', $authLevel);
     } else {
         $options = new \DedicatedManager\Services\ServerOptions();
         $account = new \DedicatedManager\Services\Account();
         $system = new \DedicatedManager\Services\SystemConfig();
         $authLevel = new \DedicatedManager\Services\AuthorizationLevels();
     }
     $titleService = new \DedicatedManager\Services\TitleService();
     $this->response->titles = $titleService->getList();
     $this->response->configFile = $configFile;
     $this->response->configList = $service->getList();
     $this->response->authLevel = $this->session->get('authLevel', $authLevel);
     $this->response->options = $this->session->get('options', $options);
     $this->response->account = $this->session->get('account', $account);
     $this->response->system = $this->session->get('system', $system);
 }
 function doQuickStart()
 {
     $configFile = $this->request->getPostStrict('configFile');
     $matchFile = $this->request->getPostStrict('matchFile');
     $serverName = $this->request->getPost('serverName', '');
     $login = $this->request->getPost('login', '');
     $password = $this->request->getPost('password', '');
     $title = $this->request->getPost('title', null);
     $isLan = $this->request->getPost('isLan', false);
     $startManialive = $this->request->getPost('startManialive', false);
     $manialiveConfig = $this->request->getPost('manialiveConfig', '');
     $options = array();
     if ($serverName) {
         $options['servername'] = $serverName;
     }
     if ($login) {
         $options['login'] = $login;
     }
     if ($password) {
         $options['password'] = $password;
     }
     if ($title) {
         $options['title'] = $title;
     }
     $errors = array();
     try {
         $configService = new \DedicatedManager\Services\ConfigFileService();
         list(, , , $authLevel) = $configService->get($configFile);
         $error = _('An error appeared while starting the server.');
         $service = new \DedicatedManager\Services\ServerService();
         $server = new \DedicatedManager\Services\Server();
         $server->rpcHost = '127.0.0.1';
         $server->rpcPort = $service->start($configFile, $matchFile, (bool) $isLan, $options);
         $server->rpcPassword = $authLevel->superAdmin;
         $service->register($server);
         if ($startManialive && $manialiveConfig) {
             usleep(200);
             $service = new \DedicatedManager\Services\ManialiveService();
             $service->start($manialiveConfig, array('address' => $server->rpcHost, 'rpcport' => $server->rpcPort, 'password' => $server->rpcPassword));
         }
     } catch (\Exception $e) {
         \ManiaLib\Application\ErrorHandling::logException($e);
         $errors[] = $error;
     }
     if ($errors) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../quickStart');
     }
     $this->session->set('success', _('Your server has been successfully started'));
     $this->goHome();
 }