/**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && function_exists('ob_gzhandler') && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         require_once _XE_PATH_ . "classes/display/VirtualXMLDisplayHandler.php";
         $handler = new VirtualXMLDisplayHandler();
     } else {
         if (Context::getRequestMethod() == 'XMLRPC') {
             require_once _XE_PATH_ . "classes/display/XMLDisplayHandler.php";
             $handler = new XMLDisplayHandler();
             if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
                 $this->gz_enabled = FALSE;
             }
         } else {
             if (Context::getRequestMethod() == 'JSON') {
                 require_once _XE_PATH_ . "classes/display/JSONDisplayHandler.php";
                 $handler = new JSONDisplayHandler();
             } else {
                 if (Context::getRequestMethod() == 'JS_CALLBACK') {
                     require_once _XE_PATH_ . "classes/display/JSCallbackDisplayHandler.php";
                     $handler = new JSCallbackDisplayHandler();
                 } else {
                     require_once _XE_PATH_ . "classes/display/HTMLDisplayHandler.php";
                     $handler = new HTMLDisplayHandler();
                 }
             }
         }
     }
     $output = $handler->toDoc($oModule);
     // call a trigger before display
     ModuleHandler::triggerCall('display', 'before', $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 (method_exists($handler, "prepareToPrint")) {
         $handler->prepareToPrint($output);
     }
     // header output
     if ($this->gz_enabled) {
         header("Content-Encoding: gzip");
     }
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode && $httpStatusCode != 200) {
         $this->_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             $this->_printJSONHeader();
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 $this->_printXMLHeader();
             } else {
                 $this->_printHTMLHeader();
             }
         }
     }
     // debugOutput output
     $this->content_size = strlen($output);
     $output .= $this->_debugOutput();
     // results directly output
     if ($this->gz_enabled) {
         print ob_gzhandler($output, 5);
     } else {
         print $output;
     }
     // call a trigger after display
     ModuleHandler::triggerCall('display', 'after', $output);
 }
 function _getTemplate()
 {
     $oNcenterModel = getModel('ncenterlite');
     $config = $oNcenterModel->getConfig();
     $oTemplateHandler = TemplateHandler::getInstance();
     $result = '';
     if (Mobile::isFromMobilePhone()) {
         $path = sprintf('%sm.skins/%s/', $this->module_path, $config->mskin);
     } else {
         $path = sprintf('%sskins/%s/', $this->module_path, $config->skin);
     }
     $result = $oTemplateHandler->compile($path, 'ncenterlite.html');
     return $result;
 }
        /**
         * action forward apply layout
         **/
        public function triggerApplyLayout(&$oModule) {
            if(!$oModule || $oModule->getLayoutFile()=='popup_layout.html') return new Object();

            if(Context::get('module')=='admin') return new Object();

            if(in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) return new Object();

            if($oModule->act == 'dispMemberLogout') return new Object();

            $site_module_info = Context::get('site_module_info');
            if(!$site_module_info || !$site_module_info->site_srl || $site_module_info->mid != $this->shop_mid) return new Object();

            $oModuleModel = getModel('module');
            $xml_info = $oModuleModel->getModuleActionXml('shop');
            if($oModule->mid == $this->shop_mid && isset($xml_info->action->{$oModule->act})) return new Object();

            $oShopView = getView('shop');

            Context::set('layout',NULL);

            // When shop pages are accessed from other modules (a page, for instance)
            // Load the appropriate layout:
            //  - tool: backend
            //  - service: frontend
            if(strpos($oModule->act, "ShopTool") !== FALSE || in_array($oModule->act, array('dispMenuAdminSiteMap'))) {
                $oShopView->initTool($oModule, TRUE);
            } else {
                if(Mobile::isFromMobilePhone())
                {
                    $oShopView = &getMobile('shop');
                }
                $oShopView->initService($oModule, TRUE);
            }

            return new Object();
        }
 function triggerBeforeDisplay(&$output)
 {
     if (Context::getResponseMethod() == 'HTML') {
         $mid = Context::get('mid');
         if ($mid) {
             $oAjaxboardModel = getModel('ajaxboard');
             $plugins_info = $oAjaxboardModel->getPluginsInfoByMid($mid, Mobile::isFromMobilePhone());
             if (count($plugins_info)) {
                 $module_config = $oAjaxboardModel->getConfig();
                 if ($module_config->type == 1) {
                     Context::loadFile($this->module_path . 'tpl/js/libs/socket.io.js', 'head');
                 }
                 Context::loadFile($this->module_path . 'tpl/js/libs/eventsource.js', 'head');
                 Context::loadFile($this->module_path . 'tpl/js/client.js', 'head');
                 $oTemplate = TemplateHandler::getInstance();
                 Context::set('waiting_message', $module_config->waiting_message);
                 Context::set('module_config', $oAjaxboardModel->getTemplateConfig());
                 $compile = $oTemplate->compile($this->module_path . 'tpl', 'templateConfig');
                 $output .= $compile;
                 $logged_info = Context::get('logged_info');
                 $user_info = $oAjaxboardModel->getFilterUserInfo($logged_info->member_srl);
                 Context::set('user_info', $user_info);
                 foreach ($plugins_info as $plugin_info) {
                     Context::set('plugin_info', $plugin_info);
                     $plugin_name = $plugin_info->plugin_name;
                     $plugin_path = $this->module_path . 'plugins/' . $plugin_name;
                     $compile = $oTemplate->compile($plugin_path, 'plugin');
                     $output .= $compile;
                 }
             }
         }
     }
     return new Object();
 }
