#472 세션을 파일기반이 아닌 DB기반으로 사용하도록 변경하고 접속자 출력 위젯 추가

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4290 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-06-18 06:56:29 +00:00
parent 474ca4df06
commit ea2fede30e
42 changed files with 702 additions and 111 deletions

View file

@ -73,12 +73,25 @@
// 기본적인 DB정보 세팅
$this->_loadDBInfo();
// 세션 핸들러 지정
$oSessionModel = &getModel('session');
$oSessionController = &getController('session');
session_set_save_handler(
array(&$oSessionController,"open"),
array(&$oSessionController,"close"),
array(&$oSessionModel,"read"),
array(&$oSessionController,"write"),
array(&$oSessionController,"destroy"),
array(&$oSessionController,"gc")
);
session_start();
// 쿠키로 설정된 언어타입 가져오기
if($_COOKIE['lang_type']) $this->lang_type = $_COOKIE['lang_type'];
else $this->lang_type = $this->db_info->lang_type;
// 등록된 기본 언어파일 찾기
$langs = file('./common/lang/lang.info');
$langs = file(_XE_PATH_.'common/lang/lang.info');
$accept_lang = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach($langs as $val) {
list($lang_prefix, $lang_text) = explode(',',$val);
@ -99,7 +112,7 @@
// 기본 언어파일 로드
$this->lang = &$GLOBALS['lang'];
$this->_loadLang("./common/lang/");
$this->_loadLang(_XE_PATH_."common/lang/");
// Request Method 설정
$this->_setRequestMethod();
@ -129,7 +142,7 @@
}
// rewrite 모듈사용 상태 체크
if(file_exists('./.htaccess')&&$this->db_info->use_rewrite == 'Y') $this->allow_rewrite = true;
if(file_exists(_XE_PATH_.'.htaccess')&&$this->db_info->use_rewrite == 'Y') $this->allow_rewrite = true;
else $this->allow_rewrite = false;
// 기본 JS/CSS 등록
@ -164,6 +177,9 @@
* @brief DB및 기타 자원들의 close
**/
function close() {
// Session Close
if(function_exists('session_write_close')) session_write_close();
// DB close
$oDB = &DB::getInstance();
if(is_object($oDB)&&method_exists($oDB, 'close')) $oDB->close();
@ -828,7 +844,7 @@
* @brief js file 목록을 return
**/
function _getJsFile() {
require_once("./classes/optimizer/Optimizer.class.php");
require_once(_XE_PATH_."classes/optimizer/Optimizer.class.php");
$oOptimizer = new Optimizer();
return $oOptimizer->getOptimizedFiles($this->_getUniqueFileList($this->js_files), "js");
}
@ -863,7 +879,7 @@
* @brief CSS file 목록 return
**/
function _getCSSFile() {
require_once("./classes/optimizer/Optimizer.class.php");
require_once(_XE_PATH_."classes/optimizer/Optimizer.class.php");
$oOptimizer = new Optimizer();
return $oOptimizer->getOptimizedFiles($this->_getUniqueFileList($this->css_files), "css");
}
@ -932,7 +948,7 @@
* @brief db설정내용이 저장되어 있는 config file의 path를 return
**/
function getConfigFile() {
return "./files/config/db.config.php";
return _XE_PATH_."files/config/db.config.php";
}
/**

View file

@ -15,7 +15,7 @@
class DB {
var $count_cache_path = './files/cache/db';
var $count_cache_path = 'files/cache/db';
var $cond_operation = array( ///< 조건문에서 조건을 등호로 표시하는 변수
'equal' => '=',
@ -43,7 +43,7 @@
var $supported_list = array(); ///< 지원하는 DB의 종류, classes/DB/DB***.class.php 를 이용하여 동적으로 작성됨
var $cache_file = './files/cache/queries/'; ///< query cache파일의 위치
var $cache_file = 'files/cache/queries/'; ///< query cache파일의 위치
/**
* @brief DB를 상속받는 특정 db type의 instance를 생성 return
@ -54,15 +54,23 @@
if(!$GLOBALS['__DB__']) {
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type,0,1)), strtolower(substr($db_type,1)));
$class_file = sprintf("./classes/db/%s.class.php", $class_name);
$class_file = sprintf("%sclasses/db/%s.class.php", _XE_PATH_, $class_name);
if(!file_exists($class_file)) new Object(-1, 'msg_db_not_setted');
require_once($class_file);
$eval_str = sprintf('$GLOBALS[\'__DB__\'] = new %s();', $class_name);
$eval_str = sprintf('$GLOBALS[\'__DB__\'][\''.$db_type.'\'] = new %s();', $class_name);
eval($eval_str);
}
return $GLOBALS['__DB__'];
return $GLOBALS['__DB__'][$db_type];
}
/**
* @brief constructor
**/
function DB() {
$this->count_cache_path = _XE_PATH_.$this->count_cache_path;
$this->cache_file = _XE_PATH_.$this->cache_file;
}
/**
@ -77,7 +85,7 @@
* @brief 지원 가능한 DB 목록을 return
**/
function _getSupportedList() {
$db_classes_path = "./classes/db/";
$db_classes_path = _XE_PATH_."classes/db/";
$filter = "/^DB([^\.]+)\.class\.php/i";
$supported_list = FileHandler::readDir($db_classes_path, $filter, true);
sort($supported_list);
@ -89,7 +97,7 @@
if(version_compare(phpversion(), '5.0') < 0 && preg_match('/pdo/i',$db_type)) continue;
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type,0,1)), strtolower(substr($db_type,1)));
$class_file = sprintf("./classes/db/%s.class.php", $class_name);
$class_file = sprintf(_XE_PATH_."classes/db/%s.class.php", $class_name);
if(!file_exists($class_file)) continue;
unset($oDB);
@ -144,7 +152,7 @@
$str .= sprintf("\t Query Failed : %d\n\t\t\t %s\n", $this->errno, $this->errstr);
if(__DEBUG_DB_OUTPUT__==1) {
$debug_file = "./files/_debug_db_query.php";
$debug_file = _XE_PATH_."files/_debug_db_query.php";
$buff = sprintf("%s\n",print_r($str,true));
if($display_line) $buff = "\n====================================\n".$buff."------------------------------------\n";
@ -161,7 +169,7 @@
// __LOG_SLOW_QUERY__ 가 정해져 있다면 시간 체크후 쿼리 로그 남김
if(__LOG_SLOW_QUERY__>0 && $elapsed_time > __LOG_SLOW_QUERY__) {
$buff = '';
$log_file = './files/_db_slow_query.php';
$log_file = _XE_PATH_.'files/_db_slow_query.php';
if(!file_exists($log_file)) {
$buff = '<?php exit();?>'."\n";
}
@ -218,17 +226,17 @@
}
if(!$target || !$module || !$id) return new Object(-1, 'msg_invalid_queryid');
$xml_file = sprintf('./%s/%s/queries/%s.xml', $target, $module, $id);
$xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id);
if(!file_exists($xml_file)) return new Object(-1, 'msg_invalid_queryid');
// 일단 cache 파일을 찾아본다
$cache_file = sprintf('%s%s.cache.php', $this->cache_file, $query_id);
$cache_file = sprintf('%s%s%s.cache.php', _XE_PATH_, $this->cache_file, $query_id);
if(file_exists($cache_file)) $cache_time = filemtime($cache_file);
else $cache_time = -1;
// 캐시 파일이 없거나 시간 비교하여 최근것이 아니면 원본 쿼리 xml파일을 찾아서 파싱을 한다
if($cache_time<filemtime($xml_file) || $cache_time < filemtime('./classes/db/DB.class.php')) {
require_once('./classes/xml/XmlQueryParser.class.php');
if($cache_time<filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php')) {
require_once(_XE_PATH_.'classes/xml/XmlQueryParser.class.php');
$oParser = new XmlQueryParser();
$oParser->parse($query_id, $xml_file, $cache_file);
}

View file

@ -668,7 +668,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf('select count(*) as "count" from %s %s', implode(',',$table_list), $condition);

View file

@ -814,7 +814,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf('select count(*) as "count" from %s %s;', implode(',',$table_list), $condition);

View file

@ -546,7 +546,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);

