32 return self::getRelativePath(
dirname(PATH_thisScript), $targetPath);
42 if (self::isAbsolutePath($targetPath)) {
43 if (strpos($targetPath, PATH_site) === 0) {
44 $targetPath = self::stripPathSitePrefix($targetPath);
45 if (!defined(
'TYPO3_cliMode')) {
49 } elseif (strpos($targetPath,
'://') !==
false) {
54 $targetPath = self::stripPathSitePrefix($targetPath);
55 if (!defined(
'TYPO3_cliMode')) {
75 if ($sourcePath !== $targetPath) {
76 $commonPrefix = self::getCommonPrefix(array($sourcePath, $targetPath));
78 $commonPrefixLength = strlen($commonPrefix);
79 $resolvedSourcePath =
'';
80 $resolvedTargetPath =
'';
82 if (strlen($sourcePath) > $commonPrefixLength) {
83 $resolvedSourcePath = (string) substr($sourcePath, $commonPrefixLength);
85 if (strlen($targetPath) > $commonPrefixLength) {
86 $resolvedTargetPath = (string) substr($targetPath, $commonPrefixLength);
88 if ($resolvedSourcePath !==
'') {
89 $sourcePathSteps = count(explode(
'/', $resolvedSourcePath));
91 $relativePath = self::sanitizeTrailingSeparator(str_repeat(
'../', $sourcePathSteps) . $resolvedTargetPath);
108 $paths = array_map(array(
'TYPO3\\CMS\\Core\\Utility\\GeneralUtility',
'fixWindowsFilePath'), $paths);
110 if (count($paths) === 1) {
111 $commonPath = array_shift($paths);
112 } elseif (count($paths) > 1) {
113 $parts = explode(
'/', array_shift($paths));
116 foreach ($parts as $part) {
117 $comparePath .= $part .
'/';
118 foreach ($paths as $path) {
119 if (strpos($path .
'/', $comparePath) !== 0) {
127 $commonPath = $comparePath;
130 if ($commonPath !== NULL) {
131 $commonPath = self::sanitizeTrailingSeparator($commonPath,
'/');
145 return rtrim($path, $separator) . $separator;
162 $currentLocale = setlocale(LC_CTYPE, 0);
163 setlocale(LC_CTYPE,
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLocale']);
165 setlocale(LC_CTYPE, $currentLocale);
183 $currentLocale = setlocale(LC_CTYPE, 0);
184 setlocale(LC_CTYPE,
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLocale']);
186 setlocale(LC_CTYPE, $currentLocale);
204 static public function pathinfo($path, $options = NULL) {
205 $currentLocale = setlocale(LC_CTYPE, 0);
206 setlocale(LC_CTYPE,
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLocale']);
208 setlocale(LC_CTYPE, $currentLocale);
220 if (static::isWindows() && (substr($path, 1, 2) ===
':/' || substr($path, 1, 2) ===
':\\')) {
224 return $path[0] ===
'/';
251 $fileName = static::basename($includeFileName);
252 $basePath = substr($baseFilenameOrPath, -1) ===
'/' ? $baseFilenameOrPath : static::dirname($baseFilenameOrPath);
253 $newDir = static::getCanonicalPath($basePath .
'/' . static::dirname($includeFileName));
255 $result = (($newDir !==
'/') ? $newDir :
'') .
'/' . $fileName;
273 $path = trim(str_replace(
'\\',
'/', $path));
277 if (strpos($path,
'://') !== FALSE) {
278 list($protocol, $path) = explode(
'://', $path);
282 $absolutePathPrefix =
'';
283 if (static::isAbsolutePath($path)) {
284 if (static::isWindows() && substr($path, 1, 2) ===
':/') {
285 $absolutePathPrefix = substr($path, 0, 3);
286 $path = substr($path, 3);
288 $path = ltrim($path,
'/');
289 $absolutePathPrefix =
'/';
293 $theDirParts = explode(
'/', $path);
294 $theDirPartsCount = count($theDirParts);
295 for ($partCount = 0; $partCount < $theDirPartsCount; $partCount++) {
297 if ($theDirParts[$partCount] ===
'') {
298 array_splice($theDirParts, $partCount, 1);
303 if ($theDirParts[$partCount] ===
'.') {
304 array_splice($theDirParts, $partCount, 1);
309 if ($theDirParts[$partCount] ===
'..') {
310 if ($partCount >= 1) {
312 array_splice($theDirParts, $partCount - 1, 2);
314 $theDirPartsCount -= 2;
315 } elseif ($absolutePathPrefix) {
318 array_splice($theDirParts, $partCount, 1);
325 return $protocol . $absolutePathPrefix . implode(
'/', $theDirParts);
336 static $pathSiteLength = NULL;
339 if (!isset($pathSiteLength)) {
340 $pathSiteLength = strlen(PATH_site);
342 return substr($path, $pathSiteLength);
357 return TYPO3_OS ===
'WIN';
static isAllowedAbsPath($path)
static getCanonicalPath($path)
static getRelativePathTo($targetPath)
static getCommonPrefix(array $paths)
static getIndpEnv($getEnvName)
static getAbsoluteWebPath($targetPath)
static pathinfo($path, $options=NULL)
static getAbsolutePathOfRelativeReferencedFileOrPath($baseFilenameOrPath, $includeFileName)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static fixWindowsFilePath($theFile)
static getRelativePath($sourcePath, $targetPath)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static isAbsolutePath($path)
static stripPathSitePrefix($path)
static resolveBackPath($pathStr)
static sanitizeTrailingSeparator($path, $separator='/')