Example #5
0
 /**
  * excute the member method specified by $act variable
  * @return boolean true : success false : fail 
  **/
 function proc()
 {
     // pass if stop_proc is true
     if ($this->stop_proc) {
         return false;
     }
     // trigger call
     $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
     if (!$triggerOutput->toBool()) {
         $this->setError($triggerOutput->getError());
         $this->setMessage($triggerOutput->getMessage());
         return false;
     }
     // execute an addon(call called_position as before_module_proc)
     $called_position = 'before_module_proc';
     $oAddonController =& getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     @(include $addon_file);
     if (isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
         // Check permissions
         if ($this->module_srl && !$this->grant->access) {
             $this->stop("msg_not_permitted_act");
             return FALSE;
         }
         // integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
         $oModuleModel =& getModel('module');
         $oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
         Context::set('module_info', $this->module_info);
         // Run
         $output = $this->{$this->act}();
     } else {
         return false;
     }
     // trigger call
     $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
     if (!$triggerOutput->toBool()) {
         $this->setError($triggerOutput->getError());
         $this->setMessage($triggerOutput->getMessage());
         return false;
     }
     // execute an addon(call called_position as after_module_proc)
     $called_position = 'after_module_proc';
     $oAddonController =& getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     @(include $addon_file);
     if (is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
         $this->setError($output->getError());
         $this->setMessage($output->getMessage());
         if (!$output->toBool()) {
             return false;
         }
     }
     // execute api methos of the module if view action is and result is XMLRPC or JSON
     if ($this->module_info->module_type == 'view') {
         if (Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
             $oAPI = getAPI($this->module_info->module, 'api');
             if (method_exists($oAPI, $this->act)) {
                 $oAPI->{$this->act}($this);
             }
         }
     }
     return true;
 }
 /**
  * Enter comments
  * @param object $obj
  * @param bool $manual_inserted
  * @return object
  */
 function insertComment($obj, $manual_inserted = FALSE)
 {
     if (!$manual_inserted && !checkCSRF()) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!is_object($obj)) {
         $obj = new stdClass();
     }
     // check if comment's module is using comment validation and set the publish status to 0 (false)
     // for inserting query, otherwise default is 1 (true - means comment is published)
     $using_validation = $this->isModuleUsingPublishValidation($obj->module_srl);
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         if ($logged_info->is_admin == 'Y') {
             $is_admin = TRUE;
         } else {
             $is_admin = FALSE;
         }
     }
     if (!$using_validation) {
         $obj->status = 1;
     } else {
         if ($is_admin) {
             $obj->status = 1;
         } else {
             $obj->status = 0;
         }
     }
     $obj->__isupdate = FALSE;
     // call a trigger (before)
     $output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // check if a posting of the corresponding document_srl exists
     $document_srl = $obj->document_srl;
     if (!$document_srl) {
         return new Object(-1, 'msg_invalid_document');
     }
     // get a object of document model
     $oDocumentModel = getModel('document');
     // even for manual_inserted if password exists, md5 it.
     if ($obj->password) {
         $obj->password = md5($obj->password);
     }
     // get the original posting
     if (!$manual_inserted) {
         $oDocument = $oDocumentModel->getDocument($document_srl);
         if ($document_srl != $oDocument->document_srl) {
             return new Object(-1, 'msg_invalid_document');
         }
         if ($oDocument->isLocked()) {
             return new Object(-1, 'msg_invalid_request');
         }
         if ($obj->homepage) {
             $obj->homepage = removeHackTag($obj->homepage);
             if (!preg_match('/^[a-z]+:\\/\\//i', $obj->homepage)) {
                 $obj->homepage = 'http://' . $obj->homepage;
             }
         }
         // input the member's information if logged-in
         if (Context::get('is_logged')) {
             $logged_info = Context::get('logged_info');
             $obj->member_srl = $logged_info->member_srl;
             // user_id, user_name and nick_name already encoded
             $obj->user_id = htmlspecialchars_decode($logged_info->user_id);
             $obj->user_name = htmlspecialchars_decode($logged_info->user_name);
             $obj->nick_name = htmlspecialchars_decode($logged_info->nick_name);
             $obj->email_address = $logged_info->email_address;
             $obj->homepage = $logged_info->homepage;
         }
     }
     // error display if neither of log-in info and user name exist.
     if (!$logged_info->member_srl && !$obj->nick_name) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!$obj->comment_srl) {
         $obj->comment_srl = getNextSequence();
     } elseif (!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) {
         return new Object(-1, 'msg_not_permitted');
     }
     // determine the order
     $obj->list_order = getNextSequence() * -1;
     // remove XE's own tags from the contents
     $obj->content = preg_replace('!<\\!--(Before|After)(Document|Comment)\\(([0-9]+),([0-9]+)\\)-->!is', '', $obj->content);
     if (Mobile::isFromMobilePhone()) {
         if ($obj->use_html != 'Y') {
             $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
         }
         $obj->content = nl2br($obj->content);
     }
     if (!$obj->regdate) {
         $obj->regdate = date("YmdHis");
     }
     // remove iframe and script if not a top administrator on the session.
     if ($logged_info->is_admin != 'Y') {
         $obj->content = removeHackTag($obj->content);
     }
     if (!$obj->notify_message) {
         $obj->notify_message = 'N';
     }
     if (!$obj->is_secret) {
         $obj->is_secret = 'N';
     }
     // begin transaction
     $oDB = DB::getInstance();
     $oDB->begin();
     // Enter a list of comments first
     $list_args = new stdClass();
     $list_args->comment_srl = $obj->comment_srl;
     $list_args->document_srl = $obj->document_srl;
     $list_args->module_srl = $obj->module_srl;
     $list_args->regdate = $obj->regdate;
     // If parent comment doesn't exist, set data directly
     if (!$obj->parent_srl) {
         $list_args->head = $list_args->arrange = $obj->comment_srl;
         $list_args->depth = 0;
         // If parent comment exists, get information of the parent comment
     } else {
         // get information of the parent comment posting
         $parent_args = new stdClass();
         $parent_args->comment_srl = $obj->parent_srl;
         $parent_output = executeQuery('comment.getCommentListItem', $parent_args);
         // return if no parent comment exists
         if (!$parent_output->toBool() || !$parent_output->data) {
             return;
         }
         $parent = $parent_output->data;
         $list_args->head = $parent->head;
         $list_args->depth = $parent->depth + 1;
         // if the depth of comments is less than 2, execute insert.
         if ($list_args->depth < 2) {
             $list_args->arrange = $obj->comment_srl;
             // if the depth of comments is greater than 2, execute update.
         } else {
             // get the top listed comment among those in lower depth and same head with parent's.
             $p_args = new stdClass();
             $p_args->head = $parent->head;
             $p_args->arrange = $parent->arrange;
             $p_args->depth = $parent->depth;
             $output = executeQuery('comment.getCommentParentNextSibling', $p_args);
             if ($output->data->arrange) {
                 $list_args->arrange = $output->data->arrange;
                 $output = executeQuery('comment.updateCommentListArrange', $list_args);
             } else {
                 $list_args->arrange = $obj->comment_srl;
             }
         }
     }
     $output = executeQuery('comment.insertCommentList', $list_args);
     if (!$output->toBool()) {
         return $output;
     }
     // insert comment
     $output = executeQuery('comment.insertComment', $obj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // creat the comment model object
     $oCommentModel = getModel('comment');
     // get the number of all comments in the posting
     $comment_count = $oCommentModel->getCommentCount($document_srl);
     // create the controller object of the document
     $oDocumentController = getController('document');
     // Update the number of comments in the post
     if (!$using_validation) {
         $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
     } else {
         if ($is_admin) {
             $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
         }
     }
     // grant autority of the comment
     $this->addGrant($obj->comment_srl);
     // call a trigger(after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     if (!$manual_inserted) {
         // send a message if notify_message option in enabled in the original article
         $oDocument->notify(Context::getLang('comment'), $obj->content);
         // send a message if notify_message option in enabled in the original comment
         if ($obj->parent_srl) {
             $oParent = $oCommentModel->getComment($obj->parent_srl);
             if ($oParent->get('member_srl') != $oDocument->get('member_srl')) {
                 $oParent->notify(Context::getLang('comment'), $obj->content);
             }
         }
     }
     $this->sendEmailToAdminAfterInsertComment($obj);
     $output->add('comment_srl', $obj->comment_srl);
     return $output;
 }