View file

@ -556,7 +556,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);

View file

@ -545,7 +545,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);

View file

@ -564,7 +564,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);

View file

@ -605,7 +605,7 @@
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
**/
function _getNavigationData($table_list, $columns, $condition, $output) {
require_once('./classes/page/PageHandler.class.php');
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
// 전체 개수를 구함
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);

View file

@ -88,8 +88,10 @@
* 주어진 경로를 단계별로 접근하여 recursive하게 디렉토리 생성
**/
function makeDir($path_string) {
$path_string = str_replace(_XE_PATH_,'',$path_string);
$path_list = explode('/', $path_string);
$path = _XE_PATH_;
for($i=0;$i<count($path_list);$i++) {
if(!$path_list[$i]) continue;
$path .= $path_list[$i].'/';

View file

@ -63,7 +63,7 @@
// 애드온 실행 (모듈 실행 전)
$called_position = 'before_module_init';
@include("./files/cache/activated_addons.cache.php");
@include(_XE_PATH_."files/cache/activated_addons.cache.php");
}
/**
@ -251,10 +251,7 @@
* @brief module의 위치를 찾아서 return
**/
function getModulePath($module) {
$class_path = sprintf('./modules/%s/', $module);
if(is_dir($class_path)) return $class_path;
return "";
return sprintf('./modules/%s/', $module);
}
/**
@ -262,7 +259,7 @@
**/
function &getModuleInstance($module, $type = 'view', $kind = '') {
$class_path = ModuleHandler::getModulePath($module);
if(!$class_path) return NULL;
if(!is_dir(_XE_PATH_.$class_path)) return NULL;
if(__DEBUG__==3) $start_time = getMicroTime();
@ -277,7 +274,7 @@
// 상위 클래스명 구함
if(!class_exists($module)) {
$high_class_file = sprintf('%s%s.class.php', $class_path, $module);
$high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_,$class_path, $module);
if(!file_exists($high_class_file)) return NULL;
require_once($high_class_file);
}
@ -287,33 +284,33 @@
case 'controller' :
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"Controller");
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"Controller");
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
}
break;
case 'model' :
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"Model");
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"Model");
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
}
break;
case 'class' :
$instance_name = $module;
$class_file = sprintf('%s%s.class.php', $class_path, $module);
$class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
break;
default :
$type = 'view';
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"View");
$class_file = sprintf('%s%s.admin.view.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.admin.view.php', _XE_PATH_, $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"View");
$class_file = sprintf('%s%s.view.php', $class_path, $module, $type);
$class_file = sprintf('%s%s%s.view.php', _XE_PATH_, $class_path, $module, $type);
}
break;
}
@ -361,7 +358,7 @@
$oModuleModel = &getModel('module');
$cache_dir = sprintf("./files/cache/triggers/");
$cache_dir = sprintf("%sfiles/cache/triggers/",_XE_PATH_);
if(!is_dir($cache_dir)) FileHandler::makeDir($cache_dir);
$cache_file = sprintf("%s%s.%s", $cache_dir, $trigger_name, $called_position);

