Merge pull request #260 from kijin/pr/misc-optimizations

여러 가지 자잘한 기능 정리 및 캐시 설정 개선
This commit is contained in:
Kijin Sung 2016-02-11 14:51:03 +09:00
commit 94cd5570b0
19 changed files with 292 additions and 463 deletions

View file

@ -8,17 +8,22 @@
*/ */
class CacheHandler extends Handler class CacheHandler extends Handler
{ {
/**
* Instances are stored here.
*/
protected static $_instances = array();
/** /**
* instance of cache handler * instance of cache handler
* @var CacheBase * @var CacheBase
*/ */
var $handler = null; protected $handler = null;
/** /**
* Version of key group * Version of key group
* @var int * @var int
*/ */
var $keyGroupVersions = null; protected $keyGroupVersions = null;
/** /**
* Get a instance of CacheHandler(for singleton) * Get a instance of CacheHandler(for singleton)
@ -28,14 +33,14 @@ class CacheHandler extends Handler
* @param boolean $always_use_file If set true, use a file cache always * @param boolean $always_use_file If set true, use a file cache always
* @return CacheHandler * @return CacheHandler
*/ */
function getInstance($target = 'object', $info = null, $always_use_file = false) public static function getInstance($target = 'object', $info = null, $always_use_file = false)
{ {
$cache_handler_key = $target . ($always_use_file ? '_file' : ''); $key = 'object' . ($always_use_file ? '_file' : '');
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key]) if (!isset(self::$_instances[$key]))
{ {
$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key] = new CacheHandler($target, $info, $always_use_file); self::$_instances[$key] = new self($target, $info, $always_use_file);
} }
return $GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key]; return self::$_instances[$key];
} }
/** /**
@ -44,76 +49,47 @@ class CacheHandler extends Handler
* Do not use this directly. You can use getInstance() instead. * Do not use this directly. You can use getInstance() instead.
* *
* @see CacheHandler::getInstance * @see CacheHandler::getInstance
* @param string $target type of cache (object|template) * @param string $target type of cache (object)
* @param object $info info. of DB * @param object $info info. of DB
* @param boolean $always_use_file If set true, use a file cache always * @param boolean $always_use_file If set true, use a file cache always
* @return CacheHandler * @return CacheHandler
*/ */
function __construct($target, $info = null, $always_use_file = false) protected function __construct($target, $info = null, $always_use_file = false)
{ {
if(!$info) // Allow using custom cache info for backward compatibility.
if (is_object($info) && $info->use_object_cache)
{ {
$info = Context::getDBInfo(); $cache_config = $info->use_object_cache;
}
else
{
$cache_config = config('cache');
if (is_array($cache_config) && count($cache_config))
{
$cache_config = array_first($cache_config);
}
} }
if($info) // Handle various types of cache backend.
if (preg_match('/^(apc|memcache|redis|wincache|file)/', strval($cache_config), $matches))
{ {
if($target == 'object') $type = $matches[1];
{
if($info->use_object_cache == 'apc')
{
$type = 'apc';
}
else if(substr($info->use_object_cache, 0, 8) == 'memcache')
{
$type = 'memcache';
$url = $info->use_object_cache;
}
else if(substr($info->use_object_cache, 0, 5) == 'redis')
{
$type = 'redis';
$url = $info->use_object_cache;
}
else if($info->use_object_cache == 'wincache')
{
$type = 'wincache';
}
else if($info->use_object_cache == 'file')
{
$type = 'file';
} }
elseif ($always_use_file) elseif ($always_use_file)
{ {
$type = 'file'; $type = 'file';
} }
} else
else if($target == 'template')
{ {
if($info->use_template_cache == 'apc') return;
{
$type = 'apc';
}
else if(substr($info->use_template_cache, 0, 8) == 'memcache')
{
$type = 'memcache';
$url = $info->use_template_cache;
}
else if(substr($info->use_template_cache, 0, 5) == 'redis')
{
$type = 'redis';
$url = $info->use_template_cache;
}
else if($info->use_template_cache == 'wincache')
{
$type = 'wincache';
}
} }
if($type) // Create an instance of cache backend.
{
$class = 'Cache' . ucfirst($type); $class = 'Cache' . ucfirst($type);
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class); include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
$this->handler = call_user_func(array($class, 'getInstance'), $url); $this->handler = $class::getInstance($cache_config);
// Initialize key group versions.
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0); $this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
if(!$this->keyGroupVersions) if(!$this->keyGroupVersions)
{ {
@ -121,22 +97,25 @@ class CacheHandler extends Handler
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0); $this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
} }
} }
}
}
/** /**
* Return whether support or not support cache * Return whether support or not support cache
* *
* @return boolean * @return boolean
*/ */
function isSupport() public function isSupport($type = null, $cache_config = null)
{ {
if($this->handler && $this->handler->isSupport()) if ($type === null)
{ {
return true; return ($this->handler && $this->handler->isSupport());
}
else
{
$class = 'Cache' . ucfirst(str_replace('memcached', 'memcache', $type));
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
$handler = $class::getInstance($cache_config, true);
return $handler->isSupport();
} }
return false;
} }
/** /**
@ -145,11 +124,9 @@ class CacheHandler extends Handler
* @param string $key The key that will be associated with the item. * @param string $key The key that will be associated with the item.
* @return string Returns cache name * @return string Returns cache name
*/ */
function getCacheKey($key) public function getCacheKey($key)
{ {
$key = str_replace('/', ':', $key); return RX_VERSION . ':' . str_replace('/', ':', $key);
return __XE_VERSION__ . ':' . $key;
} }
/** /**
@ -160,16 +137,10 @@ class CacheHandler extends Handler
* If stored time is older then modified time, return false. * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success. * @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/ */
function get($key, $modified_time = 0) public function get($key, $modified_time = 0)
{ {
if(!$this->handler) if (!$key) return false;
{ return $this->handler ? $this->handler->get($this->getCacheKey($key), $modified_time) : false;
return false;
}
$key = $this->getCacheKey($key);
return $this->handler->get($key, $modified_time);
} }
/** /**
@ -182,16 +153,10 @@ class CacheHandler extends Handler
* If no ttl is supplied, use the default valid time. * If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void. * @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/ */
function put($key, $obj, $valid_time = 0) public function put($key, $obj, $valid_time = 0)
{ {
if(!$this->handler && !$key) if (!$key) return false;
{ return $this->handler ? $this->handler->put($this->getCacheKey($key), $obj, $valid_time) : false;
return false;
}
$key = $this->getCacheKey($key);
return $this->handler->put($key, $obj, $valid_time);
} }
/** /**
@ -200,16 +165,10 @@ class CacheHandler extends Handler
* @param string $key Cache key * @param string $key Cache key
* @return void * @return void
*/ */
function delete($key) public function delete($key)
{ {
if(!$this->handler) if (!$key) return false;
{ return $this->handler ? $this->handler->delete($this->getCacheKey($key)) : false;
return false;
}
$key = $this->getCacheKey($key);
return $this->handler->delete($key);
} }
/** /**
@ -220,16 +179,10 @@ class CacheHandler extends Handler
* If stored time is older then modified time, the data is invalid. * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid. * @return bool Return true on valid or false on invalid.
*/ */
function isValid($key, $modified_time) public function isValid($key, $modified_time = 0)
{ {
if(!$this->handler) if (!$key) return false;
{ return $this->handler ? $this->handler->isValid($this->getCacheKey($key), $modified_time) : false;
return false;
}
$key = $this->getCacheKey($key);
return $this->handler->isValid($key, $modified_time);
} }
/** /**
@ -237,14 +190,9 @@ class CacheHandler extends Handler
* *
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void. * @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/ */
function truncate() public function truncate()
{ {
if(!$this->handler) return $this->handler ? $this->handler->truncate() : false;
{
return false;
}
return $this->handler->truncate();
} }
/** /**
@ -263,7 +211,7 @@ class CacheHandler extends Handler
* @param string $key Cache key * @param string $key Cache key
* @return string * @return string
*/ */
function getGroupKey($keyGroupName, $key) public function getGroupKey($keyGroupName, $key)
{ {
if(!$this->keyGroupVersions[$keyGroupName]) if(!$this->keyGroupVersions[$keyGroupName])
{ {
@ -280,12 +228,11 @@ class CacheHandler extends Handler
* @param string $keyGroupName Group name * @param string $keyGroupName Group name
* @return void * @return void
*/ */
function invalidateGroupKey($keyGroupName) public function invalidateGroupKey($keyGroupName)
{ {
$this->keyGroupVersions[$keyGroupName]++; $this->keyGroupVersions[$keyGroupName]++;
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0); $this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
} }
} }
/** /**
@ -299,7 +246,7 @@ class CacheBase
* Default valid time * Default valid time
* @var int * @var int
*/ */
var $valid_time = 36000; public $valid_time = 36000;
/** /**
* Get cached data * Get cached data
@ -309,7 +256,7 @@ class CacheBase
* If stored time is older then modified time, return false. * If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success. * @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/ */
function get($key, $modified_time = 0) public function get($key, $modified_time = 0)
{ {
return false; return false;
} }
@ -324,11 +271,19 @@ class CacheBase
* If no ttl is supplied, use the default valid time. * If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void. * @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/ */
function put($key, $obj, $valid_time = 0) public function put($key, $obj, $valid_time = 0)
{ {
return false; return false;
} }
/**
* Alias of put()
*/
public function set($key, $obj, $valid_time = 0)
{
return $this->put($key, $obj, $valid_time = 0);
}
/** /**
* Return whether cache is valid or invalid * Return whether cache is valid or invalid
* *
@ -337,7 +292,7 @@ class CacheBase
* If stored time is older then modified time, the data is invalid. * If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid. * @return bool Return true on valid or false on invalid.
*/ */
function isValid($key, $modified_time = 0) public function isValid($key, $modified_time = 0)
{ {
return false; return false;
} }
@ -347,7 +302,7 @@ class CacheBase
* *
* @return boolean * @return boolean
*/ */
function isSupport() public function isSupport()
{ {
return false; return false;
} }
@ -357,7 +312,7 @@ class CacheBase
* *
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void. * @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/ */
function truncate() public function truncate()
{ {
return false; return false;
} }

View file

@ -21,11 +21,12 @@ class CacheMemcache extends CacheBase
* @param string $url url of memcache * @param string $url url of memcache
* @return CacheMemcache instance of CacheMemcache * @return CacheMemcache instance of CacheMemcache
*/ */
function getInstance($url) function getInstance($url, $force_new_instance = false)
{ {
if(!$GLOBALS['__CacheMemcache__']) if(!$GLOBALS['__CacheMemcache__'] || $force_new_instance)
{ {
$GLOBALS['__CacheMemcache__'] = new CacheMemcache($url); $GLOBALS['__CacheMemcache__'] = new CacheMemcache($url);
unset($GLOBALS['XE_MEMCACHE_SUPPORT']);
} }
return $GLOBALS['__CacheMemcache__']; return $GLOBALS['__CacheMemcache__'];
} }

View file

@ -21,9 +21,9 @@ class CacheRedis extends CacheBase
* @param string $url url of Redis * @param string $url url of Redis
* @return CacheRedis instance of CacheRedis * @return CacheRedis instance of CacheRedis
*/ */
function getInstance($url) function getInstance($url, $force_new_instance = false)
{ {
if(!$GLOBALS['__CacheRedis__']) if(!$GLOBALS['__CacheRedis__'] || $force_new_instance)
{ {
$GLOBALS['__CacheRedis__'] = new CacheRedis($url); $GLOBALS['__CacheRedis__'] = new CacheRedis($url);
} }

View file

@ -22,24 +22,18 @@ class DB
* priority of DBMS * priority of DBMS
* @var array * @var array
*/ */
var $priority_dbms = array( protected static $priority_dbms = array(
'mysqli' => 6, 'mysqli' => 6,
'mysql' => 4, 'mysql' => 4,
'cubrid' => 2, 'cubrid' => 2,
'mssql' => 1 'mssql' => 1
); );
/**
* count cache path
* @var string
*/
var $count_cache_path = 'files/cache/db';
/** /**
* operations for condition * operations for condition
* @var array * @var array
*/ */
var $cond_operation = array( protected static $cond_operation = array(
'equal' => '=', 'equal' => '=',
'more' => '>=', 'more' => '>=',
'excess' => '>', 'excess' => '>',
@ -54,83 +48,83 @@ class DB
* master database connection string * master database connection string
* @var array * @var array
*/ */
var $master_db = NULL; protected $master_db = NULL;
/** /**
* array of slave databases connection strings * array of slave databases connection strings
* @var array * @var array
*/ */
var $slave_db = NULL; protected $slave_db = NULL;
var $result = NULL; protected $result = NULL;
/** /**
* error code (0 means no error) * error code (0 means no error)
* @var int * @var int
*/ */
var $errno = 0; protected $errno = 0;
/** /**
* error message * error message
* @var string * @var string
*/ */
var $errstr = ''; protected $errstr = '';
/** /**
* query string of latest executed query * query string of latest executed query
* @var string * @var string
*/ */
var $query = ''; protected $query = '';
var $connection = ''; protected $connection = '';
/** /**
* elapsed time of latest executed query * elapsed time of latest executed query
* @var int * @var int
*/ */
var $elapsed_time = 0; protected $elapsed_time = 0;
/** /**
* elapsed time of latest executed DB class * elapsed time of latest executed DB class
* @var int * @var int
*/ */
var $elapsed_dbclass_time = 0; protected $elapsed_dbclass_time = 0;
/** /**
* transaction flag * transaction flag
* @var boolean * @var boolean
*/ */
var $transaction_started = FALSE; protected $transaction_started = FALSE;
var $is_connected = FALSE; protected $is_connected = FALSE;
/** /**
* returns enable list in supported dbms list * returns enable list in supported dbms list
* will be written by classes/DB/DB***.class.php * will be written by classes/DB/DB***.class.php
* @var array * @var array
*/ */
var $supported_list = array(); protected static $supported_list = array();
/** /**
* location of query cache * location of query cache
* @var string * @var string
*/ */
var $cache_file = 'files/cache/queries/'; protected $cache_file = 'files/cache/queries/';
/** /**
* stores database type: 'mysql','cubrid','mssql' etc. or 'db' when database is not yet set * stores database type: 'mysql','cubrid','mssql' etc. or 'db' when database is not yet set
* @var string * @var string
*/ */
var $db_type; public $db_type;
/** /**
* flag to decide if class prepared statements or not (when supported); can be changed from db.config.info * flag to decide if class prepared statements or not (when supported); can be changed from db.config.info
* @var string * @var string
*/ */
var $use_prepared_statements; public $use_prepared_statements;
/** /**
* leve of transaction * leve of transaction
* @var unknown * @var unknown
*/ */
private $transactionNestedLevel = 0; protected $transactionNestedLevel = 0;
/** /**
* returns instance of certain db type * returns instance of certain db type
@ -189,7 +183,6 @@ class DB
*/ */
public function __construct() public function __construct()
{ {
$this->count_cache_path = _XE_PATH_ . $this->count_cache_path;
$this->cache_file = _XE_PATH_ . $this->cache_file; $this->cache_file = _XE_PATH_ . $this->cache_file;
} }
@ -199,10 +192,9 @@ class DB
* check by instance can creatable * check by instance can creatable
* @return array return supported DBMS list * @return array return supported DBMS list
*/ */
function getSupportedList() public static function getSupportedList()
{ {
$oDB = new DB(); return self::_getSupportedList();
return $oDB->_getSupportedList();
} }
/** /**
@ -210,20 +202,18 @@ class DB
* this list return by child class * this list return by child class
* @return array return enable DBMS list in supported dbms list * @return array return enable DBMS list in supported dbms list
*/ */
function getEnableList() public static function getEnableList()
{ {
is_a($this, 'DB') ? $self = $this : $self = self::getInstance(); if(!self::$supported_list)
if(!$self->supported_list)
{ {
$oDB = new DB(); $oDB = new DB();
$self->supported_list = $oDB->_getSupportedList(); self::$supported_list = self::_getSupportedList();
} }
$enableList = array(); $enableList = array();
if(is_array($self->supported_list)) if(is_array(self::$supported_list))
{ {
foreach($self->supported_list AS $key => $value) foreach(self::$supported_list AS $key => $value)
{ {
if($value->enable) if($value->enable)
{ {
@ -239,20 +229,18 @@ class DB
* this list return by child class * this list return by child class
* @return array return disable DBMS list in supported dbms list * @return array return disable DBMS list in supported dbms list
*/ */
function getDisableList() public static function getDisableList()
{ {
is_a($this, 'DB') ? $self = $this : $self = self::getInstance(); if(!self::$supported_list)
if(!$self->supported_list)
{ {
$oDB = new DB(); $oDB = new DB();
$self->supported_list = $oDB->_getSupportedList(); self::$supported_list = self::_getSupportedList();
} }
$disableList = array(); $disableList = array();
if(is_array($self->supported_list)) if(is_array(self::$supported_list))
{ {
foreach($self->supported_list AS $key => $value) foreach(self::$supported_list AS $key => $value)
{ {
if(!$value->enable) if(!$value->enable)
{ {
@ -265,17 +253,16 @@ class DB
/** /**
* returns list of supported dbms list * returns list of supported dbms list
* this method is private *
* @return array return supported DBMS list * @return array return supported DBMS list
*/ */
function _getSupportedList() protected static function _getSupportedList()
{ {
static $get_supported_list = ''; if(self::$supported_list)
if(is_array($get_supported_list))
{ {
$this->supported_list = $get_supported_list; return self::$supported_list;
return $this->supported_list;
} }
$get_supported_list = array(); $get_supported_list = array();
$db_classes_path = _XE_PATH_ . "classes/db/"; $db_classes_path = _XE_PATH_ . "classes/db/";
$filter = "/^DB([^\.]+)\.class\.php/i"; $filter = "/^DB([^\.]+)\.class\.php/i";
@ -303,41 +290,13 @@ class DB
} }
// sort // sort
@usort($get_supported_list, array($this, '_sortDBMS')); usort($get_supported_list, function($a, $b) {
$priority_a = isset(self::$priority_dbms[$a->db_type]) ? self::$priority_dbms[$a->db_type] : 0;
$priority_b = isset(self::$priority_dbms[$b->db_type]) ? self::$priority_dbms[$b->db_type] : 0;
return $a - $b;
});
$this->supported_list = $get_supported_list; return self::$supported_list = $get_supported_list;
return $this->supported_list;
}
/**
* sort dbms as priority
*/
function _sortDBMS($a, $b)
{
if(!isset($this->priority_dbms[$a->db_type]))
{
$priority_a = 0;
}
else
{
$priority_a = $this->priority_dbms[$a->db_type];
}
if(!isset($this->priority_dbms[$b->db_type]))
{
$priority_b = 0;
}
else
{
$priority_b = $this->priority_dbms[$b->db_type];
}
if($priority_a == $priority_b)
{
return 0;
}
return ($priority_a > $priority_b) ? -1 : 1;
} }
/** /**
@ -345,7 +304,7 @@ class DB
* The value is set in the child class * The value is set in the child class
* @return boolean true: is supported, false: is not supported * @return boolean true: is supported, false: is not supported
*/ */
function isSupported() public function isSupported()
{ {
return self::$isSupported; return self::$isSupported;
} }
@ -356,7 +315,7 @@ class DB
* @param int $indx key of server list * @param int $indx key of server list
* @return boolean true: connected, false: not connected * @return boolean true: connected, false: not connected
*/ */
function isConnected($type = 'master', $indx = 0) public function isConnected($type = 'master', $indx = 0)
{ {
if($type == 'master') if($type == 'master')
{ {
@ -373,7 +332,7 @@ class DB
* @param string $query query string * @param string $query query string
* @return void * @return void
*/ */
function actStart($query) public function actStart($query)
{ {
$this->setError(0, 'success'); $this->setError(0, 'success');
$this->query = $query; $this->query = $query;
@ -385,7 +344,7 @@ class DB
* finish recording log * finish recording log
* @return void * @return void
*/ */
function actFinish() public function actFinish()
{ {
if(!$this->query) if(!$this->query)
{ {
@ -461,7 +420,7 @@ class DB
* @param array $log values set query debug * @param array $log values set query debug
* @return void * @return void
*/ */
function setQueryLog($log) public function setQueryLog($log)
{ {
$GLOBALS['__db_queries__'][] = $log; $GLOBALS['__db_queries__'][] = $log;
} }
@ -472,7 +431,7 @@ class DB
* @param string $errstr error message * @param string $errstr error message
* @return void * @return void
*/ */
function setError($errno = 0, $errstr = 'success') public function setError($errno = 0, $errstr = 'success')
{ {
$this->errno = $errno; $this->errno = $errno;
$this->errstr = $errstr; $this->errstr = $errstr;
@ -482,7 +441,7 @@ class DB
* Return error status * Return error status
* @return boolean true: error, false: no error * @return boolean true: error, false: no error
*/ */
function isError() public function isError()
{ {
return ($this->errno !== 0); return ($this->errno !== 0);
} }
@ -491,7 +450,7 @@ class DB
* Returns object of error info * Returns object of error info
* @return object object of error * @return object object of error
*/ */
function getError() public function getError()
{ {
$this->errstr = Context::convertEncodingStr($this->errstr); $this->errstr = Context::convertEncodingStr($this->errstr);
return new Object($this->errno, $this->errstr); return new Object($this->errno, $this->errstr);
@ -505,7 +464,7 @@ class DB
* @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
* @return object result of query * @return object result of query
*/ */
function executeQuery($query_id, $args = NULL, $arg_columns = NULL, $type = NULL) public function executeQuery($query_id, $args = NULL, $arg_columns = NULL, $type = NULL)
{ {
static $cache_file = array(); static $cache_file = array();
@ -572,7 +531,7 @@ class DB
* @param string $xml_file original xml query file * @param string $xml_file original xml query file
* @return string cache file * @return string cache file
*/ */
function checkQueryCacheFile($query_id, $xml_file) public function checkQueryCacheFile($query_id, $xml_file)
{ {
// first try finding cache file // first try finding cache file
$cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type); $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type);
@ -601,7 +560,7 @@ class DB
* @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns * @param array $arg_columns column list. if you want get specific colums from executed result, add column list to $arg_columns
* @return object result of query * @return object result of query
*/ */
function _executeQuery($cache_file, $source_args, $query_id, $arg_columns, $type) public function _executeQuery($cache_file, $source_args, $query_id, $arg_columns, $type)
{ {
global $lang; global $lang;
@ -619,7 +578,7 @@ class DB
$output = include($cache_file); $output = include($cache_file);
if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) if($output instanceof Object && !$output->toBool())
{ {
return $output; return $output;
} }
@ -652,7 +611,7 @@ class DB
{ {
$output = $this->getError(); $output = $this->getError();
} }
else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) elseif(!($output instanceof Object))
{ {
$output = new Object(); $output = new Object();
} }
@ -668,57 +627,9 @@ class DB
* @param string $condition condition to get data * @param string $condition condition to get data
* @return int count of cache data * @return int count of cache data
*/ */
function getCountCache($tables, $condition) public function getCountCache($tables, $condition)
{ {
return FALSE; return FALSE;
/*
if(!$tables)
{
return FALSE;
}
if(!is_dir($this->count_cache_path))
{
return FileHandler::makeDir($this->count_cache_path);
}
$condition = md5($condition);
if(!is_array($tables))
{
$tables_str = $tables;
}
else
{
$tables_str = implode('.', $tables);
}
$cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
FileHandler::makeDir($cache_path);
$cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
if(!file_exists($cache_filename))
{
return FALSE;
}
$cache_mtime = filemtime($cache_filename);
if(!is_array($tables))
{
$tables = array($tables);
}
foreach($tables as $alias => $table)
{
$table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime)
{
return FALSE;
}
}
$count = (int) FileHandler::readFile($cache_filename);
return $count;
*/
} }
/** /**
@ -728,37 +639,9 @@ class DB
* @param int $count count of cache data to save * @param int $count count of cache data to save
* @return void * @return void
*/ */
function putCountCache($tables, $condition, $count = 0) public function putCountCache($tables, $condition, $count = 0)
{ {
return FALSE; return FALSE;
/*
if(!$tables)
{
return FALSE;
}
if(!is_dir($this->count_cache_path))
{
return FileHandler::makeDir($this->count_cache_path);
}
$condition = md5($condition);
if(!is_array($tables))
{
$tables_str = $tables;
}
else
{
$tables_str = implode('.', $tables);
}
$cache_path = sprintf('%s/%s%s', $this->count_cache_path, $this->prefix, $tables_str);
FileHandler::makeDir($cache_path);
$cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
FileHandler::writeFile($cache_filename, $count);
*/
} }
/** /**
@ -766,29 +649,9 @@ class DB
* @param array|string $tables tables to reset cache data * @param array|string $tables tables to reset cache data
* @return boolean true: success, false: failed * @return boolean true: success, false: failed
*/ */
function resetCountCache($tables) public function resetCountCache($tables)
{ {
return FALSE; return FALSE;
/*
if(!$tables)
{
return FALSE;
}
return FileHandler::makeDir($this->count_cache_path);
if(!is_array($tables))
{
$tables = array($tables);
}
foreach($tables as $alias => $table)
{
$filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
FileHandler::removeFile($filename);
FileHandler::writeFile($filename, '');
}
return TRUE;
*/
} }
/** /**
@ -796,7 +659,7 @@ class DB
* @param string $table_name * @param string $table_name
* @return void * @return void
*/ */
function dropTable($table_name) public function dropTable($table_name)
{ {
if(!$table_name) if(!$table_name)
{ {
@ -812,7 +675,7 @@ class DB
* @param boolean $with_values * @param boolean $with_values
* @return string * @return string
*/ */
function getSelectSql($query, $with_values = TRUE) public function getSelectSql($query, $with_values = TRUE)
{ {
$select = $query->getSelectString($with_values); $select = $query->getSelectString($with_values);
if($select == '') if($select == '')
@ -881,7 +744,7 @@ class DB
* *
* @param $queryObject * @param $queryObject
*/ */
function getClickCountQuery($queryObject) public function getClickCountQuery($queryObject)
{ {
$new_update_columns = array(); $new_update_columns = array();
$click_count_columns = $queryObject->getClickCountColumns(); $click_count_columns = $queryObject->getClickCountColumns();
@ -907,7 +770,7 @@ class DB
* @param boolean $with_priority * @param boolean $with_priority
* @return string * @return string
*/ */
function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE) public function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE)
{ {
$sql = 'DELETE '; $sql = 'DELETE ';
@ -939,7 +802,7 @@ class DB
* @param boolean $with_priority * @param boolean $with_priority
* @return string * @return string
*/ */
function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE) public function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE)
{ {
$columnsList = $query->getUpdateString($with_values); $columnsList = $query->getUpdateString($with_values);
if($columnsList == '') if($columnsList == '')
@ -971,7 +834,7 @@ class DB
* @param boolean $with_priority * @param boolean $with_priority
* @return string * @return string
*/ */
function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE) public function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE)
{ {
$tableName = $query->getFirstTableName(); $tableName = $query->getFirstTableName();
$values = $query->getInsertString($with_values); $values = $query->getInsertString($with_values);
@ -984,7 +847,7 @@ class DB
* Return index from slave server list * Return index from slave server list
* @return int * @return int
*/ */
function _getSlaveConnectionStringIndex() public function _getSlaveConnectionStringIndex()
{ {
$max = count($this->slave_db); $max = count($this->slave_db);
$indx = rand(0, $max - 1); $indx = rand(0, $max - 1);
@ -997,7 +860,7 @@ class DB
* @param int $indx if indx value is NULL, return rand number in slave server list * @param int $indx if indx value is NULL, return rand number in slave server list
* @return resource * @return resource
*/ */
function _getConnection($type = 'master', $indx = NULL) public function _getConnection($type = 'master', $indx = NULL)
{ {
if($type == 'master' || $this->transactionNestedLevel) if($type == 'master' || $this->transactionNestedLevel)
{ {
@ -1036,26 +899,18 @@ class DB
* check db information exists * check db information exists
* @return boolean * @return boolean
*/ */
function _dbInfoExists() public function _dbInfoExists()
{ {
if(!$this->master_db) return ($this->master_db && count($this->slave_db));
{
return FALSE;
}
if(count($this->slave_db) === 0)
{
return FALSE;
}
return TRUE;
} }
/** /**
* DB disconnection * DB disconnection
* this method is protected *
* @param resource $connection * @param resource $connection
* @return void * @return void
*/ */
function _close($connection) protected function _close($connection)
{ {
} }
@ -1066,7 +921,7 @@ class DB
* @param int $indx number in slave dbms server list * @param int $indx number in slave dbms server list
* @return void * @return void
*/ */
function close($type = 'master', $indx = 0) public function close($type = 'master', $indx = 0)
{ {
if(!$this->isConnected($type, $indx)) if(!$this->isConnected($type, $indx))
{ {
@ -1093,7 +948,7 @@ class DB
* this method is protected * this method is protected
* @return boolean * @return boolean
*/ */
function _begin($transactionLevel = 0) protected function _begin($transactionLevel = 0)
{ {
return TRUE; return TRUE;
} }
@ -1102,7 +957,7 @@ class DB
* DB transaction start * DB transaction start
* @return void * @return void
*/ */
function begin() public function begin()
{ {
if(!$this->isConnected()) if(!$this->isConnected())
{ {
@ -1121,7 +976,7 @@ class DB
* this method is protected * this method is protected
* @return boolean * @return boolean
*/ */
function _rollback($transactionLevel = 0) protected function _rollback($transactionLevel = 0)
{ {
return TRUE; return TRUE;
} }
@ -1130,7 +985,7 @@ class DB
* DB transaction rollback * DB transaction rollback
* @return void * @return void
*/ */
function rollback() public function rollback()
{ {
if(!$this->isConnected() || !$this->transaction_started) if(!$this->isConnected() || !$this->transaction_started)
{ {
@ -1152,7 +1007,7 @@ class DB
* this method is protected * this method is protected
* @return boolean * @return boolean
*/ */
function _commit() protected function _commit()
{ {
return TRUE; return TRUE;
} }
@ -1162,7 +1017,7 @@ class DB
* @param boolean $force regardless transaction start status or connect status, forced to commit * @param boolean $force regardless transaction start status or connect status, forced to commit
* @return void * @return void
*/ */
function commit($force = FALSE) public function commit($force = FALSE)
{ {
if(!$force && (!$this->isConnected() || !$this->transaction_started)) if(!$force && (!$this->isConnected() || !$this->transaction_started))
{ {
@ -1186,19 +1041,19 @@ class DB
* @param resource $connection * @param resource $connection
* @return void * @return void
*/ */
function __query($query, $connection) protected function __query($query, $connection)
{ {
} }
/** /**
* Execute the query * Execute the query
* this method is protected *
* @param string $query * @param string $query
* @param resource $connection * @param resource $connection
* @return resource * @return resource
*/ */
function _query($query, $connection = NULL) public function _query($query, $connection = NULL)
{ {
if($connection == NULL) if($connection == NULL)
{ {
@ -1221,7 +1076,7 @@ class DB
* this method is protected * this method is protected
* @return void * @return void
*/ */
function _setDBInfo() protected function _setDBInfo()
{ {
$db_info = config('db'); $db_info = config('db');
$this->master_db = $db_info['master']; $this->master_db = $db_info['master'];
@ -1236,7 +1091,7 @@ class DB
* @param array $connection * @param array $connection
* @return void * @return void
*/ */
function __connect($connection) protected function __connect($connection)
{ {
} }
@ -1247,7 +1102,7 @@ class DB
* @param resource $connection * @param resource $connection
* @return void * @return void
*/ */
function _afterConnect($connection) protected function _afterConnect($connection)
{ {
} }
@ -1259,7 +1114,7 @@ class DB
* @param int $indx number in slave dbms server list * @param int $indx number in slave dbms server list
* @return void * @return void
*/ */
function _connect($type = 'master', $indx = 0) protected function _connect($type = 'master', $indx = 0)
{ {
if($this->isConnected($type, $indx)) if($this->isConnected($type, $indx))
{ {
@ -1305,7 +1160,7 @@ class DB
* Start recording DBClass log * Start recording DBClass log
* @return void * @return void
*/ */
function actDBClassStart() public function actDBClassStart()
{ {
$this->setError(0, 'success'); $this->setError(0, 'success');
$this->act_dbclass_start = microtime(true); $this->act_dbclass_start = microtime(true);
@ -1316,7 +1171,7 @@ class DB
* Finish recording DBClass log * Finish recording DBClass log
* @return void * @return void
*/ */
function actDBClassFinish() public function actDBClassFinish()
{ {
if(!$this->query) if(!$this->query)
{ {
@ -1338,7 +1193,7 @@ class DB
* @param boolean $force force load DBParser instance * @param boolean $force force load DBParser instance
* @return DBParser * @return DBParser
*/ */
function getParser($force = FALSE) public function getParser($force = FALSE)
{ {
static $dbParser = NULL; static $dbParser = NULL;
if(!$dbParser || $force) if(!$dbParser || $force)

View file

@ -107,12 +107,6 @@ class DBCubrid extends DB
*/ */
function addQuotes($string) function addQuotes($string)
{ {
if(version_compare(PHP_VERSION, "5.4.0", "<") &&
get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
if(!is_numeric($string)) if(!is_numeric($string))
{ {
/* /*

View file

@ -94,10 +94,6 @@ class DBMssql extends DB
*/ */
function addQuotes($string) function addQuotes($string)
{ {
if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
//if(!is_numeric($string)) $string = str_replace("'","''",$string); //if(!is_numeric($string)) $string = str_replace("'","''",$string);
return $string; return $string;

View file

@ -116,10 +116,6 @@ class DBMysql extends DB
*/ */
function addQuotes($string) function addQuotes($string)
{ {
if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
if(!is_numeric($string)) if(!is_numeric($string))
{ {
$string = @mysql_real_escape_string($string); $string = @mysql_real_escape_string($string);

View file

@ -61,10 +61,6 @@ class DBMysqli extends DBMysql
*/ */
function addQuotes($string) function addQuotes($string)
{ {
if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
if(!is_numeric($string)) if(!is_numeric($string))
{ {
$connection = $this->_getConnection('master'); $connection = $this->_getConnection('master');

View file

@ -117,8 +117,6 @@ class TemplateHandler
*/ */
public function compile($tpl_path, $tpl_filename, $tpl_file = '') public function compile($tpl_path, $tpl_filename, $tpl_file = '')
{ {
$buff = false;
// store the starting time for debug information // store the starting time for debug information
if(__DEBUG__ == 3) if(__DEBUG__ == 3)
{ {
@ -143,37 +141,13 @@ class TemplateHandler
$source_template_mtime = filemtime($this->file); $source_template_mtime = filemtime($this->file);
$latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime; $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime;
// cache control // get cached file
$oCacheHandler = CacheHandler::getInstance('template'); if(!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime)
// get cached buff
if($oCacheHandler->isSupport())
{ {
$cache_key = 'template:' . $this->file; FileHandler::writeFile($this->compiled_file, $this->parse());
$buff = $oCacheHandler->get($cache_key, $latest_mtime);
}
else
{
if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
{
$buff = 'file://' . $this->compiled_file;
}
} }
if($buff === FALSE) $output = $this->_fetch($this->compiled_file);
{
$buff = $this->parse();
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $buff);
}
else
{
FileHandler::writeFile($this->compiled_file, $buff);
}
}
$output = $this->_fetch($buff);
if($__templatehandler_root_tpl == $this->file) if($__templatehandler_root_tpl == $this->file)
{ {
@ -358,54 +332,20 @@ class TemplateHandler
* @param string $buff if buff is not null, eval it instead of including compiled template file * @param string $buff if buff is not null, eval it instead of including compiled template file
* @return string * @return string
*/ */
private function _fetch($buff) private function _fetch($filename)
{ {
if(!$buff)
{
return;
}
$__Context = Context::getInstance(); $__Context = Context::getInstance();
$__Context->tpl_path = $this->path; $__Context->tpl_path = $this->path;
$level = ob_get_level(); $__ob_level_before_fetch = ob_get_level();
ob_start(); ob_start();
if(substr($buff, 0, 7) == 'file://')
{ include $filename;
if(__DEBUG__)
{
//load cache file from disk
$eval_str = FileHandler::readFile(substr($buff, 7));
$eval_str_buffed = "?>" . $eval_str;
@eval($eval_str_buffed);
$error_info = error_get_last();
//parse error
if ($error_info['type'] == 4)
{
throw new Exception("Error Parsing Template - {$error_info['message']} in template file {$this->file}");
}
}
else
{
include(substr($buff, 7));
}
}
else
{
$eval_str = "?>" . $buff;
@eval($eval_str);
$error_info = error_get_last();
//parse error
if ($error_info['type'] == 4)
{
throw new Exception("Error Parsing Template - {$error_info['message']} in template file {$this->file}");
}
}
$contents = ''; $contents = '';
while (ob_get_level() - $level > 0) { while (ob_get_level() > $__ob_level_before_fetch)
$contents .= ob_get_contents(); {
ob_end_clean(); $contents .= ob_get_clean();
} }
return $contents; return $contents;
} }

View file

@ -651,6 +651,32 @@ class adminAdminController extends admin
Rhymix\Framework\Config::set('url.http_port', $vars->http_port ?: null); Rhymix\Framework\Config::set('url.http_port', $vars->http_port ?: null);
Rhymix\Framework\Config::set('url.https_port', $vars->https_port ?: null); Rhymix\Framework\Config::set('url.https_port', $vars->https_port ?: null);
Rhymix\Framework\Config::set('url.ssl', $use_ssl); Rhymix\Framework\Config::set('url.ssl', $use_ssl);
getController('module')->updateSite((object)array(
'site_srl' => 0,
'domain' => preg_replace('@^https?://@', '', $default_url),
));
// Object cache
if ($vars->object_cache_type)
{
if ($vars->object_cache_type === 'memcached' || $vars->object_cache_type === 'redis')
{
$cache_config = $vars->object_cache_type . '://' . $vars->object_cache_host . ':' . intval($vars->object_cache_port);
}
else
{
$cache_config = $vars->object_cache_type;
}
if (!CacheHandler::isSupport($vars->object_cache_type, $cache_config))
{
return new Object(-1, 'msg_cache_handler_not_supported');
}
Rhymix\Framework\Config::set('cache', array($cache_config));
}
else
{
Rhymix\Framework\Config::set('cache', array());
}
// Other settings // Other settings
Rhymix\Framework\Config::set('use_rewrite', $vars->use_rewrite === 'Y'); Rhymix\Framework\Config::set('use_rewrite', $vars->use_rewrite === 'Y');

View file

@ -450,6 +450,27 @@ class adminAdminView extends admin
Context::set('http_port', Rhymix\Framework\Config::get('url.http_port')); Context::set('http_port', Rhymix\Framework\Config::get('url.http_port'));
Context::set('https_port', Rhymix\Framework\Config::get('url.https_port')); Context::set('https_port', Rhymix\Framework\Config::get('url.https_port'));
// Object cache
$object_cache_config = Rhymix\Framework\Config::get('cache');
if (is_array($object_cache_config))
{
$object_cache_config = array_first($object_cache_config);
}
$object_cache_types = array('apc', 'file', 'memcached', 'redis', 'wincache');
$object_cache_type = preg_match('/^(' . implode('|', $object_cache_types) . ')/', $object_cache_config, $matches) ? $matches[1] : '';
Context::set('object_cache_types', $object_cache_types);
Context::set('object_cache_type', $object_cache_type);
if ($object_cache_type)
{
Context::set('object_cache_host', parse_url($object_cache_config, PHP_URL_HOST) ?: null);
Context::set('object_cache_port', parse_url($object_cache_config, PHP_URL_PORT) ?: null);
}
else
{
Context::set('object_cache_host', null);
Context::set('object_cache_port', null);
}
// Other settings // Other settings
Context::set('use_mobile_view', Rhymix\Framework\Config::get('use_mobile_view')); Context::set('use_mobile_view', Rhymix\Framework\Config::get('use_mobile_view'));
Context::set('use_rewrite', Rhymix\Framework\Config::get('use_rewrite')); Context::set('use_rewrite', Rhymix\Framework\Config::get('use_rewrite'));

View file

@ -86,6 +86,11 @@ $lang->about_minify_scripts = 'Automatically minify all CSS and JS scripts in th
$lang->use_gzip = 'gzip Compression'; $lang->use_gzip = 'gzip Compression';
$lang->delay_session = 'Delay session start'; $lang->delay_session = 'Delay session start';
$lang->about_delay_session = 'To improve performance when using a caching proxy server such as Varnish, do not issue sessions to visitors until they log in.<br>Selecting this option may cause view counts and visitor counts to become inaccurate.'; $lang->about_delay_session = 'To improve performance when using a caching proxy server such as Varnish, do not issue sessions to visitors until they log in.<br>Selecting this option may cause view counts and visitor counts to become inaccurate.';
$lang->use_object_cache = 'Use Object Cache';
$lang->use_object_cache_do_not_use = 'none';
$lang->cache_host = 'Host';
$lang->cache_port = 'Port';
$lang->msg_cache_handler_not_supported = 'Your server does not support the selected cache method, or Rhymix is unable to use the cache with the given settings.';
$lang->msg_invalid_default_url = 'The default URL is invalid.'; $lang->msg_invalid_default_url = 'The default URL is invalid.';
$lang->msg_default_url_ssl_inconsistent = 'In order to use SSL always, the default URL must also begin with https://'; $lang->msg_default_url_ssl_inconsistent = 'In order to use SSL always, the default URL must also begin with https://';
$lang->msg_default_url_http_port_inconsistent = 'In order to change the HTTP port, the default URL must also include the port number.'; $lang->msg_default_url_http_port_inconsistent = 'In order to change the HTTP port, the default URL must also include the port number.';

View file

@ -86,6 +86,11 @@ $lang->about_minify_scripts = 'コアとすべてのモジュールに含まれ
$lang->use_gzip = 'gzip 圧縮'; $lang->use_gzip = 'gzip 圧縮';
$lang->delay_session = 'セッションの開始を遅延'; $lang->delay_session = 'セッションの開始を遅延';
$lang->about_delay_session = 'Varnishなどのプロキシキャッシュサーバ使用時のパフォーマンスを向上させるために、ログインしていないユーザーには、認証セッションを付与しません。<br>このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。'; $lang->about_delay_session = 'Varnishなどのプロキシキャッシュサーバ使用時のパフォーマンスを向上させるために、ログインしていないユーザーには、認証セッションを付与しません。<br>このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。';
$lang->use_object_cache = 'オブジェクトキャッシュ';
$lang->use_object_cache_do_not_use = '使用していない';
$lang->cache_host = 'ホスト';
$lang->cache_port = 'ポート';
$lang->msg_cache_handler_not_supported = '選択したキャッシュ方式をサーバーでサポートされていないか、与えられた情報でキャッシュにアクセスすることができません。';
$lang->msg_invalid_default_url = '基本URLが正しくありません。'; $lang->msg_invalid_default_url = '基本URLが正しくありません。';
$lang->msg_default_url_ssl_inconsistent = 'SSLを常に使用する場合、基本URLもhttps//で始まる必要があります。'; $lang->msg_default_url_ssl_inconsistent = 'SSLを常に使用する場合、基本URLもhttps//で始まる必要があります。';
$lang->msg_default_url_http_port_inconsistent = 'HTTPポートを変更する場合、基本URLも同じポートが含まれている必要があります。'; $lang->msg_default_url_http_port_inconsistent = 'HTTPポートを変更する場合、基本URLも同じポートが含まれている必要があります。';

View file

@ -86,6 +86,11 @@ $lang->about_minify_scripts = '코어와 모든 모듈에 포함된 CSS, JS 파
$lang->use_gzip = 'gzip 압축'; $lang->use_gzip = 'gzip 압축';
$lang->delay_session = '세션 시작 지연'; $lang->delay_session = '세션 시작 지연';
$lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.'; $lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.';
$lang->use_object_cache = '오브젝트 캐시 사용';
$lang->use_object_cache_do_not_use = '사용하지 않음';
$lang->cache_host = '호스트';
$lang->cache_port = '포트';
$lang->msg_cache_handler_not_supported = '선택하신 캐시 방식을 서버에서 지원하지 않거나, 주어진 정보로 캐시에 접속할 수 없습니다.';
$lang->msg_invalid_default_url = '기본 URL이 올바르지 않습니다.'; $lang->msg_invalid_default_url = '기본 URL이 올바르지 않습니다.';
$lang->msg_default_url_ssl_inconsistent = 'SSL을 항상 사용하실 경우 기본 URL도 https://로 시작해야 합니다.'; $lang->msg_default_url_ssl_inconsistent = 'SSL을 항상 사용하실 경우 기본 URL도 https://로 시작해야 합니다.';
$lang->msg_default_url_http_port_inconsistent = 'HTTP 포트를 변경하실 경우 기본 URL에도 동일한 포트가 포함되어야 합니다.'; $lang->msg_default_url_http_port_inconsistent = 'HTTP 포트를 변경하실 경우 기본 URL에도 동일한 포트가 포함되어야 합니다.';

View file

@ -58,6 +58,19 @@
<label for="use_db_session_n" class="x_inline"><input type="radio" name="use_db_session" id="use_db_session_n" value="N" checked="checked"|cond="!$use_db_session" /> {$lang->cmd_no}</label> <label for="use_db_session_n" class="x_inline"><input type="radio" name="use_db_session" id="use_db_session_n" value="N" checked="checked"|cond="!$use_db_session" /> {$lang->cmd_no}</label>
</div> </div>
</div> </div>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_object_cache}</label>
<div class="x_controls">
<select name="object_cache_type" id="object_cache_type">
<option value="">{$lang->use_object_cache_do_not_use}</option>
<option value="{$key}" loop="$object_cache_types=>$key" selected="selected"|cond="$key==$object_cache_type">{$key}</option>
</select>
<div id="object_cache_additional_config" class="x_inline" style="display:none;margin-left:16px">
<label for="object_cache_host" class="x_inline">{$lang->cache_host}: <input type="text" name="object_cache_host" id="object_cache_host" value="{$object_cache_host}" /></label>
<label for="object_cache_port" class="x_inline">{$lang->cache_port}: <input type="number" name="object_cache_port" id="object_cache_port" size="5" style="min-width:70px" value="{$object_cache_port}" /></label>
</div>
</div>
</div>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label">{$lang->minify_scripts}</label> <label class="x_control-label">{$lang->minify_scripts}</label>
<div class="x_controls"> <div class="x_controls">

View file

@ -2,6 +2,27 @@ jQuery(function($){
$('.tgContent ul').bind('click', function(){ $('.tgContent ul').bind('click', function(){
$('#sitefind_addBtn').css('display',''); $('#sitefind_addBtn').css('display','');
}); });
if ($("#object_cache_type").size()) {
$("#object_cache_type").on("change", function() {
if ($(this).val().match(/memcache|redis/)) {
$("#object_cache_additional_config").show();
if (!$("#object_cache_host").val()) {
$("#object_cache_host").val('127.0.0.1');
}
if (!$("#object_cache_port").val()) {
$("#object_cache_port").val($(this).val().match(/memcache/) ? '11211' : '6379');
}
if ($(this).val().match(/memcache/) && $("#object_cache_port").val() == '6379') {
$("#object_cache_port").val('11211');
}
if ($(this).val().match(/redis/) && $("#object_cache_port").val() == '11211') {
$("#object_cache_port").val('6379');
}
} else {
$("#object_cache_additional_config").hide();
}
}).triggerHandler("change");
}
}); });
function setStartModule(){ function setStartModule(){

View file

@ -164,7 +164,7 @@ class ModuleInstaller
} }
$output = $oModule->moduleUninstall(); $output = $oModule->moduleUninstall();
if(is_subclass_of($output, 'Object') && !$output->toBool()) if($output instanceof Object && !$output->toBool())
{ {
return $output; return $output;
} }

View file

@ -60,7 +60,7 @@ class editorController extends editor
if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
else return new Object(-1,sprintf('%s method is not exists', $method)); else return new Object(-1,sprintf('%s method is not exists', $method));
if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; if($output instanceof Object && !$output->toBool()) return $output;
$this->setError($oComponent->getError()); $this->setError($oComponent->getError());
$this->setMessage($oComponent->getMessage()); $this->setMessage($oComponent->getMessage());

View file

@ -374,7 +374,7 @@ class widgetController extends widget
return $widget_content; return $widget_content;
} }
$oCacheHandler = CacheHandler::getInstance('template'); $oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()) if($oCacheHandler->isSupport())
{ {
$key = 'widget_cache:' . $widget_sequence; $key = 'widget_cache:' . $widget_sequence;