Example #7
0
 function getAjaxboardWholeVariables()
 {
     $mid = Context::get('mid');
     $document_srl = Context::get('document_srl');
     $logged_info = Context::get('logged_info');
     $module_config = $this->getConfig();
     $module_info = $this->getLinkedModuleInfoByMid($mid);
     if (!$module_info) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oModuleModel = getModel('module');
     $origin_module_info = $oModuleModel->getModuleInfoByMid($mid);
     $lang = new stdClass();
     $lang->msg_delete_comment = Context::getLang('msg_delete_comment');
     $lang->msg_password_required = Context::getLang('msg_password_required');
     $result = new stdClass();
     $result->lang = $lang;
     $result->module_path = $this->module_path;
     $result->module_srl = $module_info->module_srl;
     $result->member_srl = $logged_info->member_srl;
     $result->document_srl = $document_srl;
     $result->notify_list = array_fill_keys(explode('|@|', $module_info->notify_list), true);
     $result->use_wfsr = $module_info->use_wfsr;
     $result->timeout = $module_config->timeout;
     $result->token = $module_config->token;
     $result->server_url = $module_config->server_url;
     if (Mobile::isFromMobilePhone() && $origin_module_info->use_mobile == 'Y') {
         if ($module_info->use_module_mobile == 'Y') {
             $result->skin_info = $this->arrangeSkinVars($this->getMobileSkinVars($module_info->module_srl));
         }
     } else {
         if ($module_info->use_module_pc == 'Y') {
             $result->skin_info = $this->arrangeSkinVars($this->getSkinVars($module_info->module_srl));
         }
     }
     $this->adds($result);
 }
 function procSocialxeInsertComment()
 {
     $oCommentController =& getController('comment');
     // 로그인 상태인지 확인
     if (count($this->providerManager->getLoggedProviderList()) == 0) {
         return $this->stop('msg_not_logged');
     }
     $args->document_srl = Context::get('document_srl');
     // 해당 문서의 댓글이 닫혀있는지 확인
     $oDocumentModel =& getModel('document');
     $oDocument = $oDocumentModel->getDocument($args->document_srl);
     if (!$oDocument->allowComment()) {
         return new Object(-1, 'msg_invalid_request');
     }
     // 데이터를 준비
     $args->parent_srl = Context::get('comment_srl');
     $args->content = trim(Context::get('content'));
     $args->nick_name = $this->providerManager->getMasterProviderNickName();
     $args->content_link = Context::get('content_link');
     $args->content_title = Context::get('content_title');
     // 1.5이상이 아니거나 모바일 클래스가 없다면, 줄 바꿈과 특수 문자 변환 실행. - XE Core에서 모바일이면 처리를 해버린다.  1.5 이하에서도 이런 현상이 있는지 몰라서 1.5 이하는 예전처럼 처리
     if (!Mobile::isFromMobilePhone() || !defined('__XE__')) {
         $args->content = nl2br(htmlspecialchars($args->content));
     }
     // 해당 문서가 비밀글인지 확인
     if ($oDocument->isSecret()) {
         $args->is_secret = 'Y';
     }
     // 댓글의 moduel_srl
     $oModuleModel =& getModel('module');
     $module_info = $oModuleModel->getModuleInfoByDocumentSrl($args->document_srl);
     $args->module_srl = $module_info->module_srl;
     // 댓글 삽입
     // XE가 대표 계정이면 XE 회원 정보를 이용하여 댓글을 등록
     if ($this->providerManager->getMasterProvider() == 'xe') {
         $manual_inserted = false;
         // 부계정이 없으면 알림 설정
         if (!$this->providerManager->getSlaveProvider()) {
             $args->notify_message = 'Y';
         }
     } else {
         $manual_inserted = true;
         $args->email_address = '';
         $args->homepage = '';
     }
     $result = $oCommentController->insertComment($args, $manual_inserted);
     if (!$result->toBool()) {
         return $result;
     }
     // 삽입된 댓글의 번호
     $comment_srl = $result->get('comment_srl');
     // 텍스타일이면 지지자 처리
     if ($module_info->module == 'textyle') {
         $oCommentModel =& getModel('comment');
         $oComment = $oCommentModel->getComment($comment_srl);
         $obj->module_srl = $module_info->module_srl;
         $obj->nick_name = $oComment->get('nick_name');
         $obj->member_srl = $oComment->get('member_srl');
         $obj->homepage = $oComment->get('homepage');
         $obj->comment_count = 1;
         $oTextyleController =& getController('textyle');
         $oTextyleController->updateTextyleSupporter($obj);
     }
     // 태그 제거 htmlspecialchars 복원
     $args->content = $this->htmlEntityDecode(strip_tags($args->content));
     // 소셜 서비스로 댓글 전송
     $output = $this->sendSocialComment($args, $comment_srl, $msg);
     if (!$output->toBool()) {
         $oCommentController->deleteComment($comment_srl);
         return $output;
     }
     // 위젯에서 화면 갱신에 사용할 정보 세팅
     $this->add('skin', Context::get('skin'));
     $this->add('document_srl', Context::get('document_srl'));
     $this->add('comment_srl', Context::get('comment_srl'));
     $this->add('list_count', Context::get('list_count'));
     $this->add('content_link', Context::get('content_link'));
     $this->add('msg', $msg);
 }
 /**
  * @brief action forward apply layout
  **/
 function triggerApplyLayout(&$oModule)
 {
     if (!$oModule || $oModule->getLayoutFile() == 'popup_layout.html') {
         return new Object();
     }
     if (Context::get('module') == 'admin') {
         return new Object();
     }
     if (in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         return new Object();
     }
     if ($oModule->act == 'dispMemberLogout') {
         return new Object();
     }
     $site_module_info = Context::get('site_module_info');
     if (!$site_module_info || !$site_module_info->site_srl || $site_module_info->mid != $this->textyle_mid) {
         return new Object();
     }
     $oModuleModel =& getModel('module');
     $xml_info = $oModuleModel->getModuleActionXml('textyle');
     if ($oModule->mid == $this->textyle_mid && isset($xml_info->action->{$oModule->act})) {
         return new Object();
     }
     $oTextyleModel =& getModel('textyle');
     $oTextyleView =& getView('textyle');
     Context::set('layout', null);
     if ($oTextyleModel->isAttachedMenu($oModule->act)) {
         $oTextyleView->initTool($oModule, true);
     } else {
         if (Mobile::isFromMobilePhone()) {
             $oTextyleView =& getMobile('textyle');
         }
         $oTextyleView->initService($oModule, true);
     }
     return new Object();
 }
 /**
  * display contents from executed module
  * @param ModuleObject $oModule module instance
  * @return void
  * */
 function displayContent($oModule = NULL)
 {
     // If the module is not set or not an object, set error
     if (!$oModule || !is_object($oModule)) {
         $this->error = 'msg_module_is_not_exists';
         $this->httpStatusCode = '404';
     }
     // If connection to DB has a problem even though it's not install module, set error
     if ($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE) {
         $this->error = 'msg_dbconnect_failed';
     }
     // Call trigger after moduleHandler proc
     $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
     if (!$output->toBool()) {
         $this->error = $output->getMessage();
     }
     // Use message view object, if HTML call
     $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
     if (!isset($methodList[Context::getRequestMethod()])) {
         if ($_SESSION['XE_VALIDATOR_RETURN_URL']) {
             $display_handler = new DisplayHandler();
             $display_handler->_debugOutput();
             header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
             return;
         }
         // If error occurred, handle it
         if ($this->error) {
             // display content with message module instance
             $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
             $oMessageObject = ModuleHandler::getModuleInstance('message', $type);
             $oMessageObject->setError(-1);
             $oMessageObject->setMessage($this->error);
             $oMessageObject->dispMessage();
             if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') {
                 $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
                 $oMessageObject->setTemplateFile('http_status_code');
             }
             // If module was called normally, change the templates of the module into ones of the message view module
             if ($oModule) {
                 $oModule->setTemplatePath($oMessageObject->getTemplatePath());
                 $oModule->setTemplateFile($oMessageObject->getTemplateFile());
                 // Otherwise, set message instance as the target module
             } else {
                 $oModule = $oMessageObject;
             }
             $this->_clearErrorSession();
         }
         // Check if layout_srl exists for the module
         if (Mobile::isFromMobilePhone()) {
             $layout_srl = $oModule->module_info->mlayout_srl;
         } else {
             $layout_srl = $oModule->module_info->layout_srl;
         }
         // if layout_srl is rollback by module, set default layout
         if ($layout_srl == -1) {
             $viewType = Mobile::isFromMobilePhone() ? 'M' : 'P';
             $oLayoutAdminModel = getAdminModel('layout');
             $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
         }
         if ($layout_srl && !$oModule->getLayoutFile()) {
             // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
             $oLayoutModel = getModel('layout');
             $layout_info = $oLayoutModel->getLayout($layout_srl);
             if ($layout_info) {
                 // Input extra_vars into $layout_info
                 if ($layout_info->extra_var_count) {
                     foreach ($layout_info->extra_var as $var_id => $val) {
                         if ($val->type == 'image') {
                             if (strncmp('./files/attach/images/', $val->value, 22) === 0) {
                                 $val->value = Context::getRequestUri() . substr($val->value, 2);
                             }
                         }
                         $layout_info->{$var_id} = $val->value;
                     }
                 }
                 // Set menus into context
                 if ($layout_info->menu_count) {
                     foreach ($layout_info->menu as $menu_id => $menu) {
                         // set default menu set(included home menu)
                         if (!$menu->menu_srl || $menu->menu_srl == -1) {
                             $oMenuAdminController = getAdminController('menu');
                             $homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
                             if (FileHandler::exists($homeMenuCacheFile)) {
                                 include $homeMenuCacheFile;
                             }
                             if (!$menu->menu_srl) {
                                 $menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file);
                                 $menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file);
                                 $layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl;
                             } else {
                                 $menu->xml_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->xml_file);
                                 $menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file);
                             }
                         }
                         $php_file = FileHandler::exists($menu->php_file);
                         if ($php_file) {
                             include $php_file;
                         }
                         Context::set($menu_id, $menu);
                     }
                 }
                 // Set layout information into context
                 Context::set('layout_info', $layout_info);
                 $oModule->setLayoutPath($layout_info->path);
                 $oModule->setLayoutFile('layout');
                 // If layout was modified, use the modified version
                 $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
                 if (file_exists($edited_layout)) {
                     $oModule->setEditedLayoutFile($edited_layout);
                 }
             }
         }
         $isLayoutDrop = Context::get('isLayoutDrop');
         if ($isLayoutDrop) {
             $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
             if ($kind == 'admin') {
                 $oModule->setLayoutFile('popup_layout');
             } else {
                 $oModule->setLayoutPath('common/tpl');
                 $oModule->setLayoutFile('default_layout');
             }
         }
     }
     // Display contents
     $oDisplayHandler = new DisplayHandler();
     $oDisplayHandler->printContent($oModule);
 }
