diff --git a/.gitignore b/.gitignore
index 2917e66cb..1ab6c7b20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,8 @@
.DS_Store
Thumbs.db
-config.user.inc.php
+/config/config.user.inc.php
+/config/install.config.php
/files/
/build/
/libs/
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/CONTRIBUTING.md b/CONTRIBUTING.md
index b5053ce24..7e482d998 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,13 +8,13 @@
- 무관한 이슈에 댓글을 달지 말아 주십시오. 엉뚱한 사람에게 메일 알림이 전달됩니다.
- 2가지 이상 서로 다른 문제가 있는 경우, 각각 이슈를 등록해 주십시오.
- 보안 취약점은 공개적으로 언급하지 말고 devops@rhymix.org로 알려 주시면 감사하겠습니다.
-- **버그 신고 전 자신의 서버가 RhymiX의 실행 환경을 충족하는지 확인해 주십시오.**
+- **버그 신고 전 자신의 서버가 Rhymix의 실행 환경을 충족하는지 확인해 주십시오.**
- PHP 5.3 미만, EUC-KR 환경, 퍼미션 오류 등은 호스팅 업체에 문의하셔야 합니다.
- 자신의 서버 환경은 `phpinfo`를 사용하여 확인할 수 있습니다.
- **버그 신고에는 아래의 내용을 반드시 포함시켜 주십시오.**
- 실행 환경
- 호스팅 환경에 대한 간단한 설명 (예: ○○24 리눅스 웹호스팅)
- - RhymiX 버전 (예: 1.8.15)
+ - Rhymix 버전 (예: 1.8.15)
- PHP 버전 (예: 5.6.16)
- 브라우저 종류 및 버전 (예: IE 11)
- 에러가 발생하는 경우 에러 메시지 전체
@@ -39,7 +39,7 @@
- 모든 소스 코드의 저작권은 해당 작성자가 가집니다.
- 모든 소스 코드에는 GPL v2 또는 그 이후 버전의 라이선스가 적용됩니다.
- - RhymiX 개발팀을 비롯한 전세계 어느 누구라도 어떤 목적으로든지 자유롭게 사용, 수정, 재배포할 수 있습니다.
+ - Rhymix 개발팀을 비롯한 전세계 어느 누구라도 어떤 목적으로든지 자유롭게 사용, 수정, 재배포할 수 있습니다.
- 타인에게 저작권이 있는 코드를 가져온 경우, 원본의 라이선스를 GPL로 전환할 수 있어야 합니다.
- 한 번 적용한 라이선스는 철회할 수 없습니다.
- **풀 리퀘스트를 작성하실 경우 위의 두 가지에 동의하시는 것으로 간주합니다.**
@@ -150,7 +150,7 @@ PHPDoc 주석 작성에 어려움이 있는 경우, 다른 클래스와 함수
### 기타
-RhymiX에서 정한 `error_reporting` 설정 하에서 어떤 에러도 발생하지 않도록 하는 것을 목표로 합니다.
+Rhymix에서 정한 `error_reporting` 설정 하에서 어떤 에러도 발생하지 않도록 하는 것을 목표로 합니다.
문자열과 문자열, 정수와 정수를 비교할 때는 가능하면 `==` 대신 `===`을 사용합니다.
실제 자료형이 다를 가능성이 있는 경우 `intval()`, `strval()` 등의 함수와 함께 사용합니다.
diff --git a/COPYRIGHT b/COPYRIGHT
index f04e44091..6c9ed950e 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,2 +1,2 @@
-Copyright (c) RhymiX Developers and Contributors
+Copyright (c) Rhymix Developers and Contributors
Copyright (c) NAVER
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/README.md b/README.md
index d81b41b63..7c3975e43 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,19 @@
-[](https://www.rhymix.org)
+[](https://www.rhymix.org)
-RhymiX(라이믹스)는 누구든지 쉽고 자유롭게 독립적인 홈페이지를 만들어
+Rhymix(라이믹스)는 누구든지 쉽고 자유롭게 독립적인 홈페이지를 만들어
자신을 표현하고 커뮤니티를 키워나갈 수 있도록 돕기 위한 CMS(content management system)입니다.
XETOWN 커뮤니티에서 [XE](https://www.xpressengine.com)를 fork(가지치기)하여 진행하는 프로젝트로,
누구나 무료로 사용할 수 있고 개발에 참여할 수도 있는 자유 소프트웨어(free software)입니다.
-RhymiX는 "시를 짓다, 운을 맞추다"라는 의미의 "rhyme"과
+Rhymix는 "시를 짓다, 운을 맞추다"라는 의미의 "rhyme"과
"조합하다, 변주하다"라는 의미의 "remix"를 합친 이름입니다.
라이믹스는 인터넷 공간에서 자유롭게 창작 활동을 하고
다양한 소프트웨어와 콘텐츠를 조합하여 새로운 것을 만들어내는 모든 사용자들을 응원합니다.
### 개발 방향
-RhymiX는 개발자와 사용자가 서로의 권리와 책임을 존중하는 인터넷 생태계,
+Rhymix는 개발자와 사용자가 서로의 권리와 책임을 존중하는 인터넷 생태계,
중앙집중형 SNS 플랫폼에 의존하지 않고도 누구나 내 목소리를 낼 수 있는 세상,
벤처기업이나 스타트업의 개발자들뿐 아니라 평범한 블로거, 동호회, 학생, 장애인 등도
사이버 공간에 당당하게 집을 짓고 서로 소통할 수 있는 미래를 만들어가길 원합니다.
@@ -47,7 +47,7 @@ RhymiX는 개발자와 사용자가 서로의 권리와 책임을 존중하는
### 개발 참여
-RhymiX는 개발자, 디자이너, 번역가 등의 도움과 일반 사용자들의 버그 신고를 환영합니다.
+Rhymix는 개발자, 디자이너, 번역가 등의 도움과 일반 사용자들의 버그 신고를 환영합니다.
참여를 원하시는 분은 질서있고 효율적인 프로젝트 운영을 위해
[CONTRIBUTING.md](./CONTRIBUTING.md)를 먼저 읽어 주시기 바랍니다.
@@ -57,28 +57,28 @@ devops@rhymix.org로 알려 주시면 감사하겠습니다.
### 공식 홈페이지
- XETOWN : https://www.xetown.com
-- RhymiX : https://www.rhymix.org
+- Rhymix : https://www.rhymix.org
### 저작권 및 라이선스
-RhymiX는 [GNU GPL v2](http://korea.gnu.org/documents/copyleft/gpl.ko.html)
+Rhymix는 [GNU GPL v2](http://korea.gnu.org/documents/copyleft/gpl.ko.html)
또는 그 이후 버전 라이선스의 적용을 받는 자유 소프트웨어(free software)입니다.
자유 소프트웨어는 "오픈소스" 또는 "개방형"이라는 명칭으로도 알려져 있으며,
개발자와 사용자의 자유와 권리, 참여와 책임을 강조하는 프로그램으로
누구나 무료로 사용할 수 있고 개발에 참여할 수도 있습니다.
-RhymiX는 [NAVER](https://www.navercorp.com/)가 저작권을 가진
+Rhymix는 [NAVER](https://www.navercorp.com/)가 저작권을 가진
[XpressEngine](https://www.xpressengine.com)의 소스코드에 바탕을 두고 있습니다.
-RhymiX 개발자들이 추가 및 변경한 부분의 저작권은 해당 개발자들에게 있습니다.
+Rhymix 개발자들이 추가 및 변경한 부분의 저작권은 해당 개발자들에게 있습니다.
XpressEngine은 초창기에 GPL을 사용하다가 버전 1.4.0부터 LGPL로 전환했지만,
-RhymiX는 사용자의 권리를 더욱 보호하고 자유 소프트웨어 본연의 정신에 충실하기 위해 라이선스를 GPL로 되돌렸습니다.
+Rhymix는 사용자의 권리를 더욱 보호하고 자유 소프트웨어 본연의 정신에 충실하기 위해 라이선스를 GPL로 되돌렸습니다.
(라이선스 전환은 [LGPL v2.1 제3조](http://korea.gnu.org/people/chsong/copyleft/lgpl.ko.html#term3)에서 허용하고 있습니다.)
GPL은 WordPress, Drupal, Joomla 등 세계적인 CMS들이 공통으로 채택하고 있는 라이선스이므로
사용자 및 개발자의 권리와 의무도 이러한 CMS들의 경우와 동일합니다.
-홈페이지에 RhymiX를 사용하는 것만으로 소스코드를 공개할 의무가 발생하지는 않으며,
-RhymiX의 소스코드를 수정하거나 확장 기능을 직접 개발하여 사용하더라도 마찬가지입니다.
+홈페이지에 Rhymix를 사용하는 것만으로 소스코드를 공개할 의무가 발생하지는 않으며,
+Rhymix의 소스코드를 수정하거나 확장 기능을 직접 개발하여 사용하더라도 마찬가지입니다.
그러나 직접 개발한 확장 기능을 제3자에게 배포 또는 판매할 경우에는 반드시 소스코드를 제공해야 하며,
이러한 소스코드는 모두 GPL 라이선스의 적용을 받습니다.
diff --git a/addons/member_communication/conf/info.xml b/addons/member_communication/conf/info.xml
index 00f38f2f1..d9419aec7 100644
--- a/addons/member_communication/conf/info.xml
+++ b/addons/member_communication/conf/info.xml
@@ -1,45 +1,16 @@
- 커뮤니케이션
- コミュニケーション
- 会员交流
- Communication
- Truyền thông
- 커뮤니케이션
- 커뮤니케이션
- Общение
- 交流
+ [DEPRECATED] 커뮤니케이션
+ [DEPRECATED] コミュニケーション
+ [DEPRECATED] 会员交流
+ [DEPRECATED] Communication
+ [DEPRECATED] Truyền thông
+ [DEPRECATED] Communication
+ [DEPRECATED] Communication
+ [DEPRECATED] Общение
+ [DEPRECATED] 交流
- 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다.
- 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다.
-
-
- メッセージ・友達機能を使うにはこのアドオンを「使用」にして下さい。
-
-
- 此插件可激活短信箱及添加好友功能。
-
-
- 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.
-
-
- 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다.
- 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다.
-
-
- 커뮤니케이션 기능을 활성화 시켜 쪽지나 친구기능을 사용할 수 있도록 해줍니다.
- 쪽지, 친구기능등을 사용하기 위해서는 이 애드온을 사용으로 설정하면 됩니다.
-
-
- Активизирует модуль Общение, позволяет использование сообщений между друзьями.
-
-
- 讓會員擁有短訊和新增好友功能。
+ [DEPRECATED] 이 애드온은 빈 애드온입니다. 모든 기능은 커뮤니케이션 모듈로 이전되었습니다.
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
-
-
-
+
\ No newline at end of file
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..c6498c297 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/addons/point_level_icon/conf/info.xml b/addons/point_level_icon/conf/info.xml
index 174175fca..6bbe48857 100644
--- a/addons/point_level_icon/conf/info.xml
+++ b/addons/point_level_icon/conf/info.xml
@@ -59,4 +59,29 @@
NAVER
NAVER
+
+
+
+ 아이콘 중복 설정
+ 아이콘 중복 설정을 적용할 경우 그룹아이콘이 있을때 포인트 레벨 아이콘은 띄우지 않도록 합니다.
+
+ 적용하지 않음
+ 不启用
+ 적용하지 않음
+ 關閉
+ Not apply
+ Not apply
+ Không áp dụng
+
+
+ 적용
+ 启用
+ 적용
+ 開啟
+ Apply
+ Apply
+ Áp dụng
+
+
+
diff --git a/addons/point_level_icon/point_level_icon.addon.php b/addons/point_level_icon/point_level_icon.addon.php
index 69f7eb8d9..fd3b2919e 100644
--- a/addons/point_level_icon/point_level_icon.addon.php
+++ b/addons/point_level_icon/point_level_icon.addon.php
@@ -19,7 +19,9 @@ if($called_position != "before_display_content" || Context::get('act') == 'dispP
require_once(_XE_PATH_ . 'addons/point_level_icon/point_level_icon.lib.php');
-$temp_output = preg_replace_callback('!<(div|span|a)([^\>]*)member_([0-9\-]+)([^\>]*)>(.*?)\<\/(div|span|a)\>!is', 'pointLevelIconTrans', $output);
+$temp_output = preg_replace_callback('!<(div|span|a)([^\>]*)member_([0-9\-]+)([^\>]*)>(.*?)\<\/(div|span|a)\>!is', function($matches) use($addon_info) {
+ return pointLevelIconTrans($matches, $addon_info);
+}, $output);
if($temp_output)
{
$output = $temp_output;
diff --git a/addons/point_level_icon/point_level_icon.lib.php b/addons/point_level_icon/point_level_icon.lib.php
index 9dd9e3054..f72b46359 100644
--- a/addons/point_level_icon/point_level_icon.lib.php
+++ b/addons/point_level_icon/point_level_icon.lib.php
@@ -4,7 +4,7 @@
/**
* @brief Function to change point icon.
*/
-function pointLevelIconTrans($matches)
+function pointLevelIconTrans($matches, $addon_info)
{
$member_srl = $matches[3];
// If anonymous or not member_srl go to Hide Point Icon
@@ -15,12 +15,14 @@ function pointLevelIconTrans($matches)
$orig_text = preg_replace('/' . preg_quote($matches[5], '/') . '<\/' . $matches[6] . '>$/', '', $matches[0]);
- $oMemberModel = getModel('member');
-
- // Check Group Image Mark
- if($oMemberModel->getGroupImageMark($member_srl))
+ if($addon_info->icon_duplication != 'Y')
{
- return $orig_text . $matches[5] . '' . $matches[6] . '>';
+ // Check Group Image Mark
+ $oMemberModel = getModel('member');
+ if($oMemberModel->getGroupImageMark($member_srl))
+ {
+ return $orig_text . $matches[5] . '' . $matches[6] . '>';
+ }
}
if(!isset($GLOBALS['_pointLevelIcon'][$member_srl]))
diff --git a/classes/cache/CacheHandler.class.php b/classes/cache/CacheHandler.class.php
index 39a038999..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 56eeab0cc..d3f6914ea 100644
--- a/classes/context/Context.class.php
+++ b/classes/context/Context.class.php
@@ -9,7 +9,6 @@
*/
class Context
{
-
/**
* Allow rewrite
* @var bool TRUE: using rewrite mod, FALSE: otherwise
@@ -209,7 +208,7 @@ class Context
*/
public function init()
{
- // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above
+ // Fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above.
if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
{
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
@@ -220,17 +219,14 @@ class Context
unset($GLOBALS['HTTP_RAW_POST_DATA']);
}
}
-
- // set context variables in $GLOBALS (backward compatibility)
+
+ // Set global variables for backward compatibility.
$GLOBALS['__Context__'] = $this;
- $GLOBALS['lang'] = &$this->lang;
$this->_COOKIE = $_COOKIE;
-
- // 20140429 editor/image_link
+
+ // Set information about the current request.
+ $this->setRequestMethod();
$this->_checkGlobalVars();
-
- $this->setRequestMethod('');
-
$this->_setXmlRpcArgument();
$this->_setJSONRequestArgument();
$this->_setRequestArgument();
@@ -241,77 +237,37 @@ class Context
self::$_instance->request_method = 'XMLRPC';
self::$_instance->response_method = 'JSON';
}
-
+
+ // Load system configuration.
$this->loadDBInfo();
- if($this->db_info->use_sitelock == 'Y')
- {
- if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
-
- if(!IpFilter::filter($whitelist))
- {
- $title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...';
- $message = $this->db_info->sitelock_message;
-
- define('_XE_SITELOCK_', TRUE);
- define('_XE_SITELOCK_TITLE_', $title);
- define('_XE_SITELOCK_MESSAGE_', $message);
-
- header("HTTP/1.1 403 Forbidden");
- if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
- {
- include _XE_PATH_ . 'common/tpl/sitelock.user.html';
- }
- else
- {
- include _XE_PATH_ . 'common/tpl/sitelock.html';
- }
- exit;
- }
- }
-
- // If XE is installed, get virtual site information
+
+ // If Rhymix is installed, get virtual site information.
if(self::isInstalled())
{
$oModuleModel = getModel('module');
- $site_module_info = $oModuleModel->getDefaultMid();
-
- if(!isset($site_module_info))
- {
- $site_module_info = new stdClass;
- }
-
+ $site_module_info = $oModuleModel->getDefaultMid() ?: new stdClass;
+
// if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config
if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
{
$site_module_info->domain = $this->db_info->default_url;
}
-
+
self::set('site_module_info', $site_module_info);
if($site_module_info->site_srl && isSiteID($site_module_info->domain))
{
self::set('vid', $site_module_info->domain, TRUE);
}
-
- if(!isset($this->db_info))
- {
- $this->db_info = new stdClass;
- }
-
- $this->db_info->lang_type = $site_module_info->default_language;
- if(!$this->db_info->lang_type)
- {
- $this->db_info->lang_type = 'ko';
- }
- if(!$this->db_info->use_db_session)
- {
- $this->db_info->use_db_session = 'N';
- }
+ }
+ else
+ {
+ $site_module_info = new stdClass;
}
- // Load Language File
- $lang_supported = self::loadLangSelected();
-
- // Retrieve language type set in user's cookie
+ // Load language support.
+ $enabled_langs = self::loadLangSelected();
+ self::set('lang_supported', $enabled_langs);
+
if($this->lang_type = self::get('l'))
{
if($_COOKIE['lang_type'] != $this->lang_type)
@@ -323,33 +279,29 @@ class Context
{
$this->lang_type = $_COOKIE['lang_type'];
}
-
- // If it's not exists, follow default language type set in db_info
- if(!$this->lang_type)
+ elseif($site_module_info->default_language)
+ {
+ $this->lang_type = $this->db_info->lang_type = $site_module_info->default_language;
+ }
+ else
{
$this->lang_type = $this->db_info->lang_type;
}
-
- // if still lang_type has not been set or has not-supported type , set as Korean.
- if(!$this->lang_type)
- {
- $this->lang_type = 'ko';
- }
- if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
+
+ if(!$this->lang_type || !isset($enabled_langs[$this->lang_type]))
{
$this->lang_type = 'ko';
}
- self::set('lang_supported', $lang_supported);
self::setLangType($this->lang_type);
-
- // Load languages
+
$this->lang = Rhymix\Framework\Lang::getInstance($this->lang_type);
$this->lang->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
$this->lang->loadDirectory(RX_BASEDIR . 'modules/module/lang', 'module');
-
+ $GLOBALS['lang'] = $this->lang;
+
// set session handler
- if(self::isInstalled() && $this->db_info->use_db_session == 'Y')
+ if(self::isInstalled() && config('session.use_db'))
{
$oSessionModel = getModel('session');
$oSessionController = getController('session');
@@ -370,19 +322,19 @@ class Context
$session_id = $_COOKIE[$session_name];
}
- if($session_id !== NULL || $this->db_info->delay_session != 'Y')
+ if($session_id !== NULL || !config('session.delay'))
{
$this->setCacheControl(0, false);
session_start();
}
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())
{
@@ -412,57 +364,31 @@ class Context
}
}
}
-
- // check if using rewrite module
- $this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE);
-
+
// set locations for javascript use
- $url = array();
- $current_url = self::getRequestUri();
- if($_SERVER['REQUEST_METHOD'] == 'GET')
+ $current_url = $request_uri = self::getRequestUri();
+ if ($_SERVER['REQUEST_METHOD'] == 'GET' && $this->get_vars)
{
- if($this->get_vars)
+ if ($query_string = http_build_query($this->get_vars))
{
- $url = array();
- foreach($this->get_vars as $key => $val)
- {
- if(is_array($val) && count($val) > 0)
- {
- foreach($val as $k => $v)
- {
- $url[] = $key . '[' . $k . ']=' . urlencode($v);
- }
- }
- elseif($val)
- {
- $url[] = $key . '=' . urlencode($val);
- }
- }
-
- $current_url = self::getRequestUri();
- if($url) $current_url .= '?' . join('&', $url);
- }
- else
- {
- $current_url = self::getUrl();
+ $current_url .= '?' . $query_string;
}
}
- else
+ if (strpos($current_url, 'xn--') !== false)
{
- $current_url = self::getRequestUri();
+ $current_url = self::decodeIdna($current_url);
+ }
+ if (strpos($request_uri, 'xn--') !== false)
+ {
+ $request_uri = self::decodeIdna($request_uri);
}
-
self::set('current_url', $current_url);
- self::set('request_uri', self::getRequestUri());
-
- if(strpos($current_url, 'xn--') !== FALSE)
+ self::set('request_uri', $request_uri);
+
+ // If the site is locked, display the locked page.
+ if(config('lock.locked'))
{
- self::set('current_url', self::decodeIdna($current_url));
- }
-
- if(strpos(self::getRequestUri(), 'xn--') !== FALSE)
- {
- self::set('request_uri', self::decodeIdna(self::getRequestUri()));
+ self::enforceSiteLock();
}
}
@@ -485,7 +411,7 @@ class Context
{
if(self::getSessionStatus())
{
- return;
+ return true;
}
if($force_start || (count($_SESSION) && !headers_sent()))
{
@@ -493,7 +419,9 @@ class Context
unset($_SESSION);
session_start();
$_SESSION = $tempSession;
+ return true;
}
+ return false;
}
/**
@@ -503,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();
+ }
}
/**
@@ -535,81 +467,109 @@ class Context
*
* @return void
*/
- public static function loadDBInfo()
+ public static function loadDBInfo($config = null)
{
- if(!self::isInstalled())
+ // Load new configuration format.
+ if ($config === null)
{
+ $config = Rhymix\Framework\Config::getAll();
+ }
+ if (!count($config))
+ {
+ self::$_instance->db_info = self::$_instance->db_info ?: new stdClass;
return;
}
- $config_file = self::getConfigFile();
- if(is_readable($config_file))
- {
- include($config_file);
- }
+ // Copy to old format for backward compatibility.
+ self::$_instance->db_info = self::convertDBInfo($config);
+ self::$_instance->allow_rewrite = self::$_instance->db_info->use_rewrite;
+ self::set('_http_port', self::$_instance->db_info->http_port ?: null);
+ self::set('_https_port', self::$_instance->db_info->https_port ?: null);
+ self::set('_use_ssl', self::$_instance->db_info->use_ssl);
+ $GLOBALS['_time_zone'] = self::$_instance->db_info->time_zone;
+ }
- // If master_db information does not exist, the config file needs to be updated
- if(!isset($db_info->master_db))
+ /**
+ * Convert Rhymix configuration to XE DBInfo format
+ *
+ * @param array $config
+ * @return object
+ */
+ public static function convertDBInfo($config)
+ {
+ $db_info = new stdClass;
+ $db_info->master_db = array(
+ 'db_type' => $config['db']['master']['type'] . ($config['db']['master']['engine'] === 'innodb' ? '_innodb' : ''),
+ 'db_hostname' => $config['db']['master']['host'],
+ 'db_port' => $config['db']['master']['port'],
+ 'db_userid' => $config['db']['master']['user'],
+ 'db_password' => $config['db']['master']['pass'],
+ 'db_database' => $config['db']['master']['database'],
+ 'db_table_prefix' => $config['db']['master']['prefix'],
+ 'db_charset' => $config['db']['master']['charset'],
+ );
+ $db_info->slave_db = array();
+ foreach ($config['db'] as $key => $dbconfig)
{
- $db_info->master_db = array();
- $db_info->master_db["db_type"] = $db_info->db_type;
- unset($db_info->db_type);
- $db_info->master_db["db_port"] = $db_info->db_port;
- unset($db_info->db_port);
- $db_info->master_db["db_hostname"] = $db_info->db_hostname;
- unset($db_info->db_hostname);
- $db_info->master_db["db_password"] = $db_info->db_password;
- unset($db_info->db_password);
- $db_info->master_db["db_database"] = $db_info->db_database;
- unset($db_info->db_database);
- $db_info->master_db["db_userid"] = $db_info->db_userid;
- unset($db_info->db_userid);
- $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix;
- unset($db_info->db_table_prefix);
-
- if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0)
+ if ($key !== 'master')
{
- $db_info->master_db["db_table_prefix"] .= '_';
+ $db_info->slave_db[] = array(
+ 'db_type' => $dbconfig['type'] . ($dbconfig['engine'] === 'innodb' ? '_innodb' : ''),
+ 'db_hostname' => $dbconfig['host'],
+ 'db_port' => $dbconfig['port'],
+ 'db_userid' => $dbconfig['user'],
+ 'db_password' => $dbconfig['pass'],
+ 'db_database' => $dbconfig['database'],
+ 'db_table_prefix' => $dbconfig['prefix'],
+ 'db_charset' => $dbconfig['charset'],
+ );
}
-
- $db_info->slave_db = array($db_info->master_db);
- self::setDBInfo($db_info);
-
- $oInstallController = getController('install');
- $oInstallController->makeConfigFile();
}
-
- if(!$db_info->use_prepared_statements)
+ if (!count($db_info->slave_db))
{
- $db_info->use_prepared_statements = 'Y';
+ $db_info->slave_db = array($db_info->master_db);
}
-
- if(!$db_info->time_zone)
- $db_info->time_zone = date('O');
- $GLOBALS['_time_zone'] = $db_info->time_zone;
- $GLOBALS['_time_zone_offset'] = get_time_zone_offset($db_info->time_zone);
-
- if($db_info->qmail_compatibility != 'Y')
- $db_info->qmail_compatibility = 'N';
- $GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
-
- if(!$db_info->use_db_session)
- $db_info->use_db_session = 'N';
- if(!$db_info->use_ssl)
- $db_info->use_ssl = 'none';
- self::set('_use_ssl', $db_info->use_ssl);
- self::set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
- self::set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL);
-
- if(!$db_info->sitelock_whitelist) {
- $db_info->sitelock_whitelist = '127.0.0.1';
+ $db_info->use_object_cache = count($config['cache']) ? array_first($config['cache']) : null;
+ $db_info->ftp_info = new stdClass;
+ $db_info->ftp_info->ftp_host = $config['ftp']['host'];
+ $db_info->ftp_info->ftp_port = $config['ftp']['port'];
+ $db_info->ftp_info->ftp_user = $config['ftp']['user'];
+ $db_info->ftp_info->ftp_pasv = $config['ftp']['pasv'] ? 'Y' : 'N';
+ $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;
}
-
- if(is_string($db_info->sitelock_whitelist)) {
- $db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist);
+ $db_info->http_port = $config['url']['http_port'];
+ $db_info->https_port = $config['url']['https_port'];
+ $db_info->use_ssl = $config['url']['ssl'];
+ $db_info->lang_type = $config['locale']['default_lang'];
+ $db_info->time_zone = $config['locale']['internal_timezone'];
+ $db_info->time_zone = sprintf('%s%02d%02d', $db_info->time_zone >= 0 ? '+' : '-', abs($db_info->time_zone) / 3600, (abs($db_info->time_zone) % 3600 / 60));
+ $db_info->delay_session = $config['session']['delay'] ? 'Y' : 'N';
+ $db_info->use_db_session = $config['session']['use_db'] ? 'Y' : 'N';
+ $db_info->minify_scripts = $config['view']['minify_scripts'] ? 'Y' : 'N';
+ $db_info->admin_ip_list = count($config['admin']['allow']) ? $config['admin']['allow'] : null;
+ $db_info->use_sitelock = $config['lock']['locked'] ? 'Y' : 'N';
+ $db_info->sitelock_title = $config['lock']['title'];
+ $db_info->sitelock_message = $config['lock']['message'];
+ $db_info->sitelock_whitelist = count($config['lock']['allow']) ? $config['lock']['allow'] : array('127.0.0.1');
+ $db_info->embed_white_iframe = $config['embedfilter']['iframe'];
+ $db_info->embed_white_object = $config['embedfilter']['object'];
+ $db_info->use_mobile_view = $config['use_mobile_view'] ? 'Y' : 'N';
+ $db_info->use_prepared_statements = $config['use_prepared_statements'] ? 'Y' : 'N';
+ $db_info->use_rewrite = $config['use_rewrite'] ? 'Y' : 'N';
+ $db_info->use_sso = $config['use_sso'] ? 'Y' : 'N';
+ if (is_array($config['other']))
+ {
+ foreach ($config['other'] as $key => $value)
+ {
+ $db_info->{$key} = $value;
+ }
}
-
- self::setDBInfo($db_info);
+ return $db_info;
}
/**
@@ -650,7 +610,7 @@ class Context
*/
public static function getSslStatus()
{
- return self::getDBInfo()->use_ssl;
+ return self::get('_use_ssl');
}
/**
@@ -660,7 +620,7 @@ class Context
*/
public static function getDefaultUrl()
{
- return self::getDBInfo()->default_url;
+ return self::$_instance->db_info->default_url;
}
/**
@@ -680,39 +640,21 @@ class Context
*/
public static function loadLangSelected()
{
- static $lang_selected = null;
- if(!$lang_selected)
+ static $lang_selected = array();
+ if(!count($lang_selected))
{
- $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
- if(!FileHandler::hasContent($selected_lang_file))
+ $supported = Rhymix\Framework\Lang::getSupportedList();
+ $selected = Rhymix\Framework\Config::get('locale.enabled_lang');
+ if ($selected)
{
- $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
- FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
- }
-
- if(!FileHandler::hasContent($selected_lang_file))
- {
- $lang_selected = Rhymix\Framework\Lang::getSupportedList();
- $buff = '';
- foreach($lang_selected as $key => $val)
+ foreach ($selected as $lang)
{
- $buff .= "$key,$val\n";
+ $lang_selected[$lang] = $supported[$lang];
}
- FileHandler::writeFile($selected_lang_file, $buff);
}
else
{
- $langs = file($selected_lang_file);
- foreach($langs as $val)
- {
- list($lang_prefix, $lang_text) = explode(',', $val);
- if($lang_prefix === 'jp')
- {
- $lang_prefix = 'ja';
- }
- $lang_text = trim($lang_text);
- $lang_selected[$lang_prefix] = $lang_text;
- }
+ $lang_selected = $supported;
}
}
return $lang_selected;
@@ -726,7 +668,7 @@ class Context
public function checkSSO()
{
// pass if it's not GET request or XE is not yet installed
- if($this->db_info->use_sso != 'Y' || isCrawler())
+ if(!config('use_sso') || isCrawler())
{
return TRUE;
}
@@ -820,7 +762,8 @@ class Context
*/
public static function isFTPRegisted()
{
- return file_exists(self::getFTPConfigFile());
+ $ftp_info = self::$_instance->db_info->ftp_info;
+ return ($ftp_info->ftp_user && $ftp_info->ftp_root_path);
}
/**
@@ -830,11 +773,11 @@ class Context
*/
public static function getFTPInfo()
{
- if(!self::isFTPRegisted())
+ $ftp_info = self::$_instance->db_info->ftp_info;
+ if (!$ftp_info->ftp_user || !$ftp_info->ftp_root_path)
{
return null;
}
- include(self::getFTPConfigFile());
return $ftp_info;
}
@@ -929,7 +872,14 @@ class Context
{
$plugin_name = null;
}
- return self::$_instance->lang->loadDirectory($path, $plugin_name);
+
+ if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
+ {
+ $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
+ $GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
+ }
+
+ return $GLOBALS['lang']->loadDirectory($path, $plugin_name);
}
/**
@@ -940,6 +890,11 @@ class Context
*/
public static function setLangType($lang_type = 'ko')
{
+ if (!self::$_instance->db_info)
+ {
+ self::$_instance->db_info = new stdClass;
+ }
+ self::$_instance->db_info->lang_type = $lang_type;
self::$_instance->lang_type = $lang_type;
self::set('lang_type', $lang_type);
@@ -967,8 +922,13 @@ class Context
*/
public static function getLang($code)
{
- $lang = self::$_instance->lang;
- return isset($lang->{$code}) ? $lang->{$code} : $code;
+ if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
+ {
+ $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
+ $GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
+ }
+
+ return $GLOBALS['lang']->get($code);
}
/**
@@ -980,7 +940,13 @@ class Context
*/
public static function setLang($code, $val)
{
- self::$_instance->lang->{$code} = $val;
+ if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
+ {
+ $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
+ $GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
+ }
+
+ $GLOBALS['lang']->set($code, $val);
}
/**
@@ -1216,7 +1182,7 @@ class Context
{
continue;
}
- $key = htmlentities($key);
+ $key = escape($key);
$val = $this->_filterRequestVar($key, $val);
if($requestMethod == 'GET' && isset($_GET[$key]))
@@ -1392,7 +1358,7 @@ class Context
$result = array();
foreach($val as $k => $v)
{
- $k = htmlentities($k);
+ $k = escape($k);
if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
{
$result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
@@ -1411,10 +1377,21 @@ class Context
if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
{
- $result[$k] = stripslashes($result[$k]);
+ if (is_array($result[$k]))
+ {
+ array_walk_recursive($result[$k], function(&$val) { $val = stripslashes($val); });
+ }
+ else
+ {
+ $result[$k] = stripslashes($result[$k]);
+ }
}
- if(!is_array($result[$k]))
+ if(is_array($result[$k]))
+ {
+ array_walk_recursive($result[$k], function(&$val) { $val = trim($val); });
+ }
+ else
{
$result[$k] = trim($result[$k]);
}
@@ -1478,6 +1455,79 @@ class Context
}
}
+ /**
+ * Enforce site lock.
+ */
+ private static function enforceSiteLock()
+ {
+ // Allow if the current user is logged in as administrator, or trying to log in.
+ $logged_info = self::get('logged_info');
+ if ($logged_info && $logged_info->is_admin === 'Y')
+ {
+ return;
+ }
+ elseif (in_array(self::get('act'), array('procMemberLogin', 'dispMemberLogout')))
+ {
+ return;
+ }
+
+ // Allow if the current user is in the list of allowed IPs.
+ $allowed_list = config('lock.allow');
+ foreach ($allowed_list as $allowed_ip)
+ {
+ if (Rhymix\Framework\IpFilter::inRange(RX_CLIENT_IP, $allowed_ip))
+ {
+ return;
+ }
+ }
+
+ // Set headers and constants for backward compatibility.
+ header('HTTP/1.1 503 Service Unavailable');
+ define('_XE_SITELOCK_', TRUE);
+ define('_XE_SITELOCK_TITLE_', config('lock.title') ?: self::getLang('admin.sitelock_in_use'));
+ define('_XE_SITELOCK_MESSAGE_', config('lock.message'));
+ unset($_SESSION['XE_VALIDATOR_RETURN_URL']);
+
+ // Load the sitelock template.
+ if(FileHandler::exists(RX_BASEDIR . 'common/tpl/sitelock.user.html'))
+ {
+ include RX_BASEDIR . 'common/tpl/sitelock.user.html';
+ }
+ else
+ {
+ 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)
@@ -1845,7 +1895,7 @@ class Context
self::$_user_vars->{$key} = $val;
self::$_instance->{$key} = $val;
- if($set_to_get_vars)
+ if($set_to_get_vars || isset(self::$_instance->get_vars->{$key}))
{
if($val === NULL || $val === '')
{
@@ -2003,6 +2053,10 @@ class Context
{
return self::$_instance->ssl_actions;
}
+ else
+ {
+ return array();
+ }
}
/**
@@ -2468,7 +2522,7 @@ class Context
*/
public static function getConfigFile()
{
- return _XE_PATH_ . 'files/config/db.config.php';
+ return RX_BASEDIR . Rhymix\Framework\Config::$old_db_config_filename;
}
/**
@@ -2478,7 +2532,7 @@ class Context
*/
public static function getFTPConfigFile()
{
- return _XE_PATH_ . 'files/config/ftp.config.php';
+ return RX_BASEDIR . Rhymix\Framework\Config::$old_ftp_config_filename;
}
/**
@@ -2488,7 +2542,7 @@ class Context
*/
public static function isInstalled()
{
- return FileHandler::hasContent(self::getConfigFile());
+ return (bool)config('config_version');
}
/**
@@ -2509,7 +2563,7 @@ class Context
*/
public static function isAllowRewrite()
{
- return self::getInstance()->allow_rewrite;
+ return self::$_instance->allow_rewrite;
}
/**
diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php
index 6a5a6cc1e..fbc205adc 100644
--- a/classes/db/DB.class.php
+++ b/classes/db/DB.class.php
@@ -22,26 +22,18 @@ class DB
* priority of DBMS
* @var array
*/
- var $priority_dbms = array(
+ protected static $priority_dbms = array(
'mysqli' => 6,
- 'mysqli_innodb' => 5,
'mysql' => 4,
- 'mysql_innodb' => 3,
'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' => '>',
@@ -56,94 +48,98 @@ 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
* @param string $db_type type of db
* @return DB return DB object instance
*/
- function &getInstance($db_type = NULL)
+ public static function getInstance($db_type = NULL)
{
if(!$db_type)
{
- $db_type = Context::getDBType();
+ $db_type = config('db.master.type');
+ if (config('db.master.engine') === 'innodb')
+ {
+ $db_type .= '_innodb';
+ }
}
if(!$db_type && Context::isInstalled())
{
@@ -157,7 +153,7 @@ class DB
if(!isset($GLOBALS['__DB__'][$db_type]))
{
$class_name = 'DB' . ucfirst($db_type);
- $class_file = _XE_PATH_ . "classes/db/$class_name.class.php";
+ $class_file = RX_BASEDIR . "classes/db/$class_name.class.php";
if(!file_exists($class_file))
{
return new Object(-1, 'msg_db_not_setted');
@@ -165,7 +161,7 @@ class DB
// get a singletone instance of the database driver class
require_once($class_file);
- $GLOBALS['__DB__'][$db_type] = call_user_func(array($class_name, 'create'));
+ $GLOBALS['__DB__'][$db_type] = new $class_name;
$GLOBALS['__DB__'][$db_type]->db_type = $db_type;
}
@@ -176,7 +172,7 @@ class DB
* returns instance of db
* @return DB return DB object instance
*/
- function create()
+ public static function create()
{
return new static();
}
@@ -185,9 +181,8 @@ class DB
* constructor
* @return void
*/
- function __construct()
+ public function __construct()
{
- $this->count_cache_path = _XE_PATH_ . $this->count_cache_path;
$this->cache_file = _XE_PATH_ . $this->cache_file;
}
@@ -197,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();
}
/**
@@ -208,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)
{
@@ -237,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)
{
@@ -263,86 +253,50 @@ 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";
$supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE);
// after creating instance of class, check is supported
- for($i = 0; $i < count($supported_list); $i++)
+ foreach ($supported_list as $db_type)
{
- $db_type = $supported_list[$i];
-
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1)));
$class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name);
- if(!file_exists($class_file))
+ if(!file_exists($class_file) || stripos($class_file, '_innodb') !== false)
{
continue;
}
-
- unset($oDB);
+
require_once($class_file);
$oDB = new $class_name();
-
- if(!$oDB)
- {
- continue;
- }
-
+
$obj = new stdClass;
$obj->db_type = $db_type;
$obj->enable = $oDB->isSupported() ? TRUE : FALSE;
-
+ unset($oDB);
+
$get_supported_list[] = $obj;
}
// 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;
}
/**
@@ -350,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;
}
@@ -361,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')
{
@@ -378,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;
@@ -390,7 +344,7 @@ class DB
* finish recording log
* @return void
*/
- function actFinish()
+ public function actFinish()
{
if(!$this->query)
{
@@ -410,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);
}
/**
@@ -466,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);
}
/**
@@ -477,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;
@@ -487,7 +433,7 @@ class DB
* Return error status
* @return boolean true: error, false: no error
*/
- function isError()
+ public function isError()
{
return ($this->errno !== 0);
}
@@ -496,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);
@@ -510,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();
@@ -577,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);
@@ -606,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;
@@ -624,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;
}
@@ -657,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();
}
@@ -673,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;
-*/
}
/**
@@ -733,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);
-*/
}
/**
@@ -771,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;
- */
}
/**
@@ -801,7 +651,7 @@ class DB
* @param string $table_name
* @return void
*/
- function dropTable($table_name)
+ public function dropTable($table_name)
{
if(!$table_name)
{
@@ -817,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 == '')
@@ -886,7 +736,7 @@ class DB
*
* @param $queryObject
*/
- function getClickCountQuery($queryObject)
+ public function getClickCountQuery($queryObject)
{
$new_update_columns = array();
$click_count_columns = $queryObject->getClickCountColumns();
@@ -912,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 ';
@@ -944,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 == '')
@@ -976,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);
@@ -989,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);
@@ -1002,15 +852,15 @@ 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')
+ if($type == 'master' || $this->transactionNestedLevel)
{
if(!$this->master_db['is_connected'])
{
$this->_connect($type);
}
- $this->connection = 'Master ' . $this->master_db['db_hostname'];
+ $this->connection = 'master (' . $this->master_db['host'] . ')';
return $this->master_db["resource"];
}
@@ -1019,12 +869,21 @@ class DB
$indx = $this->_getSlaveConnectionStringIndex($type);
}
+ if($this->slave_db[$indx]['host'] == $this->master_db['host'] && $this->slave_db[$indx]['port'] == $this->master_db['port'])
+ {
+ if(!$this->master_db['is_connected'])
+ {
+ $this->_connect($type);
+ }
+ $this->connection = 'master (' . $this->master_db['host'] . ')';
+ return $this->master_db["resource"];
+ }
+
if(!$this->slave_db[$indx]['is_connected'])
{
$this->_connect($type, $indx);
}
-
- $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname'];
+ $this->connection = 'slave (' . $this->slave_db[$indx]['host'] . ')';
return $this->slave_db[$indx]["resource"];
}
@@ -1032,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)
{
}
@@ -1062,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))
{
@@ -1089,7 +940,7 @@ class DB
* this method is protected
* @return boolean
*/
- function _begin($transactionLevel = 0)
+ protected function _begin($transactionLevel = 0)
{
return TRUE;
}
@@ -1098,7 +949,7 @@ class DB
* DB transaction start
* @return void
*/
- function begin()
+ public function begin()
{
if(!$this->isConnected())
{
@@ -1117,7 +968,7 @@ class DB
* this method is protected
* @return boolean
*/
- function _rollback($transactionLevel = 0)
+ protected function _rollback($transactionLevel = 0)
{
return TRUE;
}
@@ -1126,7 +977,7 @@ class DB
* DB transaction rollback
* @return void
*/
- function rollback()
+ public function rollback()
{
if(!$this->isConnected() || !$this->transaction_started)
{
@@ -1148,7 +999,7 @@ class DB
* this method is protected
* @return boolean
*/
- function _commit()
+ protected function _commit()
{
return TRUE;
}
@@ -1158,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))
{
@@ -1182,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)
{
@@ -1217,25 +1068,13 @@ class DB
* this method is protected
* @return void
*/
- function _setDBInfo()
+ protected function _setDBInfo()
{
- $db_info = Context::getDBInfo();
- $this->master_db = $db_info->master_db;
- if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"]
- && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"]
- && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"]
- && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"]
- && $db_info->master_db["db_database"] == $db_info->slave_db[0]["db_database"]
- )
- {
- $this->slave_db[0] = &$this->master_db;
- }
- else
- {
- $this->slave_db = $db_info->slave_db;
- }
- $this->prefix = $db_info->master_db["db_table_prefix"];
- $this->use_prepared_statements = $db_info->use_prepared_statements;
+ $db_info = config('db');
+ $this->master_db = $db_info['master'];
+ $this->slave_db = $db_info ? array_values($db_info) : null;
+ $this->prefix = $this->master_db['prefix'];
+ $this->use_prepared_statements = config('use_prepared_statements');
}
/**
@@ -1244,7 +1083,7 @@ class DB
* @param array $connection
* @return void
*/
- function __connect($connection)
+ protected function __connect($connection)
{
}
@@ -1255,7 +1094,7 @@ class DB
* @param resource $connection
* @return void
*/
- function _afterConnect($connection)
+ protected function _afterConnect($connection)
{
}
@@ -1267,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))
{
@@ -1288,7 +1127,7 @@ class DB
{
$connection = &$this->slave_db[$indx];
}
-
+
$result = $this->__connect($connection);
if($result === NULL || $result === FALSE)
{
@@ -1301,7 +1140,7 @@ class DB
$connection["is_connected"] = TRUE;
// Save connection info for db logs
- $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"];
+ $this->connection = $type . ' (' . $connection['host'] . ')';
// regist $this->close callback
register_shutdown_function(array($this, "close"));
@@ -1313,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);
@@ -1324,7 +1163,7 @@ class DB
* Finish recording DBClass log
* @return void
*/
- function actDBClassFinish()
+ public function actDBClassFinish()
{
if(!$this->query)
{
@@ -1346,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 aaff4c6c3..9059b99ce 100644
--- a/classes/db/DBCubrid.class.php
+++ b/classes/db/DBCubrid.class.php
@@ -55,15 +55,6 @@ class DBCubrid extends DB
$this->_connect();
}
- /**
- * Create an instance of this class
- * @return DBCubrid return DBCubrid object instance
- */
- function create()
- {
- return new DBCubrid;
- }
-
/**
* DB Connect
* this method is private
@@ -73,7 +64,7 @@ class DBCubrid extends DB
function __connect($connection)
{
// attempts to connect
- $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]);
+ $result = @cubrid_connect($connection['host'], $connection['port'], $connection['database'], $connection['user'], $connection['pass']);
// check connections
if(!$result)
@@ -116,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))
{
/*
@@ -986,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)
{
@@ -1017,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)
@@ -1049,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)
@@ -1092,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())
@@ -1162,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);
@@ -1210,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 7dda69d35..c6d150b8c 100644
--- a/classes/db/DBMssql.class.php
+++ b/classes/db/DBMssql.class.php
@@ -48,15 +48,6 @@ class DBMssql extends DB
$this->_connect();
}
- /**
- * Create an instance of this class
- * @return DBMssql return DBMssql object instance
- */
- function create()
- {
- return new DBMssql;
- }
-
/**
* DB Connect
* this method is private
@@ -68,7 +59,11 @@ class DBMssql extends DB
//sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
//sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
//sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL );
- $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"]));
+ $result = @sqlsrv_connect($connection['host'], array(
+ 'Database' => $connection['database'],
+ 'UID' => $connection['user'],
+ 'PWD' => $connection['pass'],
+ ));
if(!$result)
{
@@ -99,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;
@@ -952,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())
@@ -1033,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 268ce952d..1b5264ed8 100644
--- a/classes/db/DBMysql.class.php
+++ b/classes/db/DBMysql.class.php
@@ -58,13 +58,13 @@ class DBMysql extends DB
function __connect($connection)
{
// Ignore if no DB information exists
- if(strpos($connection["db_hostname"], ':') === false && $connection["db_port"])
+ if(strpos($connection['host'], ':') === false && $connection['port'])
{
- $connection["db_hostname"] .= ':' . $connection["db_port"];
+ $connection['host'] .= ':' . $connection['port'];
}
// Attempt to connect
- $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
+ $result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']);
if(!$result)
{
exit('Unable to connect to DB.');
@@ -79,16 +79,16 @@ class DBMysql extends DB
// Error appears if the version is lower than 4.1.13
if(version_compare(mysql_get_server_info($result), '4.1.13', '<'))
{
- $this->setError(-1, 'RhymiX requires MySQL 4.1.13 or later. Current MySQL version is ' . mysql_get_server_info());
+ $this->setError(-1, 'Rhymix requires MySQL 4.1.13 or later. Current MySQL version is ' . mysql_get_server_info());
return;
}
// Set charset
- $this->charset = isset($connection["db_charset"]) ? $connection["db_charset"] : 'utf8';
+ $this->charset = isset($connection['charset']) ? $connection['charset'] : 'utf8';
mysql_set_charset($this->charset, $result);
// select db
- @mysql_select_db($connection["db_database"], $result);
+ @mysql_select_db($connection['database'], $result);
if(mysql_error())
{
$this->setError(mysql_errno(), mysql_error());
@@ -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 95bfb4d3f..8c425be45 100644
--- a/classes/db/DBMysqli.class.php
+++ b/classes/db/DBMysqli.class.php
@@ -24,20 +24,13 @@ class DBMysqli extends DBMysql
function __connect($connection)
{
// Attempt to connect
- if($connection["db_port"])
+ if($connection['port'])
{
- $result = @mysqli_connect($connection["db_hostname"]
- , $connection["db_userid"]
- , $connection["db_password"]
- , $connection["db_database"]
- , $connection["db_port"]);
+ $result = @mysqli_connect($connection['host'], $connection['user'], $connection['pass'], $connection['database'], $connection['port']);
}
else
{
- $result = @mysqli_connect($connection["db_hostname"]
- , $connection["db_userid"]
- , $connection["db_password"]
- , $connection["db_database"]);
+ $result = @mysqli_connect($connection['host'], $connection['user'], $connection['pass'], $connection['database']);
}
$error = mysqli_connect_errno();
if($error)
@@ -45,7 +38,7 @@ class DBMysqli extends DBMysql
$this->setError($error, mysqli_connect_error());
return;
}
- $this->charset = isset($connection["db_charset"]) ? $connection["db_charset"] : 'utf8';
+ $this->charset = isset($connection['charset']) ? $connection['charset'] : 'utf8';
mysqli_set_charset($result, $this->charset);
return $result;
}
@@ -68,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');
@@ -89,6 +78,11 @@ class DBMysqli extends DBMysql
*/
function __query($query, $connection)
{
+ if ($connection === null)
+ {
+ debug_print_backtrace();
+ exit;
+ }
if($this->use_prepared_statements == 'Y')
{
// 1. Prepare query
diff --git a/classes/db/queryparts/table/CubridTableWithHint.class.php b/classes/db/queryparts/table/CubridTableWithHint.class.php
index a8b1e1640..9f614a816 100644
--- a/classes/db/queryparts/table/CubridTableWithHint.class.php
+++ b/classes/db/queryparts/table/CubridTableWithHint.class.php
@@ -49,8 +49,7 @@ class CubridTableWithHint extends Table
$result = '';
// Retrieve table prefix, to add it to index name
- $db_info = Context::getDBInfo();
- $prefix = $db_info->master_db["db_table_prefix"];
+ $prefix = config('db.master.prefix');
foreach($this->index_hints_list as $index_hint)
{
diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php
index 15a71f809..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; // / gzhandler_enable
- )
+ if(config('view.use_gzip') && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && extension_loaded('zlib') && $oModule->gzhandler_enable)
{
$this->gz_enabled = TRUE;
}
@@ -65,12 +60,17 @@ class DisplayHandler extends Handler
// call a trigger before display
ModuleHandler::triggerCall('display', 'before', $output);
-
+ $original_output = $output;
+
// execute add-on
$called_position = 'before_display_content';
$oAddonController = getController('addon');
$addon_file = $oAddonController->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"))
{
@@ -78,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)
{
@@ -107,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;
@@ -119,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, '
-
-