function start()
 {
     $configFile = $this->request->getPostStrict('configFile');
     $spectate = $this->request->getPostStrict('spectate');
     list($options, $account, $system, $authLevel, $isLan) = $this->fetchAndAssertConfig(_('starting it'));
     $spectate = \DedicatedManager\Services\Spectate::fromArray($spectate);
     switch ($spectate->method) {
         case 'managed':
             try {
                 list($rpcHost, $rpcPort, $rpcPass) = explode(':', $spectate->managed, 3);
                 $connection = \Maniaplanet\DedicatedServer\Connection::factory($rpcHost, $rpcPort, 5, 'SuperAdmin', $rpcPass);
                 $info = $connection->getSystemInfo();
                 $gameServer = $info->publishedIp . ':' . $info->port;
                 $password = $connection->getServerPasswordForSpectator();
             } catch (\Exception $e) {
                 $errors[] = _('Cannot retrieve server connection');
             }
             break;
         case 'ip':
             $gameServer = $spectate->ip . ':' . $spectate->port;
             $password = $spectate->password;
             break;
         case 'login':
             $gameServer = $spectate->login;
             $password = $spectate->password;
             break;
     }
     $this->session->set('configFile', $configFile);
     $this->session->set('spectate', $spectate);
     $errors = array();
     if (strpbrk($configFile, '\\/:*?"<>|')) {
         $errors[] = _('The server config filename must not contain any of the following characters: \\ / : * ? " < > |');
     }
     if (!$errors) {
         try {
             $error = _('An error appeared while writing the server configuration file');
             $service = new \DedicatedManager\Services\ConfigFileService();
             $service->save($configFile, $options, $account, $system, $authLevel);
             $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->startRelay($configFile, $gameServer, $password, $isLan);
             $server->rpcPassword = $authLevel->superAdmin;
             $service->register($server);
         } catch (\Exception $e) {
             \ManiaLib\Application\ErrorHandling::logException($e);
             $errors[] = $error;
         }
     }
     if ($errors) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../spectate');
     }
     $this->session->set('success', _('Your relay server has been successfully started'));
     $this->goHome();
 }
 function start()
 {
     $configFile = $this->request->getPostStrict('configFile');
     $matchFile = $this->request->getPostStrict('matchFile');
     list($options, $account, $system, $authLevel, $isLan) = $this->fetchAndAssertConfig(_('starting it'));
     $gameInfos = $this->fetchAndAssertSettings(_('starting server'));
     $maps = $this->fetchAndAssertMaps(_('starting server'));
     $scriptRules = $this->session->get('scriptSettings', array());
     $randomize = $this->session->get('randomize', false);
     $this->session->set('configFile', $configFile);
     $this->session->set('matchFile', $matchFile);
     $errors = array();
     if (strpbrk($configFile, '\\/:*?"<>|')) {
         $errors[] = _('The server config filename must not contain any of the following characters: \\ / : * ? " < > |');
     }
     if (strpbrk($matchFile, '\\/:*?"<>|')) {
         $errors[] = _('The match settings filename must not contain any of the following characters: \\ / : * ? " < > |');
     }
     if (!$errors) {
         try {
             $error = _('An error appeared while writing the server configuration file.');
             $service = new \DedicatedManager\Services\ConfigFileService();
             $service->save($configFile, $options, $account, $system, $authLevel);
             $error = _('An error appeared while writing the MatchSettings file.');
             $service = new \DedicatedManager\Services\MatchSettingsFileService();
             $service->save($matchFile, $gameInfos, $maps, $scriptRules, $randomize);
             $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, $isLan);
             $server->rpcPassword = $authLevel->superAdmin;
             $service->register($server);
         } catch (\Exception $e) {
             \ManiaLib\Application\ErrorHandling::logException($e);
             $errors[] = $error;
         }
     }
     if ($errors) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../preview');
     }
     $this->session->set('success', _('Your server has been successfully started'));
     $this->goHome();
 }