경로문제로 인해 g4_path() 수정

This commit is contained in:
gnuboard
2013-03-20 10:14:02 +09:00
parent 9e4f620a74
commit ef297dfcea

View File

@ -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}
<li><strong><?=$dbconfig_file?></strong></li>
</ul>
<p>프로그램 설치 후 실행하시기 바랍니다.</p>
<a href="<?=G4_URL?>/install/">그누보드4S 설치하기</a>
<a href="./install/">그누보드4S 설치하기</a>
</div>
</body>
</html>