Example #1
0
 /**
  * @brief 외부 http로 요청되는 파일일 경우 파일을 받아와서 저장 후 return
  **/
 function getHtmlPage($path, $caching_interval, $cache_file)
 {
     // 캐시 검사
     if ($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval * 60 > time()) {
         $content = FileHandler::readFile($cache_file);
     } else {
         FileHandler::getRemoteFile($path, $cache_file);
         $content = FileHandler::readFile($cache_file);
     }
     // opage controller 생성
     $oOpageController =& getController('opage');
     // 외부 서버의 페이지 일 경우 이미지, css, javascript등의 url을 변경
     $content = $oOpageController->replaceSrc($content, $path);
     // 해당 문서를 utf-8로 변경
     $buff->content = $content;
     $buff = Context::convertEncoding($buff);
     $content = $buff->content;
     // title 추출
     $title = $oOpageController->getTitle($content);
     if ($title) {
         Context::setBrowserTitle($title);
     }
     // header script 추출
     $head_script = $oOpageController->getHeadScript($content);
     if ($head_script) {
         Context::addHtmlHeader($head_script);
     }
     // body 내용 추출
     $body_script = $oOpageController->getBodyScript($content);
     if (!$body_script) {
         $body_script = $content;
     }
     return $content;
 }
 function triggerDisplay()
 {
     //trigger display before();
     if (strpos(Context::get('act'), "ispBoardAdmin") || strpos(Context::get('act'), "ispBoard_extendAdmin")) {
         $core_ver = __XE_VERSION__ ? __XE_VERSION__ : __ZBXE_VERSION__;
         $is_active = Context::get('act') == 'dispBoard_extendAdminBoardModify' ? true : false;
         $url = getNotEncodedUrl('act', 'dispBoard_extendAdminBoardModify', 'selected_var_idx', '', 'type', '');
         $text = "목록수정";
         if ($core_ver >= 1.7) {
             $active = $is_active ? "class='x_active'" : "";
             $html = sprintf("<li %s><a href='%s'>%s</a></li>", $active, $url, $text);
             $script = "jQuery(document).ready(function(\$){\$('.x_nav').append(\"{$html}\");});";
         } else {
             if ($core_ver >= 1.5) {
                 $active = $is_active ? "class='active'" : "";
                 $html = sprintf("<li %s><a href='%s'>%s</a></li>", $active, $url, $text);
                 $script = "jQuery(document).ready(function(\$){\$('.x .cnb ul').append(\"{$html}\");});";
             } else {
                 if ($core_ver >= 1.4) {
                     $active = $is_active ? "class='on'" : "";
                     $html = sprintf("<li %s><a href='%s'>%s</a></li>", $active, $url, $text);
                     $script = "jQuery(document).ready(function(\$){\$('#xeAdmin .header4 .localNavigation').append(\"{$html}\");});";
                 } else {
                     $this->stop('지원하지 않는 버전입니다. board_extend 모듈을 제거해주시기 바랍니다.');
                 }
             }
         }
         Context::addHtmlHeader("<script type='text/javascript'>{$script}</script>");
     }
 }
 /**
  * @brief index page
  */
 function dispNproductIndex()
 {
     // add translation for javascript
     Context::addHtmlHeader(sprintf("<script>\n\t\t\t\t\t\t\t\t\t\t\txe.lang.msg_put_item_in_cart = '%s';\n\t\t\t\t\t\t\t\t\t\t</script>", Context::getLang('msg_put_item_in_cart')));
     if (Context::get('item_srl') || Context::get('document_srl')) {
         return $this->dispNproductItemDetail();
     }
     $this->dispNproductItemList();
 }
        function before_module_init(&$ModuleHandler)
        {
            $logged_info = Context::get('logged_info');
            if ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) {
                return false;
            }
            // if($this->addon_info->target != 'all' && Context::get('is_logged'))
            // {
            // 	return false;
            // }
            if ($_SESSION['XE_VALIDATOR_ERROR'] == -1) {
                $_SESSION['member_captcha_authed'] = false;
            }
            if ($_SESSION['member_captcha_authed']) {
                return false;
            }
            $type = Context::get('captchaType');
            $this->target_acts = array();
            if ($this->addon_info->apply_find_account == 'apply') {
                $this->target_acts[] = 'procMemberFindAccount';
            }
            if ($this->addon_info->apply_resend_auth_mail == 'apply') {
                $this->target_acts[] = 'procMemberResendAuthMail';
            }
            if ($this->addon_info->apply_signup == 'apply') {
                $this->target_acts[] = 'procMemberInsert';
            }
            if (Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') {
                if ($type == 'inline') {
                    if (!$this->compareCaptcha()) {
                        Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang');
                        $_SESSION['XE_VALIDATOR_ERROR'] = -1;
                        $_SESSION['XE_VALIDATOR_MESSAGE'] = Context::getLang('captcha_denied');
                        $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
                        $_SESSION['XE_VALIDATOR_RETURN_URL'] = Context::get('error_return_url');
                        $ModuleHandler->_setInputValueToSession();
                    }
                } else {
                    Context::addHtmlHeader('<script>
						if(!captchaTargetAct) {var captchaTargetAct = [];}
						captchaTargetAct.push("' . implode('","', $this->target_acts) . '");
						</script>');
                    Context::loadFile(array('./addons/captcha_member/captcha.min.js', 'body', '', null), true);
                }
            }
            // compare session when calling actions such as writing a post or a comment on the board/issue tracker module
            if (!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) {
                Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang');
                $ModuleHandler->error = "captcha_denied";
            }
            return true;
        }
