mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7440 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
aff477dd54
commit
e5c5449be4
9 changed files with 38 additions and 179 deletions
|
|
@ -44,9 +44,6 @@
|
|||
var $supported_list = array(); ///< list of supported db, (will be written by classes/DB/DB***.class.php)
|
||||
|
||||
var $cache_file = 'files/cache/queries/'; ///< location of query cache
|
||||
var $path;
|
||||
var $tableMtime = array();
|
||||
var $disabled_cache_tables = array('session','counter_log','counter_site_status','counter_status');
|
||||
|
||||
/**
|
||||
* @brief returns instance of certain db type
|
||||
|
|
@ -62,11 +59,9 @@
|
|||
$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);
|
||||
require_once($class_file);
|
||||
$eval_str = sprintf('$GLOBALS[\'__DB__\'][\''.$db_type.'\'] = new %s();', $class_name);
|
||||
eval($eval_str);
|
||||
|
||||
register_shutdown_function(array(&$GLOBALS['__DB__'][$db_type],'_updateTableMtime'));
|
||||
}
|
||||
|
||||
return $GLOBALS['__DB__'][$db_type];
|
||||
|
|
@ -242,7 +237,7 @@
|
|||
* @return result of query
|
||||
* @remarks this function finds xml file or cache file of $query_id, compiles it and then execute it
|
||||
**/
|
||||
function executeQuery($query_id, $args = NULL, $update_mtime = true) {
|
||||
function executeQuery($query_id, $args = NULL) {
|
||||
if(!$query_id) return new Object(-1, 'msg_invalid_queryid');
|
||||
|
||||
$id_args = explode('.', $query_id);
|
||||
|
|
@ -265,7 +260,7 @@
|
|||
$cache_file = $this->checkQueryCacheFile($query_id, $xml_file);
|
||||
|
||||
// execute query
|
||||
return $this->_executeQuery($cache_file, $args, $query_id, $update_mtime);
|
||||
return $this->_executeQuery($cache_file, $args, $query_id);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -301,7 +296,7 @@
|
|||
* @param[in] $query_id query id
|
||||
* @return result of query
|
||||
**/
|
||||
function _executeQuery($cache_file, $source_args, $query_id, $update_mtime = true) {
|
||||
function _executeQuery($cache_file, $source_args, $query_id) {
|
||||
global $lang;
|
||||
|
||||
if(!file_exists($cache_file)) return new Object(-1, 'msg_invalid_queryid');
|
||||
|
|
@ -316,39 +311,21 @@
|
|||
// execute appropriate query
|
||||
switch($output->action) {
|
||||
case 'insert' :
|
||||
//$this->resetCountCache($output->tables);
|
||||
if($update_mtime) $this->updateTableMtime($output->tables);
|
||||
$this->resetCountCache($output->tables);
|
||||
$output = $this->_executeInsertAct($output);
|
||||
break;
|
||||
case 'update' :
|
||||
//$this->resetCountCache($output->tables);
|
||||
if($update_mtime) $this->updateTableMtime($output->tables);
|
||||
$this->resetCountCache($output->tables);
|
||||
$output = $this->_executeUpdateAct($output);
|
||||
break;
|
||||
case 'delete' :
|
||||
//$this->resetCountCache($output->tables);
|
||||
if($update_mtime) $this->updateTableMtime($output->tables);
|
||||
$this->resetCountCache($output->tables);
|
||||
$output = $this->_executeDeleteAct($output);
|
||||
break;
|
||||
case 'select' :
|
||||
if(count(array_intersect($this->disabled_cache_tables, $output->tables))==0){
|
||||
$CacheHandler = &CacheHandler::getInstance();
|
||||
$cache_support = $CacheHandler->isSupport();
|
||||
|
||||
if($cache_support){
|
||||
$cache_key = $query_id . serialize($source_args);
|
||||
$buff = $CacheHandler->get($cache_key, $this->_getTableMtime($output->tables));
|
||||
if($buff){
|
||||
return $buff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = $this->_executeSelectAct($output);
|
||||
if($cache_support && $cache_key) $CacheHandler->put($cache_key, $output);
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->isError()) $output = $this->getError();
|
||||
else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) $output = new Object();
|
||||
$output->add('_query', $this->query);
|
||||
|
|
@ -357,43 +334,6 @@
|
|||
return $output;
|
||||
}
|
||||
|
||||
function updateTableMtime($tables){
|
||||
$this->tableMtime = array_merge($this->tableMtime,$tables);
|
||||
}
|
||||
|
||||
function _updateTableMtime(){
|
||||
$tables = array_unique($this->tableMtime);
|
||||
foreach($tables as $table){
|
||||
if(!in_array($table, $this->disabled_cache_tables)){
|
||||
touch(_XE_PATH_.'files/cache/'.$table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _getTableMtime($tables){
|
||||
$tablemtime = array(null);
|
||||
foreach($tables as $table){
|
||||
if($GLOBALS['TABLEMTIME'][$table]){
|
||||
$tablemtime[] = $GLOBALS['TABLEMTIME'][$table];
|
||||
continue;
|
||||
}
|
||||
|
||||
$file = _XE_PATH_.'files/cache/'.$table;
|
||||
if(file_exists($file)){
|
||||
if(!$GLOBALS['TABLEMTIME'][$table]){
|
||||
$GLOBALS['TABLEMTIME'][$table] = filemtime($file);
|
||||
}
|
||||
|
||||
$tablemtime[] = $GLOBALS['TABLEMTIME'][$table];
|
||||
}else{
|
||||
touch($file);
|
||||
}
|
||||
}
|
||||
|
||||
$mtime = max($tablemtime);
|
||||
return !$mtime ? time() : $mtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check $val with $filter_type
|
||||
* @param[in] $key key value
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
//debugPrint($query);
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
$this->actStart($query);
|
||||
|
||||
|
|
@ -599,47 +599,18 @@
|
|||
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||
|
||||
$CacheHandler = &CacheHandler::getInstance();
|
||||
$cache_support = $CacheHandler->isSupport();
|
||||
|
||||
if($cache_support){
|
||||
|
||||
// 전체 개수를 구함
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
|
||||
$cache_key = join(',',$output->tables) . $count_condition;
|
||||
$mtime = $this->_getTableMtime($output->tables);
|
||||
|
||||
$total_count = $CacheHandler->get($cache_key, $mtime);
|
||||
|
||||
if(!$total_count){
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition);
|
||||
if (count($output->groups))
|
||||
$count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
|
||||
$result = $this->_query($count_query);
|
||||
$count_output = $this->_fetch($result);
|
||||
$total_count = (int)$count_output->count;
|
||||
|
||||
$CacheHandler->put($cache_key, $total_count.'');
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
// 전체 개수를 구함
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
if($total_count === false) {
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition);
|
||||
if (count($output->groups))
|
||||
$count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
|
||||
$result = $this->_query($count_query);
|
||||
$count_output = $this->_fetch($result);
|
||||
$total_count = (int)$count_output->count;
|
||||
$this->putCountCache($output->tables, $count_condition, $total_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 전체 개수를 구함
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
if($total_count === false) {
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition);
|
||||
if (count($output->groups))
|
||||
$count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
|
||||
$result = $this->_query($count_query);
|
||||
$count_output = $this->_fetch($result);
|
||||
$total_count = (int)$count_output->count;
|
||||
$this->putCountCache($output->tables, $count_condition, $total_count);
|
||||
}
|
||||
|
||||
$list_count = $output->list_count['value'];
|
||||
if(!$list_count) $list_count = 20;
|
||||
|
|
@ -681,9 +652,6 @@
|
|||
}
|
||||
|
||||
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
|
||||
|
||||
|
||||
|
||||
$result = $this->_query($query);
|
||||
if($this->isError()) {
|
||||
$buff = new Object();
|
||||
|
|
|
|||
|
|
@ -55,25 +55,14 @@
|
|||
$this->tpl_path = preg_replace('/^\.\//','',$tpl_path);
|
||||
$this->tpl_file = $tpl_file;
|
||||
|
||||
$CacheHandler = &CacheHandler::getInstance('template');
|
||||
if($CacheHandler->isSupport()){
|
||||
$buff = $CacheHandler->get('template:'.$tpl_file, filemtime(FileHandler::getRealPath($tpl_file)));
|
||||
if(!$buff){
|
||||
$buff = $this->_compileTplFile($tpl_file);
|
||||
$CacheHandler->put('template:'.$tpl_file, $buff);
|
||||
}
|
||||
// get cached compiled file name
|
||||
$compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file));
|
||||
|
||||
$output = $this->_fetch('', $buff, $tpl_path);
|
||||
}else{
|
||||
// get cached compiled file name
|
||||
$compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file));
|
||||
// compile
|
||||
$buff = $this->_compile($tpl_file, $compiled_tpl_file);
|
||||
|
||||
// compile
|
||||
$buff = $this->_compile($tpl_file, $compiled_tpl_file);
|
||||
|
||||
// make a result, combining Context and compiled_tpl_file
|
||||
$output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path);
|
||||
}
|
||||
// make a result, combining Context and compiled_tpl_file
|
||||
$output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path);
|
||||
|
||||
if(__DEBUG__==3 ) $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
|
||||
|
||||
|
|
@ -331,7 +320,7 @@
|
|||
$output = sprintf(
|
||||
'<?php%s'.
|
||||
'$oTemplate = &TemplateHandler::getInstance();%s'.
|
||||
'echo $oTemplate->compile(\'%s\',\'%s\');%s'.
|
||||
'print $oTemplate->compile(\'%s\',\'%s\');%s'.
|
||||
'?>%s',
|
||||
|
||||
"\n",
|
||||
|
|
@ -530,6 +519,5 @@
|
|||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@
|
|||
* 0 : 제한 없음 (권장하지 않음)
|
||||
* 1 : 지정한 IP 주소에만 허용
|
||||
**/
|
||||
if(!defined('__DEBUG_PROTECT__')) define('__DEBUG_PROTECT__', 0);
|
||||
//if(!defined('__DEBUG_PROTECT_IP__')) define('__DEBUG_PROTECT_IP__', '127.0.0.1');
|
||||
if(!defined('__DEBUG_PROTECT__')) define('__DEBUG_PROTECT__', 1);
|
||||
if(!defined('__DEBUG_PROTECT_IP__')) define('__DEBUG_PROTECT_IP__', '127.0.0.1');
|
||||
|
||||
/**
|
||||
* @brief DB 오류 메세지 출력 정의
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
* 1 : 사용함
|
||||
* 대부분의 서버에서는 문제가 없는데 특정 서버군에서 압축전송시 IE에서 오동작을 일으키는경우가 있음
|
||||
**/
|
||||
if(!defined('__OB_GZHANDLER_ENABLE__')) define('__OB_GZHANDLER_ENABLE__', 0);
|
||||
if(!defined('__OB_GZHANDLER_ENABLE__')) define('__OB_GZHANDLER_ENABLE__', 1);
|
||||
|
||||
/**
|
||||
* @brief php unit test (경로/tests/index.php) 의 실행 유무 지정
|
||||
|
|
@ -134,7 +134,6 @@
|
|||
require(_XE_PATH_.'classes/xml/XmlParser.class.php');
|
||||
require(_XE_PATH_.'classes/xml/XmlJsFilter.class.php');
|
||||
require(_XE_PATH_.'classes/context/Context.class.php');
|
||||
require(_XE_PATH_.'classes/cache/CacheHandler.class.php');
|
||||
require(_XE_PATH_.'classes/db/DB.class.php');
|
||||
require(_XE_PATH_.'classes/file/FileHandler.class.php');
|
||||
require(_XE_PATH_.'classes/widget/WidgetHandler.class.php');
|
||||
|
|
|
|||
|
|
@ -171,9 +171,9 @@
|
|||
* @param args object 변수로 선언된 인자값
|
||||
* @return 처리결과
|
||||
**/
|
||||
function executeQuery($query_id, $args = null, $update_mtime = true) {
|
||||
function executeQuery($query_id, $args = null) {
|
||||
$oDB = &DB::getInstance();
|
||||
return $oDB->executeQuery($query_id, $args, $update_mtime = true);
|
||||
return $oDB->executeQuery($query_id, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,10 +53,8 @@
|
|||
if($oContext->checkSSO()) {
|
||||
$oModuleHandler = new ModuleHandler();
|
||||
if($oModuleHandler->init()) {
|
||||
$start_time = microtime(1);
|
||||
$oModule = &$oModuleHandler->procModule();
|
||||
$oModuleHandler->displayContent($oModule);
|
||||
debugPrint(microtime(1) - $start_time);
|
||||
}
|
||||
}
|
||||
$oContext->close();
|
||||
|
|
|
|||
|
|
@ -409,7 +409,6 @@
|
|||
* @brief 문서 삭제
|
||||
**/
|
||||
function deleteDocument($document_srl, $is_admin = false) {
|
||||
|
||||
// trigger 호출 (before)
|
||||
$trigger_obj->document_srl = $document_srl;
|
||||
$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
|
||||
|
|
@ -466,7 +465,6 @@
|
|||
// commit
|
||||
$oDB->commit();
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -474,7 +472,6 @@
|
|||
* @brief 문서를 휴지통으로 옮김
|
||||
**/
|
||||
function moveDocumentToTrash($obj) {
|
||||
|
||||
// 주어진 trash_srl이 없으면 trash_srl 등록
|
||||
if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
|
||||
else $trash_args->trash_srl = $obj->trash_srl;
|
||||
|
|
@ -568,13 +565,7 @@
|
|||
|
||||
// 조회수 업데이트
|
||||
$args->document_srl = $document_srl;
|
||||
$output = executeQuery('document.updateReadedCount', $args, false);
|
||||
$CacheHandler = &CacheHandler::getInstance();
|
||||
if($CacheHandler->isSupport()){
|
||||
$readed_count = $oDocument->get('readed_count')+1;
|
||||
$oDocument->add('readed_count', $readed_count);
|
||||
$CacheHandler->put('readed_count:'.$document_srl, $readed_count);
|
||||
}
|
||||
$output = executeQuery('document.updateReadedCount', $args);
|
||||
|
||||
// 세션 등록
|
||||
$_SESSION['readed_document'][$document_srl] = true;
|
||||
|
|
|
|||
|
|
@ -56,12 +56,6 @@
|
|||
$this->add('title', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('title'));
|
||||
$this->add('content', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('content'));
|
||||
}
|
||||
|
||||
$CacheHandler = &CacheHandler::getInstance();
|
||||
if($CacheHandler->isSupport()){
|
||||
$readed_count = $CacheHandler->get('readed_count:'.$document_srl);
|
||||
if($readed_count) $this->add('readed_count', $readed_count);
|
||||
}
|
||||
}
|
||||
|
||||
function isExists() {
|
||||
|
|
|
|||
|
|
@ -95,12 +95,11 @@
|
|||
function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true) {
|
||||
if(!$document_srl) return new documentItem();
|
||||
|
||||
if(!isset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl])) {
|
||||
$oDocument = new documentItem($document_srl, true);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
||||
}
|
||||
|
||||
if(!isset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl])) {
|
||||
$oDocument = new documentItem($document_srl, true);
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
||||
}
|
||||
if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant();
|
||||
|
||||
return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
|
|
@ -161,21 +160,6 @@
|
|||
if(!in_array($obj->sort_index, array('list_order','regdate','last_update','update_order','readed_count','voted_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) $obj->sort_index = 'list_order';
|
||||
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
||||
|
||||
$CacheHandler = &CacheHandler::getInstance();
|
||||
$cache_support = $CacheHandler->isSupport();
|
||||
if($cache_support){
|
||||
$obj->e = $except_notice;
|
||||
$obj->l = $load_extra_vars;
|
||||
$oDB = &DB::getInstance();
|
||||
$mtime = $oDB->_getTableMtime(array('documents'));
|
||||
|
||||
$cache_key = 'documentlist'.serialize($obj);
|
||||
$buff = $CacheHandler->get($cache_key, $mtime);
|
||||
if($buff){
|
||||
return $buff;
|
||||
}
|
||||
}
|
||||
|
||||
// module_srl 대신 mid가 넘어왔을 경우는 직접 module_srl을 구해줌
|
||||
if($obj->mid) {
|
||||
$oModuleModel = &getModel('module');
|
||||
|
|
@ -420,9 +404,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
if($cache_support && $cache_key){
|
||||
$CacheHandler->put($cache_key, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue