From ef297dfcea51aaa88b7f86efc96cb67b9abc492b Mon Sep 17 00:00:00 2001 From: gnuboard Date: Wed, 20 Mar 2013 10:14:02 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=AC=B8=EC=A0=9C=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B8=ED=95=B4=20g4=5Fpath()=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.php | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/common.php b/common.php index dff8c4e0a..706d7339b 100644 --- a/common.php +++ b/common.php @@ -69,18 +69,44 @@ $g4 = array(); function g4_path() { - $path = dirname(__FILE__); // 예) /home/sir/www/g4s + $result['path'] = dirname(__FILE__); + $root = str_replace($_SERVER['DOCUMENT_ROOT'], '', $result['path']); + $port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''; + $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://'; + $user = str_replace(str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']); + $result['url'] = $http.$_SERVER['SERVER_NAME'].$port.$user.$root; + + + //$base_dir = parse_url($_SERVER['REQUEST_URI']); + //print_r($base_dir); + /* $linux_dir = str_replace("\\", "/", $path); // 예) /home/sir/www/g4s $document_root = str_replace("\\", "/", $_SERVER['DOCUMENT_ROOT']); // 예) /home/sir/www - $base_dir = preg_replace('#^'.$document_root.'#i', '', $linux_dir); // 예) /g4s + + if (strpos($linux_dir, $document_root) === false) { + for($base_dir = dirname($_SERVER['SCRIPT_NAME']); strpos($linux_dir, $base_dir) === false; $base_dir = dirname($base_dir)); + + if (strlen($base_dir) && strlen($linux_dir) != (strrpos($linux_dir, $base_dir)+strlen($base_dir))) { + $base_dir = substr($linux_dir, strrpos($linux_dir, $base_dir)); + } + } + else { + $base_dir = preg_replace('#^'.$document_root.'#i', '', $linux_dir); // 예) /g4s + } + + if (strlen($base_dir) && substr($base_dir, 0, 1) != '/') $base_dir = '/'.$base_dir; + $port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''; $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://'; $result = array(); - $result['path'] = $path; + // 윈도우의 경우 역슬레쉬 경로인데 그다지 권장하지 않는다. php에서는 슬레쉬도 경로 인자로 인식하므로 슬레쉬 사용. + $result['path'] = $linux_dir; + $result['url'] = $http.$_SERVER['SERVER_NAME'].$port.$base_dir; $result['curr_url'] = $http.$_SERVER['SERVER_NAME'].$port.$_SERVER['PHP_SELF']; $result['curr_uri'] = $result['curr_url'] . ($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : ''); + */ return $result; } @@ -127,7 +153,7 @@ div a {display:block;margin:50px auto 10px;width:170px;text-align:center}
  • 프로그램 설치 후 실행하시기 바랍니다.

    - 그누보드4S 설치하기 + 그누보드4S 설치하기