View file

@ -228,7 +228,7 @@
* @brief template 경로 지정
**/
function setTemplatePath($path) {
if(substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/';
$this->template_path = $path;
}
@ -274,8 +274,8 @@
* @brief layout 경로 지정
**/
function setLayoutPath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/';
if(substr($path,0,2)!='./') $path = './'.$path;
$this->layout_path = $path;
}
@ -297,7 +297,7 @@
// addon 실행(called_position 를 before_module_proc로 하여 호출)
$called_position = 'before_module_proc';
@include("./files/cache/activated_addons.cache.php");
@include(_XE_PATH_."files/cache/activated_addons.cache.php");
// 지금까지 이상이 없었다면 action 실행
if(!$this->stop_proc) {
@ -347,7 +347,7 @@
// addon 실행(called_position 를 after_module_proc로 하여 호출)
$called_position = 'after_module_proc';
@include("./files/cache/activated_addons.cache.php");
@include(_XE_PATH_."files/cache/activated_addons.cache.php");
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
$this->setError($output->getError());

View file

@ -49,12 +49,12 @@
$output->tables[$alias] = $table_name;
// 테이블을 찾아서 컬럼의 속성을 구함
$table_file = sprintf('./%s/%s/schemas/%s.xml', 'modules', $module, $table_name);
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
if(!file_exists($table_file)) {
$searched_list = FileHandler::readDir('./modules');
$searched_list = FileHandler::readDir(_XE_PATH_.'modules');
$searched_count = count($searched_list);
for($i=0;$i<$searched_count;$i++) {
$table_file = sprintf('./%s/%s/schemas/%s.xml', 'modules', $searched_list[$i], $table_name);
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name);
if(file_exists($table_file)) break;
}
}