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, '