function triggerDisplayBefore(&$content) { if (Context::getResponseMethod() != 'HTML') { return new Object(); } $grant = Context::get('grant'); $logged_info = Context::get('logged_info'); if ((!$grant || $grant->manager != 1) && $logged_info->is_admin != 'Y') { return new Object(); } preg_replace_callback('!<img([^\\>]*)widget=([^\\>]*?)\\>!is', array($this, '_setGrantByWidgetSequence'), $content); Context::loadFile('./modules/magiccontent/tpl/js/magiccontent_for_admin.js'); Context::loadFile('./modules/magiccontent/tpl/css/magiccontent_for_admin.css'); return new Object(); }
/** * @brief Aroundmap 모듈이 사용가능한지 체크 * @param $act 현재페이지의 액션 값 * @param $module_srl 현재 게시판의 번호 * @return true/false */ function isAroundmapEnable($act, $module_srl) { // 현재의 액션이 쓰기(수정), 보기 페이지인지 확인 if ($act != 'dispBoardWrite' && $act != 'dispBoardContent' && $act != null) { return false; } // 현재 페이지가 HTML페이지인지 확인 if (Context::getResponseMethod() != 'HTML') { return false; } // 현재 모듈이 aroundmap에 적용된 모듈인지 확인 if (!$module_srl || !$this->isModuleEnable($module_srl)) { return false; } return true; }
/** * @brief Editor of the components separately if you use a unique code to the html code for a method to change * * Images and multimedia, seolmundeung unique code is required for the editor component added to its own code, and then * DocumentModule:: transContent() of its components transHtml() method call to change the html code for your own */ function transHTML($xml_obj) { $gallery_info = new stdClass(); $gallery_info->srl = rand(111111, 999999); $gallery_info->border_thickness = (int) $xml_obj->attrs->border_thickness; $gallery_info->gallery_style = $xml_obj->attrs->gallery_style; $color_preg = "/^([a-fA-F0-9]{6})/"; $gallery_info->border_color = preg_replace($color_preg, "#\$1", $xml_obj->attrs->border_color); $gallery_info->bg_color = preg_replace($color_preg, "#\$1", $xml_obj->attrs->bg_color); $gallery_info->gallery_align = $xml_obj->attrs->gallery_align; if (!in_array($gallery_info->gallery_align, array('left', 'center', 'right'))) { $gallery_info->gallery_align = 'center'; } $images_list = $xml_obj->attrs->images_list; $images_list = preg_replace('/\\.(gif|jpe?g|png) /i', ".\\1\n", $images_list); $images_list = explode("\n", trim($images_list)); $gallery_info->images_list = preg_grep("/^[a-z0-9\\/]+\\.(gif|jpe?g|png)+\$/", $images_list); // If you set the output to output the XML code generated a list of the image if (Context::getResponseMethod() == 'XMLRPC') { $output = array(); for ($i = 0; $i < count($gallery_info->images_list); $i++) { $output[] = sprintf('<img src="%s" alt="" />', $gallery_info->images_list[$i]); } $output[] = '<br />'; return implode('<br />', $output); } // HTML gallery output, the output settings via the template for the conversion to generate the html code should preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i', $xml_obj->attrs->style, $matches); $gallery_info->width = trim($matches[3][0]); if (!$gallery_info->width) { $gallery_info->width = 400; } Context::set('gallery_info', $gallery_info); $tpl_path = $this->component_path . 'tpl'; Context::set("tpl_path", $tpl_path); if ($gallery_info->gallery_style == "list") { $tpl_file = 'list_gallery.html'; } elseif ($gallery_info->gallery_style == "slide") { $tpl_file = 'slide_gallery.html'; } else { $tpl_file = 'jquery.bxslider.html'; } $oTemplate =& TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); }
/** * @brief Editor of the components separately if you use a unique code to the html code for a method to change * * Images and multimedia, seolmundeung unique code is required for the editor component added to its own code, and then * DocumentModule:: transContent() of its components transHtml() method call to change the html code for your own **/ function transHTML($xml_obj) { $gallery_info->srl = rand(111111, 999999); $gallery_info->border_thickness = $xml_obj->attrs->border_thickness; $gallery_info->gallery_style = $xml_obj->attrs->gallery_style; $gallery_info->border_color = $xml_obj->attrs->border_color; $gallery_info->bg_color = $xml_obj->attrs->bg_color; $gallery_info->gallery_align = $xml_obj->attrs->gallery_align; $images_list = $xml_obj->attrs->images_list; $images_list = preg_replace('/\\.(gif|jpg|jpeg|png) /i', ".\\1\n", $images_list); $gallery_info->images_list = explode("\n", trim($images_list)); // If you set the output to output the XML code generated a list of the image if (Context::getResponseMethod() == 'XMLRPC') { $output = ''; for ($i = 0; $i < count($gallery_info->images_list); $i++) { $output .= sprintf('<img src="%s" alt="" /><br />', $gallery_info->images_list[$i]); } return $output; } // HTML gallery output, the output settings via the template for the conversion to generate the html code should preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i', $xml_obj->attrs->style, $matches); $gallery_info->width = trim($matches[3][0]); if (!$gallery_info->width) { $gallery_info->width = 400; } Context::set('gallery_info', $gallery_info); $tpl_path = $this->component_path . 'tpl'; Context::set("tpl_path", $tpl_path); if ($gallery_info->gallery_style == "list") { $tpl_file = 'list_gallery.html'; } else { $tpl_file = 'slide_gallery.html'; } $oTemplate =& TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); }
/** * @brief Editor of the components separately if you use a unique code to the html code for a method to change * * Images and multimedia, seolmundeung unique code is required for the editor component added to its own code, and then * DocumentModule:: transContent() of its components transHtml() method call to change the html code for your own **/ function transHTML($xml_obj) { $src = $xml_obj->attrs->multimedia_src; $style = $xml_obj->attrs->style; preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i', $style, $matches); $width = trim($matches[3][0]); $height = trim($matches[3][1]); if (!$width) { $width = 400; } if (!$height) { $height = 400; } $auto_start = $xml_obj->attrs->auto_start; if ($auto_start != "true") { $auto_start = "false"; } else { $auto_start = "true"; } $wmode = $xml_obj->attrs->wmode; if ($wmode == 'window') { $wmode = 'window'; } elseif ($wmode == 'opaque') { $wmode = 'opaque'; } else { $wmode = 'transparent'; } $caption = $xml_obj->body; $src = str_replace(array('&', '"'), array('&', '&qout;'), $src); $src = str_replace('&amp;', '&', $src); if (Context::getResponseMethod() != "XMLRPC") { return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\", { \"autostart\" : %s, \"wmode\" : \"%s\" });</script>", $src, $width, $height, $auto_start, $wmode); } else { return sprintf("<div style=\"width: %dpx; height: %dpx;\"><span style=\"position:relative; top:%dpx;left:%d\"><img src=\"%s\" /><br />Attached Multimedia</span></div>", $width, $height, $height / 2 - 16, $width / 2 - 31, Context::getRequestUri() . './modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif'); } }
/** * @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method * * 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서 * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경 **/ function transHTML($xml_obj) { $gallery_info->srl = rand(111111, 999999); $gallery_info->border_thickness = $xml_obj->attrs->border_thickness; $gallery_info->gallery_style = $xml_obj->attrs->gallery_style; $gallery_info->border_color = $xml_obj->attrs->border_color; $gallery_info->bg_color = $xml_obj->attrs->bg_color; $gallery_info->gallery_align = $xml_obj->attrs->gallery_align; $images_list = $xml_obj->attrs->images_list; $images_list = preg_replace('/\\.(gif|jpg|jpeg|png) /i', ".\\1\n", $images_list); $gallery_info->images_list = explode("\n", trim($images_list)); // 만약 출력설정이 XML일 경우 이미지 목록만 출력하도록 코드 생성 if (Context::getResponseMethod() == 'XMLRPC') { $output = ''; for ($i = 0; $i < count($gallery_info->images_list); $i++) { $output .= sprintf('<img src="%s" alt="" /><br />', $gallery_info->images_list[$i]); } return $output; } // HTML 출력일 경우 템플릿 변환을 거쳐서 갤러리 출력 설정에 맞는 html코드를 생성하도록 함 preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i', $xml_obj->attrs->style, $matches); $gallery_info->width = trim($matches[3][0]); if (!$gallery_info->width) { $gallery_info->width = 400; } Context::set('gallery_info', $gallery_info); $tpl_path = $this->component_path . 'tpl'; Context::set("tpl_path", $tpl_path); if ($gallery_info->gallery_style == "list") { $tpl_file = 'list_gallery.html'; } else { $tpl_file = 'slide_gallery.html'; } $oTemplate =& TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); }
public function testRequsetResponseMethod() { $this->assertEquals(Context::getRequestMethod(), 'GET'); $_SERVER['REQUEST_METHOD'] = 'POST'; Context::setRequestMethod(); $this->assertEquals(Context::getRequestMethod(), 'POST'); $GLOBALS['HTTP_RAW_POST_DATA'] = 'abcde'; Context::setRequestMethod(); $this->assertEquals(Context::getRequestMethod(), 'XMLRPC'); $_SERVER['CONTENT_TYPE'] = 'application/json'; Context::setRequestMethod(); $this->assertEquals(Context::getRequestMethod(), 'JSON'); Context::setRequestMethod('POST'); $this->assertEquals(Context::getRequestMethod(), 'POST'); $this->assertEquals(Context::getResponseMethod(), 'HTML'); Context::setRequestMethod('JSON'); $this->assertEquals(Context::getResponseMethod(), 'JSON'); Context::setResponseMethod('WRONG_TYPE'); $this->assertEquals(Context::getResponseMethod(), 'HTML'); Context::setResponseMethod('XMLRPC'); $this->assertEquals(Context::getResponseMethod(), 'XMLRPC'); Context::setResponseMethod('HTML'); $this->assertEquals(Context::getResponseMethod(), 'HTML'); }
/** * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n * This method only functions when __DEBUG__ variable is set to 1. * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php * @return void */ function _debugOutput() { if (!__DEBUG__) { return; } $end = getMicroTime(); // Firebug console output if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) { static $firephp; if (!isset($firephp)) { $firephp = FirePHP::getInstance(true); } if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.'); return; } // display total execution time and Request/Response info if (__DEBUG__ & 2) { $firephp->fb(array('Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(), array(array('Request URI', 'Request method', 'Response method', 'Response contents size', 'Memory peak usage'), array(sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']), $_SERVER['REQUEST_METHOD'], Context::getResponseMethod(), $this->content_size . ' byte', FileHandler::filesize(memory_get_peak_usage())))), 'TABLE'); $firephp->fb(array('Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__), array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'), array(sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']), sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']), sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])))), 'TABLE'); } // display DB query history if (__DEBUG__ & 4 && $GLOBALS['__db_queries__']) { $queries_output = array(array('Result/' . PHP_EOL . 'Elapsed time', 'Query ID', 'Query')); foreach ($GLOBALS['__db_queries__'] as $query) { $queries_output[] = array($query['result'] . PHP_EOL . sprintf('%0.5f', $query['elapsed_time']), str_replace(_XE_PATH_, '', $query['called_file']) . PHP_EOL . $query['called_method'] . '()' . PHP_EOL . $query['query_id'], $query['query']); } $firephp->fb(array('DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), $queries_output), 'TABLE'); } // dislpay the file and HTML comments } else { $buff = array(); // display total execution time and Request/Response info if (__DEBUG__ & 2) { if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { return; } // Request/Response information $buff[] = "\n- Request/ Response info"; $buff[] = sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']); $buff[] = sprintf("\tRequest method \t\t\t: %s", $_SERVER['REQUEST_METHOD']); $buff[] = sprintf("\tResponse method \t\t: %s", Context::getResponseMethod()); $buff[] = sprintf("\tResponse contents size\t: %d byte", $this->content_size); // total execution time $buff[] = sprintf("\n- Total elapsed time : %0.5f sec", $end - __StartTime__); $buff[] = sprintf("\tclass file load elapsed time \t: %0.5f sec", $GLOBALS['__elapsed_class_load__']); $buff[] = sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']); $buff[] = sprintf("\tXmlParse compile elapsed time\t: %0.5f sec", $GLOBALS['__xmlparse_elapsed__']); $buff[] = sprintf("\tPHP elapsed time \t\t\t\t: %0.5f sec", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']); $buff[] = sprintf("\tDB class elapsed time \t\t\t: %0.5f sec", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']); // widget execution time $buff[] = sprintf("\tWidgets elapsed time \t\t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']); // layout execution time $buff[] = sprintf("\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']); // Widgets, the editor component replacement time $buff[] = sprintf("\tTrans Content \t\t\t\t\t: %0.5f sec", $GLOBALS['__trans_content_elapsed__']); } // DB Logging if (__DEBUG__ & 4) { if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { return; } if ($GLOBALS['__db_queries__']) { $buff[] = sprintf("\n- DB Queries : %d Queries. %0.5f sec", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']); $num = 0; foreach ($GLOBALS['__db_queries__'] as $query) { if ($query['result'] == 'Success') { $query_result = "Query Success"; } else { $query_result = sprintf("Query {$s} : %d\n\t\t\t %s", $query['result'], $query['errno'], $query['errstr']); } $buff[] = sprintf("\t%02d. %s\n\t\t%0.6f sec. %s.", ++$num, $query['query'], $query['elapsed_time'], $query_result); $buff[] = sprintf("\t\tConnection: %s.", $query['connection']); $buff[] = sprintf("\t\tQuery ID: %s", $query['query_id']); $buff[] = sprintf("\t\tCalled: %s. %s()", str_replace(_XE_PATH_, '', $query['called_file']), $query['called_method']); } } } // Output in HTML comments if ($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') { $buff = implode("\r\n", $buff); $buff = sprintf("[%s %s:%d]\r\n%s", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true)); if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; } return "<!--\r\n" . $buff . "\r\n-->"; } // Output to a file if ($buff && __DEBUG_OUTPUT__ == 0) { $debug_file = _XE_PATH_ . 'files/_debug_message.php'; $buff = implode(PHP_EOL, $buff); $buff = sprintf("[%s]\n%s", date('Y-m-d H:i:s'), print_r($buff, true)); $buff = str_repeat('=', 80) . "\n" . $buff . "\n" . str_repeat('-', 80); $buff = "\n<?php\n/*" . $buff . "*/\n?>\n"; if (!@file_put_contents($debug_file, $buff, FILE_APPEND | LOCK_EX)) { return; } } } }
/** * Enviroment information send to XE collect server * @return void */ function showSendEnv() { if (Context::getResponseMethod() != 'HTML') { return; } $server = 'http://collect.xpressengine.com/env/img.php?'; $path = './files/env/'; $install_env = $path . 'install'; $mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2)); if (file_exists(FileHandler::getRealPath($install_env))) { $oAdminAdminModel = getAdminModel('admin'); $params = $oAdminAdminModel->getEnv('INSTALL'); $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params); Context::addHtmlFooter($img); FileHandler::writeFile($path . $mainVersion, '1'); } else { if (isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion))) { if ($_SESSION['enviroment_gather'] == 'Y') { $oAdminAdminModel = getAdminModel('admin'); $params = $oAdminAdminModel->getEnv(); $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params); Context::addHtmlFooter($img); } FileHandler::writeFile($path . $mainVersion, '1'); unset($_SESSION['enviroment_gather']); } } }
/** * @brief Widget code compiles and prints the information to trigger * display:: before invoked in */ function triggerWidgetCompile(&$content) { if (Context::getResponseMethod() != 'HTML') { return new Object(); } $content = $this->transWidgetCode($content, $this->layout_javascript_mode); return new Object(); }
/** * Get debug information. * * @return string */ public function getDebugInfo(&$output = null) { // Check if debugging information has already been printed. if (self::$debug_printed) { return; } else { self::$debug_printed = 1; } // Check if debugging is enabled for this request. if (!config('debug.enabled') || !Rhymix\Framework\Debug::isEnabledForCurrentUser()) { return; } // Do not display debugging information if there is no output. $display_type = config('debug.display_type'); if ($output === null && $display_type !== 'file') { return; } // Print debug information. switch ($display_type) { case 'panel': $data = Rhymix\Framework\Debug::getDebugData(); $display_content = array_fill_keys(config('debug.display_content'), true); if (count($display_content) && !isset($display_content['entries'])) { $data->entries = null; } if (count($display_content) && !isset($display_content['queries'])) { unset($data->queries); } if (count($display_content) && !isset($display_content['slow_queries'])) { unset($data->slow_queries); } if (count($display_content) && !isset($display_content['slow_triggers'])) { unset($data->slow_triggers); } if (count($display_content) && !isset($display_content['slow_widgets'])) { unset($data->slow_widgets); } if (count($display_content) && !isset($display_content['slow_remote_requests'])) { unset($data->slow_remote_requests); } if ($data->entries) { foreach ($data->entries as &$entry) { if (is_scalar($entry->message)) { $entry->message = var_export($entry->message, true); } else { $entry->message = trim(print_r($entry->message, true)); } } } switch (Context::getResponseMethod()) { case 'HTML': $json_options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE : 0; $panel_script = sprintf('<script src="%s%s?%s"></script>', RX_BASEURL, 'common/js/debug.js', filemtime(RX_BASEDIR . 'common/js/debug.js')); if (isset($_SESSION['_rx_debug_previous'])) { $panel_script .= "\n<script>\nvar rhymix_debug_previous = " . json_encode($_SESSION['_rx_debug_previous'], $json_options) . ";\n</script>"; unset($_SESSION['_rx_debug_previous']); } $panel_script .= "\n<script>\nvar rhymix_debug_content = " . json_encode($data, $json_options) . ";\n</script>"; $body_end_position = strrpos($output, '</body>') ?: strlen($output); $output = substr($output, 0, $body_end_position) . "\n{$panel_script}\n" . substr($output, $body_end_position); return; case 'JSON': if (RX_POST && preg_match('/^proc/', Context::get('act'))) { $data->ajax_module = Context::get('module'); $data->ajax_act = Context::get('act'); $_SESSION['_rx_debug_previous'] = $data; } else { unset($_SESSION['_rx_debug_previous']); } if (preg_match('/^(.+)\\}$/', $output, $matches)) { $output = $matches[1] . ',"_rx_debug":' . json_encode($data) . '}'; } return; default: return; } case 'comment': case 'file': default: if ($display_type === 'comment' && Context::getResponseMethod() !== 'HTML') { return; } ob_start(); $data = Rhymix\Framework\Debug::getDebugData(); $display_content = array_fill_keys(config('debug.display_content'), true); include RX_BASEDIR . 'common/tpl/debug_comment.html'; $content = preg_replace('/\\n{2,}/', "\n\n", trim(ob_get_clean())) . PHP_EOL; if ($display_type === 'file') { $log_filename = config('debug.log_filename') ?: 'files/debug/YYYYMMDD.php'; $log_filename = str_replace(array('YYYY', 'YY', 'MM', 'DD'), array(getInternalDateTime(RX_TIME, 'Y'), getInternalDateTime(RX_TIME, 'y'), getInternalDateTime(RX_TIME, 'm'), getInternalDateTime(RX_TIME, 'd')), $log_filename); $log_filename = RX_BASEDIR . $log_filename; if (!file_exists($log_filename) || !filesize($log_filename)) { $phpheader = '<?php exit; ?>' . "\n"; } else { $phpheader = ''; } FileHandler::writeFile($log_filename, $phpheader . $content . PHP_EOL, 'a'); return ''; } else { return '<!--' . PHP_EOL . $content . PHP_EOL . '-->'; } } }
public function triggerDisplayLogMessages() { if(__DEBUG__ && __XE_SHOP_DEBUG__ && !in_array(Context::getResponseMethod(), array('XMLRPC', 'JSON'))) { // Load XE Shop errors $shop_log_messages = FileHandler::readFile(ShopLogger::LOG_FILE_PATH); Context::set('shop_log_messages', $shop_log_messages); // Load XE Core query log $debug_messages = FileHandler::readFile(ShopLogger::XE_CORE_DEBUG_MESSAGE_PATH); Context::set('debug_messages', $debug_messages); // Load DB Query log $debug_db_query = FileHandler::readFile(ShopLogger::XE_CORE_DEBUG_DB_QUERY_PATH); Context::set('debug_db_query', $debug_db_query); $oTemplateHandler = TemplateHandler::getInstance(); $view_logs = $oTemplateHandler->compile(_XE_PATH_ . '/modules/shop/tpl', 'log_viewer.html'); print $view_logs; } }
/** * 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); }
/** * 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; }
<?php if (!defined("__ZBXE__")) { exit; } if (Context::getRequestMethod() == "XMLRPC" || Context::getResponseMethod() == "XMLRPC") { 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"); // ]]>
function triggerBeforeDisplay(&$output_display) { $act = Context::get('act'); // 팝업창이면 중지 if (Context::get('ncenterlite_is_popup')) { return; } // 자신의 알림목록을 보고 있을 경우엔 알림센터창을 띄우지 않는다. if ($act == 'dispNcenterliteNotifyList') { return; } if (count($this->disable_notify_bar_act)) { if (in_array(Context::get('act'), $this->disable_notify_bar_act)) { return; } } // HTML 모드가 아니면 중지 + act에 admin이 포함되어 있으면 중지 if (Context::getResponseMethod() != 'HTML' || strpos(strtolower(Context::get('act')), 'admin') !== false) { return; } $logged_info = Context::get('logged_info'); // 로그인 상태가 아니면 중지 if (!$logged_info) { return; } $module_info = Context::get('module_info'); if (count($this->disable_notify_bar_mid)) { if (in_array($module_info->mid, $this->disable_notify_bar_mid)) { return; } } // admin 모듈이면 중지 if ($module_info->module == 'admin') { return; } $oNcenterliteModel = getModel('ncenterlite'); $config = $oNcenterliteModel->getConfig(); // 알림센터가 비활성화 되어 있으면 중지 if ($config->use != 'Y') { return new Object(); } if ($config->display_use == 'N') { return new Object(); } // 노티바 제외 페이지이면 중지 if (in_array($module_info->module_srl, $config->hide_module_srls)) { return new Object(); } Context::set('ncenterlite_config', $config); $oModuleModel = getModel('module'); $ncenterlite_module_info = $oModuleModel->getModuleInfoXml('ncenterlite'); $jsCacheRefresh = '?' . $ncenterlite_module_info->version . '.' . $ncenterlite_module_info->date . '.js'; Context::addJsFile('./modules/ncenterlite/tpl/js/ncenterlite.js' . $jsCacheRefresh, true, '', 100000); $oNcenterliteModel = getModel('ncenterlite'); // 알림 목록 가져오기 $_output = $oNcenterliteModel->getMyNotifyList(); if (!$_output->data) { return; } // 알림 메시지가 없어도 항상 표시하게 하려면 이 줄을 제거 또는 주석 처리하세요. $_latest_notify_id = array_slice($_output->data, 0, 1); $_latest_notify_id = $_latest_notify_id[0]->notify; Context::set('ncenterlite_latest_notify_id', $_latest_notify_id); if ($_COOKIE['_ncenterlite_hide_id'] && $_COOKIE['_ncenterlite_hide_id'] == $_latest_notify_id) { return; } setcookie('_ncenterlite_hide_id', '', 0, '/'); $oMemberModel = getModel('member'); $memberConfig = $oMemberModel->getMemberConfig(); if ($memberConfig->profile_image == 'Y') { $profileImage = $oMemberModel->getProfileImage($logged_info->member_srl); Context::set('profileImage', $profileImage); } Context::set('useProfileImage', $memberConfig->profile_image == 'Y' ? true : false); Context::set('ncenterlite_list', $_output->data); Context::set('ncenterlite_page_navigation', $_output->page_navigation); if (Mobile::isFromMobilePhone()) { $this->template_path = sprintf('%sm.skins/%s/', $this->module_path, $config->mskin); if (!is_dir($this->template_path) || !$config->mskin) { $config->mskin = 'default'; $this->template_path = sprintf('%sm.skins/%s/', $this->module_path, $config->mskin); } } else { $this->template_path = sprintf('%sskins/%s/', $this->module_path, $config->skin); if (!is_dir($this->template_path) || !$config->skin) { $config->skin = 'default'; $this->template_path = sprintf('%sskins/%s/', $this->module_path, $config->skin); } } Context::addHtmlFooter('<script>'); if ($config->message_notify != 'N') { Context::addHtmlFooter('window.xeNotifyMessage = function() {};'); } Context::addHtmlFooter('(function(){setTimeout(function(){var s = jQuery(document).scrollTop();jQuery(document).scrollTop(s-30);}, 700);})();</script>'); $this->_addFile(); $html = $this->_getTemplate(); $output_display = $html . $output_display; }
<?php if (!defined("__ZBXE__")) { exit; } if ($called_position != "before_display_content") { return; } // applying to only board module $oBoardView =& getView('board'); if (Context::getResponseMethod() == "XMLRPC" || Context::getRequestMethod() == 'XMLRPC' || $oBoardView->act != 'dispBoardContent') { return; } if (!$addon_info->display) { Context::addCssFile('./addons/exif/css/exif.css'); } if ($addon_info->display == '2') { Context::addCssFile('./addons/exif/css/exif2.css'); } if ($addon_info->display == '3') { Context::addCssFile('./addons/exif/css/exif3.css'); } else { Context::addJsFile('./addons/exif/js/exif.js', false, '', null, 'body'); } require_once "exif.lib.php"; // call getImageExif() with retrieved image path $pattern_image_tag = "/<img(.*?)(src=\"[^ ]*)(files\\/attach\\/images\\/[^\"]+)+([^>]*?)(>)+/i"; $pattern_documents_area = '/<!--BeforeDocument\\([0-9]+,[0-9]+\\)-->.+<!--AfterDocument\\([0-9]+,[0-9]+\\)-->/is'; $output = preg_replace_callback($pattern_documents_area, create_function('$matches', "return preg_replace_callback('{$pattern_image_tag}', 'getExifData', \$matches[0]);"), $output);
<?php if (!defined("__ZBXE__")) { exit; } /** * @file lemonpen.addon.php * @author zero (zero@nzeo.com) * @brief LemonPen addon * 스프링노트의 레몬펜을 사이트에 설치하는 애드온입니다 **/ if (Context::getResponseMethod() == "XMLRPC") { return; } // 모듈의 실행 이후에 script를 추가함 if (Context::get('module') != 'admin' && $called_position == 'after_module_proc') { if ($this->getLayoutFile() != 'popup_layout.html') { $sid = $addon_info->sid; if ($sid) { Context::addHtmlFooter(sprintf('<script src="http://script.lemonpen.com/site/lemonpen.js?sid=%s" type="text/javascript" charset="UTF-8"></script>', $sid)); $GLOBALS['__lemonpen_is_called__'] = true; } } return; } // XE의 문서와 permant link를 레몬펜의 규약에 맞춰서 출력 if ($GLOBALS['__lemonpen_is_called__'] && $called_position == 'before_display_content') { // 글 본문을 링크 $output = preg_replace('/<div class="document_([0-9]+)_([0-9]+) xe_content">/is', '<div class="document_$1_$2 xe_content hentry"><a href="' . getUrl('', 'document_srl', "\$1") . '" rel="bookmark" style="display:none;">' . getUrl('', 'document_srl', "\$1") . '</a>', $output); // 댓글 본문을 링크 $output = preg_replace('/<div class="comment_([0-9]+)_([0-9]+) xe_content">/is', '<div class="comment_$1_$2 xe_content hentry"><a href="' . getUrl('', 'document_srl', "\$1") . '" rel="bookmark" style="display:none;">' . getUrl('', 'document_srl', "\$1") . '</a>', $output);
/** * @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method * * 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서 * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경 **/ function transHTML($xml_obj) { $use_folder = $xml_obj->attrs->use_folder; $folder_opener = $xml_obj->attrs->folder_opener; if (!$folder_opener) { $folder_opener = "more..."; } $folder_closer = $xml_obj->attrs->folder_closer; if (!$folder_closer) { $folder_closer = "close..."; } $bold = $xml_obj->attrs->bold; $color = $xml_obj->attrs->color; $margin = $xml_obj->attrs->margin; $padding = $xml_obj->attrs->padding; $border_style = $xml_obj->attrs->border_style; $border_thickness = $xml_obj->attrs->border_thickness; $border_color = $xml_obj->attrs->border_color; $bg_color = $xml_obj->attrs->bg_color; $body = $xml_obj->body; if (Context::getResponseMethod() == 'XMLRPC') { return $body; } $output = ""; $style = sprintf('margin:%spx;padding:%spx;background-color:#%s;', $margin, $padding, $bg_color); switch ($border_style) { case "solid": $style .= "border:" . $border_thickness . "px solid #" . $border_color . ";"; break; case "dotted": $style .= "border:" . $border_thickness . "px dotted #" . $border_color . ";"; break; case "left_solid": $style .= "border-left:" . $border_thickness . "px solid #" . $border_color . ";"; break; case "left_dotted": $style .= "border-elft:" . $border_thickness . "px dotted #" . $border_color . ";"; break; } if ($use_folder == "Y") { $folder_id = rand(1000000, 9999999); $folder_opener = str_replace("&", "&", $folder_opener); $folder_closer = str_replace("&", "&", $folder_closer); if ($bold == "Y") { $class = "bold"; } switch ($color) { case "red": $class .= " editor_red_text"; break; case "yellow": $class .= " editor_yellow_text"; break; case "green": $class .= " editor_green_text"; break; default: $class .= " editor_blue_text"; break; } $style .= "display:none;"; $folder_margin = sprintf("%spx %spx %spx %spx", $margin, $margin, 10, $margin); $output .= sprintf('<div id="folder_open_%s" style="margin:%s;display:block;"><a class="%s" href="#" onclick="zbxe_folder_open(\'%s\');return false;">%s</a></div>', $folder_id, $folder_margin, $class, $folder_id, $folder_opener); $output .= sprintf('<div id="folder_close_%s" style="margin:%s;display:none;"><a class="%s" href="#" onclick="zbxe_folder_close(\'%s\');return false;">%s</a></div>', $folder_id, $folder_margin, $class, $folder_id, $folder_closer); $output .= sprintf('<div style="%s" id="folder_%s">%s</div>', $style, $folder_id, $body); } else { $output .= sprintf('<div style="%s">%s</div>', $style, $body); } return $output; }
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(); }
/** * @brief 디버그 모드일 경우 디버깅 메시지 출력 * * __DEBUG__ 값이 1 이상이면 __DEBUG_OUTPUT__ 값에 따라 메시지 출력. * __DEBUG__를 세팅하고, __DEBUG_OUTPUT__ == 0 이면 * tail -f ./files/_debug_message.php로 하여 console로 확인하면 편리함 **/ function _debugOutput() { if (!__DEBUG__) { return; } $end = getMicroTime(); // Firebug 콘솔 출력 if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '5.2.0', '>=')) { static $firephp; if (!isset($firephp)) { $firephp = FirePHP::getInstance(true); } if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.'); return; } // 전체 실행 시간 출력, Request/Response info 출력 if (__DEBUG__ & 2) { $firephp->fb(array('Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(), array(array('Request URI', 'Request method', 'Response method', 'Response contents size'), array(sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']), $_SERVER['REQUEST_METHOD'], Context::getResponseMethod(), $this->content_size . ' byte'))), 'TABLE'); $firephp->fb(array('Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__), array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'), array(sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']), sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']), sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])))), 'TABLE'); } // DB 쿼리 내역 출력 if (__DEBUG__ & 4 && $GLOBALS['__db_queries__']) { $queries_output = array(array('Query', 'Elapsed time', 'Result')); foreach ($GLOBALS['__db_queries__'] as $query) { array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result'])); } $firephp->fb(array('DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), $queries_output), 'TABLE'); } // 파일 및 HTML 주석으로 출력 } else { // 전체 실행 시간 출력, Request/Response info 출력 if (__DEBUG__ & 2) { // Request/Response 정보 작성 $buff .= "\n- Request/ Response info\n"; $buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']); $buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']); $buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod()); $buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size); // 전체 실행 시간 $buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end - __StartTime__); $buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']); $buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']); $buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']); $buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']); // 위젯 실행 시간 작성 $buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']); // 레이아웃 실행 시간 $buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']); // 위젯, 에디터 컴포넌트 치환 시간 $buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']); } // DB 로그 작성 if (__DEBUG__ & 4) { if ($GLOBALS['__db_queries__']) { $buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']); $num = 0; foreach ($GLOBALS['__db_queries__'] as $query) { $buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']); if ($query['result'] == 'Success') { $buff .= "Query Success\n"; } else { $buff .= sprintf("Query {$s} : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']); } } } } // HTML 주석으로 출력 if (__DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') { $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true)); if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; } return "<!--\r\n" . $buff . "\r\n-->"; } // 파일에 출력 if (__DEBUG_OUTPUT__ == 0) { $debug_file = _XE_PATH_ . 'files/_debug_message.php'; $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true)); $buff = str_repeat('=', 40) . "\n" . $buff . str_repeat('-', 40); $buff = "\n<?php\n/*" . $buff . "*/\n?>\n"; if (@(!($fp = fopen($debug_file, 'a')))) { return; } fwrite($fp, $buff); fclose($fp); } } }
/** * 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; }
function triggerBeforeDisplay(&$output_content) { if (Context::getResponseMethod() != 'HTML') { return; } if (Context::get('module') == 'admin') { return; } $oModuleModel = getModel('module'); $config = $this->getConfig(); $logged_info = Context::get('logged_info'); $current_module_info = Context::get('current_module_info'); $site_module_info = Context::get('site_module_info'); $document_srl = Context::get('document_srl'); $is_article = false; $is_index = $current_module_info->module_srl == $site_module_info->module_srl ? true : false; $piece = new stdClass(); $piece->document_title = null; $piece->type = 'website'; $piece->url = getFullUrl(''); $piece->title = Context::getBrowserTitle(); $piece->description = $config->site_description; $piece->keywords = $config->site_keywords; $piece->image = array(); $piece->author = null; if ($document_srl) { $oDocument = Context::get('oDocument'); if (!is_a($oDocument, 'documentItem')) { $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($document_srl); } if (is_a($oDocument, 'documentItem') && $document_srl == $oDocument->document_srl) { $is_article = true; } } // 문서 데이터 수집 if ($is_article) { if (!$oDocument->isSecret()) { $piece->document_title = $oDocument->getTitleText(); $piece->url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl); $piece->type = 'article'; $piece->description = trim(str_replace(' ', ' ', $oDocument->getContentText(400))); $piece->author = $oDocument->getNickName(); if (count($oDocument->get('tag_list'))) { $tags = implode(',', $oDocument->get('tag_list')); if ($tags) { $piece->keywords = $tags; } } if ($oDocument->hasUploadedFiles()) { $image_ext = array('bmp', 'gif', 'jpg', 'jpeg', 'png'); foreach ($oDocument->getUploadedFiles() as $file) { if ($file->isvalid != 'Y') { continue; } $ext = array_pop(explode('.', $file->uploaded_filename)); if (!in_array(strtolower($ext), $image_ext)) { continue; } $piece->image[] = Context::get('request_uri') . $file->uploaded_filename; } } } else { $piece->url = getFullUrl('', 'mid', $current_module_info->mid); } } else { if (!$is_index) { $page = Context::get('page') > 1 ? Context::get('page') : null; $piece->url = getNotEncodedFullUrl('mid', $current_module_info->mid, 'page', $page); } } $piece->title = $this->getBrowserTitle($piece->document_title); if ($config->site_image_url) { $piece->image[] = $config->site_image_url; } $this->addLink('canonical', $piece->url); $this->addMeta('keywords', $piece->keywords); $this->addMeta('description', $piece->description); // Open Graph $this->addMeta('og:type', $piece->type); $this->addMeta('og:url', $piece->url); $this->addMeta('og:site_name', $config->site_name); $this->addMeta('og:title', $piece->title); $this->addMeta('og:description', $piece->description); $this->addMeta('og:article:author', $piece->author); foreach ($piece->image as $img) { $this->addMeta('og:image', $img); } $this->canonical_url = $piece->url; $this->applySEO(); if ($config->use_optimize_title == 'Y') { Context::setBrowserTitle($piece->title); } }
/** * @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(); }
<?php if (!defined("__ZBXE__")) { exit; } /** * @file autolink.addon.php * @author zero (zero@nzeo.com) * @brief 자동 링크 애드온 **/ if ($called_position == 'after_module_proc' && Context::getResponseMethod() != "XMLRPC") { Context::addJsFile('./addons/autolink/autolink.js'); }
<?php /* Copyright (C) NAVER <http://www.navercorp.com> */ if (!defined('__XE__')) { exit; } /** * @file image_name.addon.php * @author NAVER (developers@xpressengine.com) * @brief Display user image name/image mark * * Find member_srl in the part with <div class="member_MemberSerialNumber"> .... </div> * Check if ther is image name and image mark. Then change it. */ /** * Just before displaying, change image name/ image mark */ if ($called_position != "before_display_content" || Context::get('act') == 'dispPageAdminContentModify' || Context::getResponseMethod() != 'HTML' || isCrawler()) { return; } // Include a file having functions to replace member image name/mark require_once './addons/member_extra_info/member_extra_info.lib.php'; // 1. Find a part <div class="member_MemberSerialNumber"> content </div> in the output document, change it to image name/mark by using MemberController::transImageName() $temp_output = preg_replace_callback('!<(div|span|a)([^\\>]*)member_([0-9]+)([^\\>]*)>(.*?)\\<\\/(div|span|a)\\>!is', 'memberTransImageName', $output); if ($temp_output) { $output = $temp_output; } unset($temp_output); /* End of file member_extra_info.addon.php */ /* Location: ./addons/member_extra_info/member_extra_info.addon.php */
<?php /* Copyright (C) NAVER <http://www.navercorp.com> */ if (!defined('__XE__')) { exit; } /** * @file autolink.addon.php * @author NAVER (developers@xpressengine.com) * @brief Automatic link add-on */ if ($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML") { Context::loadFile(array('./addons/autolink/autolink.js', 'body', '', null), true); } /* End of file autolink.addon.php */ /* Location: ./addons/autolink/autolink.addon.php */
function triggerBeforeDisplay(&$output_display) { $act = Context::get('act'); // 팝업창이면 중지 if (Context::get('ncenterlite_is_popup')) { return; } // 자신의 알림목록을 보고 있을 경우엔 알림센터창을 띄우지 않는다. if ($act == 'dispNcenterliteNotifyList') { return; } if (count($this->disable_notify_bar_act)) { if (in_array(Context::get('act'), $this->disable_notify_bar_act)) { return; } } // HTML 모드가 아니면 중지 + act에 admin이 포함되어 있으면 중지 if (Context::getResponseMethod() != 'HTML' || strpos(strtolower(Context::get('act')), 'admin') !== false) { return; } // 로그인 상태가 아니면 중지 if (!Context::get('is_logged')) { return; } $module_info = Context::get('module_info'); if (count($this->disable_notify_bar_mid)) { if (in_array($module_info->mid, $this->disable_notify_bar_mid)) { return; } } // admin 모듈이면 중지 if ($module_info->module == 'admin') { return; } $oNcenterliteModel = getModel('ncenterlite'); $config = $oNcenterliteModel->getConfig(); // if the array is empty, dose not output the notification. if (empty($config->use)) { return new Object(); } if ($config->display_use == 'mobile' && !Mobile::isFromMobilePhone() || $config->display_use == 'pc' && Mobile::isFromMobilePhone() || $config->display_use == 'none') { return new Object(); } // 노티바 제외 페이지이면 중지 if (in_array($module_info->module_srl, $config->hide_module_srls)) { return new Object(); } Context::set('ncenterlite_config', $config); $js_args = array('./modules/ncenterlite/tpl/js/ncenterlite.js', 'body', '', 100000); Context::loadFile($js_args); // 알림 목록 가져오기 $logged_info = Context::get('logged_info'); $_output = $oNcenterliteModel->getMyNotifyList($logged_info->member_srl); // 알림 메시지가 없어도 항상 표시하게 하려면 이 줄을 제거 또는 주석 처리하세요. if (!$_output->data) { return; } $_latest_notify_id = array_slice($_output->data, 0, 1); $_latest_notify_id = $_latest_notify_id[0]->notify; Context::set('ncenterlite_latest_notify_id', $_latest_notify_id); if ($_COOKIE['_ncenterlite_hide_id'] && $_COOKIE['_ncenterlite_hide_id'] == $_latest_notify_id) { return; } setcookie('_ncenterlite_hide_id', '', 0, '/'); $oMemberModel = getModel('member'); $memberConfig = $oMemberModel->getMemberConfig(); if ($memberConfig->profile_image == 'Y') { $profileImage = $oMemberModel->getProfileImage($logged_info->member_srl); Context::set('profileImage', $profileImage); } Context::set('useProfileImage', $memberConfig->profile_image == 'Y' ? true : false); Context::set('ncenterlite_list', $_output->data); Context::set('ncenterlite_page_navigation', $_output->page_navigation); Context::set('_ncenterlite_num', $_output->page_navigation->total_count); if (Mobile::isFromMobilePhone()) { $this->template_path = sprintf('%sm.skins/%s/', $this->module_path, $config->mskin); if (!is_dir($this->template_path) || !$config->mskin) { $config->mskin = 'default'; $this->template_path = sprintf('%sm.skins/%s/', $this->module_path, $config->mskin); } } else { $this->template_path = sprintf('%sskins/%s/', $this->module_path, $config->skin); if (!is_dir($this->template_path) || !$config->skin) { $config->skin = 'default'; $this->template_path = sprintf('%sskins/%s/', $this->module_path, $config->skin); } } $this->_addFile(); $html = $this->_getTemplate(); $output_display = $html . $output_display; }
<?php if (!defined('__XE__')) { exit; } if ($called_position == 'before_module_proc' && Context::getResponseMethod() == 'HTML' && $addon_info->r_ncart_mid && !Context::get('hide_trolley')) { require_once './addons/trolley/trolley.lib.php'; $addon_info->r_trolley_id = 'trolley'; $logged_info = Context::get('logged_info'); Context::set('logged_info', $logged_info); if ($this->module == 'nproduct') { // Cookie 체크 밑 업데이트. checkRecentItems($module_name, $addon_info, $this->module); } // Recent Item Set View setRecentView($addon_info); // Document Event Set setDocumentEvent($addon_info); // BUtton Event Set setButtonEvent($addon_info); } if ($called_position == 'before_display_content' && Context::getResponseMethod() == 'HTML' && $addon_info->r_ncart_mid && !Context::get('hide_trolley')) { $addon_info->r_trolley_id = 'trolley'; Context::set('recent_pass', ''); // 템플릿 파일을 지정 $tpl_file = 'trolley'; $oTemplate =& TemplateHandler::getInstance(); $output = $output . $oTemplate->compile('./addons/trolley/tpl', $tpl_file); }
<?php /* Copyright (C) NAVER <http://www.navercorp.com> */ if (!defined('__XE__')) { exit; } /** * @file counter.addon.php * @author NAVER (developers@xpressengine.com) * @brief Counter add-on */ // Execute if called_position is before_display_content if ($called_position == 'before_module_init' && Context::get('module') != 'admin' && Context::getResponseMethod() == 'HTML' && Context::isInstalled() && !isCrawler()) { $oCounterController = getController('counter'); $oCounterController->counterExecute(); } /* End of file counter.addon.php */ /* Location: ./addons/counter/counter.addon.php */