Example #11
0
 /**
  * Update the document
  * @param object $source_obj
  * @param object $obj
  * @param bool $manual_updated
  * @return object
  */
 function updateDocument($source_obj, $obj, $manual_updated = FALSE)
 {
     if (!$manual_updated && !checkCSRF()) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!$source_obj->document_srl || !$obj->document_srl) {
         return new Object(-1, 'msg_invalied_request');
     }
     if (!$obj->status && $obj->is_secret == 'Y') {
         $obj->status = 'SECRET';
     }
     if (!$obj->status) {
         $obj->status = 'PUBLIC';
     }
     // Call a trigger (before)
     $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     $oModuleModel = getModel('module');
     if (!$obj->module_srl) {
         $obj->module_srl = $source_obj->get('module_srl');
     }
     $module_srl = $obj->module_srl;
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
     $document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
     if (!$document_config) {
         $document_config = new stdClass();
     }
     if (!isset($document_config->use_history)) {
         $document_config->use_history = 'N';
     }
     $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
     if ($bUseHistory) {
         $args = new stdClass();
         $args->history_srl = getNextSequence();
         $args->document_srl = $obj->document_srl;
         $args->module_srl = $module_srl;
         if ($document_config->use_history == 'Y') {
             $args->content = $source_obj->get('content');
         }
         $args->nick_name = $source_obj->get('nick_name');
         $args->member_srl = $source_obj->get('member_srl');
         $args->regdate = $source_obj->get('last_update');
         $args->ipaddress = $source_obj->get('ipaddress');
         $output = executeQuery("document.insertHistory", $args);
     } else {
         $obj->ipaddress = $source_obj->get('ipaddress');
     }
     // List variables
     if ($obj->comment_status) {
         $obj->commentStatus = $obj->comment_status;
     }
     if (!$obj->commentStatus) {
         $obj->commentStatus = 'DENY';
     }
     if ($obj->commentStatus == 'DENY') {
         $this->_checkCommentStatusForOldVersion($obj);
     }
     if ($obj->allow_trackback != 'Y') {
         $obj->allow_trackback = 'N';
     }
     if ($obj->homepage) {
         $obj->homepage = removeHackTag($obj->homepage);
         if (!preg_match('/^[a-z]+:\\/\\//i', $obj->homepage)) {
             $obj->homepage = 'http://' . $obj->homepage;
         }
     }
     if ($obj->notify_message != 'Y') {
         $obj->notify_message = 'N';
     }
     // can modify regdate only manager
     $grant = Context::get('grant');
     if (!$grant->manager) {
         unset($obj->regdate);
     }
     // Serialize the $extra_vars
     if (!is_string($obj->extra_vars)) {
         $obj->extra_vars = serialize($obj->extra_vars);
     }
     // Remove the columns for automatic saving
     unset($obj->_saved_doc_srl);
     unset($obj->_saved_doc_title);
     unset($obj->_saved_doc_content);
     unset($obj->_saved_doc_message);
     $oDocumentModel = getModel('document');
     // Set the category_srl to 0 if the changed category is not exsiting.
     if ($source_obj->get('category_srl') != $obj->category_srl) {
         $category_list = $oDocumentModel->getCategoryList($obj->module_srl);
         if (!$category_list[$obj->category_srl]) {
             $obj->category_srl = 0;
         }
     }
     // Change the update order
     $obj->update_order = getNextSequence() * -1;
     // Hash the password if it exists
     if ($obj->password) {
         $obj->password = getModel('member')->hashPassword($obj->password);
     }
     // If an author is identical to the modifier or history is used, use the logged-in user's information.
     $logged_info = Context::get('logged_info');
     if (Context::get('is_logged') && !$manual_updated && $module_info->use_anonymous != 'Y') {
         if ($source_obj->get('member_srl') == $logged_info->member_srl) {
             $obj->member_srl = $logged_info->member_srl;
             $obj->user_name = htmlspecialchars_decode($logged_info->user_name);
             $obj->nick_name = htmlspecialchars_decode($logged_info->nick_name);
             $obj->email_address = $logged_info->email_address;
             $obj->homepage = $logged_info->homepage;
         }
     }
     // For the document written by logged-in user however no nick_name exists
     if ($source_obj->get('member_srl') && !$obj->nick_name) {
         $obj->member_srl = $source_obj->get('member_srl');
         $obj->user_name = $source_obj->get('user_name');
         $obj->nick_name = $source_obj->get('nick_name');
         $obj->email_address = $source_obj->get('email_address');
         $obj->homepage = $source_obj->get('homepage');
     }
     // If the tile is empty, extract string from the contents.
     $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
     settype($obj->title, "string");
     if ($obj->title == '') {
         $obj->title = cut_str(strip_tags($obj->content), 20, '...');
     }
     // If no tile extracted from the contents, leave it untitled.
     if ($obj->title == '') {
         $obj->title = 'Untitled';
     }
     // Remove XE's own tags from the contents.
     $obj->content = preg_replace('!<\\!--(Before|After)(Document|Comment)\\(([0-9]+),([0-9]+)\\)-->!is', '', $obj->content);
     // if use editor of nohtml, Remove HTML tags from the contents.
     if (!$manual_updated) {
         if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') {
             if ($obj->use_html != 'Y') {
                 $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
             }
             $obj->content = nl2br($obj->content);
         } else {
             $oEditorModel = getModel('editor');
             $editor_config = $oEditorModel->getEditorConfig($obj->module_srl);
             if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== FALSE) {
                 $obj->content = preg_replace('/\\<br(\\s*)?\\/?\\>/i', PHP_EOL, $obj->content);
                 $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
                 $obj->content = str_replace(array("\r\n", "\r", "\n"), '<br />', $obj->content);
             }
         }
     }
     // Change not extra vars but language code of the original document if document's lang_code is different from author's setting.
     if ($source_obj->get('lang_code') != Context::getLangType()) {
         // Change not extra vars but language code of the original document if document's lang_code doesn't exist.
         if (!$source_obj->get('lang_code')) {
             $lang_code_args = new stdClass();
             $lang_code_args->document_srl = $source_obj->get('document_srl');
             $lang_code_args->lang_code = Context::getLangType();
             $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args);
         } else {
             $extra_content = new stdClass();
             $extra_content->title = $obj->title;
             $extra_content->content = $obj->content;
             $document_args = new stdClass();
             $document_args->document_srl = $source_obj->get('document_srl');
             $document_output = executeQuery('document.getDocument', $document_args);
             $obj->title = $document_output->data->title;
             $obj->content = $document_output->data->content;
         }
     }
     // Remove iframe and script if not a top adminisrator in the session.
     if ($logged_info->is_admin != 'Y') {
         $obj->content = removeHackTag($obj->content);
     }
     // if temporary document, regdate is now setting
     if ($source_obj->get('status') == $this->getConfigStatus('temp')) {
         $obj->regdate = date('YmdHis');
     }
     // Fix encoding of non-BMP UTF-8 characters.
     $obj->title = utf8_mbencode($obj->title);
     $obj->content = utf8_mbencode($obj->content);
     // Insert data into the DB
     $output = executeQuery('document.updateDocument', $obj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // Remove all extra variables
     $extra_vars = array();
     if (Context::get('act') != 'procFileDelete') {
         $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType());
         // Insert extra variables if the document successfully inserted.
         $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
         if (count($extra_keys)) {
             foreach ($extra_keys as $idx => $extra_item) {
                 $value = NULL;
                 if (isset($obj->{'extra_vars' . $idx})) {
                     $tmp = $obj->{'extra_vars' . $idx};
                     if (is_array($tmp)) {
                         $value = implode('|@|', $tmp);
                     } else {
                         $value = trim($tmp);
                     }
                 } else {
                     if (isset($obj->{$extra_item->name})) {
                         $value = trim($obj->{$extra_item->name});
                     }
                 }
                 if ($value == NULL) {
                     continue;
                 }
                 $extra_vars[$extra_item->name] = $value;
                 $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
             }
         }
         // Inert extra vars for multi-language support of title and contents.
         if ($extra_content->title) {
             $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_' . Context::getLangType());
         }
         if ($extra_content->content) {
             $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_' . Context::getLangType());
         }
     }
     // Update the category if the category_srl exists.
     if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) {
         if ($source_obj->get('category_srl') != $obj->category_srl) {
             $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
         }
         if ($obj->category_srl) {
             $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
         }
     }
     // Call a trigger (after)
     if ($obj->update_log_setting === 'Y') {
         $obj->extra_vars = serialize($extra_vars);
         if ($this->grant->manager) {
             $obj->is_admin = 'Y';
         }
         $update_output = $this->insertDocumentUpdateLog($obj, $source_obj);
         if (!$update_output->toBool()) {
             $oDB->rollback();
             return $update_output;
         }
     }
     ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
     // commit
     $oDB->commit();
     // Remove the thumbnail file
     FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
     $output->add('document_srl', $obj->document_srl);
     //remove from cache
     Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl);
     return $output;
 }
Example #12
0
 function dispSocialxeLogin()
 {
     // 크롤러면 실행하지 않는다...
     // 소셜XE 서버에 쓸데없는 요청이 들어올까봐...
     if (isCrawler()) {
         Context::close();
         exit;
     }
     // 로그인에 사용되는 세션을 초기화한다.
     // js 사용시 최초에만 초기화하기 위해 js2 파라미터를 검사
     if (!Context::get('js2')) {
         $this->session->clearSession('js');
         $this->session->clearSession('mode');
         $this->session->clearSession('callback_query');
         $this->session->clearSession('widget_skin');
         $this->session->clearSession('info');
     }
     $provider = Context::get('provider');
     // 서비스
     $use_js = Context::get('js');
     // JS 사용 여부
     $widget_skin = Context::get('skin');
     // 위젯의 스킨명
     // 아무 것도 없는 레이아웃 적용
     $template_path = sprintf("%stpl/", $this->module_path);
     $this->setLayoutPath($template_path);
     $this->setLayoutFile("popup_layout");
     if ($provider == 'xe') {
         return $this->stop('msg_invalid_request');
     }
     // JS 사용 여부 확인
     if (($use_js || Context::get('mode') == 'socialLogin') && !Context::get('js2')) {
         // JS 사용 여부를 세션에 저장한다.
         $this->session->setSession('js', $use_js);
         $this->session->setSession('widget_skin', $widget_skin);
         // 로그인 안내 페이지 표시후 진행할 URL
         $url = getUrl('js', '', 'skin', '', 'js2', 1);
         Context::set('url', $url);
         // 로그인 안내 페이지 표시
         // 모바일 모드가 아닐때도 모바일 페이지가 정상적으로 표시되도록.
         if (class_exists('Mobile')) {
             if (!Mobile::isFromMobilePhone()) {
                 Context::addHtmlHeader('<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=yes, target-densitydpi=medium-dpi" />');
             }
         }
         // jQuery 압축 버전에 로드되는 1.5 이상에서는 min을 항상 로드(모바일 버전 때문)
         if (defined('__XE__')) {
             Context::addJsFile("./common/js/jquery.min.js", true, '', -100000);
         } else {
             Context::addJsFile("./common/js/jquery.js", true, '', -100000);
         }
         $this->setTemplatePath($template_path);
         $this->setTemplateFile('login');
         return;
     }
     $callback_query = Context::get('query');
     // 인증 후 돌아갈 페이지 쿼리
     $this->session->setSession('callback_query', $callback_query);
     $mode = Context::get('mode');
     // 작동 모드
     $this->session->setSession('mode', $mode);
     $mid = Context::get('mid');
     // 소셜 로그인 처리 중인 mid
     $this->session->setSession('mid', $mid);
     $vid = Context::get('vid');
     // 소셜 로그인 처리 중인 vid
     $this->session->setSession('vid', $vid);
     $info = Context::get('info');
     // SocialXE info 위젯 여부
     $this->session->setSession('info', $info);
     // 로그인 시도 중인 서비스는 로그아웃 시킨다.
     $this->providerManager->doLogout($provider);
     $output = $this->communicator->getLoginUrl($provider);
     if (!$output->toBool()) {
         return $output;
     }
     $url = $output->get('url');
     // 리다이렉트
     header('Location: ' . $url);
     Context::close();
     exit;
 }
Example #13
0
 /**
  * @brief Check if logged-in
  */
 function isLogged()
 {
     if ($_SESSION['is_logged']) {
         if (Mobile::isFromMobilePhone()) {
             return true;
         } else {
             if (ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) {
                 return true;
             }
         }
     }
     $_SESSION['is_logged'] = false;
     return false;
 }
