DOCUMENT_ROOT 가 현재 사용자의 경로로 나오지 않는 경우에 대한 수정

This commit is contained in:
chicpro
2013-03-20 11:20:51 +09:00
parent ca428762fd
commit 779b11002b

View File

@ -66,11 +66,13 @@ $g4 = array();
function g4_path()
{
$result['path'] = dirname(__FILE__);
$root = str_replace($_SERVER['DOCUMENT_ROOT'], '', $result['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']);
$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']);
$user = str_replace(str_replace($document_root, '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']);
$result['url'] = $http.$_SERVER['SERVER_NAME'].$port.$user.$root;
return $result;
}