Example #5
0
	/**
	 * Shop common init
	 **/
	public function initCommon($is_other_module = FALSE){
		if(!$this->checkXECoreVersion('1.4.3')) return $this->stop(sprintf(Context::getLang('msg_requried_version'),'1.4.3'));

		$oShopModel = getModel('shop');
		$oShopController = getController('shop');
		$oModuleModel = getModel('module');

		$site_module_info = Context::get('site_module_info');
		if(!$this->module_srl) {
			$site_module_info = Context::get('site_module_info');
			$site_srl = $site_module_info->site_srl;
			if($site_srl) {
				$this->module_srl = $site_module_info->index_module_srl;
				$this->module_info = $oModuleModel->getModuleInfoByModuleSrl($this->module_srl);
				if (!$is_other_module) {
					Context::set('module_info',$this->module_info);
					Context::set('mid',$this->module_info->mid);
					Context::set('current_module_info',$this->module_info);
				}
			}
		}

		if(!$this->module_info->skin) $this->module_info->skin = $this->skin;

		$preview_skin = Context::get('preview_skin');
		if($oModuleModel->isSiteAdmin(Context::get('logged_info'))&&$preview_skin) {
			if(is_dir($this->module_path.'skins/'.$preview_skin)) {
                $shop_config = new stdClass();
				$shop_config->skin = $this->module_info->skin = $preview_skin;
			}
		}

		if (!$is_other_module){
			Context::set('module_info',$this->module_info);
			Context::set('current_module_info', $this->module_info);
		}

		$this->shop = $oShopModel->getShop($this->module_info->module_srl);
		$this->site_srl = $this->shop->site_srl;
		Context::set('shop',$this->shop);

        Context::addHtmlHeader('<link rel="shortcut icon" href="'.$this->shop->getFaviconSrc().'" />');

		if($this->shop->timezone) $GLOBALS['_time_zone'] = $this->shop->timezone;

        Context::set('module', 'shop');


	}
 function init()
 {
     if ($this->module_info->module != 'nmileage') {
         $this->module_info->skin = 'default';
     }
     if (!$this->module_info->skin) {
         $this->module_info->skin = 'default';
     }
     $skin = $this->module_info->skin;
     $oModuleModel =& getModel('module');
     // 템플릿 경로 설정
     $this->setTemplatePath(sprintf('%sskins/%s', $this->module_path, $skin));
     $oLicenseModel =& getModel('license');
     if (!$oLicenseModel || $oLicenseModel && !$oLicenseModel->getLicenseConfirm()) {
         Context::addHtmlHeader("<script>jQuery(document).ready(function() { jQuery('<div style=\"background:#fff; padding:6px; position:fixed; right:6px; bottom:6px; z-index:999999; \">Powered by <a href=\"http://www.xeshoppingmall.com\">NURIGO</a></div>').appendTo('body'); });</script>");
     }
 }
 function init()
 {
     // 템플릿 경로 설정
     if ($this->module_info->module != 'nstore_digital') {
         $this->module_info->skin = 'default';
     }
     if (!$this->module_info->skin) {
         $this->module_info->skin = 'default';
     }
     if (!$this->module_info->display_caution) {
         $this->module_info->display_caution = 'Y';
     }
     $this->setTemplatePath($this->module_path . "skins/{$this->module_info->skin}");
     Context::set('module_info', $this->module_info);
     $oLicenseModel =& getModel('license');
     if (!$oLicenseModel || $oLicenseModel && !$oLicenseModel->getLicenseConfirm('nstore_digital')) {
         Context::addHtmlHeader("<script>jQuery(document).ready(function() { jQuery('<div style=\"background:#fff; padding:6px; position:fixed; right:6px; bottom:6px; z-index:999999; \">Powered by <a href=\"http://www.xeshoppingmall.com\">NURIGO</a></div>').appendTo('body'); });</script>");
     }
 }
    public function triggerBeforeDisplay(&$output)
    {
        $logged_info = Context::get('logged_info');
        $oAndroidpushappModel = getModel('androidpushapp');
        $config = $oAndroidpushappModel->getConfig();
        $args = new stdClass();
        $args->module = "resource";
        $output_c_resource = executeQuery('androidpushapp.getAModuleCount', $args);
        $output_b = executeQueryArray('board.getBoardList', $args);
        $setting_board = "";
        if ($output_c_resource->data->count) {
            $output_a = executeQueryArray('androidpushapp.getAResourceList', $args);
            foreach ($output_a->data as $data) {
                if (in_array($data->module_srl, $config->no_use_module_srls) || in_array($data->module_srl, $config->only_admin_push_module_srls)) {
                } else {
                    if (preg_match("/XEPUSH/", $_SERVER['HTTP_USER_AGENT'])) {
                        if ($setting_board == "") {
                            $setting_board = $data->browser_title . "&#" . $data->module_srl;
                        } else {
                            $setting_board = $setting_board . "/-" . $data->browser_title . "&#" . $data->module_srl;
                        }
                    } else {
                        if ($setting_board == "") {
                            $setting_board = $data->browser_title . "k324elv23ul234oenf" . $data->module_srl;
                        } else {
                            $setting_board = $setting_board . "fo034kfk0ev0kr4feldkfjsdkaj" . $data->browser_title . "k324elv23ul234oenf" . $data->module_srl;
                        }
                    }
                }
            }
        }
        foreach ($output_b->data as $data) {
            if (in_array($data->module_srl, $config->no_use_module_srls) || in_array($data->module_srl, $config->only_admin_push_module_srls)) {
            } else {
                if (preg_match("/XEPUSH/", $_SERVER['HTTP_USER_AGENT'])) {
                    if ($setting_board == "") {
                        $setting_board = $data->browser_title . "&#" . $data->module_srl;
                    } else {
                        $setting_board = $setting_board . "/-" . $data->browser_title . "&#" . $data->module_srl;
                    }
                } else {
                    if ($setting_board == "") {
                        $setting_board = $data->browser_title . "k324elv23ul234oenf" . $data->module_srl;
                    } else {
                        $setting_board = $setting_board . "fo034kfk0ev0kr4feldkfjsdkaj" . $data->browser_title . "k324elv23ul234oenf" . $data->module_srl;
                    }
                }
            }
        }
        if (preg_match("/XEPUSH/", $_SERVER['HTTP_USER_AGENT'])) {
            if ($logged_info->member_srl) {
                $htmlCode = '<script>
					function callAndroid(){		
						window.myJs.callAndroid("%d","%s","%s");
					}

					function callAndroid_login(){		
						window.myJs_login.callAndroid_login("true");
					}
					</script>';
                $htmlCode = sprintf($htmlCode, $logged_info->member_srl, $logged_info->nick_name, $setting_board);
            } else {
                $htmlCode = '<script>
					function callAndroid(){		
						window.myJs.callAndroid(null,null,"%s");
					}

					function callAndroid_login(){		
						window.myJs_login.callAndroid_login("false");
					}					
					</script>';
                $htmlCode = sprintf($htmlCode, $setting_board);
            }
            Context::addHtmlHeader($htmlCode);
        } elseif ($config->sort_v == "B" || $config->sort_v == "WB") {
            $package = $config->package;
            $p_name = explode(".", $package);
            $num_app = sizeof($p_name) - 1;
            $appname = $p_name[$num_app];
            if ($logged_info->member_srl) {
                $htmlCode = '<style type="text/css">#xepushapp {display : block;}</style>				
				<script language="JavaScript">

				function checkApplicationInstall() { 

				 var userAgent = navigator.userAgent;
				 var visitedAt = (new Date()).getTime();

				 if (userAgent.match(/Chrome/)) {
						 
						 setTimeout(function() {
							  location.href = "intent://Setting?member_srl=' . $logged_info->member_srl . '&nick_name=' . $logged_info->nick_name . '&boardset=' . $setting_board . '#Intent;scheme=' . $appname . ';package=' . $package . ';end";
						 }, 100);
					} else {
						
						setTimeout(
						   function() {
							  if ((new Date()).getTime() - visitedAt < 200) {
								 location.href = "market://details?id=' . $package . '";
							  }
						  }, 50);

						  var iframe = document.createElement("iframe");
						  iframe.style.visibility = "hidden";
						  iframe.src = "' . $appname . '://Setting?member_srl=' . $logged_info->member_srl . '&nick_name=' . $logged_info->nick_name . '&boardset=' . $setting_board . '";
						  document.body.appendChild(iframe);
						  document.body.removeChild(iframe); 
					 }
				}

				</script>';
            } else {
                $htmlCode = '<style type="text/css">#xepushapp {display : block;}</style>
				<script language="JavaScript">

				function checkApplicationInstall() {

				 var userAgent = navigator.userAgent;
				 var visitedAt = (new Date()).getTime();

				 if (userAgent.match(/Chrome/)) {
						 
						 setTimeout(function() {
							  location.href = "intent://Setting?boardset=' . $setting_board . '#Intent;scheme=' . $appname . ';package=' . $package . ';end";
						 }, 100);
					} else {
						
						setTimeout(
						   function() {
							  if ((new Date()).getTime() - visitedAt < 200) {
								 location.href = "market://details?id=' . $package . '";
							  }
						  }, 50);

						  var iframe = document.createElement("iframe");
						  iframe.style.visibility = "hidden";
						  iframe.src = "' . $appname . '://Setting?boardset=' . $setting_board . '";
						  document.body.appendChild(iframe);
						  document.body.removeChild(iframe); 
					 }
				}

				</script>';
            }
            Context::addHtmlHeader($htmlCode);
        }
    }
 /**
  * @brief <body>내의 <style태그를 header로 이동
  **/
 function moveStyleToHeader($matches)
 {
     Context::addHtmlHeader($matches[0]);
 }
<?php

if (!defined("__ZBXE__")) {
    exit;
}
/**
 * @file planet_todo.addon.php
 * @author SOL군 (sol@ngleader.com)
 * @brief
 **/