Example #14
0
 /**
  * @brief Combine skin information with module information
  */
 function syncSkinInfoToModuleInfo(&$module_info)
 {
     if (!$module_info->module_srl) {
         return;
     }
     $oCacheHandler = CacheHandler::getInstance('object', null, true);
     if (Mobile::isFromMobilePhone()) {
         $skin_vars = $this->getModuleMobileSkinVars($module_info->module_srl);
     } else {
         $skin_vars = $this->getModuleSkinVars($module_info->module_srl);
     }
     if (!$skin_vars) {
         return;
     }
     foreach ($skin_vars as $name => $val) {
         if (isset($module_info->{$name})) {
             continue;
         }
         $module_info->{$name} = $val->value;
     }
 }
 // still no act means error
 if (!$this->act) {
     $this->error = 'msg_module_is_not_exists';
     return;
 }
 // get type, kind
 $type = $xml_info->action->{$this->act}->type;
 $kind = strpos(strtolower($this->act), 'admin') !== false ? 'admin' : '';
 if (!$kind && $this->module == 'admin') {
     $kind = 'admin';
 }
 if ($this->module_info->use_mobile != "Y") {
     Mobile::setMobile(false);
 }
 // if(type == view, and case for using mobilephone)
 if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) {
     $orig_type = "view";
     $type = "mobile";
 }
 //
 // ad-hoc 끝!(ModuleHandler procModule())
 //
 // 텍스타일뷰일 때만 실행...
 if (!($this->module == 'textyle' && ($type == 'view' || $type == 'mobile'))) {
     return;
 }
 // 예약 발행해야할 문서를 구한다.
 $now = date('YmdHis');
 $oTextyleModel =& getModel('textyle');
 $args->module_srl = $this->module_info->module_srl;
 $args->less_publish_date = $now;
Example #16
0
 /**
  * @brief Check if logged-in
  */
 function isLogged()
 {
     if ($_SESSION['is_logged']) {
         if (Mobile::isFromMobilePhone()) {
             return true;
         } elseif (filter_var($_SESSION['ipaddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
             // IPv6: require same /48
             if (strncmp(inet_pton($_SESSION['ipaddress']), inet_pton($_SERVER['REMOTE_ADDR']), 6) == 0) {
                 return true;
             }
         } else {
             // IPv4: require same /24
             if (ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) {
                 return true;
             }
         }
     }
     if (Context::getSessionStatus()) {
         $_SESSION['is_logged'] = false;
     }
     return false;
 }
} elseif ($__Context->listStyle == 'gallery') {
    $__Context->mi->default_style = 'gallery';
} elseif ($__Context->listStyle == 'cloud_gall') {
    $__Context->mi->default_style = 'cloud_gall';
} elseif ($__Context->listStyle == 'guest') {
    $__Context->mi->default_style = 'guest';
} elseif ($__Context->listStyle == 'blog') {
    $__Context->mi->default_style = 'blog';
} elseif ($__Context->listStyle == 'faq') {
    $__Context->mi->default_style = 'faq';
} elseif ($__Context->listStyle == 'viewer') {
    $__Context->mi->default_style = 'viewer';
} elseif (!in_array($__Context->mi->default_style, array('list', 'webzine', 'gallery', 'cloud_gall', 'guest', 'blog', 'faq', 'viewer'))) {
    $__Context->mi->default_style = 'list';
}
if (class_exists(Mobile) && Mobile::isFromMobilePhone()) {
    ?>
<!--#Meta:common/js/jquery.min.js--><?php 
    $__tmp = array('common/js/jquery.min.js', '', '', '-100006');
    Context::loadFile($__tmp);
    unset($__tmp);
    ?>
<!--#Meta:common/js/xe.min.js--><?php 
    $__tmp = array('common/js/xe.min.js', '', '', '-100006');
    Context::loadFile($__tmp);
    unset($__tmp);
    ?>
<!--#Meta:common/js/x.min.js--><?php 
    $__tmp = array('common/js/x.min.js', '', '', '-100006');
    Context::loadFile($__tmp);
    unset($__tmp);
 /**
  * @brief 인증방법에 따른 인증 시작
  */
 function startAuthentication(&$oModule)
 {
     $oAuthenticationModel =& getModel('authentication');
     $oLayoutModel =& getModel('layout');
     $config = $oAuthenticationModel->getModuleConfig();
     $config->agreement = $oAuthenticationModel->_getAgreement();
     Context::set('config', $config);
     // KCB 본인인증일 경우
     if ($config->authentication_type == 'kcb') {
         $layout_info = $oLayoutModel->getLayout($config->layout_srl);
         if ($layout_info) {
             $oModule->setLayoutPath($layout_info->path);
             $oModule->setLayoutFile("layout");
         }
         $result_code = $oAuthenticationModel->getKcbMobileData();
         if ($result_code != '000') {
             $error_message = $oAuthenticationModel->getKcbMobileError($result_code);
             return new Object(-1, $error_message);
         }
         Context::set('next_act', $oModule->act);
         $oModule->setTemplatePath(sprintf($this->module_path . 'skins/%s/', $config->skin));
         $oModule->setTemplateFile('kcb_index');
         return new Object();
     }
     // 기존의 휴대폰 인증일경우
     $oModule->setTemplatePath(sprintf($this->module_path . 'skins/%s/', $config->skin));
     if (Mobile::isFromMobilePhone()) {
         $oModule->setTemplatePath(sprintf($this->module_path . 'm.skins/%s/', $config->mskin));
     }
     if ($config->authcode_time_limit) {
         Context::set('time_limit', $config->authcode_time_limit);
     }
     // 전송지연 현황 보여주기
     $status = $oAuthenticationModel->getDelayStatus();
     if ($status != NULL) {
         $status->sms_sk = $oAuthenticationModel->getDelayStatusString($status->sms_sk_average);
         $status->sms_kt = $oAuthenticationModel->getDelayStatusString($status->sms_kt_average);
         $status->sms_lg = $oAuthenticationModel->getDelayStatusString($status->sms_lg_average);
         Context::set('status', $status);
     }
     Context::set('number_limit', $config->number_limit);
     $oModule->setTemplatePath(sprintf($this->module_path . 'skins/%s/', $config->skin));
     $oModule->setTemplateFile('index');
     return new Object();
 }
Example #19
0
 /**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 public function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (config('view.use_gzip') && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         $handler = new VirtualXMLDisplayHandler();
     } elseif (Context::getRequestMethod() == 'JSON' || isset($_POST['_rx_ajax_compat'])) {
         $handler = new JSONDisplayHandler();
     } elseif (Context::getRequestMethod() == 'JS_CALLBACK') {
         $handler = new JSCallbackDisplayHandler();
     } elseif (Context::getRequestMethod() == 'XMLRPC') {
         $handler = new XMLDisplayHandler();
         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
             $this->gz_enabled = FALSE;
         }
     } else {
         $handler = new HTMLDisplayHandler();
     }
     $output = $handler->toDoc($oModule);
     // 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")) {
         $handler->prepareToPrint($output);
     }
     // Start the session if $_SESSION was touched
     Context::checkSessionStatus();
     // header output
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode !== 200 && !in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON', 'JS_CALLBACK'))) {
         self::_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             if (strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false) {
                 self::_printJSONHeader();
             }
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 self::_printXMLHeader();
             } else {
                 self::_printHTMLHeader();
             }
         }
     }
     // disable gzip if output already exists
     while (ob_get_level()) {
         ob_end_flush();
     }
     if (headers_sent()) {
         $this->gz_enabled = FALSE;
     }
     // enable gzip using zlib extension
     if ($this->gz_enabled) {
         ini_set('zlib.output_compression', true);
     }
     // call a trigger after display
     self::$response_size = $this->content_size = strlen($output);
     ModuleHandler::triggerCall('display', 'after', $output);
     // Output the page content and debug data.
     $debug = $this->getDebugInfo($output);
     print $output;
     print $debug;
 }
Example #20
0
 /**
  * @brief Combine skin information with module information
  **/
 function syncSkinInfoToModuleInfo(&$module_info)
 {
     if (!$module_info->module_srl) {
         return;
     }
     if (Mobile::isFromMobilePhone()) {
         $cache_key = 'object_module_mobile_skin_vars:' . $module_info->module_srl;
         $query = 'module.getModuleMobileSkinVars';
     } else {
         $cache_key = 'object_module_skin_vars:' . $module_info->module_srl;
         $query = 'module.getModuleSkinVars';
     }
     // cache controll
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $output = $oCacheHandler->get($cache_key);
     }
     if (!$output) {
         $args->module_srl = $module_info->module_srl;
         $output = executeQueryArray($query, $args);
         //insert in cache
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $output);
         }
     }
     if (!$output->toBool() || !$output->data) {
         return;
     }
     foreach ($output->data as $val) {
         if (isset($module_info->{$val->name})) {
             continue;
         }
         $module_info->{$val->name} = $val->value;
     }
 }
