diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index a267ecd96..efff9a467 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1520,5 +1520,40 @@ $oContext = &Context::getInstance(); return $oContext->allow_rewrite; } + + /** + * @brief 로컬 경로를 웹 경로로 변경 + */ + function pathToUrl($path) { + $xe = _XE_PATH_; + $path = strtr($path, "\\", "/"); + + $base_url = preg_replace('@^https?://[^/]+/+@', '', Context::getDefaultUrl()); + + $_xe = explode('/', $xe); + $_path = explode('/', $path); + $_base = explode('/', $base_url); + + if (!$_base[count($_base)-1]) array_pop($_base); + + foreach($_xe as $idx=>$dir) { + if($_path[0] != $dir) break; + array_shift($_path); + } + + $idx = count($_xe) - $idx - 1; + while($idx--) { + if (count($_base)) array_shift($_base); + else array_unshift($_base, '..'); + } + + if (count($_base)) { + array_unshift($_path, implode('/', $_base)); + } + + $path = '/'.implode('/', $_path); + + return $path; + } } ?> diff --git a/modules/opage/opage.view.php b/modules/opage/opage.view.php index d6114c035..3c122c18d 100644 --- a/modules/opage/opage.view.php +++ b/modules/opage/opage.view.php @@ -37,7 +37,6 @@ else $content = $this->executeFile($path, $caching_interval, $cache_file); } - Context::set('opage_content', $content); // 결과 출력 템플릿 지정 @@ -145,13 +144,14 @@ if(preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val)) return $matches[0]; // .. 와 같은 경우 대상 경로를 구함 - elseif(preg_match('/^(\.\.)/i',$val)) { - $p = '/'.str_replace(_XE_PATH_,'',$this->path); + elseif(preg_match('/^\.\./i',$val)) { + $p = Context::pathToUrl($this->path); return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]); } if(substr($val,0,2)=='./') $val = substr($val,2); - $p = '/'.str_replace(_XE_PATH_,'',$this->path); + //$p = '/'.str_replace(_XE_PATH_,'',$this->path); + $p = Context::pathToUrl($this->path); return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]); }