/** * Ajoute un log au fichier correspondant * * @param string $type -> Type de log : access, action, etc * @param string $str -> Ligne de log à écrire * @return bool */ public static function add($type, $str) { $out = false; $type = strtolower($type); if (defined('USER_PAGE')) { $userPage = USER_PAGE; } else { $userPage = 'index'; } if (defined('SERVER_NAME')) { $serverName = '[' . utf8_decode(SERVER_NAME) . '] '; } else { $serverName = null; } $str = '[' . date('d/m/Y H:i:s') . '] [' . $_SERVER['REMOTE_ADDR'] . '] : ' . $serverName . '[' . $userPage . '] ' . utf8_decode($str) . "\n"; $path = self::$LOGS_PATH . $type . '.log'; if (file_exists($path)) { if (File::save($path, utf8_encode($str)) !== true) { $error = Utils::t('Unable to add log in file:') . ' ' . $type . '.'; if ($_SESSION['error'] != null) { $_SESSION['error'] .= '<br />' . $error; } else { $_SESSION['error'] = $error; } } else { $out = true; } } return $out; }
} // INCLUDES require_once '../class/utils.class.php'; $serverConfig = '../../' . $path_cfg; if (file_exists($serverConfig)) { require_once $serverConfig; } $langCode = Utils::getLang(); $langFile = '../lang/' . $langCode . '.php'; if (file_exists($langFile)) { require_once $langFile; } // DATA $out = array(); if (class_exists('ServerConfig')) { if (isset(ServerConfig::$SERVERS) && count(ServerConfig::$SERVERS) > 0 && !isset(ServerConfig::$SERVERS['new server name']) && !isset(ServerConfig::$SERVERS[''])) { $out['servers'] = count(ServerConfig::$SERVERS); $out['label']['server'] = Utils::t('Server'); $out['label']['name'] = Utils::t('Server name'); $out['label']['login'] = Utils::t('Server login'); $out['label']['connect'] = Utils::t('Connected on'); $out['label']['status'] = Utils::t('Status'); $out['label']['gamemode'] = Utils::t('Game mode'); $out['label']['currentmap'] = Utils::t('Current map'); $out['label']['players'] = Utils::t('Players'); $out['label']['accessserverplayer'] = Utils::t('Access as player'); $out['label']['accessserverspectate'] = Utils::t('Access as spectator'); $out['label']['addfavourite'] = Utils::t('Add to favourite'); } } echo json_encode($out);
echo Utils::t('Click here'); ?> </a></p> <p>- <?php echo Utils::t('Unzip the plugin and place its contents into the « plugins » folder of Adminserv.'); ?> <br /> - <?php echo Utils::t('In the Configuration Extension, add the name of the plugin folder previously added.'); ?> </p> <p> <code> public static $PLUGINS = array(<br /> 'PluginName',<br /> ); </code> </p> </div> <h2><?php echo Utils::t('Create a new plugin'); ?> </h2> <div class="content"> <?php echo Utils::t('<p>To create a plugin, go to the plugins folder and duplicate file _newplugin. Replace the values in the config.ini file and folder name.<br />Then there are two PHP files:</p><ul><li>script.php : this file is executed before the header of the site. This is where all plugin script will be placed.</li><li>view.php : this file is the display of the plugin executed after the header. This is where everything will be placed the html code.</li></ul><p>You need to create resources (classes, js, css) then include these files.</p>'); ?> </div> </section> </section>
$color = 'blue'; } else { $color = 'red'; } AdminServLogs::add('action', 'Force player in ' . $color . ' team: ' . $player); } } } else { if (isset($_POST['ForceScores']) && isset($_POST['ScoreTeamBlue']) && isset($_POST['ScoreTeamRed'])) { $scoreTeamBlue = intval($_POST['ScoreTeamBlue']); $scoreTeamRed = intval($_POST['ScoreTeamRed']); $scores = array(array('PlayerId' => 0, 'Score' => $scoreTeamBlue), array('PlayerId' => 1, 'Score' => $scoreTeamRed)); if (!$client->query('ForceScores', $scores, true)) { AdminServ::error(); } else { $action = '[Admin] ' . Utils::t('The scores have been modified : $00fblue team $fffhas !scoreTeamBlue and $f00red team $fffhas !scoreTeamRed', array('!scoreTeamBlue' => $scoreTeamBlue, '!scoreTeamRed' => $scoreTeamRed)); if (!$client->query('ChatSendServerMessage', $action)) { AdminServ::error(); } else { AdminServLogs::add('action', $action); } } } else { if (isset($_POST['CancelVote'])) { if (!$client->query('CancelVote')) { AdminServ::error(); } else { Utils::redirection(); } } }
<?php // LECTURE $data['serverLines'] = AdminServ::getChatServerLines(); $lastNicknameUsed = Utils::readCookieData('adminserv_user', 2); $data['nickname'] = $lastNicknameUsed != null ? $lastNicknameUsed : Utils::t('Nickname'); $colorList = array('$ff0' => Utils::t('Color'), '$000' => Utils::t('Black'), '$f00' => Utils::t('Red'), '$0f0' => Utils::t('Green'), '$00f' => Utils::t('Blue'), '$f80' => Utils::t('Orange'), '$f0f' => Utils::t('Pink'), '$888' => Utils::t('Grey'), '$fff' => Utils::t('White')); $data['colorOptions'] = null; $lastColorUsed = Utils::readCookieData('adminserv_user', 3); foreach ($colorList as $colorCode => $colorName) { $selected = $colorCode == $lastColorUsed ? ' selected="selected"' : null; $data['colorOptions'] .= '<option value="' . $colorCode . '"' . $selected . '>' . $colorName . '</option>'; } $lastDestination = null; $lastDestinationTitle = Utils::t('server'); if (isset($_SESSION['adminserv']['chat_dst'])) { $lastDestination = $lastDestinationTitle = $_SESSION['adminserv']['chat_dst']; } $data['destination']['list'] = AdminServUI::getPlayerList($lastDestination); $data['destination']['title'] = Utils::t('Message destination') . ' : ' . $lastDestinationTitle;
$NextRoundCustomPointsArray = array(); if (count($NextRoundCustomPoints) > 0) { foreach ($NextRoundCustomPoints as $point) { $NextRoundCustomPointsArray[] = intval(trim($point)); } } if (!$client->query('SetRoundCustomPoints', $NextRoundCustomPointsArray)) { AdminServ::error(); } } // MatchSettings if (SERVER_MATCHSET) { $mapsDirectory = AdminServ::getMapsDirectoryPath(); if (array_key_exists('SaveCurrentMatchSettings', $_POST)) { if (!$client->query('SaveMatchSettings', $mapsDirectory . SERVER_MATCHSET)) { AdminServ::error(); } } } AdminServLogs::add('action', 'Save game infos'); Utils::redirection(false, '?p=' . USER_PAGE); } } // LECTURE $gameInfos = AdminServ::getGameInfos(); $data['gameInfos'] = array('curr' => $gameInfos['curr'], 'next' => $gameInfos['next']); $data['teamInfo'] = array('team1' => array('name' => Utils::t('Blue'), 'color' => '0.667', 'colorhex' => '#0000ff', 'country' => 'World|France'), 'team2' => array('name' => Utils::t('Red'), 'color' => '0', 'colorhex' => '#ff0000', 'country' => 'World|France')); if (isset($_SESSION['adminserv']['teaminfo']) && count($_SESSION['adminserv']['teaminfo']) > 0) { $data['teamInfo'] = array('team1' => $_SESSION['adminserv']['teaminfo']['team1'], 'team2' => $_SESSION['adminserv']['teaminfo']['team2']); } unset($gameInfos);
<?php // ENREGISTREMENT if (isset($_POST['savepassword'])) { $current = md5($_POST['changePasswordCurrent']); $new = md5($_POST['changePasswordNew']); if (isset($_SESSION['adminserv']['path'])) { $adminservPath = $_SESSION['adminserv']['path']; } else { $adminservPath = null; } $pathConfig = $adminservPath . 'config/'; if (OnlineConfig::PASSWORD !== $current) { AdminServ::error(Utils::t('The current password doesn\'t match.')); } else { if (($result = AdminServServerConfig::savePasswordConfig($pathConfig . 'adminserv.cfg.php', $new)) !== true) { AdminServ::error(Utils::t('Unable to save password.') . ' (' . $result . ')'); } else { $info = Utils::t('The password has been changed.'); AdminServ::info($info); AdminServLogs::add('action', $info); } } Utils::redirection(false, '?p=' . USER_PAGE); }
$playerStatus = Utils::t('Player'); } if ($player['TeamId'] == 0) { $teamName = Utils::t('Blue'); } else { if ($player['TeamId'] == 1) { $teamName = Utils::t('Red'); } else { $teamName = Utils::t('Spectator'); } } $out['players'][$serverId]['list'][$playerId] = array('name' => TmNick::toHtml(htmlspecialchars($player['NickName'], ENT_QUOTES, 'UTF-8'), 10, true), 'status' => $playerStatus, 'teamId' => $player['TeamId'], 'teamName' => $teamName); $playerId++; } } else { $out['players'][$serverId]['list'] = Utils::t('No player'); } // Tri mode team if ($gameModeName == 'Team' && $countPlayerList > 0) { uasort($out['players'][$serverId]['list'], 'sortByTeam'); } // Count players $maxPlayers = $queriesData['GetMaxPlayers']; $out['players'][$serverId]['count']['current'] = $countPlayerList; $out['players'][$serverId]['count']['max'] = $maxPlayers['NextValue']; } } // Déconnexion $client->Terminate(); $serverId++; }
<?php // SESSION if (!isset($_SESSION['adminserv']['allow_config_servers'])) { AdminServ::error(Utils::t('You are not allowed to configure the servers')); Utils::redirection(); } // VERIFICATION if (class_exists('ServerConfig')) { // Si on n'autorise pas la configuration en ligne if (OnlineConfig::ACTIVATE !== true) { AdminServ::info(Utils::t('No server available. To add one, configure "config/servers.cfg.php" file.')); Utils::redirection(); } elseif (USER_PAGE != 'config-addserver') { if (OnlineConfig::ADD_ONLY === true) { Utils::redirection(false, './?p=addserver'); } } } else { AdminServ::error(Utils::t('The servers configuration file isn\'t recognized by AdminServ.')); Utils::redirection(); }
?> </span> </div> <div class="fright"> <div class="selected-files-label locked"> <span class="selected-files-title"><?php echo Utils::t('For the selection'); ?> </span> <div class="selected-files-option"> <input class="button dark" type="submit" name="deleteserver" id="deleteserver" data-confirm-text="<?php echo Utils::t('Do you really want to remove this selection?'); ?> " value="<?php echo Utils::t('Delete'); ?> " /> <input class="button dark" type="submit" name="duplicateserver" id="duplicateserver" value="<?php echo Utils::t('Duplicate'); ?> " /> <input class="button dark" type="submit" name="editserver" id="editserver" value="<?php echo Utils::t('Modify'); ?> " /> </div> </div> </div> </div> </form> </section>
foreach ($_POST['map'] as $map) { $result = File::rename($data['mapsDirectoryPath'] . $map, $newPath . basename($map)); if ($result !== true) { AdminServ::error(Utils::t('Unable to move the map') . ' : ' . $map . ' (' . $result . ')'); break; } else { AdminServLogs::add('action', 'Move map: ' . $map . ' to ' . $newPath . basename($map)); } } Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory); } else { if (isset($_POST['deleteMap']) && isset($_POST['map']) && count($_POST['map']) > 0) { foreach ($_POST['map'] as $map) { $result = File::delete($data['mapsDirectoryPath'] . $map); if ($result !== true) { AdminServ::error(Utils::t('Unable to delete the map') . ' : ' . $map . ' (' . $result . ')'); break; } else { AdminServLogs::add('action', 'Delete map: ' . $map); } } Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory); } } } } } } } // Save MatchSettings if ((isset($_POST['addMap']) || isset($_POST['insertMap'])) && SERVER_MATCHSET) {
/** * Inclue les fichiers pour le rendu d'un plugin * * @param string $pluginName -> Le nom du dossier plugin * @return html */ public static function renderPlugin($pluginName = null) { global $client, $translate, $args; if ($pluginName === null) { $pluginName = USER_PLUGIN; } // Tente de récupérer les plugins d'une autre config self::setPluginsList(); // Création du rendu du plugin $pluginPath = AdminServConfig::$PATH_PLUGINS . $pluginName . '/'; $scriptFile = $pluginPath . 'script.php'; $viewFile = $pluginPath . 'view.php'; if (file_exists($scriptFile) && file_exists($viewFile)) { // Process require_once $scriptFile; // Terminate client if (isset($client) && $client->socket != null) { $client->Terminate(); } // Header AdminServUI::getHeader(); // Content echo '<section class="plugins hasMenu">' . '<section class="cadre left menu">' . self::getMenuList() . '</section>' . '<section class="cadre right">' . '<h1>' . self::getConfig($pluginName, 'name') . '</h1>'; require_once $viewFile; echo '</section>' . '</section>'; // Footer AdminServUI::getFooter(); AdminServLogs::add('access', 'Plugin: ' . $pluginName); } else { AdminServ::error(Utils::t('Plugin error: script.php or view.php file is missing.')); AdminServUI::getHeader(); AdminServUI::getFooter(); } }
/** * Sauvegarde le fichier de configuration des serveurs * * @param array $serverData -> assoc array(name, address, port, matchsettings, adminlevel => array(SuperAdmin, Admin, User)); * @param int $editServer -> Id du serveur à éditer * @param array $serverList -> Liste des serveurs de la config * @return bool or string error */ public static function saveServerConfig($serverData = array(), $editServer = -1, $serverList = array()) { // Liste des serveurs if (isset($serverList) && count($serverList) > 0) { $servers = $serverList; } else { $servers = ServerConfig::$SERVERS; } // Template $fileTemplate = self::$CONFIG_START_TEMPLATE; $i = 0; foreach ($servers as $serverName => $serverValues) { // Édition if ($i == $editServer && isset($serverData) && count($serverData) > 0) { $fileTemplate .= self::getServerTemplate($serverData); } else { // Récupération des données des serveurs existant $getServerValues = array('name' => $serverName, 'address' => $serverValues['address'], 'port' => $serverValues['port'], 'mapsbasepath' => isset($serverValues['mapsbasepath']) ? $serverValues['mapsbasepath'] : '', 'matchsettings' => $serverValues['matchsettings'], 'adminlevel' => array()); foreach ($serverValues['adminlevel'] as $admLvlId => $admLvlValue) { $getServerValues['adminlevel'][$admLvlId] = $admLvlValue; } // Ajout des données au template $fileTemplate .= self::getServerTemplate($getServerValues); } $i++; } // Ajout d'un nouveau if ($editServer === -1 && isset($serverData) && count($serverData) > 0) { if (self::getServerId($serverData['name']) === -1) { $fileTemplate .= self::getServerTemplate($serverData); } else { return Utils::t('The server already exist! Change the name.'); } } $fileTemplate .= self::$CONFIG_END_TEMPLATE; // Enregistrement return File::save(self::$CONFIG_PATH . self::$CONFIG_FILENAME, $fileTemplate, false); }
// SET $setServerData = array('name' => trim(htmlspecialchars(addslashes($_POST['server'][0] . ' - ' . Utils::t('copy')))), 'address' => trim($getServerData['address']), 'port' => intval($getServerData['port']), 'matchsettings' => trim($getServerData['matchsettings']), 'adminlevel' => array('SuperAdmin' => $getServerData['adminlevel']['SuperAdmin'], 'Admin' => $getServerData['adminlevel']['Admin'], 'User' => $getServerData['adminlevel']['User'])); if (AdminServServerConfig::saveServerConfig($setServerData)) { $action = Utils::t('This server has been duplicated.'); AdminServ::info($action); AdminServLogs::add('action', $action); Utils::redirection(false, '?p=' . USER_PAGE); } else { AdminServ::error(Utils::t('Unable to duplicate server.')); } } // SUPPRESSION if (isset($_POST['deleteserver'])) { $servers = ServerConfig::$SERVERS; unset($servers[$_POST['server'][0]]); if (($result = AdminServServerConfig::saveServerConfig(array(), -1, $servers)) !== true) { AdminServ::error(Utils::t('Unable to delete server.') . ' (' . $result . ')'); } else { $action = Utils::t('The "!serverName" server has been deleted.', array('!serverName' => $_POST['server'][0])); AdminServ::info($action); AdminServLogs::add('action', $action); Utils::redirection(false, '?p=' . USER_PAGE); } } // SERVERLIST $data['servers'] = array(); if (is_array(ServerConfig::$SERVERS) && !empty(ServerConfig::$SERVERS)) { $data['servers'] = ServerConfig::$SERVERS; } $data['count'] = count($data['servers']); $data['adminLevelsType'] = AdminServAdminLevel::getDefaultType();
/** * Sauvegarde le fichier de configuration des niveaux admins * * @param array $levelData -> assoc array(adminlevel => array(type), access, permission) * @param int $editLevel -> Id du niveau à éditer * @param array $levelList -> Liste des niveaux de la config * @return bool or string error */ public static function saveConfig($levelData = array(), $editLevel = -1, $levelList = array()) { // Liste des niveaux $levels = isset($levelList) && !empty($levelList) ? $levelList : AdminLevelConfig::$ADMINLEVELS; // Template $fileTemplate = self::$CONFIG_START_TEMPLATE; $i = 0; foreach ($levels as $levelName => $levelValues) { // Édition if ($i == $editLevel && isset($levelData) && !empty($levelData)) { $fileTemplate .= self::getTemplate($levelData); } else { // Récupération des données des niveaux existant $getLevelsData = array('name' => $levelName, 'adminlevel' => $levelValues['adminlevel'], 'access' => $levelValues['access'], 'permission' => $levelValues['permission']); // Ajout des données au template $fileTemplate .= self::getTemplate($getLevelsData); } $i++; } // Ajout d'un nouveau if ($editLevel === -1 && isset($levelData) && !empty($levelData)) { if (self::getId($levelData['name']) === -1) { $fileTemplate .= self::getTemplate($levelData); } else { return Utils::t('The admin level already exist! Change the name.'); } } $fileTemplate .= self::$CONFIG_END_TEMPLATE; // Enregistrement return File::save(self::$CONFIG_PATH . self::$CONFIG_FILENAME, $fileTemplate, false); }
</fieldset> <fieldset id="gameMode-laps" class="gameinfos_laps" hidden="hidden"> <legend><img src="<?php echo AdminServConfig::$PATH_RESOURCES; ?> images/16/rt_laps.png" alt="" /><?php echo AdminServ::getGameModeName(4, true); ?> </legend> <table class="game_infos"> <?php echo AdminServUI::getGameInfosField($data['gameInfos'], 'Number of laps', 'LapsNbLaps'); ?> <?php echo AdminServUI::getGameInfosField($data['gameInfos'], Utils::t('Time limit') . ' <span>(' . Utils::t('sec') . ')</span>', 'LapsTimeLimit'); ?> </table> </fieldset> <fieldset id="gameMode-cup" class="gameinfos_cup" hidden="hidden"> <legend><img src="<?php echo AdminServConfig::$PATH_RESOURCES; ?> images/16/rt_cup.png" alt="" /><?php echo AdminServ::getGameModeName(5); ?> </legend> <table class="game_infos"> <?php echo AdminServUI::getGameInfosField($data['gameInfos'], 'Points limit', 'CupPointsLimit');
$playlistEx = explode('|', $playlist); $filename = $playlistEx[1]; if (!File::delete($data['gameDataDirectory'] . 'Config/' . $filename)) { AdminServ::error(Utils::t('Unable to delete the playlist') . ' : ' . $filename); break; } else { AdminServLogs::add('action', 'Delete playlist: ' . $filename); } } Utils::redirection(false, '?p=' . USER_PAGE); } else { if (isset($_POST['createPlaylistValid']) && isset($_POST['createPlaylistName']) && $_POST['createPlaylistName'] != null) { // Fichier $filename = Str::replaceChars($_POST['createPlaylistName']); // Guestlist if ($filename != Str::replaceChars(Utils::t('Playlist name'))) { if ($_POST['createPlaylistType'] == 'guestlist') { if (!$client->query('SaveGuestList', $filename)) { AdminServ::error(); } else { AdminServLogs::add('action', 'Create playlist (guestlist): ' . $filename); } } elseif ($_POST['createPlaylistType'] == 'blacklist') { if (!$client->query('SaveBlackList', $filename)) { AdminServ::error(); } else { AdminServLogs::add('action', 'Create playlist (blacklist): ' . $filename); } } } Utils::redirection(false, '?p=' . USER_PAGE);
" data-root="<?php echo Utils::t('Root'); ?> "></div> <?php } ?> </div> <?php if (SERVER_MATCHSET && AdminServAdminLevel::hasPermission('maps_matchsettings_save')) { ?> <div class="fleft options-checkbox"> <input class="text inline" type="checkbox" name="SaveCurrentMatchSettings" id="SaveCurrentMatchSettings"<?php if (AdminServConfig::AUTOSAVE_MATCHSETTINGS === true) { echo ' checked="checked"'; } ?> value="" /><label for="SaveCurrentMatchSettings" title="<?php echo SERVER_MATCHSET; ?> "><?php echo Utils::t('Save the current MatchSettings'); ?> </label> </div> <?php } ?> </form> </section> </section>
<span class="rename-map-name"><?php echo $currentDir; ?> </span> <span class="rename-map-arrow"> </span> <input class="text width2" type="text" name="renameFolderNewName" id="renameFolderNewName" value="<?php echo $currentDir; ?> " /> </li> </ul> </div> <div id="moveFolderForm" class="option-form" hidden="hidden" data-title="<?php echo Utils::t('Move folder'); ?> " data-cancel="<?php echo Utils::t('Cancel'); ?> " data-move="<?php echo Utils::t('Move'); ?> " data-root="<?php echo Utils::t('Root'); ?> " data-movethefolder="<?php echo Utils::t('Move folder <b>!currentDir</b> in:', array('!currentDir' => $currentDir)); ?> "></div> </form> <?php }
/** * Enregistre le fichier envoyé dans un dossier sur un serveur Maniaplanet * * @param resource $client -> La ressource du client XMLRPC * @param string $uploadDirectory -> Le chemin du dossier de destination * @param bool $replaceOldFile -> Remplacement des anciens fichiers qui ont le même nom ? Non par défaut * @param function $filenameFunction -> La fonction de traitement du filename * @return array('success' => true) ou array('error' => 'error message') */ public function handleUploadManiaPlanetServer($client, $uploadDirectory, $queries, $filenameFunction = null) { // Si le client est initialisé if (!$client->socket || $client->protocol == 0) { return array('error' => Utils::t('Client not initialized')); } // Si il y a bien un fichier envoyé if (!$this->file) { return array('error' => Utils::t('No file was uploaded')); } // Récuperation de la taille du fichier et test si il n'est pas vide ou supérieur à la taille configurée $size = $this->file->getSize(); if ($size === 0) { return array('error' => Utils::t('The file is empty.')); } if ($size > $this->sizeLimit) { return array('error' => Utils::t('The file size is too large.')); } // Récuperation du nom et de l'extension du fichier pour tester si l'extension est valide et si le nom du fichier n'existe pas déjà $pathinfo = pathinfo($this->file->getName()); if ($filenameFunction != null) { $filename = $filenameFunction($pathinfo['filename']); } else { $filename = $pathinfo['filename']; } $ext = $pathinfo['extension']; if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) { return array('error' => Utils::t('The file has invalid extension (allowed extensions:') . ' ' . implode(', ', $this->allowedExtensions) . ').'); } // Enregistrement du fichier $error = false; $pathToFile = $uploadDirectory . $filename . '.' . $ext; if (file_exists($uploadDirectory)) { if (($result = $this->file->save($pathToFile)) !== true) { $error = true; } } else { if (($result = $this->file->writeMap($client, $pathToFile)) !== true) { $error = true; } } if (!$error) { // Ajout/insert la map if (isset($_GET['type']) && $_GET['type'] != 'local') { $out = $this->file->saveMap($client, $pathToFile, $queries); } else { $out = true; } } else { // Erreur des fonctions save ou writeMap if ($result) { $out = $result; } else { $out = 'write error'; } } if ($out === true) { return array('success' => true, 'out' => $out); } else { return array('error' => Utils::t('The file was not uploaded. Upload has been cancelled or a server error occurred.') . ' (' . $out . ')'); } }
AdminServ::error(Utils::t('Connection error: invalid session.')); } } } } else { if (OnlineConfig::ACTIVATE === true) { Utils::redirection(false, './config/'); } else { AdminServ::info(Utils::t('No server available. To add one, configure "config/servers.cfg.php" file.')); } } } else { if (OnlineConfig::ACTIVATE === true && !isset($_GET['error'])) { Utils::redirection(false, './config/'); } else { AdminServ::error(Utils::t('The servers configuration file isn\'t recognized by AdminServ.')); } } } else { if (isset($_SESSION['adminserv']['get_password'])) { AdminServ::info(Utils::t('It\'s your first connection and no server configured. Choose a password to configure your servers.')); } } // HTML if (isset($_GET['error'])) { AdminServ::error($_GET['error']); } else { if (isset($_GET['info'])) { AdminServ::info($_GET['info']); } }
$newPath = addslashes($_POST['optionFolderHiddenFieldValue']); if ($newPath == '.') { $newPath = $data['mapsDirectoryPath']; } $newPath .= basename($args['directory']) . '/'; $newPathFromMapsPath = str_replace($data['mapsDirectoryPath'], '', $newPath); if ($newPathFromMapsPath) { $newPathFromMapsPath = '&d=' . $newPathFromMapsPath; } if (($result = Folder::rename($data['mapsDirectoryPath'] . $args['directory'], $newPath)) !== true) { AdminServ::error(Utils::t('Unable to move the folder') . ' : ' . $args['directory'] . ' (' . $result . ')'); } else { AdminServLogs::add('action', 'Move folder: ' . $args['directory'] . ' to ' . $newPathFromMapsPath); Utils::redirection(false, '?p=' . USER_PAGE . $newPathFromMapsPath); } } else { if (isset($_POST['optionFolderHiddenFieldAction']) && $_POST['optionFolderHiddenFieldAction'] == 'delete') { if (($result = Folder::delete($data['mapsDirectoryPath'] . $args['directory'])) !== true) { AdminServ::error(Utils::t('Unable to delete the folder') . ' : ' . $args['directory'] . ' (' . $result . ')'); } else { // Clean cache $cache = new AdminServCache(); $cacheKey = 'mapslist-' . Str::replaceChars($data['mapsDirectoryPath'] . $args['directory']); $cache->delete($cacheKey); AdminServLogs::add('action', 'Delete folder: ' . $args['directory']); Utils::redirection(false, '?p=' . USER_PAGE); } } } } }
/** * Met en forme les données des maps à partir d'un MatchSettings * * @global resource $client -> Le client doit être initialisé * @param array $maps -> Le tableau extrait du matchsettings : assoc array(ident => filename) * @return array */ public static function getMapListFromMatchSetting($maps) { global $client; $out = array(); $path = self::getMapsDirectoryPath(); $countMapList = count($maps); if ($countMapList > 0) { $i = 0; foreach ($maps as $mapUId => $mapFileName) { if (in_array(File::getDoubleExtension($mapFileName), AdminServConfig::$MAP_EXTENSION)) { // Données if (SERVER_VERSION_NAME == 'TmForever') { $Gbx = new GBXChallengeFetcher($path . Str::toSlash($mapFileName)); } else { $Gbx = new GBXChallMapFetcher(); $Gbx->processFile($path . Str::toSlash($mapFileName)); } // Name $name = htmlspecialchars($Gbx->name, ENT_QUOTES, 'UTF-8'); $out['lst'][$i]['Name'] = TmNick::toHtml($name, 10, true); // Environnement $env = $Gbx->envir; if ($env == 'Speed') { $env = 'Desert'; } else { if ($env == 'Alpine') { $env = 'Snow'; } } $out['lst'][$i]['Environment'] = $env; // Autres $out['lst'][$i]['FileName'] = $mapFileName; $out['lst'][$i]['UId'] = $Gbx->uid; $out['lst'][$i]['Author'] = $Gbx->author; $i++; } } } // Nombre de maps $out += self::getNbMaps($out); if ($out['nbm']['count'] == 0) { $out['lst'] = Utils::t('No map'); } return $out; }
</tr> <tr> <td class="key"> <label for="playerToServerLogin"><i><?php echo SERVER_LOGIN; ?> </i> ←</label> </td> <td class="value"> <select class="width1" name="playerToServerLogin" id="playerToServerLogin"> <?php echo $getPlayerListUI; ?> </select> </td> <td class="info"> <?php echo Utils::t('Confirmation from a player on the server is necessary.'); ?> </td> </tr> </table> </fieldset> </div> <div class="fright save"> <input class="button light" type="submit" name="transfercoppers" id="transfercoppers" value="<?php echo Utils::t('Transfer'); ?> " /> </div> </form>
?> <?php if (AdminServAdminLevel::hasPermission('player_forcetospectator')) { ?> <input class="button dark" type="submit" name="ForceSpectatorList" id="ForceSpectatorList" value="<?php echo Utils::t('Spectator'); ?> " /> <?php } ?> <?php if (AdminServAdminLevel::hasPermission('player_forcetoplayer')) { ?> <input class="button dark" type="submit" name="ForcePlayerList" id="ForcePlayerList" value="<?php echo Utils::t('Player'); ?> " /> <?php } ?> </div> </div> </div> </div> <input type="hidden" id="currentSort" name="currentSort" value="" /> <input type="hidden" id="isTeamGameMode" name="isTeamGameMode" value="<?php echo $data['isTeamGameMode']; ?> " />
<div class="selected-files-option"> <?php if (AdminServAdminLevel::hasPermission('maps_list_removetolist')) { ?> <input class="button dark" type="submit" name="removeMap" id="removeMap" value="<?php echo Utils::t('Delete'); ?> " /> <?php } ?> <?php if (AdminServAdminLevel::hasPermission('maps_list_moveaftercurrent')) { ?> <input class="button dark" type="submit" name="chooseNextMap" id="chooseNextMap" value="<?php echo Utils::t('Move after the current map'); ?> " /> <?php } ?> </div> </div> </div> <?php } ?> </div> <input type="hidden" id="currentSort" name="currentSort" value="" /> </form>
<?php foreach ($data['menuList'] as $page => $title) { ?> <?php if (AdminServAdminLevel::hasAccess($page)) { ?> <li><a <?php if (USER_PAGE == $page) { echo 'class="active"'; } ?> href="?p=<?php echo $page; if ($args['directory']) { echo '&d=' . $args['directory']; } ?> "><?php echo Utils::t($title); ?> </a></li> <?php } ?> <?php } ?> </ul> </nav> <?php }
if ($data['gameInfos']['next']['ForceShowAllOpponents'] > 1) { echo $data['gameInfos']['next']['ForceShowAllOpponents']; } ?> "<?php if ($data['gameInfos']['next']['ForceShowAllOpponents'] < 2) { echo ' hidden="hidden"'; } ?> /> </td> <td class="preview"<?php if ($data['gameInfos']['next']['ForceShowAllOpponents'] < 2) { echo ' hidden="hidden"'; } ?> > <a class="returnDefaultValue" href="?p=<?php echo USER_PAGE; ?> "><?php echo Utils::t('Return to the default value'); ?> </a> </td> </tr> <?php } ?> </table> </fieldset>
?> <?php if (AdminServAdminLevel::hasPermission('guestban_playlist_load')) { ?> <input class="button dark" type="submit" name="loadPlaylist" id="loadPlaylist" value="<?php echo Utils::t('Load'); ?> " /> <?php } ?> <?php if (AdminServAdminLevel::hasPermission('guestban_playlist_save')) { ?> <input class="button dark" type="submit" name="savePlaylist" id="savePlaylist" value="<?php echo Utils::t('Save '); ?> " /> <?php } ?> </div> </div> </div> </div> <?php } ?> </form> </div> <?php
<tr> <td class="key"><label for="Next<?php echo $data['gameInfosField']['id']; ?> "><?php echo Utils::t($data['gameInfosField']['name']); ?> </label></td> <?php if ($data['gameInfosField']['gameInfos']['curr'] != null) { ?> <td class="value"> <input class="text width2" type="text" name="Curr<?php echo $data['gameInfosField']['id']; ?> " id="Curr<?php echo $data['gameInfosField']['id']; ?> " readonly="readonly" value="<?php if (isset($data['gameInfosField']['gameInfos']['curr'][$data['gameInfosField']['id']])) { echo $data['gameInfosField']['gameInfos']['curr'][$data['gameInfosField']['id']]; } ?> " /> </td> <?php } ?> <td class="value"> <input class="text width2" type="<?php echo isset($data['gameInfosField']['gameInfos']['next'][$data['gameInfosField']['id']]) && is_numeric($data['gameInfosField']['gameInfos']['next'][$data['gameInfosField']['id']]) ? 'number" min="0"' : 'text';