function upload()
 {
     if (!isset($_POST['path'])) {
         $this->session->set('error', _('The path must be set.'));
         $this->request->redirect('..');
     }
     $this->request->set('path', $_POST['path']);
     if ($_FILES['map']['error']) {
         switch ($_FILES['map']['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $this->session->set('error', _('File is too big.'));
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $this->session->set('error', _('File is partially uploaded.'));
                 break;
             case UPLOAD_ERR_NO_FILE:
                 $this->session->set('error', _('No file uploaded.'));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $this->session->set('error', _('Can\'t write the file on the disk.'));
                 break;
         }
         $this->request->redirect('..', 'path');
     }
     if (!preg_match('/\\.map\\.gbx$/iu', $_FILES['map']['name']) || !Map::check($_FILES['map']['tmp_name'])) {
         $this->session->set('error', _('The file must be a ManiaPlanet map.'));
         $this->request->redirect('..', 'path');
     }
     $service = new \DedicatedManager\Services\MapService();
     $service->upload($_FILES['map']['tmp_name'], $_FILES['map']['name'], $_POST['path']);
     $this->request->redirectArgList('..', 'path');
 }
 /**
  * @norelay
  * @local
  */
 function addMaps()
 {
     $maps = $this->server->connection->getMapList(-1, 0);
     $selected = \ManiaLib\Utils\Arrays::getProperty($maps, 'fileName');
     $selected = array_map(function ($s) {
         $s = preg_replace('/^\\xEF\\xBB\\xBF/', '', $s);
         return str_replace('\\', '/', $s);
     }, $selected);
     $matchSettings = $this->server->connection->getNextGameInfo();
     if ($matchSettings->gameMode == GameInfos::GAMEMODE_SCRIPT) {
         $scriptInfo = $this->server->connection->getModeScriptInfo();
         $type = explode(',', $scriptInfo->compatibleMapTypes);
         $isLaps = false;
     } else {
         $type = array('Race');
         $isLaps = $matchSettings->gameMode == GameInfos::GAMEMODE_LAPS;
     }
     $service = new \DedicatedManager\Services\MapService();
     $files = $service->getList('', true, $isLaps, $type, $this->currentMap->environnement);
     $this->response->files = $files;
     $this->response->selected = $selected;
     $header = \DedicatedManager\Helpers\Header::getInstance();
     $header->rightText = _('Back to maps list');
     $header->rightLink = $this->request->createLinkArgList('../maps', 'host', 'port');
 }
 function maps()
 {
     set_time_limit(0);
     list(, , $system) = $this->fetchAndAssertConfig(_('selecting maps'));
     $gameInfos = $this->fetchAndAssertSettings(_('selecting maps'));
     $service = new \DedicatedManager\Services\TitleService();
     $environment = $service->getEnvironment($system->title);
     if ($gameInfos->gameMode == GameInfos::GAMEMODE_SCRIPT) {
         $service = new \DedicatedManager\Services\ScriptService();
         $type = $service->getFileMapType($gameInfos->scriptName, $system->title);
     } else {
         $type = array('Race');
     }
     $isLaps = $gameInfos->gameMode == GameInfos::GAMEMODE_LAPS;
     $service = new \DedicatedManager\Services\MapService();
     $this->response->files = $service->getList('', true, $isLaps, $type, $environment);
     $this->response->selected = $this->session->get('selected', array());
     $this->response->randomize = $this->session->get('randomize', false);
     $header = \DedicatedManager\Helpers\Header::getInstance();
     $header->rightText = _('Back to game settings');
     $header->rightIcon = 'back';
     $header->rightLink = $this->request->createLinkArgList('../rules');
 }