if ($called_position == 'after_module_proc' && Context::getResponseMethod() != "XMLRPC" && Context::getResponseMethod() != "JSON") {
    $planet = Context::get('planet');
    if (!$planet || !$planet->isMyPlanet()) {
        return;
    }
    $oPlanetModel =& getModel('planet');
    $countTodo = $oPlanetModel->getTagSearchResultCount($planet->getModuleSrl(), 'todo');
    $countDone = $oPlanetModel->getTagSearchResultCount($planet->getModuleSrl(), 'done');
    Context::addHtmlHeader("<script type=\"text/javascript\">//<![CDATA[\nvar planet_todo_count={todo:" . $countTodo . ",done:" . $countDone . "};\n//]]></script>");
    Context::addJsFile('./addons/planet_todo/planet_todo.js');
}
Example #11
0
 /**
  * get a module instance and execute an action
  * @return ModuleObject executed module instance
  **/
 function procModule()
 {
     $oModuleModel =& getModel('module');
     // If error occurred while preparation, return a message instance
     if ($this->error) {
         $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
         $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // Get action information with conf/module.xml
     $xml_info = $oModuleModel->getModuleActionXml($this->module);
     // If not installed yet, modify act
     if ($this->module == "install") {
         if (!$this->act || !$xml_info->action->{$this->act}) {
             $this->act = $xml_info->default_index_act;
         }
     }
     // if act exists, find type of the action, if not use default index act
     if (!$this->act) {
         $this->act = $xml_info->default_index_act;
     }
     // still no act means error
     if (!$this->act) {
         $this->error = 'msg_module_is_not_exists';
         $this->httpStatusCode = '404';
         $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
         $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // get type, kind
     $type = $xml_info->action->{$this->act}->type;
     $ruleset = $xml_info->action->{$this->act}->ruleset;
     $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);
     }
     // admin menu check
     if (Context::isInstalled()) {
         $oMenuAdminModel =& getAdminModel('menu');
         $output = $oMenuAdminModel->getMenuByTitle('__XE_ADMIN__');
         if (!$output->menu_srl) {
             $oAdminClass =& getClass('admin');
             $oAdminClass->createXeAdminMenu();
         } else {
             if (!is_readable($output->php_file)) {
                 $oMenuAdminController =& getAdminController('menu');
                 $oMenuAdminController->makeXmlFile($output->menu_srl);
             }
         }
     }
     // Admin ip
     $logged_info = Context::get('logged_info');
     if ($kind == 'admin' && $_SESSION['denied_admin'] == 'Y') {
         $this->error = "msg_not_permitted_act";
         $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         return $oMessageObject;
     }
     // if(type == view, and case for using mobilephone)
     if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) {
         $orig_type = "view";
         $type = "mobile";
         // create a module instance
         $oModule =& $this->getModuleInstance($this->module, $type, $kind);
         if (!is_object($oModule) || !method_exists($oModule, $this->act)) {
             $type = $orig_type;
             Mobile::setMobile(false);
             $oModule =& $this->getModuleInstance($this->module, $type, $kind);
         }
     } else {
         // create a module instance
         $oModule =& $this->getModuleInstance($this->module, $type, $kind);
     }
     if (!is_object($oModule)) {
         $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
         $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // If there is no such action in the module object
     if (!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act)) {
         if (!Context::isInstalled()) {
             $this->error = 'msg_invalid_request';
             $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
             $oMessageObject->setError(-1);
             $oMessageObject->setMessage($this->error);
             $oMessageObject->dispMessage();
             if ($this->httpStatusCode) {
                 $oMessageObject->setHttpStatusCode($this->httpStatusCode);
             }
             return $oMessageObject;
         }
         $forward = null;
         // 1. Look for the module with action name
         if (preg_match('/^([a-z]+)([A-Z])([a-z0-9\\_]+)(.*)$/', $this->act, $matches)) {
             $module = strtolower($matches[2] . $matches[3]);
             $xml_info = $oModuleModel->getModuleActionXml($module);
             if ($xml_info->action->{$this->act}) {
                 $forward->module = $module;
                 $forward->type = $xml_info->action->{$this->act}->type;
                 $forward->ruleset = $xml_info->action->{$this->act}->ruleset;
                 $forward->act = $this->act;
             }
         }
         if (!$forward) {
             $forward = $oModuleModel->getActionForward($this->act);
         }
         if ($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
             $kind = strpos(strtolower($forward->act), 'admin') !== false ? 'admin' : '';
             $type = $forward->type;
             $ruleset = $forward->ruleset;
             $tpl_path = $oModule->getTemplatePath();
             $orig_module = $oModule;
             if ($type == "view" && Mobile::isFromMobilePhone()) {
                 $orig_type = "view";
                 $type = "mobile";
                 // create a module instance
                 $oModule =& $this->getModuleInstance($forward->module, $type, $kind);
                 if (!is_object($oModule) || !method_exists($oModule, $this->act)) {
                     $type = $orig_type;
                     Mobile::setMobile(false);
                     $oModule =& $this->getModuleInstance($forward->module, $type, $kind);
                 }
             } else {
                 $oModule =& $this->getModuleInstance($forward->module, $type, $kind);
             }
             $xml_info = $oModuleModel->getModuleActionXml($forward->module);
             $oMemberModel =& getModel('member');
             if ($this->module == "admin" && $type == "view") {
                 if ($logged_info->is_admin == 'Y') {
                     if ($this->act != 'dispLayoutAdminLayoutModify') {
                         $oAdminView =& getAdminView('admin');
                         $oAdminView->makeGnbUrl($forward->module);
                         $oModule->setLayoutPath("./modules/admin/tpl");
                         $oModule->setLayoutFile("layout.html");
                     }
                 } else {
                     $this->error = 'msg_is_not_administrator';
                     $oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
                     $oMessageObject->setError(-1);
                     $oMessageObject->setMessage($this->error);
                     $oMessageObject->dispMessage();
                     return $oMessageObject;
                 }
             }
             if ($kind == 'admin') {
                 $grant = $oModuleModel->getGrant($this->module_info, $logged_info);
                 if (!$grant->is_admin && !$grant->manager) {
                     $this->error = 'msg_is_not_manager';
                     $oMessageObject =& ModuleHandler::getModuleInstance('message', 'view');
                     $oMessageObject->setError(-1);
                     $oMessageObject->setMessage($this->error);
                     $oMessageObject->dispMessage();
                     return $oMessageObject;
                 }
             }
         } else {
             if ($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act)) {
                 $this->act = $xml_info->default_index_act;
             } else {
                 $this->error = 'msg_invalid_request';
                 $oModule->setError(-1);
                 $oModule->setMessage($this->error);
                 return $oModule;
             }
         }
     }
     // ruleset check...
     if (!empty($ruleset)) {
         $rulesetModule = $forward->module ? $forward->module : $this->module;
         $rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid);
         if (!empty($rulesetFile)) {
             if ($_SESSION['XE_VALIDATOR_ERROR_LANG']) {
                 $errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG'];
                 foreach ($errorLang as $key => $val) {
                     Context::setLang($key, $val);
                 }
                 unset($_SESSION['XE_VALIDATOR_ERROR_LANG']);
             }
             $Validator = new Validator($rulesetFile);
             $result = $Validator->validate();
             if (!$result) {
                 $lastError = $Validator->getLastError();
                 $returnUrl = Context::get('error_return_url');
                 $errorMsg = $lastError['msg'] ? $lastError['msg'] : 'validation error';
                 //for xml response
                 $oModule->setError(-1);
                 $oModule->setMessage($errorMsg);
                 //for html redirect
                 $this->error = $errorMsg;
                 $_SESSION['XE_VALIDATOR_ERROR'] = -1;
                 $_SESSION['XE_VALIDATOR_MESSAGE'] = $this->error;
                 $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
                 $_SESSION['XE_VALIDATOR_RETURN_URL'] = $returnUrl;
                 $this->_setInputValueToSession();
                 return $oModule;
             }
         }
     }
     $oModule->setAct($this->act);
     $this->module_info->module_type = $type;
     $oModule->setModuleInfo($this->module_info, $xml_info);
     if ($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent()) {
         global $lang;
         $header = '<style type="text/css">div.xe_mobile{opacity:0.7;margin:1em 0;padding:.5em;background:#333;border:1px solid #666;border-left:0;border-right:0}p.xe_mobile{text-align:center;margin:1em 0}a.xe_mobile{color:#ff0;font-weight:bold;font-size:24px}@media only screen and (min-width:500px){a.xe_mobile{font-size:15px}}</style>';
         $footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="' . getUrl('m', '1') . '">' . $lang->msg_pc_to_mobile . '</a></p></div>';
         Context::addHtmlHeader($header);
         Context::addHtmlFooter($footer);
     }
     if ($type == "view" && $kind != 'admin') {
         $module_config = $oModuleModel->getModuleConfig('module');
         if ($module_config->htmlFooter) {
             Context::addHtmlFooter($module_config->htmlFooter);
         }
     }
     // if failed message exists in session, set context
     $this->_setInputErrorToContext();
     $procResult = $oModule->proc();
     $methodList = array('XMLRPC' => 1, 'JSON' => 1);
     if (!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()])) {
         $error = $oModule->getError();
         $message = $oModule->getMessage();
         $messageType = $oModule->getMessageType();
         $redirectUrl = $oModule->getRedirectUrl();
         if (!$procResult) {
             $this->error = $message;
             if (!$redirectUrl && Context::get('error_return_url')) {
                 $redirectUrl = Context::get('error_return_url');
             }
             $this->_setInputValueToSession();
         } else {
             if (count($_SESSION['INPUT_ERROR'])) {
                 Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
                 $_SESSION['INPUT_ERROR'] = '';
             }
         }
         $_SESSION['XE_VALIDATOR_ERROR'] = $error;
         if ($message != 'success') {
             $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
         }
         $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
         if (Context::get('xeVirtualRequestMethod') != 'xml') {
             $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
         }
     }
     unset($logged_info);
     return $oModule;
 }
 /**
  * Add javascript codes into the header by checking values of member join form, required and others
  * @return void
  */
 function addExtraFormValidatorMessage()
 {
     $oMemberModel = getModel('member');
     $extraList = $oMemberModel->getUsedJoinFormList();
     $js_code = array();
     $js_code[] = '<script>//<![CDATA[';
     $js_code[] = '(function($){';
     $js_code[] = 'var validator = xe.getApp("validator")[0];';
     $js_code[] = 'if(!validator) return false;';
     $errorLang = array();
     foreach ($extraList as $val) {
         $title = str_ireplace(array('<script', '</script'), array('<scr"+"ipt', '</scr"+"ipt'), addslashes($val->column_title));
         if ($val->column_type == 'kr_zip' || $val->column_type == 'tel') {
             $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["%s[]","%s"]);', $val->column_name, $title);
         } else {
             $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["%s","%s"]);', $val->column_name, $title);
         }
         $errorLang[$val->column_name] = $val->column_title;
     }
     $_SESSION['XE_VALIDATOR_ERROR_LANG'] = $errorLang;
     $js_code[] = '})(jQuery);';
     $js_code[] = '//]]></script>';
     $js_code = implode("\n", $js_code);
     Context::addHtmlHeader($js_code);
 }
 function dispTextyle()
 {
     $oTextyleModel =& getModel('textyle');
     $oTextyleController =& getController('textyle');
     $oDocumentModel =& getModel('document');
     $args->category_srl = Context::get('category_srl');
     $args->search_target = Context::get('search_target');
     $args->search_keyword = Context::get('search_keyword');
     $args->module_srl = $this->module_srl;
     $args->site_srl = $this->site_srl;
     $args->page = Context::get('page');
     $args->page = $args->page > 0 ? $args->page : 1;
     Context::set('page', $args->page);
     // set category
     $category_list = $oDocumentModel->getCategoryList($this->module_srl);
     Context::set('category_list', $category_list);
     $document_srl = Context::get('document_srl');
     if ($document_srl) {
         $oDocument = $oDocumentModel->getDocument($document_srl, false, false);
         if ($oDocument->isExists()) {
             if ($oDocument->get('module_srl') != $this->module_info->module_srl) {
                 return $this->stop('msg_invalid_request');
             }
             Context::setBrowserTitle($this->textyle->get('browser_title') . ' »  ' . $oDocument->getTitle());
             // meta keywords category + tag
             $tag_array = $oDocument->get('tag_list');
             if ($tag_array) {
                 $tag = htmlspecialchars(join(', ', $tag_array));
             } else {
                 $tag = '';
             }
             $category_srl = $oDocument->get('category_srl');
             if ($tag && $category_srl > 0) {
                 $tag = $category_list[$category_srl]->title . ', ' . $tag;
             }
             Context::addHtmlHeader(sprintf('<meta name="keywords" content="%s" />', $tag));
             if ($this->grant->manager) {
                 $oDocument->setGrant();
             }
         } else {
             Context::set('document_srl', '', true);
             $oDocument = $oDocumentModel->getDocument(0, false, false);
         }
     }
     if (!$document_srl) {
         if ($args->category_srl || $args->search_target && $args->search_keyword) {
             $args->list_count = 10;
             $output = $oDocumentModel->getDocumentList($args, false, false);
             $document_list = $output->data;
             Context::set('page_navigation', $output->page_navigation);
             Context::set('document_list', $document_list);
             $this->setTemplateFile('list');
         }
     }
     if ((!$oDocument || !$oDocument->isExists()) && !$document_list) {
         $args->list_count = 1;
         $output = $oDocumentModel->getDocumentList($args, false, false);
         if ($output->data && count($output->data)) {
             $oDocument = array_pop($output->data);
         }
     }
     if ($oDocument && $oDocument->isExists()) {
         $args->document_srl = $oDocument->document_srl;
         $output = executeQuery('textyle.getNextDocument', $args);
         if ($output->data->document_srl) {
             Context::set('prev_document', new documentItem($output->data->document_srl, false));
         }
         $output = executeQuery('textyle.getPrevDocument', $args);
         if ($output->data->document_srl) {
             Context::set('next_document', new documentItem($output->data->document_srl, false));
         }
         Context::set('oDocument', $oDocument);
         $this->setTemplateFile('read');
         Context::addJsFilter($this->module_path . 'tpl/filter', 'insert_comment.xml');
     }
 }
    return;
}
if (Context::getRequestMethod() == "POST" && $called_position == 'before_module_proc') {
    $mode = $_REQUEST['mode'];
    if (!$mode || $mode != "fb") {
        return;
    }
    $oController =& getController('tccommentnotify');
    if (!$oController) {
        return;
    }
    $oController->procNotifyReceived();
    return;
}
if ($called_position == "after_module_proc") {
    $oModel =& getModel('tccommentnotify');
    if (!$oModel) {
        return;
    }
    if ($oModel->checkShouldNotify()) {
        $scriptCode = <<<EndOfScript
        <script type="text/javascript">
        // <![CDATA[
            exec_xml("tccommentnotify", "procDoNotify");
        // ]]>
        </script>

EndOfScript;
        Context::addHtmlHeader($scriptCode);
    }
}
Example #15
0
 /**
  * add meta code extracted from html body to Context, which will be
  * printed inside <header></header> later.
  * @param array $matches
  * @return void
  */
 function _moveMetaToHeader($matches)
 {
     Context::addHtmlHeader($matches[0]);
 }
 function dispMultiPostTextyle()
 {
     // $document_srl is obtained only at Comment Reply and Comment Modify.
     $document_srl = Context::get('document_srl');
     $oDocumentModel =& getModel('document');
     $category = Context::get('category');
     if ($document_srl) {
         $oDocument = $oDocumentModel->getDocument($document_srl, false, false);
         // If document exists, then this is a comment posting case,
         // so we don't need to perform all other operations
         if ($oDocument->isExists()) {
             // If this document doesn't belong to this blog module,
             // ignore it.
             if ($oDocument->get('module_srl') != $this->module_info->module_srl) {
                 return $this->stop('msg_invalid_request');
             }
         } else {
             Context::set('document_srl', '', true);
             return $this->stop('msg_invalid_request');
         }
     } else {
         $alias_title = Context::get('alias_title');
         if ($alias_title) {
             $query_arguments->alias_title = "/" . $alias_title . "/";
             $output = executeQuery('textyle.getDocumentSrlByAlias', $query_arguments);
             if ($output->data) {
                 $document_srl = $output->data->document_srl;
                 $oDocument = $oDocumentModel->getDocument($document_srl, false, false);
                 if ($oDocument->isExists()) {
                     $oDocument->alias_title = $category . '/' . $alias_title . '/';
                 }
             }
         }
     }
     // set the page
     $page = Context::get('page');
     $page = $page > 0 ? $page : 1;
     Context::set('page', $page);
     // get a list of categories of textyle
     $category_list = $oDocumentModel->getCategoryList($this->module_srl);
     Context::set('module_name', $this->textyle->domain);
     Context::set('category_list', $category_list);
     // Wanted Post List
     $args->module_srl = $this->module_srl;
     $args->page_count = 10;
     $args->sort_index = Context::get('sort_index');
     $args->order_type = Context::get('order_type');
     if (!in_array($args->sort_index, $this->order_target)) {
         $args->sort_index = $this->module_info->order_target ? $this->module_info->order_target : 'list_order';
     }
     if (!in_array($args->order_type, array('asc', 'desc'))) {
         $args->order_type = $this->module_info->order_type ? $this->module_info->order_type : 'asc';
     }
     $recentTags = array();
     // 선�� 글� 하나�� 글 목�으로 형성
     if ($oDocument && $oDocument->isExists()) {
         $mode = 'content';
         // set the browser title
         Context::setBrowserTitle($oDocument->getTitle() . ' | ' . $this->textyle->get('browser_title'));
         // set meta keywords category + all tags of the document
         $docTags = $oDocument->get('tags');
         $category_srl = $oDocument->get('category_srl');
         if ($category_srl) {
             $tags = $category_list[$category_srl]->title;
         }
         if ($docTags) {
             $docTagsArray = $oDocument->get('tag_list');
             foreach ($docTagsArray as $tag) {
                 ++$recentTags[$tag];
             }
             $tags .= ($tags ? ',' : '') . $docTags;
         }
         // 선�� 글� 하나� 경우 �전/ 다� 페�지 구함 + 조회수 �가 + referer 기�
         $oDocument->updateReadedCount();
         // referer 남김
         $oTextyleController =& getController('textyle');
         $oTextyleController->insertReferer($oDocument);
         // 관리 권한� 있다면 권한� 부여
         if ($this->grant->manager) {
             $oDocument->setGrant();
         }
         $oDocument->variables['relative_date'] = $this->zdateRelative($oDocument->getRegdateTime());
         $document_list[] = $oDocument;
         $nr_documents = count($document_list);
         Context::set('nr_documents', $nr_documents);
         if ($nr_documents == 1) {
             $_comment_list = $oDocument->getComments();
             if (isset($_comment_list)) {
                 foreach ($_comment_list as $comment) {
                     $comment->variables['relativeDate'] = $this->zdateRelative($comment->getRegdateTime());
                 }
             }
             Context::set('_comment_list', $_comment_list);
         }
         Context::set('document_list', $document_list);
     } else {
         $mode = $this->textyle->getPostStyle();
         // Check if the search is within a specific tag
         $search_target = Context::get('search_target');
         if ($search_target == 'tags') {
             $args->tag = Context::get('search_keyword');
         }
         // Get the category
         $args->category_srl = urldecode($category);
         if ($args->category_srl && !is_numeric($args->category_srl)) {
             $arguments->category_title = $args->category_srl;
             $arguments->module_srl = $this->module_srl;
             $output = executeQuery('textyle.getCategorySrl', $arguments);
             if ($output->data) {
                 $args->category_srl = $output->data->category_srl;
                 $args->categories[] = $args->category_srl;
                 if ($category_list[$args->category_srl]->child_count) {
                     foreach ($category_list[$args->category_srl]->childs as $child) {
                         $args->categories[] = $child;
                     }
                 }
                 $tags = $category_list[$args->category_srl]->title;
                 // set the browser title for this category
                 Context::setBrowserTitle($tags . ' | ' . $this->textyle->get('browser_title'));
             }
         } else {
             $args->category_srl = Context::get('category_srl');
         }
         // If there is such a category
         if ($args->category_srl) {
             Context::set('selected_category', $category_list[$args->category_srl]->title);
         } elseif ($page == 1 && !isset($args->tag)) {
             $args->module_srl = $this->module_srl;
             $args->start_date = date('YmdHis', strtotime("-1 month"));
             $args->end_date = date('YmdHis');
             $args->sort_index = 'readed_count';
             $args->page = 1;
             $args->list_count = 3;
             $mostPopularBlogs = $this->getDocumentItems('textyle.getTopViewDocumentsInDateRange', $args);
             foreach ($mostPopularBlogs->data as $popularBlog) {
                 $popularBlog->variables['relative_date'] = $this->zdateRelative($popularBlog->getRegdateTime());
                 if ($popularBlog->get('alias_title')) {
                     $popularBlog->variables['url'] = getSiteUrl() . $this->textyle->domain . '/entry/' . $popularBlog->get('alias_title');
                 } else {
                     $popularBlog->variables['url'] = getSiteUrl() . $this->textyle->domain . '/' . $popularBlog->get('document_srl');
                 }
             }
             Context::set('mostPopularBlogs', $mostPopularBlogs->data);
             unset($args->start_date);
             unset($args->end_date);
             $args->list_count = 5;
             $args->page = $page;
             $allPopularBlogs = $this->getDocumentItems('textyle.getAllTimeTopViewDocuments', $args);
             foreach ($allPopularBlogs->data as $popularBlog) {
                 $popularBlog->variables['relative_date'] = $this->zdateRelative($popularBlog->getRegdateTime());
                 if ($popularBlog->get('alias_title')) {
                     $popularBlog->variables['url'] = getSiteUrl() . $this->textyle->domain . '/entry/' . $popularBlog->get('alias_title');
                 } else {
                     $popularBlog->variables['url'] = getSiteUrl() . $this->textyle->domain . '/' . $popularBlog->get('document_srl');
                 }
             }
             Context::set('allPopularBlogs', $allPopularBlogs->data);
         }
         // Get a list of latest posts
         $args->module_srl = $this->module_srl;
         $args->list_count = $this->textyle->getPostListCount();
         $args->sort_index = 'list_order';
         $args->page = $page;
         $args->page_count = 10;
         $latestBlogs = $this->getDocumentItems('textyle.getPosts', $args);
         Context::set('latestBlogs', $latestBlogs->data);
         Context::set('page_navigation', $latestBlogs->page_navigation);
         if (isset($latestBlogs->data)) {
             foreach ($latestBlogs->data as $document) {
                 $docTags = $document->get('tag_list');
                 if (isset($docTags)) {
                     foreach ($docTags as $tag) {
                         $recentTags[$tag]++;
                     }
                 }
                 $document->variables['relative_date'] = $this->zdateRelative($document->getRegdateTime());
                 if ($document->get('alias_title')) {
                     $document->variables['url'] = getSiteUrl() . $this->textyle->domain . '/entry/' . $document->get('alias_title');
                 } else {
                     $document->variables['url'] = getSiteUrl() . $this->textyle->domain . '/' . $document->get('document_srl');
                 }
             }
         }
         arsort($recentTags);
         $tags .= ',' . implode(',', array_keys($recentTags));
     }
     Context::addHtmlHeader(sprintf('<meta name="keywords" content="%s" />', $tags));
     Context::addJsFilter($this->module_path . 'skins/' . $this->module_info->skin . '/filter', 'insert_comment.xml');
     Context::set('textyle_mode', $mode);
     Context::set('recentTags', $recentTags);
     Context::set('module_path', $this->module_path);
 }
