Exemple #1
0
 public static function sortByNickName($a, $b)
 {
     $a = TmNick::toText($a['NickName']);
     $b = TmNick::toText($b['NickName']);
     if ($a == $b) {
         return 0;
     }
     return $a < $b ? -1 : 1;
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
             foreach ($playerList as $player) {
                 if ($player['IsSpectator'] != 0) {
                     $playerStatus = Utils::t('Spectator');
                 } else {
                     $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'];
     }
 }
Exemple #4
0
 /**
  * Récupère la liste des joueurs
  *
  * @param string $currentPlayerLogin -> Le login joueur à sélectionner
  * @return string
  */
 public static function getPlayerList($currentPlayerLogin = null)
 {
     global $client;
     $out = '<option value="null">' . Utils::t('No player available') . '</option>';
     if (!$client->query('GetPlayerList', AdminServConfig::LIMIT_PLAYERS_LIST, 0, 1)) {
         AdminServ::error();
     } else {
         $playerList = $client->getResponse();
         if (count($playerList) > 0) {
             $out = null;
             foreach ($playerList as $player) {
                 if ($currentPlayerLogin == $player['Login']) {
                     $selected = ' selected="selected"';
                 } else {
                     $selected = null;
                 }
                 $out .= '<option value="' . $player['Login'] . '"' . $selected . '>' . TmNick::toText($player['NickName']) . '</option>';
             }
         }
     }
     return $out;
 }
Exemple #5
0
<?php

// INCLUDES
require_once '../class/tmnick.class.php';
// ISSET
if (isset($_GET['t'])) {
    $text = stripslashes($_GET['t']);
} else {
    $text = null;
}
// DATA
$out = null;
if ($text != null) {
    $out['str'] = TmNick::toHtml(nl2br($text), 10, false, false, '#666');
}
// OUT
echo json_encode($out);