Example #21
0
 /**
  * when display mode is HTML, prepare code before print.
  * @param string $output compiled template string
  * @return void
  */
 function prepareToPrint(&$output)
 {
     if (Context::getResponseMethod() != 'HTML') {
         return;
     }
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // move <style ..></style> in body to the header
     $output = preg_replace_callback('!<style(.*?)>(.*?)<\\/style>!is', array($this, '_moveStyleToHeader'), $output);
     // move <link ..></link> in body to the header
     $output = preg_replace_callback('!<link(.*?)/>!is', array($this, '_moveLinkToHeader'), $output);
     // move <meta ../> in body to the header
     $output = preg_replace_callback('!<meta(.*?)(?:\\/|)>!is', array($this, '_moveMetaToHeader'), $output);
     // change a meta fine(widget often put the tag like <!--Meta:path--> to the content because of caching)
     $output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\\_\\-\\/\\.\\@]+)-->/is', array($this, '_transMeta'), $output);
     // handles a relative path generated by using the rewrite module
     if (Context::isAllowRewrite()) {
         $url = parse_url(Context::getRequestUri());
         $real_path = $url['path'];
         $pattern = '/src=("|\'){1}(\\.\\/)?(files\\/attach|files\\/cache|files\\/faceOff|files\\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\\/([^"\']+)\\.(jpg|jpeg|png|gif)("|\'){1}/s';
         $output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output);
         $pattern = '/href=("|\'){1}(\\?[^"\']+)/s';
         $output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output);
         if (Context::get('vid')) {
             $pattern = '/\\/' . Context::get('vid') . '\\?([^=]+)=/is';
             $output = preg_replace($pattern, '/?$1=', $output);
         }
     }
     // prevent the 2nd request due to url(none) of the background-image
     $output = preg_replace('/url\\((["\']?)none(["\']?)\\)/is', 'none', $output);
     if (is_array(Context::get('INPUT_ERROR'))) {
         $INPUT_ERROR = Context::get('INPUT_ERROR');
         $keys = array_keys($INPUT_ERROR);
         $keys = '(' . implode('|', $keys) . ')';
         $output = preg_replace_callback('@(<input)([^>]*?)\\sname="' . $keys . '"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output);
         $output = preg_replace_callback('@<select[^>]*\\sname="' . $keys . '".+</select>@isU', array(&$this, '_preserveSelectValue'), $output);
         $output = preg_replace_callback('@<textarea[^>]*\\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__trans_content_elapsed__'] = getMicroTime() - $start;
     }
     // Remove unnecessary information
     $output = preg_replace('/member\\_\\-([0-9]+)/s', 'member_0', $output);
     // set icon
     $oAdminModel = getAdminModel('admin');
     $favicon_url = $oAdminModel->getFaviconUrl();
     $mobicon_url = $oAdminModel->getMobileIconUrl();
     Context::set('favicon_url', $favicon_url);
     Context::set('mobicon_url', $mobicon_url);
     // convert the final layout
     Context::set('content', $output);
     $oTemplate = TemplateHandler::getInstance();
     if (Mobile::isFromMobilePhone()) {
         $this->_loadMobileJSCSS();
         $output = $oTemplate->compile('./common/tpl', 'mobile_layout');
     } else {
         $this->_loadJSCSS();
         $output = $oTemplate->compile('./common/tpl', 'common_layout');
     }
     // replace the user-defined-language
     $oModuleController = getController('module');
     $oModuleController->replaceDefinedLangCode($output);
 }
Example #22
0
 /**
  * Fix the comment
  * @param object $obj
  * @param bool $is_admin
  * @param bool $manual_updated
  * @return object
  */
 function updateComment($obj, $is_admin = FALSE, $manual_updated = FALSE)
 {
     if (!$manual_updated && !checkCSRF()) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!is_object($obj)) {
         $obj = new stdClass();
     }
     $obj->__isupdate = TRUE;
     // call a trigger (before)
     $output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // create a comment model object
     $oCommentModel = getModel('comment');
     // get the original data
     $source_obj = $oCommentModel->getComment($obj->comment_srl);
     if (!$source_obj->getMemberSrl()) {
         $obj->member_srl = $source_obj->get('member_srl');
         $obj->user_name = $source_obj->get('user_name');
         $obj->nick_name = $source_obj->get('nick_name');
         $obj->email_address = $source_obj->get('email_address');
         $obj->homepage = $source_obj->get('homepage');
     }
     // check if permission is granted
     if (!$is_admin && !$source_obj->isGranted()) {
         return new Object(-1, 'msg_not_permitted');
     }
     if ($obj->password) {
         $obj->password = getModel('member')->hashPassword($obj->password);
     }
     if ($obj->homepage) {
         $obj->homepage = removeHackTag($obj->homepage);
         if (!preg_match('/^[a-z]+:\\/\\//i', $obj->homepage)) {
             $obj->homepage = 'http://' . $obj->homepage;
         }
     }
     // set modifier's information if logged-in and posting author and modifier are matched.
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         if ($source_obj->member_srl == $logged_info->member_srl) {
             $obj->member_srl = $logged_info->member_srl;
             $obj->user_name = $logged_info->user_name;
             $obj->nick_name = $logged_info->nick_name;
             $obj->email_address = $logged_info->email_address;
             $obj->homepage = $logged_info->homepage;
         }
     }
     // if nick_name of the logged-in author doesn't exist
     if ($source_obj->get('member_srl') && !$obj->nick_name) {
         $obj->member_srl = $source_obj->get('member_srl');
         $obj->user_name = $source_obj->get('user_name');
         $obj->nick_name = $source_obj->get('nick_name');
         $obj->email_address = $source_obj->get('email_address');
         $obj->homepage = $source_obj->get('homepage');
     }
     if (!$obj->content) {
         $obj->content = $source_obj->get('content');
     }
     // remove XE's wn tags from contents
     $obj->content = preg_replace('!<\\!--(Before|After)(Document|Comment)\\(([0-9]+),([0-9]+)\\)-->!is', '', $obj->content);
     if (Mobile::isFromMobilePhone()) {
         if ($obj->use_html != 'Y') {
             $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
         }
         $obj->content = nl2br($obj->content);
     }
     // remove iframe and script if not a top administrator on the session
     if ($logged_info->is_admin != 'Y') {
         $obj->content = removeHackTag($obj->content);
     }
     // begin transaction
     $oDB = DB::getInstance();
     $oDB->begin();
     // Update
     $output = executeQuery('comment.updateComment', $obj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // call a trigger (after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     $output->add('comment_srl', $obj->comment_srl);
     return $output;
 }
 /**
  * @brief Enter comments
  **/
 function insertReview($obj, $manual_inserted = false)
 {
     $obj->__isupdate = false;
     // call a trigger (before)
     $output = ModuleHandler::triggerCall('store_review.insertReview', 'before', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // check if a posting of the corresponding item_srl exists
     $item_srl = $obj->item_srl;
     if (!$item_srl) {
         return new Object(-1, 'msg_invalid_item');
     }
     // even for manual_inserted if password exists, md5 it.
     if ($obj->password) {
         $obj->password = md5($obj->password);
     }
     // get the original posting
     if (!$manual_inserted) {
         if ($obj->homepage && !preg_match('/^[a-z]+:\\/\\//i', $obj->homepage)) {
             $obj->homepage = 'http://' . $obj->homepage;
         }
         // input the member's information if logged-in
         if (Context::get('is_logged')) {
             $logged_info = Context::get('logged_info');
             $obj->member_srl = $logged_info->member_srl;
             $obj->user_id = $logged_info->user_id;
             $obj->user_name = $logged_info->user_name;
             $obj->nick_name = $logged_info->nick_name;
             $obj->email_address = $logged_info->email_address;
             $obj->homepage = $logged_info->homepage;
         }
     }
     // error display if neither of log-in info and user name exist.
     if (!$logged_info->member_srl && !$obj->nick_name) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!$obj->review_srl) {
         $obj->review_srl = getNextSequence();
     }
     // determine the order
     $obj->list_order = getNextSequence() * -1;
     // remove XE's own tags from the contents
     $obj->content = preg_replace('!<\\!--(Before|After)(Document|Comment)\\(([0-9]+),([0-9]+)\\)-->!is', '', $obj->content);
     if (Mobile::isFromMobilePhone()) {
         $obj->content = nl2br(htmlspecialchars($obj->content));
     }
     if (!$obj->regdate) {
         $obj->regdate = date("YmdHis");
     }
     // remove iframe and script if not a top administrator on the session.
     if ($logged_info->is_admin != 'Y') {
         $obj->content = removeHackTag($obj->content);
     }
     if (!$obj->notify_message) {
         $obj->notify_message = 'N';
     }
     if (!$obj->is_secret) {
         $obj->is_secret = 'N';
     }
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     // Enter a list of comments first
     $list_args->review_srl = $obj->review_srl;
     $list_args->item_srl = $obj->item_srl;
     $list_args->module_srl = $obj->module_srl;
     $list_args->regdate = $obj->regdate;
     // If parent comment doesn't exist, set data directly
     if (!$obj->parent_srl) {
         $list_args->head = $list_args->arrange = $obj->review_srl;
         $list_args->depth = 0;
         // If parent comment exists, get information of the parent comment
     } else {
         // get information of the parent comment posting
         $parent_args->review_srl = $obj->parent_srl;
         $parent_output = executeQuery('store_review.getReviewListItem', $parent_args);
         // return if no parent comment exists
         if (!$parent_output->toBool() || !$parent_output->data) {
             return;
         }
         $parent = $parent_output->data;
         $list_args->head = $parent->head;
         $list_args->depth = $parent->depth + 1;
         // if the depth of comments is less than 2, execute insert.
         if ($list_args->depth < 2) {
             $list_args->arrange = $obj->review_srl;
             // if the depth of comments is greater than 2, execute update.
         } else {
             // get the top listed comment among those in lower depth and same head with parent's.
             $p_args->head = $parent->head;
             $p_args->arrange = $parent->arrange;
             $p_args->depth = $parent->depth;
             $output = executeQuery('store_review.getReviewParentNextSibling', $p_args);
             if ($output->data->arrange) {
                 $list_args->arrange = $output->data->arrange;
                 $output = executeQuery('store_review.updateReviewListArrange', $list_args);
             } else {
                 $list_args->arrange = $obj->review_srl;
             }
         }
     }
     $output = executeQuery('store_review.insertReviewList', $list_args);
     if (!$output->toBool()) {
         return $output;
     }
     // insert comment
     $output = executeQuery('store_review.insertReview', $obj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // creat the comment model object
     $oStoreReviewModel =& getModel('store_review');
     // get the number of all comments in the posting
     $review_count = $oStoreReviewModel->getReviewCount($item_srl);
     /*
     	trigger로 처리
     		$oStoreController = &getController('store');
     		// Update the number of comments in the post
     		$output = $oStoreController->updateReviewCount($item_srl, $comment_count, $obj->nick_name, true);
     */
     // grant autority of the comment
     $this->addGrant($obj->review_srl);
     // call a trigger(after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('store_review.insertReview', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     if (!$manual_inserted) {
         /*
         			// send a message if notify_message option in enabled in the original article
         			$oDocument->notify(Context::getLang('comment'), $obj->content);
         			// send a message if notify_message option in enabled in the original comment
         			if($obj->parent_srl) {
         				$oParent = $oReviewModel->getReview($obj->parent_srl);
         				if ($oParent->get('member_srl') != $oDocument->get('member_srl')) {
         					$oParent->notify(Context::getLang('comment'), $obj->content);
         				}
         			}
         */
     }
     $output->add('review_srl', $obj->review_srl);
     //remove from cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('reviewList');
     }
     return $output;
 }
