本文整理汇总了PHP中Str::replaceChars方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::replaceChars方法的具体用法?PHP Str::replaceChars怎么用?PHP Str::replaceChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::replaceChars方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
$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);
示例2: getLocalMapList
/**
* Récupère la liste des maps en local à partir d'un chemin
*
* @param string $path -> Le chemin du dossier à lister
* @param string $sortBy -> Le tri à faire sur la liste
* @return array
*/
public static function getLocalMapList($directory, $currentPath, $sortBy = null)
{
global $client;
$out = array();
if (is_array($directory)) {
if (!empty($directory['files'])) {
// Récupération du cache existant
$mapsDirectoryPath = self::getMapsDirectoryPath();
$cache = new AdminServCache();
$cacheKey = 'mapslist-' . Str::replaceChars($mapsDirectoryPath . $currentPath);
$cacheMaps = $cache->get($cacheKey);
// Fichiers
$files = array();
foreach ($directory['files'] as $fileName => $fileValues) {
$dbExt = File::getDoubleExtension($fileName);
if (in_array($dbExt, AdminServConfig::$MAP_EXTENSION)) {
$files[$fileName] = $fileValues;
}
}
// Suppression du cache en trop
$cacheOverFiles = array_diff_key($cacheMaps, $files);
if (!empty($cacheOverFiles)) {
foreach ($cacheOverFiles as $fileName => $fileValues) {
if (isset($cacheMaps[$fileName])) {
unset($cacheMaps[$fileName]);
}
}
$cache->set($cacheKey, $cacheMaps);
}
// Ajout des fichiers manquant dans le cache
$cacheMissingFiles = array_diff_key($files, $cacheMaps);
if (!empty($cacheMissingFiles)) {
// Path
$path = $mapsDirectoryPath . $currentPath;
// Création du cache
foreach ($cacheMissingFiles as $file => $values) {
// Données
$processFile = utf8_decode($file);
if (SERVER_VERSION_NAME == 'TmForever') {
$Gbx = new GBXChallengeFetcher($path . $processFile);
} else {
$Gbx = new GBXChallMapFetcher();
$Gbx->processFile($path . $processFile);
}
// Name
$filename = $Gbx->name;
if ($filename == 'read error') {
$filename = str_ireplace('.' . $dbExt, '', $file);
}
$name = htmlspecialchars($filename, ENT_QUOTES, 'UTF-8');
$out['lst'][$file]['Name'] = TmNick::toHtml($name, 10, true);
// Environnement
$env = $Gbx->envir;
if ($env == 'read error') {
$env = null;
}
if ($env == 'Speed') {
$env = 'Desert';
} else {
if ($env == 'Alpine') {
$env = 'Snow';
}
}
$out['lst'][$file]['Environment'] = $env;
// Autres
$out['lst'][$file]['FileName'] = $currentPath . $file;
$uid = $Gbx->uid;
if ($uid == 'read error') {
$uid = null;
}
$out['lst'][$file]['UId'] = $uid;
$author = $Gbx->author;
if ($author == 'read error') {
$author = null;
}
$out['lst'][$file]['Author'] = $author;
$out['lst'][$file]['Recent'] = $values['recent'];
// MapType
$mapType = $Gbx->mapType;
if ($mapType == null && $Gbx->typeName != null) {
$mapType = $Gbx->typeName;
}
$out['lst'][$file]['Type']['Name'] = self::formatScriptName($mapType);
$out['lst'][$file]['Type']['FullName'] = $mapType;
}
// Mise à jour du cache
if (!empty($cacheMaps)) {
$out['lst'] = array_merge($cacheMaps, $out['lst']);
}
$cache->set($cacheKey, $out['lst']);
} else {
$out['lst'] = $cacheMaps;
}
//.........这里部分代码省略.........
示例3: addslashes
$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);
}
}
}
}
}
示例4: foreach
foreach ($_POST['renameMapList'] as $newMapName) {
$result = File::rename($data['mapsDirectoryPath'] . $_POST['map'][$i], $data['mapsDirectoryPath'] . $args['directory'] . $newMapName);
if ($result !== true) {
AdminServ::error(Utils::t('Unable to rename the map') . ' : ' . $newMapName . ' (' . $result . ')');
break;
} else {
AdminServLogs::add('action', 'Rename map: ' . $_POST['map'][$i] . ' to ' . $newMapName);
}
$i++;
}
Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory);
} else {
if (isset($_POST['renameAutoValid']) && isset($_POST['map']) && count($_POST['map']) > 0 && isset($_POST['renameMapList']) && count($_POST['renameMapList']) > 0) {
$i = 0;
foreach ($_POST['renameMapList'] as $newMapName) {
$result = File::rename($data['mapsDirectoryPath'] . $_POST['map'][$i], $data['mapsDirectoryPath'] . $args['directory'] . Str::replaceChars($newMapName));
if ($result !== true) {
AdminServ::error(Utils::t('Unable to rename the map') . ' : ' . $newMapName . ' (' . $result . ')');
break;
} else {
AdminServLogs::add('action', 'Rename map (auto): ' . $_POST['map'][$i] . ' to ' . $newMapName);
}
$i++;
}
Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory);
} else {
if (isset($_POST['moveMapValid']) && isset($_POST['moveDirectoryList']) && isset($_POST['map']) && count($_POST['map']) > 0) {
// Chemin
if ($_POST['moveDirectoryList'] == '.') {
$newPath = $data['mapsDirectoryPath'];
} else {
示例5: array
$srvoptsImportExport = $_POST['srvoptsImportExport'];
}
// Enregistrement
if ($ChangeAuthPassword) {
if (USER_ADMINLEVEL === $ChangeAuthLevel) {
$_SESSION['adminserv']['password'] = $ChangeAuthPassword;
}
AdminServ::info(Utils::t('You changed the password "!authLevel", remember it at the next connection!', array('!authLevel' => $ChangeAuthLevel)));
AdminServLogs::add('action', 'Change authentication password for ' . $ChangeAuthLevel . ' level');
} elseif ($srvoptsImportExport) {
// Import
if ($srvoptsImportExport == 'Import') {
$srvoptsImportName = $_POST['srvoptsImportName'];
if ($srvoptsImportName != 'none') {
$struct = AdminServ::importServerOptions($srvoptsConfigDirectory . $srvoptsImportName);
if (AdminServ::setServerOptions($struct)) {
AdminServLogs::add('action', 'Import server options from ' . $srvoptsConfigDirectory . $srvoptsImportName);
}
}
} elseif ($srvoptsImportExport == 'Export') {
$srvoptsExportName = Str::replaceChars($_POST['srvoptsExportName']);
AdminServ::exportServerOptions($srvoptsConfigDirectory . $srvoptsExportName . '.txt', $struct);
}
} elseif (AdminServ::setServerOptions($struct)) {
AdminServLogs::add('action', 'Save server options');
}
Utils::redirection(false, '?p=' . USER_PAGE);
}
// LECTURE
$data['srvOpt'] = AdminServ::getServerOptions();
$data['adminLevels'] = AdminServAdminLevel::getServerList();
示例6: array
<?php
// ENREGISTREMENT
if (isset($_POST['savematchsetting']) && isset($_SESSION['adminserv']['matchset_maps_selected'])) {
// Filename
$matchSettingName = Str::replaceChars($_POST['matchSettingName']);
$filename = $data['mapsDirectoryPath'] . $args['directory'] . $matchSettingName;
if (File::getExtension($matchSettingName) != 'txt') {
$filename .= '.txt';
}
$struct = array();
// Gameinfos
$gameinfos = AdminServ::getGameInfosStructFromPOST();
$struct['gameinfos'] = array('game_mode' => $gameinfos['GameMode'], 'chat_time' => $gameinfos['ChatTime'], 'finishtimeout' => $gameinfos['FinishTimeout'], 'allwarmupduration' => $gameinfos['AllWarmUpDuration'], 'disablerespawn' => $gameinfos['DisableRespawn'], 'forceshowallopponents' => $gameinfos['ForceShowAllOpponents'], 'rounds_pointslimit' => $gameinfos['RoundsPointsLimit'], 'rounds_custom_points' => $gameinfos['RoundCustomPoints'], 'rounds_usenewrules' => $gameinfos['RoundsUseNewRules'], 'rounds_forcedlaps' => $gameinfos['RoundsForcedLaps'], 'rounds_pointslimitnewrules' => $gameinfos['RoundsPointsLimitNewRules'], 'team_pointslimit' => $gameinfos['TeamPointsLimit'], 'team_maxpoints' => $gameinfos['TeamMaxPoints'], 'team_usenewrules' => $gameinfos['TeamUseNewRules'], 'team_pointslimitnewrules' => $gameinfos['TeamPointsLimitNewRules'], 'timeattack_limit' => $gameinfos['TimeAttackLimit'], 'timeattack_synchstartperiod' => $gameinfos['TimeAttackSynchStartPeriod'], 'laps_nblaps' => $gameinfos['LapsNbLaps'], 'laps_timelimit' => $gameinfos['LapsTimeLimit'], 'cup_pointslimit' => $gameinfos['CupPointsLimit'], 'cup_roundsperchallenge' => $gameinfos['CupRoundsPerMap'], 'cup_nbwinners' => $gameinfos['CupNbWinners'], 'cup_warmupduration' => $gameinfos['CupWarmUpDuration']);
if (SERVER_VERSION_NAME != 'TmForever') {
$struct['gameinfos']['script_name'] = $gameinfos['ScriptName'];
}
// HotSeat
$struct['hotseat'] = array('game_mode' => intval($_POST['hotSeatGameMode']), 'time_limit' => TimeDate::secToMillisec(intval($_POST['hotSeatTimeLimit'])), 'rounds_count' => intval($_POST['hotSeatCountRound']));
// Filter
$struct['filter'] = array('is_lan' => array_key_exists('filterIsLan', $_POST), 'is_internet' => array_key_exists('filterIsInternet', $_POST), 'is_solo' => array_key_exists('filterIsSolo', $_POST), 'is_hotseat' => array_key_exists('filterIsHotSeat', $_POST), 'sort_index' => intval($_POST['filterSortIndex']), 'random_map_order' => array_key_exists('filterRandomMaps', $_POST), 'force_default_gamemode' => intval($_POST['filterDefaultGameMode']));
// ScriptSettings
if (!$client->query('GetModeScriptInfo')) {
AdminServ::error();
} else {
$scriptsettings = $client->getResponse();
if (!empty($scriptsettings['ParamDescs'])) {
foreach ($scriptsettings['ParamDescs'] as $param) {
$struct['scriptsettings'][] = array('name' => $param['Name'], 'type' => $param['Type'], 'value' => $param['Default']);
}
}
示例7: replaceFilename
function replaceFilename($str)
{
return Str::replaceChars($str);
}