Example #17
0
 /**
  * Modify admin layout of faceoff
  * @deprecated
  * @return void
  */
 function dispLayoutAdminLayoutModify()
 {
     // Get layout_srl
     $current_module_info = Context::get('current_module_info');
     $layout_srl = $current_module_info->layout_srl;
     // Remove the remaining tmp files because of temporarily saving
     // This part needs to be modified
     $delete_tmp = Context::get('delete_tmp');
     if ($delete_tmp == 'Y') {
         $oLayoutAdminController = getAdminController('layout');
         $oLayoutAdminController->deleteUserLayoutTempFile($layout_srl);
     }
     $oLayoutModel = getModel('layout');
     // layout file is used as a temp.
     $oLayoutModel->setUseUserLayoutTemp();
     // Apply CSS in inline style
     $faceoffcss = $oLayoutModel->_getUserLayoutFaceOffCss($current_module_info->layout_srl);
     $css = FileHandler::readFile($faceoffcss);
     $match = null;
     preg_match_all('/([^\\{]+)\\{([^\\}]*)\\}/is', $css, $match);
     for ($i = 0, $c = count($match[1]); $i < $c; $i++) {
         $name = trim($match[1][$i]);
         $css = trim($match[2][$i]);
         if (!$css) {
             continue;
         }
         $css = str_replace('./images/', Context::getRequestUri() . $oLayoutModel->getUserLayoutImagePath($layout_srl), $css);
         $style[] .= sprintf('"%s":"%s"', $name, $css);
     }
     if (count($style)) {
         $script = '<script type="text/javascript"> var faceOffStyle = {' . implode(',', $style) . '}; </script>';
         Context::addHtmlHeader($script);
     }
     $oTemplate =& TemplateHandler::getInstance();
     Context::set('content', $oTemplate->compile($this->module_path . 'tpl', 'about_faceoff'));
     // Change widget codes in Javascript mode
     $oWidgetController = getController('widget');
     $oWidgetController->setWidgetCodeInJavascriptMode();
     // Set a template file
     $this->setTemplateFile('faceoff_layout_edit');
 }
