From e4c9bf5ba455568b67d508cac0be6a3da4dd6b94 Mon Sep 17 00:00:00 2001 From: thisgun Date: Wed, 31 May 2017 15:42:51 +0900 Subject: [PATCH] =?UTF-8?q?g5=5Fpath=20=ED=95=A8=EC=88=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 608a779ac..da867ec16 100644 --- a/common.php +++ b/common.php @@ -32,10 +32,11 @@ function g5_path() $result['path'] = str_replace('\\', '/', dirname(__FILE__)); $tilde_remove = preg_replace('/^\/\~[^\/]+(.*)$/', '$1', $_SERVER['SCRIPT_NAME']); $document_root = str_replace($tilde_remove, '', $_SERVER['SCRIPT_FILENAME']); - $root = str_replace($document_root, '', $result['path']); + $pattern = '/' . preg_quote($document_root, '/') . '/i'; + $root = preg_replace($pattern, '', $result['path']); $port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''; $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://'; - $user = str_replace(str_replace($document_root, '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']); + $user = str_replace(preg_replace($pattern, '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']); $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; if(isset($_SERVER['HTTP_HOST']) && preg_match('/:[0-9]+$/', $host)) $host = preg_replace('/:[0-9]+$/', '', $host);