Ejemplo n.º 1
0
 function start($configFile)
 {
     $config = $this->fetchAndAssertConfig(_('starting it'));
     $server = $this->session->get('server');
     $this->session->set('configFile', $configFile);
     $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\ManialiveFileService();
             $service->save($configFile, $config);
             $error = _('An error appeared while starting ManiaLive');
             $service = new \DedicatedManager\Services\ManialiveService();
             $service->start($configFile, 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('../preview');
     }
     $this->session->set('success', _('ManiaLive has been successfully started'));
     $this->backToServer();
 }
Ejemplo n.º 2
0
 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();
 }