diff --git a/.travis.yml b/.travis.yml index 7686fb2d4..23ccb125a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_script: - if [[ ! -f codecept.phar ]]; then wget http://codeception.com/codecept.phar; fi script: - if [[ -f codecept.phar ]]; then php codecept.phar build; fi -- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip Install; fi +- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi - if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi - grunt lint notifications: diff --git a/Gruntfile.js b/Gruntfile.js index 66be1ac71..243a6a552 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -39,6 +39,8 @@ module.exports = function(grunt) { import : 2, 'adjoining-classes' : false, 'box-model' : false, + 'box-sizing' : false, + 'font-sizes' : false, 'duplicate-background-images' : false, 'ids' : false, 'important' : false, diff --git a/addons/member_communication/conf/info.xml b/addons/member_communication/conf/info.xml index 00f38f2f1..667368f27 100644 --- a/addons/member_communication/conf/info.xml +++ b/addons/member_communication/conf/info.xml @@ -10,36 +10,7 @@ Общение 交流 - 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다. - 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다. - - - メッセージ・友達機能を使うにはこのアドオンを「使用」にして下さい。 - - - 此插件可激活短信箱及添加好友功能。 - - - This addon enables the communication module in order to use messaging or friend functions. - Please enable this addon in case you want to use those functions. - - - Addon này cho phép sử dụng Module truyền thông để sử dụng tin nhắn hay chức năng bạn bè. - Hãy kích hoạt nếu bạn muốn sử dụng chức năng này. - - - 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다. - 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다. - - - 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다. - 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다. - - - Активизирует модуль Общение, позволяет использование сообщений между друзьями. - - - 讓會員擁有短訊和新增好友功能。 + 이 애드온은 더 이상 역활을 하지 않습니다. 이 애드온의 기능은 커뮤니케이션 모듈로 흡수되었습니다. 1.7 2013-11-27 @@ -56,39 +27,5 @@ NAVER - - 알람기능 사용 - Using alarm - Using alarm - Using alarm - Using alarm - Using alarm - Using alarm - 새로운 쪽지가 왔을때 팝업으로 알립니다. - Pop-up alram when new message received. - Pop-up alram when new message received. - Pop-up alram when new message received. - Pop-up alram when new message received. - Pop-up alram when new message received. - Pop-up alram when new message received. - - 사용함 - Using - Using - Using - Using - Using - Using - - - 사용하지 않음 - Not using - Not using - Not using - Not using - Not using - Not using - - diff --git a/addons/member_communication/lang/en.php b/addons/member_communication/lang/en.php deleted file mode 100644 index bdfbfc3ce..000000000 --- a/addons/member_communication/lang/en.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = 'You have %d new message(s). Do you want to check it now?'; diff --git a/addons/member_communication/lang/es.php b/addons/member_communication/lang/es.php deleted file mode 100644 index 146c9b962..000000000 --- a/addons/member_communication/lang/es.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = 'Usted tiene un nuevo mensaje. Quiere comprobar ahora?'; diff --git a/addons/member_communication/lang/ja.php b/addons/member_communication/lang/ja.php deleted file mode 100644 index 39a7d3c53..000000000 --- a/addons/member_communication/lang/ja.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = '%d件の新しいメッセージがあります。確認しますか?'; diff --git a/addons/member_communication/lang/ko.php b/addons/member_communication/lang/ko.php deleted file mode 100644 index c3e865818..000000000 --- a/addons/member_communication/lang/ko.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = '%d개의 새로운 메시지가 도착하였습니다. 확인하시겠습니까?'; diff --git a/addons/member_communication/lang/ru.php b/addons/member_communication/lang/ru.php deleted file mode 100644 index 4b132bd1b..000000000 --- a/addons/member_communication/lang/ru.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = 'У Вас новые сообщения. Проверите сейчас?'; diff --git a/addons/member_communication/lang/vi.php b/addons/member_communication/lang/vi.php deleted file mode 100644 index e27acc310..000000000 --- a/addons/member_communication/lang/vi.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = 'Bạn có một tin nhắn mới. bạn có muốn kiểm tra ngay bây giờ không?'; diff --git a/addons/member_communication/lang/zh-CN.php b/addons/member_communication/lang/zh-CN.php deleted file mode 100644 index 51f4fc2e6..000000000 --- a/addons/member_communication/lang/zh-CN.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = '您有新消息。要确认吗?'; diff --git a/addons/member_communication/lang/zh-TW.php b/addons/member_communication/lang/zh-TW.php deleted file mode 100644 index 4a4798b01..000000000 --- a/addons/member_communication/lang/zh-TW.php +++ /dev/null @@ -1,2 +0,0 @@ -alert_new_message_arrived = '您收到 %d 個新訊息。要檢視嗎?'; diff --git a/addons/member_communication/member_communication.addon.php b/addons/member_communication/member_communication.addon.php index 0c660c1e9..739abc3d3 100644 --- a/addons/member_communication/member_communication.addon.php +++ b/addons/member_communication/member_communication.addon.php @@ -1,85 +1,6 @@ */ +/* 이 애드온은 communication 모둘로 흡수 되었습니다. */ -if(!defined('__XE__')) - exit(); - -/** - * @file member_communication.addon.php - * @author NAVER (developers@xpressengine.com) - * @brief Promote user communication - * - * - Pop-up the message if new message comes in - * - When calling MemberModel::getMemberMenu, feature to send a message is added - * - When caliing MemberModel::getMemberMenu, feature to add a friend is added - */ -// Stop if non-logged-in user is -if(!Context::get('is_logged') || isCrawler()) -{ - return; -} - -$logged_info = Context::get('logged_info'); - -/** - * Message/Friend munus are added on the pop-up window and member profile. Check if a new message is received - * */ -if($this->module != 'member' && $called_position == 'before_module_init') -{ - // Load a language file from the communication module - Context::loadLang(_XE_PATH_ . 'modules/communication/lang'); - // Add menus on the member login information - $oMemberController = getController('member'); - $oMemberController->addMemberMenu('dispCommunicationFriend', 'cmd_view_friend'); - $oMemberController->addMemberMenu('dispCommunicationMessages', 'cmd_view_message_box'); - - $flag_file = _XE_PATH_ . 'files/member_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl) . $logged_info->member_srl; - if($addon_info->use_alarm != 'N' && file_exists($flag_file)) - { - // Pop-up to display messages if a flag on new message is set - $new_message_count = (int) trim(FileHandler::readFile($flag_file)); - FileHandler::removeFile($flag_file); - Context::loadLang(_XE_PATH_ . 'addons/member_communication/lang'); - Context::loadFile(array('./addons/member_communication/tpl/member_communication.js'), true); - - $text = preg_replace('@\r?\n@', '\\n', addslashes(Context::getLang('alert_new_message_arrived'))); - Context::addHtmlFooter(""); - } -} -elseif($this->act == 'getMemberMenu' && $called_position == 'before_module_proc') -{ - $member_srl = Context::get('target_srl'); - $oCommunicationModel = getModel('communication'); - - // Add a feature to display own message box. - if($logged_info->member_srl == $member_srl) - { - $mid = Context::get('cur_mid'); - $oMemberController = getController('member'); - // Add your own viewing Note Template - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationMessages'), 'cmd_view_message_box', '', 'self'); - // Display a list of friends - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationFriend'), 'cmd_view_friend', '', 'self'); - // If not, Add menus to send message and to add friends - } - else - { - // Get member information - $oMemberModel = getModel('member'); - $target_member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl); - if(!$target_member_info->member_srl) - { - return; - } - - $oMemberController = getController('member'); - // Add a menu for sending message - if($logged_info->is_admin == 'Y' || $target_member_info->allow_message == 'Y' || ($target_member_info->allow_message == 'F' && $oCommunicationModel->isFriend($member_srl))) - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl), 'cmd_send_message', '', 'popup'); - // Add a menu for listing friends (if a friend is new) - if(!$oCommunicationModel->isAddedFriend($member_srl)) - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl), 'cmd_add_friend', '', 'popup'); - } -} /* End of file member_communication.addon.php */ /* Location: ./addons/member_communication/member_communication.addon.php */ diff --git a/addons/member_communication/tpl/member_communication.js b/addons/member_communication/tpl/member_communication.js deleted file mode 100644 index d92c813ea..000000000 --- a/addons/member_communication/tpl/member_communication.js +++ /dev/null @@ -1,26 +0,0 @@ -(function($){ -window.xeNotifyMessage = function(text, count){ - var $bar; - $bar = $('div.message.info'); - if(!$bar.length) { - $bar = $('
') - .hide() - .css({ - 'position' : 'absolute', - 'z-index' : '100', - }) - .prependTo(document.body); - } - text = text.replace('%d', count); - var cur_module = current_url.getQuery('module'); - if( cur_module == "admin" ) - h = $bar.html('

'+text+'

').height(); - else - h = $bar.html('

'+text+'

