コード例 #1
0
 function setConfig()
 {
     $options = $this->request->getPostStrict('options');
     $account = $this->request->getPostStrict('account');
     $system = $this->request->getPostStrict('system');
     $authLevel = $this->request->getPostStrict('authLevel');
     $isOnline = $this->request->getPost('isOnline', 0);
     $options = \DedicatedManager\Services\ServerOptions::fromArray($options);
     $options->callVoteRatio = $options->callVoteRatio < 0 ? -1 : $options->callVoteRatio / 100;
     $options->nextCallVoteTimeOut = $options->nextCallVoteTimeOut * 1000;
     $account = \DedicatedManager\Services\Account::fromArray($account);
     $system = \DedicatedManager\Services\SystemConfig::fromArray($system);
     $authLevel = \DedicatedManager\Services\AuthorizationLevels::fromArray($authLevel);
     $this->session->set('options', $options);
     $this->session->set('account', $account);
     $this->session->set('system', $system);
     $this->session->set('authLevel', $authLevel);
     $this->session->set('isLan', !$isOnline);
     $service = new \DedicatedManager\Services\ConfigFileService();
     if ($errors = $service->validate($options, $account, $system, $authLevel, !$isOnline)) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../config');
     }
 }
コード例 #2
0
 /**
  * @redirect
  */
 function setConfig($options, $rpcPassword, $connectionRates)
 {
     $options = \DedicatedManager\Services\ServerOptions::fromArray($options);
     $options->callVoteRatio = $options->callVoteRatio < 0 ? $options->callVoteRatio : $options->callVoteRatio / 100;
     $options->nextCallVoteTimeOut = $options->nextCallVoteTimeOut * 1000;
     $service = new \DedicatedManager\Services\ConfigFileService();
     if ($errors = $service->validate($options)) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../config', 'host', 'port');
     }
     $optionsCur = $this->server->connection->getServerOptions();
     $options->nextVehicleNetQuality = $optionsCur->nextVehicleNetQuality;
     $options->nextUseChangingValidationSeed = $optionsCur->nextUseChangingValidationSeed;
     try {
         $options->ensureCast();
         $this->server->connection->setServerOptions($options->toArray());
         $this->server->connection->disableHorns($options->disableHorns);
         $this->server->connection->setConnectionRates((int) $connectionRates['download'], (int) $connectionRates['upload']);
         if ($rpcPassword != $this->server->rpcPassword) {
             $this->server->connection->changeAuthPassword('SuperAdmin', $rpcPassword);
             $this->server->closeConnection();
             $this->server->rpcPassword = $rpcPassword;
             $service = new \DedicatedManager\Services\ServerService();
             $service->register($this->server);
         }
         $this->session->set('success', _('Configuration successfully changed'));
     } catch (\Exception $e) {
         \ManiaLib\Application\ErrorHandling::logException($e);
         $this->session->set('error', _('An error occured while changing server configuration'));
     }
     $this->request->redirectArgList('../config', 'host', 'port');
 }