Example #18
0
}
/**
 * @file blogapicounter.addon.php
 * @author NHN (developers@xpressengine.com)
 * @brief Add blogAPI
 *
 * It enables to write a post by using an external tool such as ms live writer, firefox performancing, zoundry and so on.
 * It should be called before executing the module(before_module_proc). If not, it is forced to shut down.
 **/
// Insert a rsd tag when called_position is after_module_proc
if ($called_position == 'after_module_proc') {
    // Create rsd address of the current module
    $site_module_info = Context::get('site_module_info');
    $rsd_url = getFullSiteUrl($site_module_info->domain, '', 'mid', $site_module_info->mid, 'act', 'api');
    // Insert rsd tag into the header
    Context::addHtmlHeader("    " . '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsd_url . '" />');
}
// If act isnot api, just return
if ($_REQUEST['act'] != 'api') {
    return;
}
// Read func file
require_once './addons/blogapi/blogapi.func.php';
// xmlprc parsing
// Parse the requested xmlrpc
$oXmlParser = new XmlParser();
$xmlDoc = $oXmlParser->parse();
$method_name = $xmlDoc->methodcall->methodname->body;
$params = $xmlDoc->methodcall->params->param;
if ($params && !is_array($params)) {
    $params = array($params);
 /**
  * get a module instance and execute an action
  * @return ModuleObject executed module instance
  * */
 function procModule()
 {
     $oModuleModel = getModel('module');
     $display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
     // If error occurred while preparation, return a message instance
     if ($this->error) {
         $this->_setInputErrorToContext();
         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // Get action information with conf/module.xml
     $xml_info = $oModuleModel->getModuleActionXml($this->module);
     // If not installed yet, modify act
     if ($this->module == "install") {
         if (!$this->act || !$xml_info->action->{$this->act}) {
             $this->act = $xml_info->default_index_act;
         }
     }
     // if act exists, find type of the action, if not use default index act
     if (!$this->act) {
         $this->act = $xml_info->default_index_act;
     }
     // still no act means error
     if (!$this->act) {
         $this->error = 'msg_module_is_not_exists';
         $this->httpStatusCode = '404';
         $this->_setInputErrorToContext();
         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // get type, kind
     $type = $xml_info->action->{$this->act}->type;
     $ruleset = $xml_info->action->{$this->act}->ruleset;
     $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
     if (!$kind && $this->module == 'admin') {
         $kind = 'admin';
     }
     // check REQUEST_METHOD in controller
     if ($type == 'controller') {
         $allowedMethod = $xml_info->action->{$this->act}->method;
         if (!$allowedMethod) {
             $allowedMethodList[0] = 'POST';
         } else {
             $allowedMethodList = explode('|', strtoupper($allowedMethod));
         }
         if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) {
             $this->error = "msg_invalid_request";
             $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
             $oMessageObject->setError(-1);
             $oMessageObject->setMessage($this->error);
             $oMessageObject->dispMessage();
             return $oMessageObject;
         }
     }
     if ($this->module_info->use_mobile != "Y") {
         Mobile::setMobile(FALSE);
     }
     $logged_info = Context::get('logged_info');
     // check CSRF for POST actions
     if (Context::getRequestMethod() === 'POST' && Context::isInstalled() && $this->act !== 'procFileUpload' && !checkCSRF()) {
         $this->error = 'msg_invalid_request';
         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         return $oMessageObject;
     }
     // Admin ip
     if ($kind == 'admin' && $_SESSION['denied_admin'] == 'Y') {
         $this->_setInputErrorToContext();
         $this->error = "msg_not_permitted_act";
         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         return $oMessageObject;
     }
     // if(type == view, and case for using mobilephone)
     if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) {
         $orig_type = "view";
         $type = "mobile";
         // create a module instance
         $oModule = $this->getModuleInstance($this->module, $type, $kind);
         if (!is_object($oModule) || !method_exists($oModule, $this->act)) {
             $type = $orig_type;
             Mobile::setMobile(FALSE);
             $oModule = $this->getModuleInstance($this->module, $type, $kind);
         }
     } else {
         // create a module instance
         $oModule = $this->getModuleInstance($this->module, $type, $kind);
     }
     if (!is_object($oModule)) {
         $this->_setInputErrorToContext();
         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
         $oMessageObject->setError(-1);
         $oMessageObject->setMessage($this->error);
         $oMessageObject->dispMessage();
         if ($this->httpStatusCode) {
             $oMessageObject->setHttpStatusCode($this->httpStatusCode);
         }
         return $oMessageObject;
     }
     // If there is no such action in the module object
     if (!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act)) {
         if (!Context::isInstalled()) {
             $this->_setInputErrorToContext();
             $this->error = 'msg_invalid_request';
             $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
             $oMessageObject->setError(-1);
             $oMessageObject->setMessage($this->error);
             $oMessageObject->dispMessage();
             if ($this->httpStatusCode) {
                 $oMessageObject->setHttpStatusCode($this->httpStatusCode);
             }
             return $oMessageObject;
         }
         $forward = NULL;
         // 1. Look for the module with action name
         if (preg_match('/^([a-z]+)([A-Z])([a-z0-9\\_]+)(.*)$/', $this->act, $matches)) {
             $module = strtolower($matches[2] . $matches[3]);
             $xml_info = $oModuleModel->getModuleActionXml($module);
             if ($xml_info->action->{$this->act} && (stripos($this->act, 'admin') !== FALSE || $xml_info->action->{$this->act}->standalone != 'false')) {
                 $forward = new stdClass();
                 $forward->module = $module;
                 $forward->type = $xml_info->action->{$this->act}->type;
                 $forward->ruleset = $xml_info->action->{$this->act}->ruleset;
                 $forward->act = $this->act;
             } else {
                 $this->error = 'msg_invalid_request';
                 $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                 $oMessageObject->setError(-1);
                 $oMessageObject->setMessage($this->error);
                 $oMessageObject->dispMessage();
                 return $oMessageObject;
             }
         }
         if (!$forward) {
             $forward = $oModuleModel->getActionForward($this->act);
         }
         if ($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
             $kind = stripos($forward->act, 'admin') !== FALSE ? 'admin' : '';
             $type = $forward->type;
             $ruleset = $forward->ruleset;
             $tpl_path = $oModule->getTemplatePath();
             $orig_module = $oModule;
             $xml_info = $oModuleModel->getModuleActionXml($forward->module);
             // SECISSUE also check foward act method
             // check REQUEST_METHOD in controller
             if ($type == 'controller') {
                 $allowedMethod = $xml_info->action->{$forward->act}->method;
                 if (!$allowedMethod) {
                     $allowedMethodList[0] = 'POST';
                 } else {
                     $allowedMethodList = explode('|', strtoupper($allowedMethod));
                 }
                 if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) {
                     $this->error = "msg_invalid_request";
                     $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                     $oMessageObject->setError(-1);
                     $oMessageObject->setMessage($this->error);
                     $oMessageObject->dispMessage();
                     return $oMessageObject;
                 }
             }
             if ($type == "view" && Mobile::isFromMobilePhone()) {
                 $orig_type = "view";
                 $type = "mobile";
                 // create a module instance
                 $oModule = $this->getModuleInstance($forward->module, $type, $kind);
                 if (!is_object($oModule) || !method_exists($oModule, $this->act)) {
                     $type = $orig_type;
                     Mobile::setMobile(FALSE);
                     $oModule = $this->getModuleInstance($forward->module, $type, $kind);
                 }
             } else {
                 $oModule = $this->getModuleInstance($forward->module, $type, $kind);
             }
             if (!is_object($oModule)) {
                 $this->_setInputErrorToContext();
                 $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                 $oMessageObject->setError(-1);
                 $oMessageObject->setMessage('msg_module_is_not_exists');
                 $oMessageObject->dispMessage();
                 if ($this->httpStatusCode) {
                     $oMessageObject->setHttpStatusCode($this->httpStatusCode);
                 }
                 return $oMessageObject;
             }
             if ($this->module == "admin" && $type == "view") {
                 if ($logged_info->is_admin == 'Y') {
                     if ($this->act != 'dispLayoutAdminLayoutModify') {
                         $oAdminView = getAdminView('admin');
                         $oAdminView->makeGnbUrl($forward->module);
                         $oModule->setLayoutPath("./modules/admin/tpl");
                         $oModule->setLayoutFile("layout.html");
                     }
                 } else {
                     $this->_setInputErrorToContext();
                     $this->error = 'msg_is_not_administrator';
                     $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                     $oMessageObject->setError(-1);
                     $oMessageObject->setMessage($this->error);
                     $oMessageObject->dispMessage();
                     return $oMessageObject;
                 }
             }
             if ($kind == 'admin') {
                 $grant = $oModuleModel->getGrant($this->module_info, $logged_info);
                 if (!$grant->manager) {
                     $this->_setInputErrorToContext();
                     $this->error = 'msg_is_not_manager';
                     $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                     $oMessageObject->setError(-1);
                     $oMessageObject->setMessage($this->error);
                     $oMessageObject->dispMessage();
                     return $oMessageObject;
                 } else {
                     if (!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager') {
                         $this->_setInputErrorToContext();
                         $this->error = 'msg_is_not_administrator';
                         $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
                         $oMessageObject->setError(-1);
                         $oMessageObject->setMessage($this->error);
                         $oMessageObject->dispMessage();
                         return $oMessageObject;
                     }
                 }
             }
         } else {
             if ($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act)) {
                 $this->act = $xml_info->default_index_act;
             } else {
                 $this->error = 'msg_invalid_request';
                 $oModule->setError(-1);
                 $oModule->setMessage($this->error);
                 return $oModule;
             }
         }
     }
     // ruleset check...
     if (!empty($ruleset)) {
         $rulesetModule = $forward->module ? $forward->module : $this->module;
         $rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid);
         if (!empty($rulesetFile)) {
             if ($_SESSION['XE_VALIDATOR_ERROR_LANG']) {
                 $errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG'];
                 foreach ($errorLang as $key => $val) {
                     Context::setLang($key, $val);
                 }
                 unset($_SESSION['XE_VALIDATOR_ERROR_LANG']);
             }
             $Validator = new Validator($rulesetFile);
             $result = $Validator->validate();
             if (!$result) {
                 $lastError = $Validator->getLastError();
                 $returnUrl = Context::get('error_return_url');
                 $errorMsg = $lastError['msg'] ? $lastError['msg'] : 'validation error';
                 //for xml response
                 $oModule->setError(-1);
                 $oModule->setMessage($errorMsg);
                 //for html redirect
                 $this->error = $errorMsg;
                 $_SESSION['XE_VALIDATOR_ERROR'] = -1;
                 $_SESSION['XE_VALIDATOR_MESSAGE'] = $this->error;
                 $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
                 $_SESSION['XE_VALIDATOR_RETURN_URL'] = $returnUrl;
                 $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
                 $this->_setInputValueToSession();
                 return $oModule;
             }
         }
     }
     $oModule->setAct($this->act);
     $this->module_info->module_type = $type;
     $oModule->setModuleInfo($this->module_info, $xml_info);
     $skipAct = array('dispEditorConfigPreview' => 1, 'dispLayoutPreviewWithModule' => 1);
     $db_use_mobile = Mobile::isMobileEnabled();
     if ($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true) {
         global $lang;
         $header = '<style>div.xe_mobile{opacity:0.7;margin:1em 0;padding:.5em;background:#333;border:1px solid #666;border-left:0;border-right:0}p.xe_mobile{text-align:center;margin:1em 0}a.xe_mobile{color:#ff0;font-weight:bold;font-size:24px}@media only screen and (min-width:500px){a.xe_mobile{font-size:15px}}</style>';
         $footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="' . getUrl('m', '1') . '">' . $lang->msg_pc_to_mobile . '</a></p></div>';
         Context::addHtmlHeader($header);
         Context::addHtmlFooter($footer);
     }
     if ($type == "view" && $kind != 'admin') {
         $module_config = $oModuleModel->getModuleConfig('module');
         if ($module_config->htmlFooter) {
             Context::addHtmlFooter($module_config->htmlFooter);
         }
         if ($module_config->siteTitle) {
             $siteTitle = Context::getBrowserTitle();
             if (!$siteTitle) {
                 Context::setBrowserTitle($module_config->siteTitle);
             }
         }
     }
     // if failed message exists in session, set context
     $this->_setInputErrorToContext();
     $procResult = $oModule->proc();
     $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
     if (!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()])) {
         $error = $oModule->getError();
         $message = $oModule->getMessage();
         $messageType = $oModule->getMessageType();
         $redirectUrl = $oModule->getRedirectUrl();
         if ($messageType == 'error') {
             debugPrint($message, 'ERROR');
         }
         if (!$procResult) {
             $this->error = $message;
             if (!$redirectUrl && Context::get('error_return_url')) {
                 $redirectUrl = Context::get('error_return_url');
             }
             $this->_setInputValueToSession();
         } else {
         }
         $_SESSION['XE_VALIDATOR_ERROR'] = $error;
         $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
         if ($message != 'success') {
             $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
         }
         $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
         if (Context::get('xeVirtualRequestMethod') != 'xml') {
             $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
         }
     }
     unset($logged_info);
     return $oModule;
 }