Example #24
0
 /**
  * excute the member method specified by $act variable
  * @return boolean true : success false : fail
  * */
 function proc()
 {
     // pass if stop_proc is true
     if ($this->stop_proc) {
         debugPrint($this->message, 'ERROR');
         return FALSE;
     }
     // trigger call
     $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
     if (!$triggerOutput->toBool()) {
         $this->setError($triggerOutput->getError());
         $this->setMessage($triggerOutput->getMessage());
         return FALSE;
     }
     // execute an addon(call called_position as before_module_proc)
     $called_position = 'before_module_proc';
     $oAddonController = getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     if (FileHandler::exists($addon_file)) {
         include $addon_file;
     }
     if (isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
         // Check permissions
         if ($this->module_srl && !$this->grant->access) {
             $this->stop("msg_not_permitted_act");
             return FALSE;
         }
         // integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
         $is_default_skin = !Mobile::isFromMobilePhone() && $this->module_info->is_skin_fix == 'N' || Mobile::isFromMobilePhone() && $this->module_info->is_mskin_fix == 'N';
         $usedSkinModule = !($this->module == 'page' && ($this->module_info->page_type == 'OUTSIDE' || $this->module_info->page_type == 'WIDGET'));
         if ($usedSkinModule && $is_default_skin && $this->module != 'admin' && strpos($this->act, 'Admin') === false && $this->module == $this->module_info->module) {
             $dir = Mobile::isFromMobilePhone() ? 'm.skins' : 'skins';
             $valueName = Mobile::isFromMobilePhone() ? 'mskin' : 'skin';
             $oModuleModel = getModel('module');
             $skinType = Mobile::isFromMobilePhone() ? 'M' : 'P';
             $skinName = $oModuleModel->getModuleDefaultSkin($this->module, $skinType);
             if ($this->module == 'page') {
                 $this->module_info->{$valueName} = $skinName;
             } else {
                 $isTemplatPath = strpos($this->getTemplatePath(), '/tpl/') !== FALSE;
                 if (!$isTemplatPath) {
                     $this->setTemplatePath(sprintf('%s%s/%s/', $this->module_path, $dir, $skinName));
                 }
             }
         }
         $oModuleModel = getModel('module');
         $oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
         Context::set('module_info', $this->module_info);
         // Run
         $output = $this->{$this->act}();
     } else {
         return FALSE;
     }
     // trigger call
     $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
     if (!$triggerOutput->toBool()) {
         $this->setError($triggerOutput->getError());
         $this->setMessage($triggerOutput->getMessage());
         return FALSE;
     }
     // execute an addon(call called_position as after_module_proc)
     $called_position = 'after_module_proc';
     $oAddonController = getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     if (FileHandler::exists($addon_file)) {
         include $addon_file;
     }
     if (is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
         $this->setError($output->getError());
         $this->setMessage($output->getMessage());
         if (!$output->toBool()) {
             return FALSE;
         }
     }
     // execute api methos of the module if view action is and result is XMLRPC or JSON
     if ($this->module_info->module_type == 'view') {
         if (Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
             $oAPI = getAPI($this->module_info->module, 'api');
             if (method_exists($oAPI, $this->act)) {
                 $oAPI->{$this->act}($this);
             }
         }
     }
     return TRUE;
 }
 /**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         $handler = new VirtualXMLDisplayHandler();
     } else {
         if (Context::getRequestMethod() == 'XMLRPC') {
             $handler = new XMLDisplayHandler();
             if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
                 $this->gz_enabled = FALSE;
             }
         } else {
             if (Context::getRequestMethod() == 'JSON') {
                 $handler = new JSONDisplayHandler();
             } else {
                 if (Context::getRequestMethod() == 'JS_CALLBACK') {
                     $handler = new JSCallbackDisplayHandler();
                 } else {
                     $handler = new HTMLDisplayHandler();
                 }
             }
         }
     }
     $output = $handler->toDoc($oModule);
     // call a trigger before display
     ModuleHandler::triggerCall('display', 'before', $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 (method_exists($handler, "prepareToPrint")) {
         $handler->prepareToPrint($output);
     }
     // Start the session if $_SESSION was touched
     Context::getInstance()->checkSessionStatus();
     // header output
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode && $httpStatusCode != 200) {
         $this->_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             $this->_printJSONHeader();
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 $this->_printXMLHeader();
             } else {
                 $this->_printHTMLHeader();
             }
         }
     }
     // debugOutput output
     $this->content_size = strlen($output);
     $output .= $this->_debugOutput();
     // disable gzip if output already exists
     ob_flush();
     if (headers_sent()) {
         $this->gz_enabled = FALSE;
     }
     // enable gzip using zlib extension
     if ($this->gz_enabled) {
         ini_set('zlib.output_compression', true);
     }
     // results directly output
     print $output;
     // call a trigger after display
     ModuleHandler::triggerCall('display', 'after', $output);
     flushSlowlog();
 }
Example #26
0
 /**
  * display contents from executed module
  * @param ModuleObject $oModule module instance
  * @return void
  **/
 function displayContent($oModule = NULL)
 {
     // If the module is not set or not an object, set error
     if (!$oModule || !is_object($oModule)) {
         $this->error = 'msg_module_is_not_exists';
         $this->httpStatusCode = '404';
     }
     // If connection to DB has a problem even though it's not install module, set error
     if ($this->module != 'install' && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == false) {
         $this->error = 'msg_dbconnect_failed';
     }
     // Call trigger after moduleHandler proc
     $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
     if (!$output->toBool()) {
         $this->error = $output->getMessage();
     }
     // Use message view object, if HTML call
     $methodList = array('XMLRPC' => 1, 'JSON' => 1);
     if (!isset($methodList[Context::getRequestMethod()])) {
         if ($_SESSION['XE_VALIDATOR_RETURN_URL']) {
             $display_handler = new DisplayHandler();
             $display_handler->_debugOutput();
             header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
             return;
         }
         // If error occurred, handle it
         if ($this->error) {
             // display content with message module instance
             $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
             $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
             $oMessageObject->setError(-1);
             $oMessageObject->setMessage($this->error);
             $oMessageObject->dispMessage();
             if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') {
                 $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
                 $oMessageObject->setTemplateFile('http_status_code');
             }
             // If module was called normally, change the templates of the module into ones of the message view module
             if ($oModule) {
                 $oModule->setTemplatePath($oMessageObject->getTemplatePath());
                 $oModule->setTemplateFile($oMessageObject->getTemplateFile());
                 // Otherwise, set message instance as the target module
             } else {
                 $oModule = $oMessageObject;
             }
             $this->_clearErrorSession();
         }
         // Check if layout_srl exists for the module
         if (Mobile::isFromMobilePhone()) {
             $layout_srl = $oModule->module_info->mlayout_srl;
         } else {
             $layout_srl = $oModule->module_info->layout_srl;
         }
         if ($layout_srl && !$oModule->getLayoutFile()) {
             // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
             $oLayoutModel =& getModel('layout');
             $layout_info = $oLayoutModel->getLayout($layout_srl);
             if ($layout_info) {
                 // Input extra_vars into $layout_info
                 if ($layout_info->extra_var_count) {
                     foreach ($layout_info->extra_var as $var_id => $val) {
                         if ($val->type == 'image') {
                             if (preg_match('/^\\.\\/files\\/attach\\/images\\/(.+)/i', $val->value)) {
                                 $val->value = Context::getRequestUri() . substr($val->value, 2);
                             }
                         }
                         $layout_info->{$var_id} = $val->value;
                     }
                 }
                 // Set menus into context
                 if ($layout_info->menu_count) {
                     foreach ($layout_info->menu as $menu_id => $menu) {
                         if (file_exists($menu->php_file)) {
                             @(include $menu->php_file);
                         }
                         Context::set($menu_id, $menu);
                     }
                 }
                 // Set layout information into context
                 Context::set('layout_info', $layout_info);
                 $oModule->setLayoutPath($layout_info->path);
                 $oModule->setLayoutFile('layout');
                 // If layout was modified, use the modified version
                 $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
                 if (file_exists($edited_layout)) {
                     $oModule->setEditedLayoutFile($edited_layout);
                 }
             }
         }
     }
     // Display contents
     $oDisplayHandler = new DisplayHandler();
     $oDisplayHandler->printContent($oModule);
 }
