1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-29 04:55:02 +03:00

fix проблемы с web- и server- путями

This commit is contained in:
Alexey Kachayev 2009-12-13 21:49:05 +00:00
parent b87b45ec59
commit 07e37311ea

View file

@ -211,13 +211,18 @@ class LsImage extends Module {
* @param string $sPath * @param string $sPath
* @return string * @return string
*/ */
public function GetServerPath($sPath) { public function GetServerPath($sPath) {
$sPath=str_replace(Config::Get('path.root.web'), Config::Get('path.root.server'), $sPath);
/** /**
* Отделяем ?-суфикс в Web адресах * Определяем, принадлежит ли этот адрес основному домену
*/ */
list($sPath,)=explode('?',$sPath,2); if(parse_url($sPath,PHP_URL_HOST)!=parse_url(Config::Get('path.root.web'),PHP_URL_HOST)) {
return $sPath; return $sPath;
}
/**
* Выделяем адрес пути
*/
$sPath = parse_url($sPath,PHP_URL_PATH);
return rtrim(Config::Get('path.root.server'),'/').'/'.ltrim($sPath,'/');
} }
/** /**
* Возвращает серверный адрес по переданному web-адресу * Возвращает серверный адрес по переданному web-адресу
@ -226,8 +231,8 @@ class LsImage extends Module {
* @return string * @return string
*/ */
public function GetWebPath($sPath) { public function GetWebPath($sPath) {
return str_replace(rtrim(Config::Get('path.root.server'),'/'), rtrim(Config::Get('path.root.web'),'/'), $sPath); return str_replace(realpath(Config::Get('path.root.server')), Config::Get('path.root.web'), realpath($sPath));
} }
/** /**
* Получает директорию для данного пользователя * Получает директорию для данного пользователя
* Используется фомат хранения данных (/images/us/er/id/yyyy/mm/dd/file.jpg) * Используется фомат хранения данных (/images/us/er/id/yyyy/mm/dd/file.jpg)