Example #20
0
 /**
  * @brief Save the file and return if a file is requested by http
  */
 function getHtmlPage($path, $caching_interval, $cache_file)
 {
     // Verify cache
     if ($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval * 60 > $_SERVER['REQUEST_TIME']) {
         $content = FileHandler::readFile($cache_file);
     } else {
         FileHandler::getRemoteFile($path, $cache_file);
         $content = FileHandler::readFile($cache_file);
     }
     // Create opage controller
     $oPageController = getController('page');
     // change url of image, css, javascript and so on if the page is from external server
     $content = $oPageController->replaceSrc($content, $path);
     // Change the document to utf-8 format
     $buff = new stdClass();
     $buff->content = $content;
     $buff = Context::convertEncoding($buff);
     $content = $buff->content;
     // Extract a title
     $title = $oPageController->getTitle($content);
     if ($title) {
         Context::setBrowserTitle($title);
     }
     // Extract header script
     $head_script = $oPageController->getHeadScript($content);
     if ($head_script) {
         Context::addHtmlHeader($head_script);
     }
     // Extract content from the body
     $body_script = $oPageController->getBodyScript($content);
     if (!$body_script) {
         $body_script = $content;
     }
     return $content;
 }
Example #21
0
 /**
  * Preview a layout
  * @return void|Object (void : success, Object : fail)
  */
 function dispLayoutPreview()
 {
     // admin check
     // this act is admin view but in normal view because do not load admin css/js files
     $logged_info = Context::get('logged_info');
     if ($logged_info->is_admin != 'Y') {
         return $this->stop('msg_invalid_request');
     }
     $layout_srl = Context::get('layout_srl');
     $code = Context::get('code');
     $code_css = Context::get('code_css');
     if (!$layout_srl || !$code) {
         return new Object(-1, 'msg_invalid_request');
     }
     // Get the layout information
     $oLayoutModel = getModel('layout');
     $layout_info = $oLayoutModel->getLayout($layout_srl);
     if (!$layout_info) {
         return new Object(-1, 'msg_invalid_request');
     }
     // Separately handle the layout if its type is faceoff
     if ($layout_info && $layout_info->type == 'faceoff') {
         $oLayoutModel->doActivateFaceOff($layout_info);
     }
     // Apply CSS directly
     Context::addHtmlHeader("<style type=\"text/css\" charset=\"UTF-8\">" . $code_css . "</style>");
     // Set names and values of extra_vars to $layout_info
     if ($layout_info->extra_var_count) {
         foreach ($layout_info->extra_var as $var_id => $val) {
             $layout_info->{$var_id} = $val->value;
         }
     }
     // menu in layout information becomes an argument for Context:: set
     if ($layout_info->menu_count) {
         foreach ($layout_info->menu as $menu_id => $menu) {
             $menu->php_file = FileHandler::getRealPath($menu->php_file);
             if (FileHandler::exists($menu->php_file)) {
                 include $menu->php_file;
             }
             Context::set($menu_id, $menu);
         }
     }
     Context::set('layout_info', $layout_info);
     Context::set('content', Context::getLang('layout_preview_content'));
     // Temporary save the codes
     $edited_layout_file = _XE_PATH_ . 'files/cache/layout/tmp.tpl';
     FileHandler::writeFile($edited_layout_file, $code);
     // Compile
     $oTemplate =& TemplateHandler::getInstance();
     $layout_path = $layout_info->path;
     $layout_file = 'layout';
     $layout_tpl = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
     Context::set('layout', 'none');
     // Convert widgets and others
     $oContext =& Context::getInstance();
     Context::set('layout_tpl', $layout_tpl);
     // Delete Temporary Files
     FileHandler::removeFile($edited_layout_file);
     $this->setTemplateFile('layout_preview');
 }