Example #27
-1
 /**
  * Insert the document
  * @param object $obj
  * @param bool $manual_inserted
  * @param bool $isRestore
  * @return object
  */
 function insertDocument($obj, $manual_inserted = false, $isRestore = false)
 {
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     // List variables
     if ($obj->comment_status) {
         $obj->commentStatus = $obj->comment_status;
     }
     if (!$obj->commentStatus) {
         $obj->commentStatus = 'DENY';
     }
     if ($obj->commentStatus == 'DENY') {
         $this->_checkCommentStatusForOldVersion($obj);
     }
     if ($obj->allow_trackback != 'Y') {
         $obj->allow_trackback = 'N';
     }
     if ($obj->homepage && !preg_match('/^[a-z]+:\\/\\//i', $obj->homepage)) {
         $obj->homepage = 'http://' . $obj->homepage;
     }
     if ($obj->notify_message != 'Y') {
         $obj->notify_message = 'N';
     }
     if (!$isRestore) {
         $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
     }
     //board에서 form key값으로 ipaddress를 사용하면 엄한 ip가 등록됨. 필터와는 상관없슴
     // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid
     if (!is_string($obj->extra_vars)) {
         $obj->extra_vars = serialize($obj->extra_vars);
     }
     // Remove the columns for automatic saving
     unset($obj->_saved_doc_srl);
     unset($obj->_saved_doc_title);
     unset($obj->_saved_doc_content);
     unset($obj->_saved_doc_message);
     // Call a trigger (before)
     $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // Register it if no given document_srl exists
     if (!$obj->document_srl) {
         $obj->document_srl = getNextSequence();
     }
     $oDocumentModel =& getModel('document');
     // Set to 0 if the category_srl doesn't exist
     if ($obj->category_srl) {
         $category_list = $oDocumentModel->getCategoryList($obj->module_srl);
         if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) {
             return new Object(-1, 'msg_not_permitted');
         }
         if (count($category_list) > 0 && !$category_list[$obj->category_srl]) {
             $obj->category_srl = 0;
         }
     }
     // Set the read counts and update order.
     if (!$obj->readed_count) {
         $obj->readed_count = 0;
     }
     if (!$isRestore) {
         $obj->update_order = $obj->list_order = getNextSequence() * -1;
     } else {
         $obj->update_order = $obj->list_order;
     }
     // Check the status of password hash for manually inserting. Apply md5 hashing for otherwise.
     if ($obj->password && !$obj->password_is_hashed) {
         $obj->password = md5($obj->password);
     }
     // Insert member's information only if the member is logged-in and not manually registered.
     $logged_info = Context::get('logged_info');
     if (Context::get('is_logged') && !$manual_inserted && !$isRestore) {
         $obj->member_srl = $logged_info->member_srl;
         $obj->user_id = $logged_info->user_id;
         $obj->user_name = $logged_info->user_name;
         $obj->nick_name = $logged_info->nick_name;
         $obj->email_address = $logged_info->email_address;
         $obj->homepage = $logged_info->homepage;
     }
     // If the tile is empty, extract string from the contents.
     settype($obj->title, "string");
     if ($obj->title == '') {
         $obj->title = cut_str(strip_tags($obj->content), 20, '...');
     }
     // If no tile extracted from the contents, leave it untitled.
     if ($obj->title == '') {
         $obj->title = 'Untitled';
     }
     // Remove XE's own tags from the contents.
     $obj->content = preg_replace('!<\\!--(Before|After)(Document|Comment)\\(([0-9]+),([0-9]+)\\)-->!is', '', $obj->content);
     if (Mobile::isFromMobilePhone()) {
         if ($obj->use_html != 'Y') {
             $obj->content = htmlspecialchars($obj->content);
         }
         $obj->content = nl2br($obj->content);
     }
     // Remove iframe and script if not a top adminisrator in the session.
     if ($logged_info->is_admin != 'Y') {
         $obj->content = removeHackTag($obj->content);
     }
     // An error appears if both log-in info and user name don't exist.
     if (!$logged_info->member_srl && !$obj->nick_name) {
         return new Object(-1, 'msg_invalid_request');
     }
     $obj->lang_code = Context::getLangType();
     // Insert data into the DB
     if (!$obj->status) {
         $this->_checkDocumentStatusForOldVersion($obj);
     }
     $output = executeQuery('document.insertDocument', $obj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // Insert extra variables if the document successfully inserted.
     $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
     if (count($extra_keys)) {
         foreach ($extra_keys as $idx => $extra_item) {
             $value = '';
             if (isset($obj->{'extra_vars' . $idx})) {
                 $tmp = $obj->{'extra_vars' . $idx};
                 if (is_array($tmp)) {
                     $value = implode('|@|', $tmp);
                 } else {
                     $value = trim($tmp);
                 }
             } elseif (isset($obj->{$extra_item->name})) {
                 $value = trim($obj->{$extra_item->name});
             }
             if (!isset($value)) {
                 continue;
             }
             $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
         }
     }
     // Update the category if the category_srl exists.
     if ($obj->category_srl) {
         $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
     }
     // Call a trigger (after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     // return
     $this->addGrant($obj->document_srl);
     $output->add('document_srl', $obj->document_srl);
     $output->add('category_srl', $obj->category_srl);
     //remove from cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'object:' . $obj->document_srl;
         $oCacheHandler->delete($cache_key);
         $oCacheHandler->invalidateGroupKey('documentList');
     }
     return $output;
 }
Example #28
-2
 /**
  * @brief Combine skin information with module information
  */
 function syncSkinInfoToModuleInfo(&$module_info)
 {
     if (!$module_info->module_srl) {
         return;
     }
     if (Mobile::isFromMobilePhone()) {
         $skin_vars = $this->getModuleMobileSkinVars($module_info->module_srl);
     } else {
         $skin_vars = $this->getModuleSkinVars($module_info->module_srl);
     }
     if (!$skin_vars) {
         return;
     }
     foreach ($skin_vars as $name => $val) {
         if (isset($module_info->{$name})) {
             continue;
         }
         $module_info->{$name} = $val->value;
     }
 }
if (!defined("__XE__")) {
    exit;
}
?>
<!--#Meta:modules/editor/tpl/js/editor_common.min.js--><?php 
$__tmp = array('modules/editor/tpl/js/editor_common.min.js', '', '', '');
Context::loadFile($__tmp);
unset($__tmp);
if (!Mobile::isFromMobilePhone()) {
    ?>
<!--#Meta:modules/board/skins/sketchbook5_youtube/js/xe_textarea.min.js--><?php 
    $__tmp = array('modules/board/skins/sketchbook5_youtube/js/xe_textarea.min.js', '', '', '');
    Context::loadFile($__tmp);
    unset($__tmp);
}
if (Mobile::isFromMobilePhone()) {
    ?>
<!--#Meta:modules/board/skins/sketchbook5_youtube/js/xe_textarea_m.js--><?php 
    $__tmp = array('modules/board/skins/sketchbook5_youtube/js/xe_textarea_m.js', '', '', '');
    Context::loadFile($__tmp);
    unset($__tmp);
}
if (Mobile::isMobileCheckByAgent()) {
    $__Context->mi->cmt_wrt = 'simple';
}
?>
<div class="cmt_editor"<?php 
if ($__Context->mi->cmt_wrt_position == 'cmt_wrt_btm' && $__Context->oDocument->getCommentcount()) {
    ?>
 style="margin-top:30px"<?php 
}
 function startAuthentication(&$oModule)
 {
     $oAuthenticationModel =& getModel('authentication');
     $config = $oAuthenticationModel->getModuleConfig();
     $config->agreement = $oAuthenticationModel->_getAgreement();
     if (Mobile::isFromMobilePhone()) {
         $oModule->setTemplatePath(sprintf($this->module_path . 'm.skins/%s/', $config->mskin));
     } else {
         $oModule->setTemplatePath(sprintf($this->module_path . 'skins/%s/', $config->skin));
     }
     if ($config->authcode_time_limit) {
         Context::set('time_limit', $config->authcode_time_limit);
     }
     // 전송지연 현황 보여주기
     $status = $oAuthenticationModel->getDelayStatus();
     if ($status != NULL) {
         $status->sms_sk = $oAuthenticationModel->getDelayStatusString($status->sms_sk_average);
         $status->sms_kt = $oAuthenticationModel->getDelayStatusString($status->sms_kt_average);
         $status->sms_lg = $oAuthenticationModel->getDelayStatusString($status->sms_lg_average);
         Context::set('status', $status);
     }
     Context::set('number_limit', $config->number_limit);
     Context::set('config', $config);
     Context::set('target_action', $oModule->act);
     $oLayoutModel =& getModel('layout');
     $layout_info = $oLayoutModel->getLayout($config->layout_srl);
     if ($layout_info) {
         $oModule->setLayoutPath($layout_info->path);
         $oModule->setLayoutFile("layout");
     }
     $oModule->setTemplateFile('index');
 }