From 07e37311eacf879084a5133add4ce03ae7439bf5 Mon Sep 17 00:00:00 2001 From: Alexey Kachayev Date: Sun, 13 Dec 2009 21:49:05 +0000 Subject: [PATCH] =?UTF-8?q?fix=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=20=D1=81=20web-=20=D0=B8=20server-=20=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/modules/image/Image.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/engine/modules/image/Image.class.php b/engine/modules/image/Image.class.php index 85b52d9f..b652f2e6 100644 --- a/engine/modules/image/Image.class.php +++ b/engine/modules/image/Image.class.php @@ -211,13 +211,18 @@ class LsImage extends Module { * @param string $sPath * @return string */ - public function GetServerPath($sPath) { - $sPath=str_replace(Config::Get('path.root.web'), Config::Get('path.root.server'), $sPath); + public function GetServerPath($sPath) { /** - * Отделяем ?-суфикс в Web адресах + * Определяем, принадлежит ли этот адрес основному домену */ - list($sPath,)=explode('?',$sPath,2); - return $sPath; + if(parse_url($sPath,PHP_URL_HOST)!=parse_url(Config::Get('path.root.web'),PHP_URL_HOST)) { + return $sPath; + } + /** + * Выделяем адрес пути + */ + $sPath = parse_url($sPath,PHP_URL_PATH); + return rtrim(Config::Get('path.root.server'),'/').'/'.ltrim($sPath,'/'); } /** * Возвращает серверный адрес по переданному web-адресу @@ -226,8 +231,8 @@ class LsImage extends Module { * @return string */ 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)