<?php

if (!defined("__ZBXE__")) {
    exit;
}
/**
 * @file planet_todo.addon.php
 * @author SOL군 (sol@ngleader.com)
 * @brief
 **/
if ($called_position == 'after_module_proc' && Context::getResponseMethod() != "XMLRPC" && Context::getResponseMethod() != "JSON") {
    $planet = Context::get('planet');
    if (!$planet || !$planet->isMyPlanet()) {
        return;
    }
    $oPlanetModel =& getModel('planet');
    $countBookmark = $oPlanetModel->getTagSearchResultCount($planet->getModuleSrl(), 'bookmark');
    Context::addHtmlHeader("<script type=\"text/javascript\">//<![CDATA[\nvar planet_bookmark_count=" . (int) $countBookmark . ";\n//]]></script>");
    Context::addHtmlHeader("<link rel=\"stylesheet\" href=\"./addons/planet_bookmark/style.css\" type=\"text/css\" />");
    Context::addJsFile('./addons/planet_bookmark/planet_bookmark.js');
}
Example #23
0
 /**
  * @brief board module message
  **/
 function alertMessage($message)
 {
     $script = sprintf('<script> xAddEventListener(window,"load", function() { alert("%s"); } );</script>', Context::getLang($message));
     Context::addHtmlHeader($script);
 }
Example #24
0
 function dispSocialxeTextyleTool()
 {
     // 텍스타일의 최신 버전이 아니면 직접 처리
     $oTextyleView =& getView('textyle');
     if (!method_exists($oTextyleView, 'initTool')) {
         $oTextyleModel =& getModel('textyle');
         $site_module_info = Context::get('site_module_info');
         $textyle = $oTextyleModel->getTextyle($site_module_info->index_module_srl);
         Context::set('textyle', $textyle);
         Context::set('custom_menu', $oTextyleModel->getTextyleCustomMenu());
         $template_path = sprintf("%stpl", $oTextyleView->module_path);
         $this->setLayoutPath($template_path);
         $this->setLayoutFile('_tool_layout');
         if ($_COOKIE['tclnb']) {
             Context::addBodyClass('lnbClose');
         } else {
             Context::addBodyClass('lnbToggleOpen');
         }
         // browser title 지정
         Context::setBrowserTitle($textyle->get('browser_title') . ' - admin');
         Context::addHtmlHeader('<link rel="shortcut icon" href="' . $textyle->getFaviconSrc() . '" />');
     }
     // 설정 정보를 받아옴
     Context::set('config', $this->config);
     // 서비스 목록
     $provider_list = $this->providerManager->getFullProviderList();
     Context::set('provider_list', $provider_list);
     // 템플릿 파일 지정
     $this->setTemplatePath($this->module_path . 'tpl');
     $this->setTemplateFile('textyleConfig');
 }
Example #25
0
 /**
  * Add javascript codes into the header by checking values of document_extra_keys type, required and others
  * @param int $module_srl
  * @return void
  */
 function addXmlJsFilter($module_srl)
 {
     $oDocumentModel = getModel('document');
     $extra_keys = $oDocumentModel->getExtraKeys($module_srl);
     if (!count($extra_keys)) {
         return;
     }
     $js_code = array();
     $js_code[] = '<script>//<![CDATA[';
     $js_code[] = '(function($){';
     $js_code[] = 'var validator = xe.getApp("validator")[0];';
     $js_code[] = 'if(!validator) return false;';
     $logged_info = Context::get('logged_info');
     foreach ($extra_keys as $idx => $val) {
         $idx = $val->idx;
         if ($val->type == 'kr_zip') {
             $idx .= '[]';
         }
         $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
         $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
         if ($val->is_required == 'Y') {
             $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
         }
     }
     $js_code[] = '})(jQuery);';
     $js_code[] = '//]]></script>';
     $js_code = implode("\n", $js_code);
     Context::addHtmlHeader($js_code);
 }