').height(); - $bar.show().animate({top:0}); - // hide after 10 seconds - setTimeout(function(){ - $bar.slideUp(); - }, 5000); -}; -})(jQuery); diff --git a/classes/cache/CacheHandler.class.php b/classes/cache/CacheHandler.class.php index 895ce9c69..f98c77def 100644 --- a/classes/cache/CacheHandler.class.php +++ b/classes/cache/CacheHandler.class.php @@ -8,17 +8,22 @@ */ class CacheHandler extends Handler { + /** + * Instances are stored here. + */ + protected static $_instances = array(); + /** * instance of cache handler * @var CacheBase */ - var $handler = null; + protected $handler = null; /** * Version of key group * @var int */ - var $keyGroupVersions = null; + protected $keyGroupVersions = null; /** * 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 * @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' : ''); - if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key]) + $key = 'object' . ($always_use_file ? '_file' : ''); + 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,84 +49,53 @@ class CacheHandler extends Handler * Do not use this directly. You can use getInstance() instead. * * @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 boolean $always_use_file If set true, use a file cache always * @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 = $cache_config_array = $info->use_object_cache; } - - if($info) + else { - if($target == 'object') + $cache_config = $cache_config_array = config('cache'); + if (is_array($cache_config) && count($cache_config)) { - 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'; - } - else if($always_use_file) - { - $type = 'file'; - } - } - else if($target == 'template') - { - if($info->use_template_cache == 'apc') - { - $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) - { - $class = 'Cache' . ucfirst($type); - include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class); - $this->handler = call_user_func(array($class, 'getInstance'), $url); - $this->keyGroupVersions = $this->handler->get('key_group_versions', 0); - if(!$this->keyGroupVersions) - { - $this->keyGroupVersions = array(); - $this->handler->put('key_group_versions', $this->keyGroupVersions, 0); - } + $cache_config = array_first($cache_config); } } + + // Handle various types of cache backend. + if (preg_match('/^(apc|memcache|redis|wincache|file)/', strval($cache_config), $matches)) + { + $type = $matches[1]; + } + elseif ($always_use_file) + { + $type = 'file'; + } + else + { + return; + } + + // Create an instance of cache backend. + $class = 'Cache' . ucfirst($type); + include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class); + $this->handler = $class::getInstance($cache_config_array); + + // Initialize key group versions. + $this->keyGroupVersions = $this->handler->get('key_group_versions', 0); + if(!$this->keyGroupVersions) + { + $this->keyGroupVersions = array(); + $this->handler->put('key_group_versions', $this->keyGroupVersions, 0); + } } /** @@ -129,14 +103,19 @@ class CacheHandler extends Handler * * @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. * @return string Returns cache name */ - function getCacheKey($key) + public function getCacheKey($key) { - $key = str_replace('/', ':', $key); - - return __XE_VERSION__ . ':' . $key; + return RX_VERSION . ':' . str_replace('/', ':', $key); } /** @@ -160,16 +137,10 @@ class CacheHandler extends Handler * 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. */ - function get($key, $modified_time = 0) + public function get($key, $modified_time = 0) { - if(!$this->handler) - { - return false; - } - - $key = $this->getCacheKey($key); - - return $this->handler->get($key, $modified_time); + if (!$key) return false; + return $this->handler ? $this->handler->get($this->getCacheKey($key), $modified_time) : false; } /** @@ -182,16 +153,10 @@ class CacheHandler extends Handler * 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. */ - function put($key, $obj, $valid_time = 0) + public function put($key, $obj, $valid_time = 0) { - if(!$this->handler && !$key) - { - return false; - } - - $key = $this->getCacheKey($key); - - return $this->handler->put($key, $obj, $valid_time); + if (!$key) return false; + return $this->handler ? $this->handler->put($this->getCacheKey($key), $obj, $valid_time) : false; } /** @@ -200,16 +165,10 @@ class CacheHandler extends Handler * @param string $key Cache key * @return void */ - function delete($key) + public function delete($key) { - if(!$this->handler) - { - return false; - } - - $key = $this->getCacheKey($key); - - return $this->handler->delete($key); + if (!$key) return false; + return $this->handler ? $this->handler->delete($this->getCacheKey($key)) : false; } /** @@ -220,16 +179,10 @@ class CacheHandler extends Handler * If stored time is older then modified time, the data is 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) - { - return false; - } - - $key = $this->getCacheKey($key); - - return $this->handler->isValid($key, $modified_time); + if (!$key) return false; + return $this->handler ? $this->handler->isValid($this->getCacheKey($key), $modified_time) : false; } /** @@ -237,14 +190,9 @@ class CacheHandler extends Handler * * @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 false; - } - - return $this->handler->truncate(); + return $this->handler ? $this->handler->truncate() : false; } /** @@ -263,7 +211,7 @@ class CacheHandler extends Handler * @param string $key Cache key * @return string */ - function getGroupKey($keyGroupName, $key) + public function getGroupKey($keyGroupName, $key) { if(!$this->keyGroupVersions[$keyGroupName]) { @@ -280,12 +228,11 @@ class CacheHandler extends Handler * @param string $keyGroupName Group name * @return void */ - function invalidateGroupKey($keyGroupName) + public function invalidateGroupKey($keyGroupName) { $this->keyGroupVersions[$keyGroupName]++; $this->handler->put('key_group_versions', $this->keyGroupVersions, 0); } - } /** @@ -299,7 +246,7 @@ class CacheBase * Default valid time * @var int */ - var $valid_time = 36000; + public $valid_time = 36000; /** * Get cached data @@ -309,7 +256,7 @@ class CacheBase * 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. */ - function get($key, $modified_time = 0) + public function get($key, $modified_time = 0) { return false; } @@ -324,10 +271,18 @@ class CacheBase * 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. */ - function put($key, $obj, $valid_time = 0) + public function put($key, $obj, $valid_time = 0) { 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 @@ -337,7 +292,7 @@ class CacheBase * If stored time is older then modified time, the data is 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; } @@ -347,7 +302,7 @@ class CacheBase * * @return boolean */ - function isSupport() + public function isSupport() { return false; } @@ -357,7 +312,7 @@ class CacheBase * * @return bool|void Returns true on success or false on failure. If use CacheFile, returns void. */ - function truncate() + public function truncate() { return false; } diff --git a/classes/cache/CacheMemcache.class.php b/classes/cache/CacheMemcache.class.php index b37019ab6..c7ba54d93 100644 --- a/classes/cache/CacheMemcache.class.php +++ b/classes/cache/CacheMemcache.class.php @@ -9,11 +9,12 @@ class CacheMemcache extends CacheBase { /** - * instance of Memcahe - * @var Memcahe + * Instance of Memcache */ - var $Memcache; - var $SelectedExtension; + protected static $_instance; + protected $_conn; + protected $_status; + protected $_useExtension; /** * Get instance of CacheMemcache @@ -21,13 +22,13 @@ class CacheMemcache extends CacheBase * @param string $url url of memcache * @return CacheMemcache instance of CacheMemcache */ - function getInstance($url) + public static function getInstance($url, $force_new_instance = false) { - if(!$GLOBALS['__CacheMemcache__']) + if(!self::$_instance || $force_new_instance) { - $GLOBALS['__CacheMemcache__'] = new CacheMemcache($url); + self::$_instance = new self($url); } - return $GLOBALS['__CacheMemcache__']; + return self::$_instance; } /** @@ -37,19 +38,19 @@ class CacheMemcache extends CacheBase * @param string $url url of memcache * @return void */ - function __construct($url) + protected function __construct($url) { //$config['url'] = array('memcache://localhost:11211'); $config['url'] = is_array($url) ? $url : array($url); if(class_exists('Memcached')) { - $this->Memcache = new Memcached; - $this->SelectedExtension = 'Memcached'; + $this->_conn = new Memcached; + $this->_useExtension = 'Memcached'; } elseif(class_exists('Memcache')) { - $this->Memcache = new Memcache; - $this->SelectedExtension = 'Memcache'; + $this->_conn = new Memcache; + $this->_useExtension = 'Memcache'; } else { @@ -59,7 +60,7 @@ class CacheMemcache extends CacheBase foreach($config['url'] as $url) { $info = parse_url($url); - $this->Memcache->addServer($info['host'], $info['port']); + $this->_conn->addServer($info['host'], $info['port']); } } @@ -68,24 +69,24 @@ class CacheMemcache extends CacheBase * * @return bool Return true on support or false on not support */ - function isSupport() + public function isSupport() { - if(isset($GLOBALS['XE_MEMCACHE_SUPPORT'])) + if(isset($this->_status)) { - return $GLOBALS['XE_MEMCACHE_SUPPORT']; + return $this->_status; } - if($this->SelectedExtension === 'Memcached') + if($this->_useExtension === 'Memcached') { - return $GLOBALS['XE_MEMCACHE_SUPPORT'] = $this->Memcache->set('xe', 'xe', 1); + return $this->_status = $this->_conn->set('xe', 'xe', 1); } - elseif($this->SelectedExtension === 'Memcache') + elseif($this->_useExtension === 'Memcache') { - return $GLOBALS['XE_MEMCACHE_SUPPORT'] = $this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1); + return $this->_status = $this->_conn->set('xe', 'xe', MEMCACHE_COMPRESSED, 1); } else { - return $GLOBALS['XE_MEMCACHE_SUPPORT'] = false; + return $this->_status = false; } } @@ -95,7 +96,7 @@ class CacheMemcache extends CacheBase * @param string $key Cache key * @return string Return unique key */ - function getKey($key) + protected function getKey($key) { return md5(_XE_PATH_ . $key); } @@ -117,20 +118,20 @@ class CacheMemcache extends CacheBase * If it's equal to zero, use the default valid time CacheMemcache::valid_time. * @return bool Returns true on success or false on failure. */ - function put($key, $buff, $valid_time = 0) + public function put($key, $buff, $valid_time = 0) { if($valid_time == 0) { $valid_time = $this->valid_time; } - if($this->SelectedExtension === 'Memcached') + if($this->_useExtension === 'Memcached') { - return $this->Memcache->set($this->getKey($key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); + return $this->_conn->set($this->getKey($key), array(time(), $buff), $valid_time); } else { - return $this->Memcache->set($this->getKey($key), array($_SERVER['REQUEST_TIME'], $buff), MEMCACHE_COMPRESSED, $valid_time); + return $this->_conn->set($this->getKey($key), array(time(), $buff), MEMCACHE_COMPRESSED, $valid_time); } } @@ -142,20 +143,17 @@ class CacheMemcache extends CacheBase * If stored time is older then modified time, the data is invalid. * @return bool Return true on valid or false on invalid. */ - function isValid($key, $modified_time = 0) + public function isValid($key, $modified_time = 0) { - $_key = $this->getKey($key); - - $obj = $this->Memcache->get($_key); + $obj = $this->_conn->get($this->getKey($key)); if(!$obj || !is_array($obj)) { return false; } - unset($obj[1]); if($modified_time > 0 && $modified_time > $obj[0]) { - $this->_delete($_key); + $this->delete($key); return false; } @@ -172,10 +170,9 @@ class CacheMemcache extends CacheBase * 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. */ - function get($key, $modified_time = 0) + public function get($key, $modified_time = 0) { - $_key = $this->getKey($key); - $obj = $this->Memcache->get($_key); + $obj = $this->_conn->get($this->getKey($key)); if(!$obj || !is_array($obj)) { return false; @@ -183,12 +180,10 @@ class CacheMemcache extends CacheBase if($modified_time > 0 && $modified_time > $obj[0]) { - $this->_delete($_key); + $this->delete($key); return false; } - unset($obj[0]); - return $obj[1]; } @@ -200,22 +195,9 @@ class CacheMemcache extends CacheBase * @param string $key The key associated with the item to delete. * @return void */ - function delete($key) + public function delete($key) { - $_key = $this->getKey($key); - $this->_delete($_key); - } - - /** - * Delete item from the server(private) - * - * @see CacheMemcache::delete() - * @param string $_key The key associated with the item to delete. - * @return void - */ - function _delete($_key) - { - $this->Memcache->delete($_key); + return $this->_conn->delete($this->getKey($key)); } /** @@ -227,9 +209,9 @@ class CacheMemcache extends CacheBase * * @return bool Returns true on success or false on failure. */ - function truncate() + public function truncate() { - return $this->Memcache->flush(); + return $this->_conn->flush(); } } diff --git a/classes/cache/CacheRedis.class.php b/classes/cache/CacheRedis.class.php index 0c8742ba5..028b1341c 100644 --- a/classes/cache/CacheRedis.class.php +++ b/classes/cache/CacheRedis.class.php @@ -9,11 +9,11 @@ class CacheRedis extends CacheBase { /** - * instance of Redis - * @var redis + * Instance of Memcache */ - var $redis; - var $status; + protected static $_instance; + protected $_conn; + protected $_status; /** * Get instance of CacheRedis @@ -21,13 +21,13 @@ class CacheRedis extends CacheBase * @param string $url url of Redis * @return CacheRedis instance of CacheRedis */ - function getInstance($url) + public static function getInstance($url, $force_new_instance = false) { - if(!$GLOBALS['__CacheRedis__']) + if(!self::$_instance || $force_new_instance) { - $GLOBALS['__CacheRedis__'] = new CacheRedis($url); + self::$_instance = new self($url); } - return $GLOBALS['__CacheRedis__']; + return self::$_instance; } /** @@ -37,34 +37,33 @@ class CacheRedis extends CacheBase * @param string $url url of Redis * @return void */ - function __construct($url) + protected function __construct($url) { - //$config['url'] = 'redis://localhost:6379/1'; - $config['url'] = is_array($url) ? reset($url) : $url; + //$url = 'redis://localhost:6379/1'; + $url = is_array($url) ? reset($url) : $url; if(!class_exists('Redis')) { - return $this->status = false; + $this->_status = false; } try { - $this->redis = new Redis; + $this->_conn = new Redis; $info = parse_url($url); - $this->redis->connect($info['host'], $info['port'], 0.15); + $this->_conn->connect($info['host'], $info['port'], 0.15); if(isset($info['user']) || isset($info['pass'])) { - $this->redis->auth(isset($info['user']) ? $info['user'] : $info['pass']); + $this->_conn->auth(isset($info['user']) ? $info['user'] : $info['pass']); } if(isset($info['path']) && $dbnum = intval(substr($info['path'], 1))) { - $this->redis->select($dbnum); + $this->_conn->select($dbnum); } - return $this->status = true; } catch(RedisException $e) { - return $this->status = false; + $this->_status = false; } } @@ -73,20 +72,20 @@ class CacheRedis extends CacheBase * * @return bool Return true on support or false on not support */ - function isSupport() + public function isSupport() { - if($this->status !== null) + if($this->_status !== null) { - return $this->status; + return $this->_status; } try { - return $this->redis->setex('xe', 1, 'xe'); + return $this->_conn->setex('xe', 1, 'xe'); } catch(RedisException $e) { - return $this->status = false; + return $this->_status = false; } } @@ -96,7 +95,7 @@ class CacheRedis extends CacheBase * @param string $key Cache key * @return string Return unique key */ - function getKey($key) + protected function getKey($key) { static $prefix = null; if($prefix === null) @@ -123,7 +122,7 @@ class CacheRedis extends CacheBase * If it's equal to zero, use the default valid time CacheRedis::valid_time. * @return bool Returns true on success or false on failure. */ - function put($key, $buff, $valid_time = 0) + public function put($key, $buff, $valid_time = 0) { if($valid_time > 60 * 60 * 24 * 30) { @@ -136,11 +135,11 @@ class CacheRedis extends CacheBase try { - return $this->redis->setex($this->getKey($key), $valid_time, serialize(array($_SERVER['REQUEST_TIME'], $buff))); + return $this->_conn->setex($this->getKey($key), $valid_time, serialize(array($_SERVER['REQUEST_TIME'], $buff))); } catch(RedisException $e) { - return $this->status = false; + return $this->_status = false; } } @@ -152,20 +151,18 @@ class CacheRedis extends CacheBase * If stored time is older then modified time, the data is invalid. * @return bool Return true on valid or false on invalid. */ - function isValid($key, $modified_time = 0) + public function isValid($key, $modified_time = 0) { - $_key = $this->getKey($key); - $obj = $this->redis->get($_key); + $obj = $this->_conn->get($this->getKey($key)); $obj = $obj ? unserialize($obj) : false; if(!$obj || !is_array($obj)) { return false; } - unset($obj[1]); if($modified_time > 0 && $modified_time > $obj[0]) { - $this->redis->del($_key); + $this->_conn->del($this->getKey($key)); return false; } @@ -182,10 +179,9 @@ class CacheRedis extends CacheBase * 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. */ - function get($key, $modified_time = 0) + public function get($key, $modified_time = 0) { - $_key = $this->getKey($key); - $obj = $this->redis->get($_key); + $obj = $this->_conn->get($this->getKey($key)); $obj = $obj ? unserialize($obj) : false; if(!$obj || !is_array($obj)) { @@ -194,7 +190,7 @@ class CacheRedis extends CacheBase if($modified_time > 0 && $modified_time > $obj[0]) { - $this->redis->del($_key); + $this->_conn->del($this->getKey($key)); return false; } @@ -209,17 +205,15 @@ class CacheRedis extends CacheBase * @param string $key The key associated with the item to delete. * @return void */ - function delete($key) + public function delete($key) { - $_key = $this->getKey($key); - try { - $this->redis->del($_key); + return $this->_conn->del($this->getKey($key)); } catch(RedisException $e) { - return $this->status = false; + return $this->_status = false; } } @@ -231,15 +225,15 @@ class CacheRedis extends CacheBase * * @return bool Returns true on success or false on failure. */ - function truncate() + public function truncate() { try { - return $this->redis->flushDB(); + return $this->_conn->flushDB(); } catch(RedisException $e) { - return $this->status = false; + return $this->_status = false; } } diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index c9522e5d0..1479efabe 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -329,12 +329,12 @@ class Context } else { - ob_start(); $this->setCacheControl(-1, true); - register_shutdown_function(array($this, 'checkSessionStatus')); $_SESSION = array(); } + ob_start(); + // set authentication information in Context and session if(self::isInstalled()) { @@ -411,7 +411,7 @@ class Context { if(self::getSessionStatus()) { - return; + return true; } if($force_start || (count($_SESSION) && !headers_sent())) { @@ -419,7 +419,9 @@ class Context unset($_SESSION); session_start(); $_SESSION = $tempSession; + return true; } + return false; } /** @@ -429,7 +431,11 @@ class Context */ public static function close() { - session_write_close(); + // Check session status and close it if open. + if (self::checkSessionStatus()) + { + session_write_close(); + } } /** @@ -531,6 +537,10 @@ class Context $db_info->ftp_info->ftp_root_path = $config['ftp']['path']; $db_info->ftp_info->sftp = $config['ftp']['sftp'] ? 'Y' : 'N'; $db_info->default_url = $config['url']['default']; + if (!$db_info->default_url) + { + $db_info->default_url = (RX_SSL ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . RX_BASEURL; + } $db_info->http_port = $config['url']['http_port']; $db_info->https_port = $config['url']['https_port']; $db_info->use_ssl = $config['url']['ssl']; @@ -1464,18 +1474,39 @@ class Context } else { - self::setBrowserTitle(self::getSiteTitle()); - $oMessageObject = getView('message'); - $oMessageObject->setHttpStatusCode(503); - $oMessageObject->setError(-1); - $oMessageObject->setMessage(_XE_SITELOCK_TITLE_); - $oMessageObject->dispMessage(); - $oModuleHandler = new ModuleHandler; - $oModuleHandler->displayContent($oMessageObject); + self::displayErrorPage(_XE_SITELOCK_TITLE_, _XE_SITELOCK_MESSAGE_, 503); } exit; } - + + /** + * Display a generic error page and exit. + * + * @param string $title + * @param string $message + * @return void + */ + public static function displayErrorPage($title = 'Error', $message = '', $status = 500) + { + // Change current directory to the Rhymix installation path. + chdir(\RX_BASEDIR); + + // Set the title. + self::setBrowserTitle(self::getSiteTitle()); + self::addBrowserTitle($title); + + // Set the message. + $oMessageObject = getView('message'); + $oMessageObject->setError(-1); + $oMessageObject->setHttpStatusCode($status); + $oMessageObject->setMessage($title); + $oMessageObject->dispMessage($message); + + // Display the message. + $oModuleHandler = new ModuleHandler; + $oModuleHandler->displayContent($oMessageObject); + } + /** * Return request method * @return string Request method type. (Optional - GET|POST|XMLRPC|JSON) diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index a852608d9..fbc205adc 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -22,24 +22,18 @@ class DB * priority of DBMS * @var array */ - var $priority_dbms = array( + protected static $priority_dbms = array( 'mysqli' => 6, 'mysql' => 4, 'cubrid' => 2, 'mssql' => 1 ); - /** - * count cache path - * @var string - */ - var $count_cache_path = 'files/cache/db'; - /** * operations for condition * @var array */ - var $cond_operation = array( + protected static $cond_operation = array( 'equal' => '=', 'more' => '>=', 'excess' => '>', @@ -54,83 +48,83 @@ class DB * master database connection string * @var array */ - var $master_db = NULL; + protected $master_db = NULL; /** * array of slave databases connection strings * @var array */ - var $slave_db = NULL; - var $result = NULL; + protected $slave_db = NULL; + protected $result = NULL; /** * error code (0 means no error) * @var int */ - var $errno = 0; + protected $errno = 0; /** * error message * @var string */ - var $errstr = ''; + protected $errstr = ''; /** * query string of latest executed query * @var string */ - var $query = ''; - var $connection = ''; + protected $query = ''; + protected $connection = ''; /** * elapsed time of latest executed query * @var int */ - var $elapsed_time = 0; + protected $elapsed_time = 0; /** * elapsed time of latest executed DB class * @var int */ - var $elapsed_dbclass_time = 0; + protected $elapsed_dbclass_time = 0; /** * transaction flag * @var boolean */ - var $transaction_started = FALSE; - var $is_connected = FALSE; + protected $transaction_started = FALSE; + protected $is_connected = FALSE; /** * returns enable list in supported dbms list * will be written by classes/DB/DB***.class.php * @var array */ - var $supported_list = array(); + protected static $supported_list = array(); /** * location of query cache * @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 * @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 * @var string */ - var $use_prepared_statements; + public $use_prepared_statements; /** * leve of transaction * @var unknown */ - private $transactionNestedLevel = 0; + protected $transactionNestedLevel = 0; /** * returns instance of certain db type @@ -189,7 +183,6 @@ class DB */ public function __construct() { - $this->count_cache_path = _XE_PATH_ . $this->count_cache_path; $this->cache_file = _XE_PATH_ . $this->cache_file; } @@ -199,10 +192,9 @@ class DB * check by instance can creatable * @return array return supported DBMS list */ - function getSupportedList() + public static function getSupportedList() { - $oDB = new DB(); - return $oDB->_getSupportedList(); + return self::_getSupportedList(); } /** @@ -210,20 +202,18 @@ class DB * this list return by child class * @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(); - $self->supported_list = $oDB->_getSupportedList(); + self::$supported_list = self::_getSupportedList(); } $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) { @@ -239,20 +229,18 @@ class DB * this list return by child class * @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(); - $self->supported_list = $oDB->_getSupportedList(); + self::$supported_list = self::_getSupportedList(); } $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) { @@ -265,17 +253,16 @@ class DB /** * returns list of supported dbms list - * this method is private + * * @return array return supported DBMS list */ - function _getSupportedList() + protected static function _getSupportedList() { - static $get_supported_list = ''; - if(is_array($get_supported_list)) + if(self::$supported_list) { - $this->supported_list = $get_supported_list; - return $this->supported_list; + return self::$supported_list; } + $get_supported_list = array(); $db_classes_path = _XE_PATH_ . "classes/db/"; $filter = "/^DB([^\.]+)\.class\.php/i"; @@ -303,41 +290,13 @@ class DB } // 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 $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; + return self::$supported_list = $get_supported_list; } /** @@ -345,7 +304,7 @@ class DB * The value is set in the child class * @return boolean true: is supported, false: is not supported */ - function isSupported() + public function isSupported() { return self::$isSupported; } @@ -356,7 +315,7 @@ class DB * @param int $indx key of server list * @return boolean true: connected, false: not connected */ - function isConnected($type = 'master', $indx = 0) + public function isConnected($type = 'master', $indx = 0) { if($type == 'master') { @@ -373,7 +332,7 @@ class DB * @param string $query query string * @return void */ - function actStart($query) + public function actStart($query) { $this->setError(0, 'success'); $this->query = $query; @@ -385,7 +344,7 @@ class DB * finish recording log * @return void */ - function actFinish() + public function actFinish() { if(!$this->query) { @@ -405,55 +364,47 @@ class DB $log['module'] = $site_module_info->module; $log['act'] = Context::get('act'); $log['time'] = date('Y-m-d H:i:s'); + $log['backtrace'] = array(); - $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); - - foreach($bt as $no => $call) + if (config('debug.enabled') && config('debug.log_queries')) { - if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') + $bt = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); + foreach($bt as $no => $call) { - $call_no = $no; - $call_no++; - $log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line']; - $log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']); - $call_no++; - $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; - break; - } - } - - // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) - if($this->isError()) - { - $log['result'] = 'Failed'; - $log['errno'] = $this->errno; - $log['errstr'] = $this->errstr; - - if(__DEBUG_DB_OUTPUT__ == 1) - { - $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; - $buff = array(); - if(!file_exists($debug_file)) + if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') { - $buff[] = ''; + $call_no = $no; + $call_no++; + $log['called_file'] = $bt[$call_no]['file']; + $log['called_line'] = $bt[$call_no]['line']; + $call_no++; + $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; + $log['backtrace'] = array_slice($bt, $call_no, 1); + break; } - $buff[] = print_r($log, TRUE); - @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); } } else { - $log['result'] = 'Success'; + $log['called_file'] = $log['called_line'] = $log['called_method'] = null; + $log['backtrace'] = array(); + } + + // leave error log if an error occured + if($this->isError()) + { + $log['result'] = 'error'; + $log['errno'] = $this->errno; + $log['errstr'] = $this->errstr; + } + else + { + $log['result'] = 'success'; + $log['errno'] = null; + $log['errstr'] = null; } $this->setQueryLog($log); - - $log_args = new stdClass; - $log_args->query = $this->query; - $log_args->query_id = $this->query_id; - $log_args->caller = $log['called_method'] . '() in ' . $log['called_file']; - $log_args->connection = $log['connection']; - writeSlowlog('query', $elapsed_time, $log_args); } /** @@ -461,9 +412,9 @@ class DB * @param array $log values set query debug * @return void */ - function setQueryLog($log) + public function setQueryLog($log) { - $GLOBALS['__db_queries__'][] = $log; + Rhymix\Framework\Debug::addQuery($log); } /** @@ -472,7 +423,7 @@ class DB * @param string $errstr error message * @return void */ - function setError($errno = 0, $errstr = 'success') + public function setError($errno = 0, $errstr = 'success') { $this->errno = $errno; $this->errstr = $errstr; @@ -482,7 +433,7 @@ class DB * Return error status * @return boolean true: error, false: no error */ - function isError() + public function isError() { return ($this->errno !== 0); } @@ -491,7 +442,7 @@ class DB * Returns object of error info * @return object object of error */ - function getError() + public function getError() { $this->errstr = Context::convertEncodingStr($this->errstr); return new Object($this->errno, $this->errstr); @@ -505,7 +456,7 @@ class DB * @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 */ - 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(); @@ -572,7 +523,7 @@ class DB * @param string $xml_file original xml query file * @return string cache file */ - function checkQueryCacheFile($query_id, $xml_file) + public function checkQueryCacheFile($query_id, $xml_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); @@ -601,7 +552,7 @@ class DB * @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 */ - 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; @@ -619,7 +570,7 @@ class DB $output = include($cache_file); - if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) + if($output instanceof Object && !$output->toBool()) { return $output; } @@ -652,7 +603,7 @@ class DB { $output = $this->getError(); } - else if(!is_a($output, 'Object') && !is_subclass_of($output, 'Object')) + elseif(!($output instanceof Object)) { $output = new Object(); } @@ -668,57 +619,9 @@ class DB * @param string $condition condition to get data * @return int count of cache data */ - function getCountCache($tables, $condition) + public function getCountCache($tables, $condition) { 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 +631,9 @@ class DB * @param int $count count of cache data to save * @return void */ - function putCountCache($tables, $condition, $count = 0) + public function putCountCache($tables, $condition, $count = 0) { 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 +641,9 @@ class DB * @param array|string $tables tables to reset cache data * @return boolean true: success, false: failed */ - function resetCountCache($tables) + public function resetCountCache($tables) { 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 +651,7 @@ class DB * @param string $table_name * @return void */ - function dropTable($table_name) + public function dropTable($table_name) { if(!$table_name) { @@ -812,7 +667,7 @@ class DB * @param boolean $with_values * @return string */ - function getSelectSql($query, $with_values = TRUE) + public function getSelectSql($query, $with_values = TRUE) { $select = $query->getSelectString($with_values); if($select == '') @@ -881,7 +736,7 @@ class DB * * @param $queryObject */ - function getClickCountQuery($queryObject) + public function getClickCountQuery($queryObject) { $new_update_columns = array(); $click_count_columns = $queryObject->getClickCountColumns(); @@ -907,7 +762,7 @@ class DB * @param boolean $with_priority * @return string */ - function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE) + public function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE) { $sql = 'DELETE '; @@ -939,7 +794,7 @@ class DB * @param boolean $with_priority * @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); if($columnsList == '') @@ -971,7 +826,7 @@ class DB * @param boolean $with_priority * @return string */ - function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE) + public function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE) { $tableName = $query->getFirstTableName(); $values = $query->getInsertString($with_values); @@ -984,7 +839,7 @@ class DB * Return index from slave server list * @return int */ - function _getSlaveConnectionStringIndex() + public function _getSlaveConnectionStringIndex() { $max = count($this->slave_db); $indx = rand(0, $max - 1); @@ -997,7 +852,7 @@ class DB * @param int $indx if indx value is NULL, return rand number in slave server list * @return resource */ - function _getConnection($type = 'master', $indx = NULL) + public function _getConnection($type = 'master', $indx = NULL) { if($type == 'master' || $this->transactionNestedLevel) { @@ -1005,7 +860,7 @@ class DB { $this->_connect($type); } - $this->connection = 'Master ' . $this->master_db['host']; + $this->connection = 'master (' . $this->master_db['host'] . ')'; return $this->master_db["resource"]; } @@ -1020,7 +875,7 @@ class DB { $this->_connect($type); } - $this->connection = 'Master ' . $this->master_db['host']; + $this->connection = 'master (' . $this->master_db['host'] . ')'; return $this->master_db["resource"]; } @@ -1028,7 +883,7 @@ class DB { $this->_connect($type, $indx); } - $this->connection = 'Slave ' . $this->slave_db[$indx]['host']; + $this->connection = 'slave (' . $this->slave_db[$indx]['host'] . ')'; return $this->slave_db[$indx]["resource"]; } @@ -1036,26 +891,18 @@ class DB * check db information exists * @return boolean */ - function _dbInfoExists() + public function _dbInfoExists() { - if(!$this->master_db) - { - return FALSE; - } - if(count($this->slave_db) === 0) - { - return FALSE; - } - return TRUE; + return ($this->master_db && count($this->slave_db)); } /** * DB disconnection - * this method is protected + * * @param resource $connection * @return void */ - function _close($connection) + protected function _close($connection) { } @@ -1066,7 +913,7 @@ class DB * @param int $indx number in slave dbms server list * @return void */ - function close($type = 'master', $indx = 0) + public function close($type = 'master', $indx = 0) { if(!$this->isConnected($type, $indx)) { @@ -1093,7 +940,7 @@ class DB * this method is protected * @return boolean */ - function _begin($transactionLevel = 0) + protected function _begin($transactionLevel = 0) { return TRUE; } @@ -1102,7 +949,7 @@ class DB * DB transaction start * @return void */ - function begin() + public function begin() { if(!$this->isConnected()) { @@ -1121,7 +968,7 @@ class DB * this method is protected * @return boolean */ - function _rollback($transactionLevel = 0) + protected function _rollback($transactionLevel = 0) { return TRUE; } @@ -1130,7 +977,7 @@ class DB * DB transaction rollback * @return void */ - function rollback() + public function rollback() { if(!$this->isConnected() || !$this->transaction_started) { @@ -1152,7 +999,7 @@ class DB * this method is protected * @return boolean */ - function _commit() + protected function _commit() { return TRUE; } @@ -1162,7 +1009,7 @@ class DB * @param boolean $force regardless transaction start status or connect status, forced to commit * @return void */ - function commit($force = FALSE) + public function commit($force = FALSE) { if(!$force && (!$this->isConnected() || !$this->transaction_started)) { @@ -1186,19 +1033,19 @@ class DB * @param resource $connection * @return void */ - function __query($query, $connection) + protected function __query($query, $connection) { } /** * Execute the query - * this method is protected + * * @param string $query * @param resource $connection * @return resource */ - function _query($query, $connection = NULL) + public function _query($query, $connection = NULL) { if($connection == NULL) { @@ -1221,7 +1068,7 @@ class DB * this method is protected * @return void */ - function _setDBInfo() + protected function _setDBInfo() { $db_info = config('db'); $this->master_db = $db_info['master']; @@ -1236,7 +1083,7 @@ class DB * @param array $connection * @return void */ - function __connect($connection) + protected function __connect($connection) { } @@ -1247,7 +1094,7 @@ class DB * @param resource $connection * @return void */ - function _afterConnect($connection) + protected function _afterConnect($connection) { } @@ -1259,7 +1106,7 @@ class DB * @param int $indx number in slave dbms server list * @return void */ - function _connect($type = 'master', $indx = 0) + protected function _connect($type = 'master', $indx = 0) { if($this->isConnected($type, $indx)) { @@ -1293,7 +1140,7 @@ class DB $connection["is_connected"] = TRUE; // Save connection info for db logs - $this->connection = ucfirst($type) . ' ' . $connection['host']; + $this->connection = $type . ' (' . $connection['host'] . ')'; // regist $this->close callback register_shutdown_function(array($this, "close")); @@ -1305,7 +1152,7 @@ class DB * Start recording DBClass log * @return void */ - function actDBClassStart() + public function actDBClassStart() { $this->setError(0, 'success'); $this->act_dbclass_start = microtime(true); @@ -1316,7 +1163,7 @@ class DB * Finish recording DBClass log * @return void */ - function actDBClassFinish() + public function actDBClassFinish() { if(!$this->query) { @@ -1338,7 +1185,7 @@ class DB * @param boolean $force force load DBParser instance * @return DBParser */ - function getParser($force = FALSE) + public function getParser($force = FALSE) { static $dbParser = NULL; if(!$dbParser || $force) diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index 542d1483c..9059b99ce 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -107,12 +107,6 @@ class DBCubrid extends DB */ function addQuotes($string) { - if(version_compare(PHP_VERSION, "5.4.0", "<") && - get_magic_quotes_gpc()) - { - $string = stripslashes(str_replace("\\", "\\\\", $string)); - } - if(!is_numeric($string)) { /* @@ -977,8 +971,6 @@ class DBCubrid extends DB return; } - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; - $result = $this->_query($query); if($result && !$this->transaction_started) { @@ -1008,8 +1000,6 @@ class DBCubrid extends DB return; } - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; - $result = $this->_query($query); if($result && !$this->transaction_started) @@ -1040,8 +1030,6 @@ class DBCubrid extends DB return; } - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; - $result = $this->_query($query); if($result && !$this->transaction_started) @@ -1083,7 +1071,6 @@ class DBCubrid extends DB return; } - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; $result = $this->_query($query, $connection); if($this->isError()) @@ -1153,7 +1140,6 @@ class DBCubrid extends DB $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); } - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; $result = $this->_query($count_query, $connection); $count_output = $this->_fetch($result); $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); @@ -1201,7 +1187,6 @@ class DBCubrid extends DB $start_count = ($page - 1) * $list_count; $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; $result = $this->_query($query, $connection); if($this->isError()) { diff --git a/classes/db/DBMssql.class.php b/classes/db/DBMssql.class.php index 9553d1fc6..c6d150b8c 100644 --- a/classes/db/DBMssql.class.php +++ b/classes/db/DBMssql.class.php @@ -94,10 +94,6 @@ class DBMssql extends DB */ 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); return $string; @@ -947,8 +943,6 @@ class DBMssql extends DB // TODO Decide if we continue to pass parameters like this $this->param = $queryObject->getArguments(); - - $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; $result = $this->_query($query, $connection); if($this->isError()) @@ -1028,7 +1022,6 @@ class DBMssql extends DB $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); } - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; $this->param = $queryObject->getArguments(); $result_count = $this->_query($count_query, $connection); $count_output = $this->_fetch($result_count); diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index c19169de7..1b5264ed8 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -116,10 +116,6 @@ class DBMysql extends DB */ 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 = @mysql_real_escape_string($string); @@ -693,7 +689,6 @@ class DBMysql extends DB function _executeInsertAct($queryObject, $with_values = true) { $query = $this->getInsertSql($queryObject, $with_values, true); - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; if(is_a($query, 'Object')) { return; @@ -715,10 +710,6 @@ class DBMysql extends DB if(!$query->toBool()) return $query; else return; } - - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; - - return $this->_query($query); } @@ -731,7 +722,6 @@ class DBMysql extends DB function _executeDeleteAct($queryObject, $with_values = true) { $query = $this->getDeleteSql($queryObject, $with_values, true); - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; if(is_a($query, 'Object')) { return; @@ -763,7 +753,6 @@ class DBMysql extends DB { return; } - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; $result = $this->_query($query, $connection); if($this->isError()) @@ -884,7 +873,6 @@ class DBMysql extends DB $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); } - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; $result_count = $this->_query($count_query, $connection); $count_output = $this->_fetch($result_count); $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); @@ -931,7 +919,6 @@ class DBMysql extends DB $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; $result = $this->_query($query, $connection); if($this->isError()) { diff --git a/classes/db/DBMysqli.class.php b/classes/db/DBMysqli.class.php index 2503bd38f..8c425be45 100644 --- a/classes/db/DBMysqli.class.php +++ b/classes/db/DBMysqli.class.php @@ -61,10 +61,6 @@ class DBMysqli extends DBMysql */ function addQuotes($string) { - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) - { - $string = stripslashes(str_replace("\\", "\\\\", $string)); - } if(!is_numeric($string)) { $connection = $this->_getConnection('master'); diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index 17a5af501..f48da0460 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -11,7 +11,7 @@ */ class DisplayHandler extends Handler { - + public static $response_size = 0; var $content_size = 0; // /< The size of displaying contents var $gz_enabled = FALSE; // / getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if(file_exists($addon_file)) include($addon_file); + if($output === false || $output === null || $output instanceof Object) + { + $output = $original_output; + } if(method_exists($handler, "prepareToPrint")) { @@ -73,10 +78,9 @@ class DisplayHandler extends Handler } // Start the session if $_SESSION was touched - Context::getInstance()->checkSessionStatus(); + Context::checkSessionStatus(); // header output - $httpStatusCode = $oModule->getHttpStatusCode(); if($httpStatusCode && $httpStatusCode != 200) { @@ -102,7 +106,10 @@ class DisplayHandler extends Handler } // disable gzip if output already exists - ob_flush(); + while (ob_get_level()) + { + ob_end_flush(); + } if(headers_sent()) { $this->gz_enabled = FALSE; @@ -114,201 +121,118 @@ class DisplayHandler extends Handler ini_set('zlib.output_compression', true); } - // results directly output - print $output; - - // debugOutput output - $this->content_size = strlen($output); - print $this->_debugOutput(); - // call a trigger after display + self::$response_size = $this->content_size = strlen($output); ModuleHandler::triggerCall('display', 'after', $output); - flushSlowlog(); + // Output the page content and debug data. + $debug = $this->getDebugInfo($output); + print $output; + print $debug; } - + /** - * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n - * This method only functions when __DEBUG__ variable is set to 1. - * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php - * @return void + * Get debug information. + * + * @return string */ - public function _debugOutput() + public function getDebugInfo(&$output) { - if(!__DEBUG__) + // Check if debugging is enabled for this request. + if (!config('debug.enabled') || !Rhymix\Framework\Debug::isEnabledForCurrentUser()) { return; } - - $end = microtime(true); - - // Firebug console output - if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) + + // Print debug information. + switch ($display_type = config('debug.display_type')) { - static $firephp; - if(!isset($firephp)) - { - $firephp = FirePHP::getInstance(true); - } - - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) - { - $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.'); - return; - } - // display total execution time and Request/Response info - if(__DEBUG__ & 2) - { - $firephp->fb( - array( - 'Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(), - array( - array('Request URI', 'Request method', 'Response method', 'Response contents size', 'Memory peak usage'), - array( - sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']), - $_SERVER['REQUEST_METHOD'], - Context::getResponseMethod(), - $this->content_size . ' byte', - FileHandler::filesize(memory_get_peak_usage()) - ) - ) - ), - 'TABLE' - ); - $firephp->fb( - array( - 'Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - RX_MICROTIME), - array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'), - array( - sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), - sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']), - sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), - sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']), - sprintf('%0.5f sec', $end - RX_MICROTIME - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']), - sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']), - sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__']) - ) - ) - ), - 'TABLE' - ); - } - - // display DB query history - if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) - { - $queries_output = array(array('Result/'.PHP_EOL.'Elapsed time', 'Query ID', 'Query')); - foreach($GLOBALS['__db_queries__'] as $query) + case 'panel': + $data = Rhymix\Framework\Debug::getDebugData(); + if ($data->entries) { - $queries_output[] = array($query['result'] . PHP_EOL . sprintf('%0.5f', $query['elapsed_time']), str_replace(_XE_PATH_, '', $query['called_file']) . PHP_EOL . $query['called_method'] . '()' . PHP_EOL . $query['query_id'], $query['query']); - } - $firephp->fb( - array( - 'DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), - $queries_output - ), - 'TABLE' - ); - } - // dislpay the file and HTML comments - } - else - { - - $buff = array(); - // display total execution time and Request/Response info - if(__DEBUG__ & 2) - { - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) - { - return; - } - - // Request/Response information - $buff[] = "\n- Request/ Response info"; - $buff[] = sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']); - $buff[] = sprintf("\tRequest method \t\t\t: %s", $_SERVER['REQUEST_METHOD']); - $buff[] = sprintf("\tResponse method \t\t: %s", Context::getResponseMethod()); - $buff[] = sprintf("\tResponse contents size\t: %d byte", $this->content_size); - - // total execution time - $buff[] = sprintf("\n- Total elapsed time : %0.5f sec", $end - RX_MICROTIME); - - $buff[] = sprintf("\tclass file load elapsed time \t: %0.5f sec", $GLOBALS['__elapsed_class_load__']); - $buff[] = sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']); - $buff[] = sprintf("\tXmlParse compile elapsed time\t: %0.5f sec", $GLOBALS['__xmlparse_elapsed__']); - $buff[] = sprintf("\tPHP elapsed time \t\t\t\t: %0.5f sec", $end - RX_MICROTIME - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']); - $buff[] = sprintf("\tDB class elapsed time \t\t\t: %0.5f sec", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']); - - // widget execution time - $buff[] = sprintf("\tWidgets elapsed time \t\t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']); - - // layout execution time - $buff[] = sprintf("\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']); - - // Widgets, the editor component replacement time - $buff[] = sprintf("\tTrans Content \t\t\t\t\t: %0.5f sec", $GLOBALS['__trans_content_elapsed__']); - } - // DB Logging - if(__DEBUG__ & 4) - { - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) - { - return; - } - - if($GLOBALS['__db_queries__']) - { - $buff[] = sprintf("\n- DB Queries : %d Queries. %0.5f sec", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']); - $num = 0; - - foreach($GLOBALS['__db_queries__'] as $query) + foreach ($data->entries as &$entry) { - if($query['result'] == 'Success') + if (is_scalar($entry->message)) { - $query_result = "Query Success"; + $entry->message = var_export($entry->message, true); } else { - $query_result = sprintf("Query $s : %d\n\t\t\t %s", $query['result'], $query['errno'], $query['errstr']); + $entry->message = trim(print_r($entry->message, true)); } - $buff[] = sprintf("\t%02d. %s\n\t\t%0.6f sec. %s.", ++$num, $query['query'], $query['elapsed_time'], $query_result); - $buff[] = sprintf("\t\tConnection: %s.", $query['connection']); - $buff[] = sprintf("\t\tQuery ID: %s", $query['query_id']); - $buff[] = sprintf("\t\tCalled: %s. %s()", str_replace(_XE_PATH_, '', $query['called_file']), $query['called_method']); } } - } - - // Output in HTML comments - if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') - { - $buff = implode("\r\n", $buff); - $buff = sprintf("[%s %s:%d]\r\n%s", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true)); - - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) + switch (Context::getResponseMethod()) { - $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; + case 'HTML': + $json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0; + $panel_script = sprintf('', RX_BASEURL, 'common/js/debug.js', filemtime(RX_BASEDIR . 'common/js/debug.js')); + if (isset($_SESSION['_rx_debug_previous'])) + { + $panel_script .= "\n"; + unset($_SESSION['_rx_debug_previous']); + } + $panel_script .= "\n"; + $body_end_position = strrpos($output, '') ?: strlen($output); + $output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position); + return; + case 'JSON': + if (RX_POST && preg_match('/^proc/', Context::get('act'))) + { + $data->ajax_module = Context::get('module'); + $data->ajax_act = Context::get('act'); + $_SESSION['_rx_debug_previous'] = $data; + } + else + { + unset($_SESSION['_rx_debug_previous']); + } + if (preg_match('/^(.+)\}$/', $output, $matches)) + { + $output = $matches[1] . ',"_rx_debug":' . json_encode($data) . '}'; + } + return; + default: + return; } - - return ""; - } - - // Output to a file - if($buff && __DEBUG_OUTPUT__ == 0) - { - $debug_file = _XE_PATH_ . 'files/_debug_message.php'; - $buff = implode(PHP_EOL, $buff); - $buff = sprintf("[%s]\n%s", date('Y-m-d H:i:s'), print_r($buff, true)); - - $buff = str_repeat('=', 80) . "\n" . $buff . "\n" . str_repeat('-', 80); - $buff = "\n\n"; - - if (!@file_put_contents($debug_file, $buff, FILE_APPEND|LOCK_EX)) + + case 'comment': + case 'file': + default: + if ($display_type === 'comment' && Context::getResponseMethod() !== 'HTML') { return; } - } + ob_start(); + $data = Rhymix\Framework\Debug::getDebugData(); + include RX_BASEDIR . 'common/tpl/debug_comment.html'; + $content = ob_get_clean(); + if ($display_type === 'file') + { + $log_filename = config('debug.log_filename') ?: 'files/debug/YYYYMMDD.php'; + $log_filename = str_replace(array('YYYY', 'YY', 'MM', 'DD'), array( + getInternalDateTime(RX_TIME, 'Y'), + getInternalDateTime(RX_TIME, 'y'), + getInternalDateTime(RX_TIME, 'm'), + getInternalDateTime(RX_TIME, 'd'), + ), $log_filename); + $log_filename = RX_BASEDIR . $log_filename; + if (!file_exists($log_filename) || !filesize($log_filename)) + { + $phpheader = '' . "\n"; + } + else + { + $phpheader = ''; + } + FileHandler::writeFile($log_filename, $phpheader . $content, 'a'); + return ''; + } + else + { + return ''; + } } } diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index 505c85b0d..0373d5510 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -86,10 +86,7 @@ class HTMLDisplayHandler if(Context::get('layout') != 'none') { - if(__DEBUG__ == 3) - { - $start = microtime(true); - } + $start = microtime(true); Context::set('content', $output, false); @@ -142,10 +139,7 @@ class HTMLDisplayHandler $pathInfo = pathinfo($layout_file); $onlyLayoutFile = $pathInfo['filename']; - if(__DEBUG__ == 3) - { - $GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start; - } + $GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start; if(stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always')) { @@ -168,10 +162,7 @@ class HTMLDisplayHandler return; } - if(__DEBUG__ == 3) - { - $start = microtime(true); - } + $start = microtime(true); // move in body to the header $output = preg_replace_callback('!(.*?)<\/style>!is', array($this, '_moveStyleToHeader'), $output); @@ -218,10 +209,7 @@ class HTMLDisplayHandler $output = preg_replace_callback('@]*\sname="' . $keys . '".+@isU', array(&$this, '_preserveTextAreaValue'), $output); } - if(__DEBUG__ == 3) - { - $GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start; - } + $GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start; // Remove unnecessary information $output = preg_replace('/member\_\-([0-9]+)/s', 'member_0', $output); diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index b996f5de0..1567df78b 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -133,23 +133,22 @@ class ModuleHandler extends Handler continue; } - $urlInfo = parse_url($url); - $host = $urlInfo['host']; - - $defaultUrl = Context::getDefaultUrl(); - if($defaultUrl) + if($host = parse_url($url, PHP_URL_HOST)) { - $defaultUrlInfo = parse_url($defaultUrl); - $defaultHost = $defaultUrlInfo['host']; - } - else - { - $defaultHost = $_SERVER['HTTP_HOST']; - } - - if($host && ($host != $defaultHost && $host != $site_module_info->domain)) - { - throw new Exception('msg_default_url_is_null'); + $defaultHost = parse_url(Context::getDefaultUrl(), PHP_URL_HOST); + if($host !== $defaultHost) + { + $siteModuleHost = $site_module_info->domain; + if(strpos($siteModuleHost, '/') !== false) + { + $siteModuleHost = parse_url($siteModuleHost, PHP_URL_HOST); + } + if($host !== $siteModuleHost) + { + Context::set('success_return_url', null); + Context::set('error_return_url', null); + } + } } } @@ -240,14 +239,7 @@ class ModuleHandler extends Handler } else { - if(!Context::getDefaultUrl()) - { - return Context::getLang('msg_default_url_is_not_defined'); - } - else - { - $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); - } + $redirect_url = getNotEncodedSiteUrl(Context::getDefaultUrl(), 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } header("Location: $redirect_url"); return FALSE; @@ -634,7 +626,7 @@ class ModuleHandler extends Handler if(!$grant->manager) { self::_setInputErrorToContext(); - $this->error = 'msg_is_not_manager'; + $this->error = 'msg_is_not_administrator'; $oMessageObject = self::getModuleInstance('message', $display_mode); $oMessageObject->setError(-1); $oMessageObject->setMessage($this->error); @@ -758,7 +750,6 @@ class ModuleHandler extends Handler $message = $oModule->getMessage(); $messageType = $oModule->getMessageType(); $redirectUrl = $oModule->getRedirectUrl(); - if($messageType == 'error') debugPrint($message, 'ERROR'); if(!$procResult) { @@ -893,10 +884,6 @@ class ModuleHandler extends Handler if($_SESSION['XE_VALIDATOR_RETURN_URL']) { - $display_handler = new DisplayHandler(); - $display_handler->_debugOutput(); - - Context::getInstance()->checkSessionStatus(); header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']); return; } @@ -1074,12 +1061,6 @@ class ModuleHandler extends Handler * */ public static function getModuleInstance($module, $type = 'view', $kind = '') { - - if(__DEBUG__ == 3) - { - $start_time = microtime(true); - } - $parent_module = $module; $kind = strtolower($kind); $type = strtolower($type); @@ -1143,11 +1124,6 @@ class ModuleHandler extends Handler $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule; } - if(__DEBUG__ == 3) - { - $GLOBALS['__elapsed_class_load__'] += microtime(true) - $start_time; - } - // return the instance return $GLOBALS['_loaded_module'][$module][$type][$kind]; } @@ -1207,11 +1183,7 @@ class ModuleHandler extends Handler } //store before trigger call time - $before_trigger_time = NULL; - if(__LOG_SLOW_TRIGGER__> 0) - { - $before_trigger_time = microtime(true); - } + $before_trigger_time = microtime(true); foreach($triggers as $item) { @@ -1227,17 +1199,20 @@ class ModuleHandler extends Handler } $before_each_trigger_time = microtime(true); - $output = $oModule->{$called_method}($obj); - $after_each_trigger_time = microtime(true); - $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time; - $slowlog = new stdClass; - $slowlog->caller = $trigger_name . '.' . $called_position; - $slowlog->called = $module . '.' . $called_method; - $slowlog->called_extension = $module; - if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog); + if ($trigger_name !== 'common.flushDebugInfo') + { + $trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method; + + Rhymix\Framework\Debug::addTrigger(array( + 'name' => $trigger_name . '.' . $called_position, + 'target' => $trigger_target, + 'target_plugin' => $module, + 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time, + )); + } if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { @@ -1249,7 +1224,39 @@ class ModuleHandler extends Handler $trigger_functions = $oModuleModel->getTriggerFunctions($trigger_name, $called_position); foreach($trigger_functions as $item) { + $before_each_trigger_time = microtime(true); $item($obj); + $after_each_trigger_time = microtime(true); + + if ($trigger_name !== 'common.writeSlowlog') + { + if (is_string($item)) + { + $trigger_target = $item; + } + elseif (is_array($item) && count($item)) + { + if (is_object($item[0])) + { + $trigger_target = get_class($item[0]) . '.' . strval($item[1]); + } + else + { + $trigger_target = implode('.', $item); + } + } + else + { + $trigger_target = 'closure'; + } + + Rhymix\Framework\Debug::addTrigger(array( + 'name' => $trigger_name . '.' . $called_position, + 'target' => $trigger_target, + 'target_plugin' => null, + 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time, + )); + } if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index 18838295b..b6e994f30 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -384,7 +384,6 @@ class ModuleObject extends Object // pass if stop_proc is true if($this->stop_proc) { - debugPrint($this->message, 'ERROR'); return FALSE; } @@ -447,6 +446,18 @@ class ModuleObject extends Object return FALSE; } + // check return value of action + if($output instanceof Object) + { + $this->setError($output->getError()); + $this->setMessage($output->getMessage()); + $original_output = clone $output; + } + else + { + $original_output = null; + } + // trigger call $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this); if(!$triggerOutput->toBool()) @@ -462,16 +473,17 @@ class ModuleObject extends Object $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if(FileHandler::exists($addon_file)) include($addon_file); - if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) + if($original_output instanceof Object && !$original_output->toBool()) + { + return FALSE; + } + elseif($output instanceof Object && $output->getError()) { $this->setError($output->getError()); $this->setMessage($output->getMessage()); - - if(!$output->toBool()) - { - return FALSE; - } + return FALSE; } + // execute api methods of the module if view action is and result is XMLRPC or JSON if($this->module_info->module_type == 'view' || $this->module_info->module_type == 'mobile') { diff --git a/classes/security/EmbedFilter.class.php b/classes/security/EmbedFilter.class.php index 12c98da94..2f90a753e 100644 --- a/classes/security/EmbedFilter.class.php +++ b/classes/security/EmbedFilter.class.php @@ -1,8 +1,6 @@ */ -include _XE_PATH_ . 'classes/security/phphtmlparser/src/htmlparser.inc'; - class EmbedFilter { @@ -17,7 +15,6 @@ class EmbedFilter * @var int */ var $allowscriptaccessKey = 0; - var $whiteUrlDefaultFile = './classes/security/conf/whitelist.php'; var $whiteUrlList = array(); var $whiteIframeUrlList = array(); var $mimeTypeList = array(); @@ -68,106 +65,9 @@ class EmbedFilter $this->checkObjectTag($content); $this->checkEmbedTag($content); - $this->checkIframeTag($content); $this->checkParamTag($content); } - /** - * Check object tag in the content. - * @return void - */ - function checkObjectTag(&$content) - { - preg_match_all('/<\s*object\s*[^>]+(?:\/?>?)/is', $content, $m); - $objectTagList = $m[0]; - if($objectTagList) - { - foreach($objectTagList AS $key => $objectTag) - { - $isWhiteDomain = true; - $isWhiteMimetype = true; - $isWhiteExt = true; - $ext = ''; - - $parser = new HtmlParser($objectTag); - while($parser->parse()) - { - if(is_array($parser->iNodeAttributes)) - { - foreach($parser->iNodeAttributes AS $attrName => $attrValue) - { - // data url check - if($attrValue && strtolower($attrName) == 'data') - { - $ext = strtolower(substr(strrchr($attrValue, "."), 1)); - $isWhiteDomain = $this->isWhiteDomain($attrValue); - } - - // mime type check - if(strtolower($attrName) == 'type' && $attrValue) - { - $isWhiteMimetype = $this->isWhiteMimetype($attrValue); - } - } - } - } - - if(!$isWhiteDomain || !$isWhiteMimetype) - { - $content = str_replace($objectTag, htmlspecialchars($objectTag, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), $content); - } - } - } - } - - /** - * Check embed tag in the content. - * @return void - */ - function checkEmbedTag(&$content) - { - preg_match_all('/<\s*embed\s*[^>]+(?:\/?>?)/is', $content, $m); - $embedTagList = $m[0]; - if($embedTagList) - { - foreach($embedTagList AS $key => $embedTag) - { - $isWhiteDomain = TRUE; - $isWhiteMimetype = TRUE; - $isWhiteExt = TRUE; - $ext = ''; - - $parser = new HtmlParser($embedTag); - while($parser->parse()) - { - if(is_array($parser->iNodeAttributes)) - { - foreach($parser->iNodeAttributes AS $attrName => $attrValue) - { - // src url check - if($attrValue && strtolower($attrName) == 'src') - { - $ext = strtolower(substr(strrchr($attrValue, "."), 1)); - $isWhiteDomain = $this->isWhiteDomain($attrValue); - } - - // mime type check - if(strtolower($attrName) == 'type' && $attrValue) - { - $isWhiteMimetype = $this->isWhiteMimetype($attrValue); - } - } - } - } - - if(!$isWhiteDomain || !$isWhiteMimetype) - { - $content = str_replace($embedTag, htmlspecialchars($embedTag, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), $content); - } - } - } - } - /** * Check iframe tag in the content. * @return void @@ -176,39 +76,52 @@ class EmbedFilter { // check in Purifier class return; + } - preg_match_all('/<\s*iframe\s*[^>]+(?:\/?>?)/is', $content, $m); - $iframeTagList = $m[0]; - if($iframeTagList) - { - foreach($iframeTagList AS $key => $iframeTag) + /** + * Check object tag in the content. + * @return void + */ + function checkObjectTag(&$content) + { + $content = preg_replace_callback('/<\s*object\s*[^>]+(?:\/?>?)/is', function($m) { + $html = Sunra\PhpSimple\HtmlDomParser::str_get_html($m[0]); + foreach ($html->find('object') as $element) { - $isWhiteDomain = TRUE; - $ext = ''; - - $parser = new HtmlParser($iframeTag); - while($parser->parse()) + if ($element->data && !$this->isWhiteDomain($element->data)) { - if(is_array($parser->iNodeAttributes)) - { - foreach($parser->iNodeAttributes AS $attrName => $attrValue) - { - // src url check - if(strtolower($attrName) == 'src' && $attrValue) - { - $ext = strtolower(substr(strrchr($attrValue, "."), 1)); - $isWhiteDomain = $this->isWhiteIframeDomain($attrValue); - } - } - } + return escape($m[0], false); } - - if(!$isWhiteDomain) + if ($element->type && !$this->isWhiteMimetype($element->type)) { - $content = str_replace($iframeTag, htmlspecialchars($iframeTag, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), $content); + return escape($m[0], false); } } - } + return $m[0]; + }, $content); + } + + /** + * Check embed tag in the content. + * @return void + */ + function checkEmbedTag(&$content) + { + $content = preg_replace_callback('/<\s*embed\s*[^>]+(?:\/?>?)/is', function($m) { + $html = Sunra\PhpSimple\HtmlDomParser::str_get_html($m[0]); + foreach ($html->find('embed') as $element) + { + if ($element->src && !$this->isWhiteDomain($element->src)) + { + return escape($m[0], false); + } + if ($element->type && !$this->isWhiteMimetype($element->type)) + { + return escape($m[0], false); + } + } + return $m[0]; + }, $content); } /** @@ -217,36 +130,20 @@ class EmbedFilter */ function checkParamTag(&$content) { - preg_match_all('/<\s*param\s*[^>]+(?:\/?>?)/is', $content, $m); - $paramTagList = $m[0]; - if($paramTagList) - { - foreach($paramTagList AS $key => $paramTag) + $content = preg_replace_callback('/<\s*param\s*[^>]+(?:\/?>?)/is', function($m) { + $html = Sunra\PhpSimple\HtmlDomParser::str_get_html($m[0]); + foreach ($html->find('param') as $element) { - $isWhiteDomain = TRUE; - $isWhiteExt = TRUE; - $ext = ''; - - $parser = new HtmlParser($paramTag); - while($parser->parse()) + foreach (array('movie', 'src', 'href', 'url', 'source') as $attr) { - if($parser->iNodeAttributes['name'] && $parser->iNodeAttributes['value']) + if ($element->$attr && !$this->isWhiteDomain($element->$attr)) { - $name = strtolower($parser->iNodeAttributes['name']); - if($name == 'movie' || $name == 'src' || $name == 'href' || $name == 'url' || $name == 'source') - { - $ext = strtolower(substr(strrchr($parser->iNodeAttributes['value'], "."), 1)); - $isWhiteDomain = $this->isWhiteDomain($parser->iNodeAttributes['value']); - - if(!$isWhiteDomain) - { - $content = str_replace($paramTag, htmlspecialchars($paramTag, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), $content); - } - } + return escape($m[0], false); } } } - } + return $m[0]; + }, $content); } /** @@ -359,8 +256,7 @@ class EmbedFilter */ function _makeWhiteDomainList($whitelist = NULL) { - $whiteUrlDefaultFile = FileHandler::getRealPath($this->whiteUrlDefaultFile); - $whiteUrlDefaultList = (include $whiteUrlDefaultFile); + $whiteUrlDefaultList = (include RX_BASEDIR . 'common/defaults/whitelist.php'); $this->extList = $whiteUrlDefaultList['extensions']; $this->mimeTypeList = $whiteUrlDefaultList['mime']; $this->whiteUrlList = array(); diff --git a/classes/security/phphtmlparser/LICENSE b/classes/security/phphtmlparser/LICENSE deleted file mode 100755 index e76b18587..000000000 --- a/classes/security/phphtmlparser/LICENSE +++ /dev/null @@ -1,48 +0,0 @@ -/* ==================================================================== - * Based on The Apache Software License, Version 1.1 - * - * Copyright (c) 2003 Jose Solorzano. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by - * Jose Solorzano." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Jose Solorzano" must not be used to endorse or promote - * products derived from this software without prior written - * permission. - * - * 5. Products derived from this software may not be called "Jose Solorzano", - * nor may "Jose Solorzano" appear in their name, without prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL STARNETSYS, LLC. OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - */ - diff --git a/classes/security/phphtmlparser/src/html2text.inc b/classes/security/phphtmlparser/src/html2text.inc deleted file mode 100755 index 72384e950..000000000 --- a/classes/security/phphtmlparser/src/html2text.inc +++ /dev/null @@ -1,214 +0,0 @@ -iHtmlText = $aHtmlText; - $this->iMaxColumns = $aMaxColumns; - } - - function convert() { - $this->iHtmlParser = new HtmlParser($this->iHtmlText); - $wholeText = ""; - while (($line = $this->getLine()) !== false) { - $wholeText .= ($line . "\r\n"); - } - return $wholeText; - } - - function getLine() { - while (true) { - if (!$this->addWordToLine($this->iCurrentWord)) { - $retvalue = $this->iCurrentLine; - $this->iCurrentLine = ""; - return $retvalue; - } - $word = $this->getWord(); - if ($word === false) { - if ($this->iCurrentLine == "") { - break; - } - $retvalue = $this->iCurrentLine; - $this->iCurrentLine = ""; - $this->iInText = false; - $this->iCurrentWord = ""; - return $retvalue; - } - } - return false; - } - - function addWordToLine ($word) { - if ($this->iInScript) { - return true; - } - $prevLine = $this->iCurrentLine; - if ($word === $this->TOKEN_BR) { - $this->iCurrentWord = ""; - return false; - } - if ($word === $this->TOKEN_P) { - $this->iCurrentWord = $this->TOKEN_BR; - return false; - } - if ($word === $this->TOKEN_UL) { - $this->iCurrentWord = $this->TOKEN_BR; - return false; - } - if ($word === $this->TOKEN_ENDUL) { - $this->iCurrentWord = $this->TOKEN_BR; - return false; - } - if ($word === $this->TOKEN_LI) { - $this->iCurrentWord = $this->TOKEN_AFTERLI; - return false; - } - $toAdd = $word; - if ($word === $this->TOKEN_AFTERLI) { - $toAdd = ""; - } - if ($prevLine != "") { - $prevLine .= " "; - } - else { - $prevLine = $this->getIndentation($word === $this->TOKEN_AFTERLI); - } - $candidateLine = $prevLine . $toAdd; - if (strlen ($candidateLine) > $this->iMaxColumns && $prevLine != "") { - return false; - } - $this->iCurrentLine = $candidateLine; - return true; - } - - function getWord() { - while (true) { - if ($this->iHtmlParser->iNodeType == NODE_TYPE_TEXT) { - if (!$this->iInText) { - $words = $this->splitWords($this->iHtmlParser->iNodeValue); - $this->iCurrentWordArray = $words; - $this->iCurrentWordIndex = 0; - $this->iInText = true; - } - if ($this->iCurrentWordIndex < count($this->iCurrentWordArray)) { - $this->iCurrentWord = $this->iCurrentWordArray[$this->iCurrentWordIndex++]; - return $this->iCurrentWord; - } - else { - $this->iInText = false; - } - } - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { - if (strcasecmp ($this->iHtmlParser->iNodeName, "br") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = $this->TOKEN_BR; - return $this->iCurrentWord; - } - else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = $this->TOKEN_P; - return $this->iCurrentWord; - } - else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = ""; - $this->iInScript = true; - return $this->iCurrentWord; - } - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = $this->TOKEN_UL; - $this->iListLevel++; - return $this->iCurrentWord; - } - else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = $this->TOKEN_LI; - return $this->iCurrentWord; - } - } - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { - if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = ""; - $this->iInScript = false; - return $this->iCurrentWord; - } - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { - $this->iHtmlParser->parse(); - $this->iCurrentWord = $this->TOKEN_ENDUL; - if ($this->iListLevel > 0) { - $this->iListLevel--; - } - return $this->iCurrentWord; - } - } - if (!$this->iHtmlParser->parse()) { - break; - } - } - return false; - } - - function splitWords ($text) { - $words = split ("[ \t\r\n]+", $text); - for ($idx = 0; $idx < count($words); $idx++) { - $words[$idx] = $this->htmlDecode($words[$idx]); - } - return $words; - } - - function htmlDecode ($text) { - // TBD - return $text; - } - - function getIndentation ($hasLI) { - $indent = ""; - $idx = 0; - for ($idx = 0; $idx < ($this->iListLevel - 1); $idx++) { - $indent .= " "; - } - if ($this->iListLevel > 0) { - $indent = $hasLI ? ($indent . "- ") : ($indent . " "); - } - return $indent; - } -} diff --git a/classes/security/phphtmlparser/src/htmlparser.inc b/classes/security/phphtmlparser/src/htmlparser.inc deleted file mode 100755 index 7cc718dbd..000000000 --- a/classes/security/phphtmlparser/src/htmlparser.inc +++ /dev/null @@ -1,365 +0,0 @@ -iHtmlText = $aHtmlText; - $this->iHtmlTextLength = strlen($aHtmlText); - $this->iNodeAttributes = array(); - $this->setTextIndex (0); - - $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" ); - $this->B_ARRAY = array (" ", "\t", "\r", "\n" ); - $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" ); - } - - /** - * Method parse. - * Parses the next node. Returns false only if - * the end of the HTML text has been reached. - * Updates values of iNode* fields. - */ - function parse() { - $text = $this->skipToElement(); - if ($text != "") { - $this->iNodeType = NODE_TYPE_TEXT; - $this->iNodeName = "Text"; - $this->iNodeValue = $text; - return true; - } - return $this->readTag(); - } - - function clearAttributes() { - $this->iNodeAttributes = array(); - } - - function readTag() { - if ($this->iCurrentChar != "<") { - $this->iNodeType = NODE_TYPE_DONE; - return false; - } - $this->clearAttributes(); - $this->skipMaxInTag ("<", 1); - if ($this->iCurrentChar == '/') { - $this->moveNext(); - $name = $this->skipToBlanksInTag(); - $this->iNodeType = NODE_TYPE_ENDELEMENT; - $this->iNodeName = $name; - $this->iNodeValue = ""; - $this->skipEndOfTag(); - return true; - } - $name = $this->skipToBlanksOrSlashInTag(); - if (!$this->isValidTagIdentifier ($name)) { - $comment = false; - if (strpos($name, "!--") === 0) { - $ppos = strpos($name, "--", 3); - if (strpos($name, "--", 3) === (strlen($name) - 2)) { - $this->iNodeType = NODE_TYPE_COMMENT; - $this->iNodeName = "Comment"; - $this->iNodeValue = "<" . $name . ">"; - $comment = true; - } - else { - $rest = $this->skipToStringInTag ("-->"); - if ($rest != "") { - $this->iNodeType = NODE_TYPE_COMMENT; - $this->iNodeName = "Comment"; - $this->iNodeValue = "<" . $name . $rest; - $comment = true; - // Already skipped end of tag - return true; - } - } - } - if (!$comment) { - $this->iNodeType = NODE_TYPE_TEXT; - $this->iNodeName = "Text"; - $this->iNodeValue = "<" . $name; - return true; - } - } - else { - $this->iNodeType = NODE_TYPE_ELEMENT; - $this->iNodeValue = ""; - $this->iNodeName = $name; - while ($this->skipBlanksInTag()) { - $attrName = $this->skipToBlanksOrEqualsInTag(); - if ($attrName != "" && $attrName != "/") { - $this->skipBlanksInTag(); - if ($this->iCurrentChar == "=") { - $this->skipEqualsInTag(); - $this->skipBlanksInTag(); - $value = $this->readValueInTag(); - $this->iNodeAttributes[strtolower($attrName)] = $value; - } - else { - $this->iNodeAttributes[strtolower($attrName)] = ""; - } - } - } - } - $this->skipEndOfTag(); - return true; - } - - function isValidTagIdentifier ($name) { - return ereg ("^[A-Za-z0-9_\\-]+$", $name); - } - - function skipBlanksInTag() { - return "" != ($this->skipInTag ($this->B_ARRAY)); - } - - function skipToBlanksOrEqualsInTag() { - return $this->skipToInTag ($this->BOE_ARRAY); - } - - function skipToBlanksInTag() { - return $this->skipToInTag ($this->B_ARRAY); - } - - function skipToBlanksOrSlashInTag() { - return $this->skipToInTag ($this->BOS_ARRAY); - } - - function skipEqualsInTag() { - return $this->skipMaxInTag ("=", 1); - } - - function readValueInTag() { - $ch = $this->iCurrentChar; - $value = ""; - if ($ch == "\"") { - $this->skipMaxInTag ("\"", 1); - $value = $this->skipToInTag ("\""); - $this->skipMaxInTag ("\"", 1); - } - else if ($ch == "'") { - $this->skipMaxInTag ("'", 1); - $value = $this->skipToInTag ("'"); - $this->skipMaxInTag ("'", 1); - } - else { - $value = $this->skipToBlanksInTag(); - } - return $value; - } - - function setTextIndex ($index) { - $this->iHtmlTextIndex = $index; - if ($index >= $this->iHtmlTextLength) { - $this->iCurrentChar = -1; - } - else { - $this->iCurrentChar = $this->iHtmlText{$index}; - } - } - - function moveNext() { - if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { - $this->setTextIndex ($this->iHtmlTextIndex + 1); - return true; - } - else { - return false; - } - } - - function skipEndOfTag() { - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == ">") { - $this->moveNext(); - return; - } - $this->moveNext(); - } - } - - function skipInTag ($chars) { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == ">") { - return $sb; - } else { - $match = false; - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - if (!$match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - } - return $sb; - } - - function skipMaxInTag ($chars, $maxChars) { - $sb = ""; - $count = 0; - while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) { - if ($ch == ">") { - return $sb; - } else { - $match = false; - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - if (!$match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - } - return $sb; - } - - function skipToInTag ($chars) { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - $match = $ch == ">"; - if (!$match) { - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - } - if ($match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - return $sb; - } - - function skipToElement() { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == "<") { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - return $sb; - } - - /** - * Returns text between current position and $needle, - * inclusive, or "" if not found. The current index is moved to a point - * after the location of $needle, or not moved at all - * if nothing is found. - */ - function skipToStringInTag ($needle) { - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); - if ($pos === false) { - return ""; - } - $top = $pos + strlen($needle); - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); - $this->setTextIndex ($top); - return $retvalue; - } -} - -function HtmlParser_ForFile ($fileName) { - return HtmlParser_ForURL($fileName); -} - -function HtmlParser_ForURL ($url) { - $fp = fopen ($url, "r"); - $content = ""; - while (true) { - $data = fread ($fp, 8192); - if (strlen($data) == 0) { - break; - } - $content .= $data; - } - fclose ($fp); - return new HtmlParser ($content); -} - -php?> diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index dcdd16b1b..ea4f6a1dd 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -42,16 +42,13 @@ class TemplateHandler { static $oTemplate = NULL; - if(__DEBUG__ == 3) + if(!isset($GLOBALS['__TemplateHandlerCalled__'])) { - if(!isset($GLOBALS['__TemplateHandlerCalled__'])) - { - $GLOBALS['__TemplateHandlerCalled__'] = 1; - } - else - { - $GLOBALS['__TemplateHandlerCalled__']++; - } + $GLOBALS['__TemplateHandlerCalled__'] = 1; + } + else + { + $GLOBALS['__TemplateHandlerCalled__']++; } if(!$oTemplate) @@ -117,13 +114,8 @@ class TemplateHandler */ public function compile($tpl_path, $tpl_filename, $tpl_file = '') { - $buff = false; - // store the starting time for debug information - if(__DEBUG__ == 3) - { - $start = microtime(true); - } + $start = microtime(true); // initiation $this->init($tpl_path, $tpl_filename, $tpl_file); @@ -143,37 +135,13 @@ class TemplateHandler $source_template_mtime = filemtime($this->file); $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime; - // cache control - $oCacheHandler = CacheHandler::getInstance('template'); - - // get cached buff - if($oCacheHandler->isSupport()) + // get cached file + if(!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime) { - $cache_key = 'template:' . $this->file; - $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; - } + FileHandler::writeFile($this->compiled_file, $this->parse()); } - if($buff === FALSE) - { - $buff = $this->parse(); - if($oCacheHandler->isSupport()) - { - $oCacheHandler->put($cache_key, $buff); - } - else - { - FileHandler::writeFile($this->compiled_file, $buff); - } - } - - $output = $this->_fetch($buff); + $output = $this->_fetch($this->compiled_file); if($__templatehandler_root_tpl == $this->file) { @@ -181,10 +149,7 @@ class TemplateHandler } // store the ending time for debug information - if(__DEBUG__ == 3) - { - $GLOBALS['__template_elapsed__'] += microtime(true) - $start; - } + $GLOBALS['__template_elapsed__'] += microtime(true) - $start; return $output; } @@ -358,54 +323,20 @@ class TemplateHandler * @param string $buff if buff is not null, eval it instead of including compiled template file * @return string */ - private function _fetch($buff) + private function _fetch($filename) { - if(!$buff) - { - return; - } - $__Context = Context::getInstance(); $__Context->tpl_path = $this->path; - $level = ob_get_level(); + $__ob_level_before_fetch = ob_get_level(); ob_start(); - if(substr($buff, 0, 7) == 'file://') - { - 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}"); - } - } - + + include $filename; + $contents = ''; - while (ob_get_level() - $level > 0) { - $contents .= ob_get_contents(); - ob_end_clean(); + while (ob_get_level() > $__ob_level_before_fetch) + { + $contents .= ob_get_clean(); } return $contents; } diff --git a/classes/xml/XmlParser.class.php b/classes/xml/XmlParser.class.php index 521396ddb..327d0219f 100644 --- a/classes/xml/XmlParser.class.php +++ b/classes/xml/XmlParser.class.php @@ -89,10 +89,7 @@ class XmlParser function parse($input = '', $arg1 = NULL, $arg2 = NULL) { // Save the compile starting time for debugging - if(__DEBUG__ == 3) - { - $start = microtime(true); - } + $start = microtime(true); $this->lang = Context::getLangType(); @@ -141,10 +138,7 @@ class XmlParser $output = array_shift($this->output); // Save compile starting time for debugging - if(__DEBUG__ == 3) - { - $GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start; - } + $GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start; return $output; } diff --git a/classes/xml/xmlquery/queryargument/DefaultValue.class.php b/classes/xml/xmlquery/queryargument/DefaultValue.class.php index 455d06537..0e0d53471 100644 --- a/classes/xml/xmlquery/queryargument/DefaultValue.class.php +++ b/classes/xml/xmlquery/queryargument/DefaultValue.class.php @@ -126,14 +126,15 @@ class DefaultValue switch($func_name) { case 'ipaddress' : - $val = '$_SERVER[\'REMOTE_ADDR\']'; + $val = '\\RX_CLIENT_IP'; $this->_is_string_from_function = TRUE; break; case 'unixtime' : - $val = '$_SERVER[\'REQUEST_TIME\']'; + $val = '\\RX_TIME'; + $this->_is_string_from_function = TRUE; break; case 'curdate' : - $val = 'date("YmdHis")'; + $val = 'getInternalDateTime()'; $this->_is_string_from_function = TRUE; break; case 'sequence' : diff --git a/common/autoload.php b/common/autoload.php index be9764689..49bc48ef0 100644 --- a/common/autoload.php +++ b/common/autoload.php @@ -3,7 +3,7 @@ /** * Set error reporting rules. */ -error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE ^ E_STRICT ^ E_DEPRECATED); +error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); /** * Suppress date/time errors until the internal time zone is set (see below). @@ -42,11 +42,6 @@ if(file_exists(RX_BASEDIR . 'config/config.user.inc.php')) require_once RX_BASEDIR . 'config/config.user.inc.php'; } -/** - * Load legacy debug settings. - */ -require_once __DIR__ . '/debug.php'; - /** * Define the list of legacy class names for the autoloader. */ @@ -198,6 +193,11 @@ require_once RX_BASEDIR . 'vendor/autoload.php'; */ Rhymix\Framework\Config::init(); +/** + * Install the debugger. + */ +Rhymix\Framework\Debug::registerErrorHandlers(error_reporting()); + /** * Set the internal timezone. */ diff --git a/common/constants.php b/common/constants.php index d084ed0f4..06f4e1810 100644 --- a/common/constants.php +++ b/common/constants.php @@ -133,6 +133,8 @@ define('_XE_PACKAGE_', 'XE'); define('_XE_LOCATION_', 'en'); define('_XE_LOCATION_SITE_', 'https://www.xpressengine.com/'); define('_XE_DOWNLOAD_SERVER_', 'https://download.xpressengine.com/'); +define('__PROXY_SERVER__', null); +define('__DEBUG__', 0); /** * Other useful constants. diff --git a/common/css/xe.css b/common/css/xe.css index 2bdbb9740..c02a052e5 100644 --- a/common/css/xe.css +++ b/common/css/xe.css @@ -290,3 +290,142 @@ button.btn { .btn-group>.btn.active { z-index: 2; } + +/* Debug */ +#rhymix_debug_button { + position: fixed; + left: 0; bottom: 40px; + background: #eeeeee; + background: linear-gradient(to bottom, #f4f4f4 0%, #eaeaea 100%); + border: 1px solid #ccc; border-left: 0; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.18), 0 0 6px 0 rgba(0, 0, 0, 0.12); + z-index: 1073741824; +} +#rhymix_debug_button:hover { + background: #dddddd; + background: linear-gradient(to bottom, #e8e8e8 0%, #d9d9d9 100%); +} +#rhymix_debug_button a { + display: block; + font: bold 12px/14px Arial, sans-serif; + color: #444; + text-decoration: none; + padding: 4px 8px; +} +#rhymix_debug_button a.has_errors { + color: #f44336; +} +#rhymix_debug_panel { + display: none; + position: fixed; + left: 0; top: 0; + max-width: 100%; + height: 100%; + overflow-y: scroll; + background: #fcfcfc; + box-sizing: border-box; + border-right: 1px solid #ccc; + box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.18), 0 0 8px 0 rgba(0, 0, 0, 0.12); + z-index: 1073741824; +} +#rhymix_debug_panel .debug_header { + clear: both; + width: 100%; + height: 36px; + background: #444444; + background: linear-gradient(to right, #222222 0%, #444444 40%, #eeeeee 100%); + position: relative; +} +#rhymix_debug_panel .debug_header h2 { + font: bold 16px/20px Arial, sans-serif; + color: #fcfcfc; + position: absolute; + left: 10px; top: 10px; + margin: 0; padding: 0; +} +#rhymix_debug_panel .debug_header .debug_maximize { + font: normal 20px/24px Arial, sans-serif; + text-decoration: none; + color: #444444; + position: absolute; + right: 32px; top: 6px; +} +#rhymix_debug_panel .debug_header .debug_close { + font: normal 28px/28px Arial, sans-serif; + text-decoration: none; + color: #444444; + position: absolute; + right: 10px; top: 4px; +} +#rhymix_debug_panel .debug_header .debug_close:hover { + color: #f44336; +} +#rhymix_debug_panel .debug_page { + clear: both; + margin: 12px 10px; + font: normal 12px/16px Arial, NanumBarunGothic, NanumGothic, "Malgun Gothic", sans-serif; +} +#rhymix_debug_panel .debug_page .debug_page_header { + padding-bottom: 8px; + border-bottom: 1px solid #ddd; + position: relative; + cursor: pointer; +} +#rhymix_debug_panel .debug_page .debug_page_header h3 { + color: #444; + font: inherit; + font-size: 14px; + font-weight: bold; + margin: 0; + padding: 0; +} +#rhymix_debug_panel .debug_page .debug_page_collapse { + display: block; + position: absolute; + right: 0; top: 0; + color: #999; + font-size: 10px; + line-height: 12px; + text-decoration: none; + padding: 2px 2px; +} +#rhymix_debug_panel .debug_page .debug_page_body { + margin: 8px 4px 8px 10px; +} +#rhymix_debug_panel .debug_page .debug_page_body h4 { + color: #444; + font: inherit; + font-size: 13px; + font-weight: bold; + margin: 0 0 8px 0; + padding: 0; +} +#rhymix_debug_panel .debug_page .debug_entry { + font-family: Consolas, "Courier New", monospace; + color: #444; + margin-left: 38px; + margin-bottom: 8px; + text-indent: -28px; + word-wrap: break-word; + word-break: break-all; +} +#rhymix_debug_panel .debug_page .debug_entry.pre_wrap { + white-space: pre-wrap; +} +#rhymix_debug_panel .debug_page .debug_entry ul.debug_metadata { + margin: 0 0 0 -16px; padding: 0; +} +#rhymix_debug_panel .debug_page .debug_entry ul.debug_metadata li { + list-style: disc; + margin: 0; padding: 0; text-indent: 0; +} +#rhymix_debug_panel .debug_page .debug_entry ul.debug_backtrace { + margin: 4px 0 0 16px; padding: 0; +} +#rhymix_debug_panel .debug_page .debug_entry ul.debug_backtrace li { + list-style: disc; + margin: 0; padding: 0; text-indent: 0; + color: #888; +} diff --git a/common/debug.php b/common/debug.php deleted file mode 100644 index 0e56fac0b..000000000 --- a/common/debug.php +++ /dev/null @@ -1,149 +0,0 @@ - - */ - -/** - * output debug message (bit value) - * - * 0: generate debug messages/not display - * 1: display messages through debugPrint() function - * 2: output execute time, Request/Response info - * 4: output DB query history - */ -if(!defined('__DEBUG__')) -{ - define('__DEBUG__', 0); -} - -/** - * output location of debug message - * - * 0: connect to the files/_debug_message.php and output - * 1: HTML output as a comment on the bottom (when response method is the HTML) - * 2: Firebug console output (PHP 4 & 5. Firebug/FirePHP plug-in required) - */ -if(!defined('__DEBUG_OUTPUT__')) -{ - define('__DEBUG_OUTPUT__', 0); -} - -/** - * output comments of the firePHP console and browser - * - * 0: No limit (not recommended) - * 1: Allow only specified IP addresses - */ -if(!defined('__DEBUG_PROTECT__')) -{ - define('__DEBUG_PROTECT__', 1); -} - -/** - * Set a ip address to allow debug - */ -if(!defined('__DEBUG_PROTECT_IP__')) -{ - define('__DEBUG_PROTECT_IP__', '127.0.0.1'); -} - -/** - * DB error message definition - * - * 0: No output - * 1: files/_debug_db_query.php connected to the output - */ -if(!defined('__DEBUG_DB_OUTPUT__')) -{ - define('__DEBUG_DB_OUTPUT__', 0); -} - -/** - * Query log for only timeout query among DB queries - * - * 0: Do not leave a log - * > 0: leave a log when the slow query takes over specified seconds - * Log file is saved as ./files/_slowlog_query.php file - */ -if(!defined('__LOG_SLOW_QUERY__')) -{ - define('__LOG_SLOW_QUERY__', 0); -} - -/** - * Trigger excute time log - * - * 0: Do not leave a log - * > 0: leave a log when the trigger takes over specified milliseconds - * Log file is saved as ./files/_slowlog_trigger.php - */ -if(!defined('__LOG_SLOW_TRIGGER__')) -{ - define('__LOG_SLOW_TRIGGER__', 0); -} - -/** - * Addon excute time log - * - * 0: Do not leave a log - * > 0: leave a log when the trigger takes over specified milliseconds - * Log file is saved as ./files/_slowlog_addon.php - */ -if(!defined('__LOG_SLOW_ADDON__')) -{ - define('__LOG_SLOW_ADDON__', 0); -} - -/** - * Widget excute time log - * - * 0: Do not leave a log - * > 0: leave a log when the widget takes over specified milliseconds - * Log file is saved as ./files/_slowlog_widget.php - */ -if(!defined('__LOG_SLOW_WIDGET__')) -{ - define('__LOG_SLOW_WIDGET__', 0); -} - -/** - * output comments of the slowlog files - * - * 0: No limit (not recommended) - * 1: Allow only specified IP addresses - */ -if(!defined('__LOG_SLOW_PROTECT__')) -{ - define('__LOG_SLOW_PROTECT__', 1); -} - -/** - * Set a ip address to allow slowlog - */ -if(!defined('__LOG_SLOW_PROTECT_IP__')) -{ - define('__LOG_SLOW_PROTECT_IP__', '127.0.0.1'); -} - -/** - * Leave DB query information - * - * 0: Do not add information to the query - * 1: Comment the XML Query ID - */ -if(!defined('__DEBUG_QUERY__')) -{ - define('__DEBUG_QUERY__', 0); -} - -/** - * __PROXY_SERVER__ has server information to request to the external through the target server - * FileHandler:: getRemoteResource uses the constant - */ -if(!defined('__PROXY_SERVER__')) -{ - define('__PROXY_SERVER__', NULL); -} diff --git a/common/defaults/config.php b/common/defaults/config.php index a9407e015..71ee5ff4f 100644 --- a/common/defaults/config.php +++ b/common/defaults/config.php @@ -89,9 +89,10 @@ return array( 'enabled' => true, 'log_errors' => true, 'log_queries' => false, - 'log_slow_queries' => 1, - 'log_slow_triggers' => 1, - 'log_slow_widgets' => 1, + 'log_slow_queries' => 0, + 'log_slow_triggers' => 0, + 'log_slow_widgets' => 0, + 'log_filename' => null, 'display_type' => 'comment', 'display_to' => 'admin', 'allow' => array(), diff --git a/classes/security/conf/whitelist.php b/common/defaults/whitelist.php similarity index 99% rename from classes/security/conf/whitelist.php rename to common/defaults/whitelist.php index abd276136..272da733b 100644 --- a/classes/security/conf/whitelist.php +++ b/common/defaults/whitelist.php @@ -1,8 +1,15 @@ or tag + /** + * Allowed domains in or tag + */ 'object' => array( // YouTube 'www.youtube.com/', @@ -49,7 +56,9 @@ return array( 'sbsplayer.sbs.co.kr/', ), - // Allowed domains in

IFrame

', @@ -59,14 +59,11 @@ class FuncIncTest extends \Codeception\TestCase\Test 'dummy' ) ); - } - - /** - * @dataProvider provider - */ - public function testXss($source, $expected) - { - $result = removeHackTag($source); - $this->assertEquals($result, $expected); + + foreach ($tests as $test) + { + $result = removeHackTag($test[0]); + $this->assertEquals($test[1], $result); + } } } diff --git a/widgets/content/conf/info.xml b/widgets/content/conf/info.xml index b76ddc545..c8b466ea2 100644 --- a/widgets/content/conf/info.xml +++ b/widgets/content/conf/info.xml @@ -622,6 +622,32 @@ Görüntüleme + + 비밀글 출력 + Display Secret + + N + 출력하지 않음 + No Display + Không hiển thị + No Display + 不显示 + 不顯示 + 表示しない + Görüntüleme + + + Y + 출력 + Display + Hiển thị + Display + 显示 + 顯示 + 表示 + Görüntüle + + new 표시 시간 (hours) new图标显示时间(hours) diff --git a/widgets/content/content.class.php b/widgets/content/content.class.php index 5399fbc98..c2777e6e3 100644 --- a/widgets/content/content.class.php +++ b/widgets/content/content.class.php @@ -249,8 +249,17 @@ class content extends WidgetHandler { $obj->order_type = $args->order_type=="desc"?"desc":"asc"; } + + if($args->show_secret == 'Y') + { + $obj->statusList = array('PUBLIC', 'SECRET'); + } + else + { + $obj->statusList = array('PUBLIC'); + } + $obj->list_count = $args->list_count * $args->page_count; - $obj->statusList = array('PUBLIC'); $output = executeQueryArray('widgets.content.getNewestDocuments', $obj); if(!$output->toBool() || !$output->data) return; // If the result exists, make each document as an object