config 파일 관계 정리

This commit is contained in:
gnuboard
2013-02-07 10:04:04 +09:00
parent 4c619faa5b
commit 32059df0ae

View File

@ -3,6 +3,8 @@
** 공통 변수, 상수, 코드
*******************************************************************************/
//error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ALL & ~E_NOTICE);
//error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
// 보안설정이나 프레임이 달라도 쿠키가 통하도록 설정
@ -65,20 +67,44 @@ $group = array();
$g4 = array();
function g4_path()
{
$path = dirname(__FILE__); // 예) /home/sir/www/g4s
$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
$port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '';
$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://';
$result = array();
$result['path'] = $path;
$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;
}
$g4_path = g4_path();
include_once($g4_path['path'].'/config.php'); // 설정 파일
unset($g4_path);
//==============================================================================
// 공통
//------------------------------------------------------------------------------
$config_user_file = dirname(__FILE__).'/config.user.php';
if (file_exists($config_user_file)) {
include_once($config_user_file);
include_once(dirname(__FILE__).'/config.php'); // 설정 파일
$dbconfig_file = G4_DATA_PATH.'/dbconfig.php';
if (file_exists($dbconfig_file)) {
include_once($dbconfig_file);
include_once(G4_LIB_PATH.'/common.lib.php'); // 공통 라이브러리
$connect_db = sql_connect(G4_MYSQL_HOST, G4_MYSQL_USER, G4_MYSQL_PASSWORD) or die('MySQL Connect Error!!!');
$select_db = sql_select_db(G4_MYSQL_DB, $connect_db) or die('MySQL DB Error!!!');
} else {
echo "<meta http-equiv='content-type' content='text/html; charset=utf-8'>";
echo "<h3>$config_user_file 파일을 찾을 수 없습니다.<br>프로그램 설치 후 실행하시기 바랍니다.</h3>";
echo "<h3>$dbconfig_file 파일을 찾을 수 없습니다.<br>프로그램 설치 후 실행하시기 바랍니다.</h3>";
echo '<a href="'.G4_URL.'/install/">설치하기</a>';
exit;
}