if ($called_position == 'before_module_init' && $this->module != 'member') {
    // 커뮤니케이션 모듈의 언어파일을 읽음
    Context::loadLang('./modules/communication/lang');
    // 회원 로그인 정보중에서 쪽지등의 메뉴를 추가
    $oMemberController =& getController('member');
    $oMemberController->addMemberMenu('dispCommunicationFriend', 'cmd_view_friend');
    $oMemberController->addMemberMenu('dispCommunicationMessages', 'cmd_view_message_box');
    // 새로운 쪽지에 대한 플래그가 있으면 쪽지 보기 팝업 띄움
    $flag_path = './files/member_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl);
    $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl);
    if (file_exists($flag_file)) {
        $new_message_count = FileHandler::readFile($flag_file);
        FileHandler::removeFile($flag_file);
        Context::loadLang('./addons/member_communication/lang');
        $script = sprintf('<script type="text/javascript"> jQuery(function() { if(confirm("%s")) { popopen("%s"); } }); </script>', sprintf(Context::getLang('alert_new_message_arrived'), $new_message_count), Context::getRequestUri() . '?module=communication&act=dispCommunicationNewMessage');
        Context::addHtmlHeader($script);
    }
    /**
     * 기능 수행 : 사용자 이름을 클릭시 요청되는 팝업메뉴의 메뉴에 쪽지 발송, 친구추가등의 링크 추가
     **/
} elseif ($called_position == 'before_module_proc' && $this->act == 'getMemberMenu') {
    $oMemberController =& getController('member');
    $member_srl = Context::get('target_srl');
    $mid = Context::get('cur_mid');
    // communication 모델 객체 생성
    $oCommunicationModel =& getModel('communication');
    // 자신이라면 쪽지함 보기 기능 추가
    if ($logged_info->member_srl == $member_srl) {
        // 자신의 쪽지함 보기 기능 추가
        $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationMessages'), 'cmd_view_message_box', './modules/communication/tpl/images/icon_message_box.gif', 'self');
        // 친구 목록 보기
 /**
  * @brief module, mid, document_srl을 이용하여 모듈을 찾고 act를 실행하기 위한 준비를 함
  **/
 function init()
 {
     // ModuleModel 객체 생성
     $oModuleModel =& getModel('module');
     $site_module_info = Context::get('site_module_info');
     if (!$this->document_srl && $this->mid && $this->entry) {
         $oDocumentModel =& getModel('document');
         $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry);
         if ($this->document_srl) {
             Context::set('document_srl', $this->document_srl);
         }
     }
     // 문서번호(document_srl)가 있을 경우 모듈 정보를 구해옴
     if ($this->document_srl && !$this->module) {
         $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
         // 문서가 존재하지 않으면 문서 정보를 제거
         if (!$module_info) {
             unset($this->document_srl);
             // 문서가 존재할 경우 모듈 정보를 바탕으로 virtual site 및 mid 비교
         } else {
             // mid 값이 다르면 문서의 mid로 설정
             if ($this->mid != $module_info->mid) {
                 $this->mid = $module_info->mid;
                 Context::set('mid', $module_info->mid, true);
             }
         }
         // 요청된 모듈과 문서 번호가 다르면 문서 번호에 의한 모듈 정보를 제거
         if ($this->module && $module_info->module != $this->module) {
             unset($module_info);
         }
     }
     // 모듈정보를 구하지 못했고 mid 요청이 있으면 mid에 해당하는 모듈 정보를 구함
     if (!$module_info && $this->mid) {
         $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl);
         //if($this->module && $module_info->module != $this->module) unset($module_info);
     }
     // module_site_srl과 site_srl 값이 다르면 redirect 시도
     if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) {
         $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
         header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
         return false;
     }
     // 역시 모듈을 못 찾았고 $module이 없다면 기본 모듈을 찾아봄
     if (!$module_info && !$this->module) {
         $module_info = $site_module_info;
     }
     if (!$module_info && !$this->module && $site_module_info->module_site_srl) {
         $module_info = $site_module_info;
     }
     // 모듈정보와 사이트 모듈정보가 다르면(다른 사이트이면) 페이지 리다이렉트
     if ($module_info && $module_info->site_srl != $site_module_info->site_srl) {
         // 현재 요청된 모듈이 가상 사이트 모듈일 경우
         if ($module_info->site_srl) {
             $site_info = $oModuleModel->getSiteInfo($module_info->site_srl);
             $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
             // 가상 사이트 모듈이 아닌데 가상 사이트에서 호출되었을 경우
         } else {
             $db_info = Context::getDBInfo();
             if (!$db_info->default_url) {
                 return die("기본 URL이 정해지지 않아서 동작을 중지합니다");
             } else {
                 $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
             }
         }
         header("location:" . $redirect_url);
         return false;
     }
     // 모듈 정보가 찾아졌을 경우 모듈 정보에서 기본 변수들을 구함, 모듈 정보에서 module 이름을 구해움
     if ($module_info) {
         $this->module = $module_info->module;
         $this->mid = $module_info->mid;
         $this->module_info = $module_info;
         Context::setBrowserTitle($module_info->browser_title);
         $part_config = $oModuleModel->getModulePartConfig('layout', $module_info->layout_srl);
         Context::addHtmlHeader($part_config->header_script);
     }
     // 모듈정보에 module과 mid를 강제로 지정
     $this->module_info->module = $this->module;
     $this->module_info->mid = $this->mid;
     // 여기까지도 모듈 정보를 찾지 못했다면 깔끔하게 시스템 오류 표시
     if (!$this->module) {
         $this->error = 'msg_module_is_not_exists';
     }
     // mid값이 있을 경우 mid값을 세팅
     if ($this->mid) {
         Context::set('mid', $this->mid, true);
     }
     // 실제 동작을 하기 전에 trigger 호출
     $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info);
     if (!$output->toBool()) {
         $this->error = $output->getMessage();
         return false;
     }
     // 현재 모듈의 정보를 세팅
     Context::set('current_module_info', $this->module_info);
     return true;
 }
Example #28
0
 /**
  * @brief convert editor component codes to be returned and specify content style.
  **/
 function triggerEditorComponentCompile(&$content)
 {
     if (Context::getResponseMethod() != 'HTML') {
         return new Object();
     }
     $module_info = Context::get('module_info');
     $module_srl = $module_info->module_srl;
     if ($module_srl) {
         $oEditorModel =& getModel('editor');
         $editor_config = $oEditorModel->getEditorConfig($module_srl);
         $content_style = $editor_config->content_style;
         if ($content_style) {
             $path = _XE_PATH_ . 'modules/editor/styles/' . $content_style . '/';
             if (is_dir($path) && file_exists($path . 'style.ini')) {
                 $ini = file($path . 'style.ini');
                 for ($i = 0, $c = count($ini); $i < $c; $i++) {
                     $file = trim($ini[$i]);
                     if (!$file) {
                         continue;
                     }
                     if (preg_match('/\\.css$/i', $file)) {
                         Context::addCSSFile('./modules/editor/styles/' . $content_style . '/' . $file, false);
                     } elseif (preg_match('/\\.js/i', $file)) {
                         Context::addJsFile('./modules/editor/styles/' . $content_style . '/' . $file, false);
                     }
                 }
             }
         }
         $content_font = $editor_config->content_font;
         $content_font_size = $editor_config->content_font_size;
         if ($content_font || $content_font_size) {
             $buff = '<style type="text/css"> .xe_content { ';
             if ($content_font) {
                 $buff .= 'font-family:' . $content_font . ';';
             }
             if ($content_font_size) {
                 $buff .= 'font-size:' . $content_font_size . ';';
             }
             $buff .= ' }</style>';
             Context::addHtmlHeader($buff);
         }
     }
     $content = $this->transComponent($content);
     return new Object();
 }
 /**
  * @brief faceoff의 관리자 layout 수정
  **/
 function dispLayoutAdminLayoutModify()
 {
     //layout_srl 를 가져온다
     $current_module_info = Context::get('current_module_info');
     $layout_srl = $current_module_info->layout_srl;
     // 파일로 임시저장을 하기때문에 남아 있을지 모르는 tmp를 지운다
     // to do 개선이 필요
     $delete_tmp = Context::get('delete_tmp');
     if ($delete_tmp == 'Y') {
         $oLayoutAdminController =& getAdminController('layout');
         $oLayoutAdminController->deleteUserLayoutTempFile($layout_srl);
     }
     $oLayoutModel =& getModel('layout');
     // layout file들은 temp로 사용한다.
     $oLayoutModel->setUseUserLayoutTemp();
     // css 를 inline style로 뽑는다
     $faceoffcss = $oLayoutModel->_getUserLayoutFaceOffCss($current_module_info->layout_srl);
     $css = FileHandler::readFile($faceoffcss);
     $match = null;
     preg_match_all('/([^\\{]+)\\{([^\\}]*)\\}/is', $css, $match);
     for ($i = 0, $c = count($match[1]); $i < $c; $i++) {
         $name = trim($match[1][$i]);
         $css = trim($match[2][$i]);
         if (!$css) {
             continue;
         }
         $css = str_replace('./images/', Context::getRequestUri() . $oLayoutModel->getUserLayoutImagePath($layout_srl), $css);
         $style[] .= sprintf('"%s":"%s"', $name, $css);
     }
     if (count($style)) {
         $script = '<script type="text/javascript"> var faceOffStyle = {' . implode(',', $style) . '}; </script>';
         Context::addHtmlHeader($script);
     }
     $oTemplate =& TemplateHandler::getInstance();
     Context::set('content', $oTemplate->compile($this->module_path . 'tpl', 'about_faceoff'));
     // 위젯 코드를 Javascript 수정모드로 변경
     $oWidgetController =& getController('widget');
     $oWidgetController->setWidgetCodeInJavascriptMode();
     // 템플릿 파일 지정
     $this->setTemplateFile('faceoff_layout_edit');
 }
                    unset($_SESSION['notify_title']);
                    unset($_SESSION['notify_srl']);
                    $new_document_notify = "<script type='text/javascript'>\n\t\t\t\t\t\t\t\t\t\t\tsocket.emit('sendToServer', {title :'" . $title . "' , document_srl : '" . $srl . "'});\n\t\t\t\t\t\t\t\t\t\t\t</script>";
                    Context::addHtmlHeader($new_document_notify);
                } else {
                    if ($_SESSION['notify_type'] == "comment") {
                        $title = $_SESSION['notify_title'];
                        $srl = $_SESSION['notify_srl'];
                        $name = $_SESSION['notify_name'];
                        $type = $_SESSION['notify_type'];
                        unset($_SESSION['notify_type']);
                        unset($_SESSION['notify_title']);
                        unset($_SESSION['notify_srl']);
                        unset($_SESSION['notify_name']);
                        $new_document_notify = "<script type='text/javascript'>\n\t\t\t\t\t\t\t\t\t\t\tsocket.emit('sendToServer', {title :'" . $title . "' , document_srl : '" . $srl . "' , name : '" . $name . "' , type : '" . $type . "'});\n\t\t\t\t\t\t\t\t\t\t</script>";
                        Context::addHtmlHeader($new_document_notify);
                    } else {
                        if ($_SESSION['notify_type'] == 'comment') {
                            unset($_SESSION['notify_name']);
                        }
                        unset($_SESSION['notify_modify']);
                        unset($_SESSION['notify_type']);
                        unset($_SESSION['notify_title']);
                        unset($_SESSION['notify_srl']);
                    }
                }
            }
        }
    }
} else {
    if ($called_position == 'after_module_proc' && in_array($this->mid, explode(",", $addon_info->module_id))) {