/** * @brief Get the points */ function getPoint($member_srl, $from_db = false) { $member_srl = abs($member_srl); // Get from instance memory if (!$from_db && $this->pointList[$member_srl]) { return $this->pointList[$member_srl]; } // Get from file cache $path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl)); $cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl); if (!$from_db && file_exists($cache_filename)) { return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename)); } // Get from the DB $args = new stdClass(); $args->member_srl = $member_srl; $output = executeQuery('point.getPoint', $args); if (isset($output->data->member_srl)) { $point = (int) $output->data->point; $this->pointList[$member_srl] = $point; if (!is_dir($path)) { FileHandler::makeDir($path); } FileHandler::writeFile($cache_filename, $point); return $point; } return 0; }
function getNewsFromAgency() { //Retrieve recent news and set them into context $newest_news_url = sprintf("http://www.xeshoppingmall.com/?module=newsagency&act=getNewsagencyArticle&inst=notice&top=6&loc=%s", _XE_LOCATION_); $cache_file = sprintf("%sfiles/cache/nstore_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_); if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) { // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page // Ensure to access the textmessageistration page even though news cannot be displayed FileHandler::writeFile($cache_file, ''); FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl(''))); } if (file_exists($cache_file)) { $oXml = new XmlParser(); $buff = $oXml->parse(FileHandler::readFile($cache_file)); $item = $buff->zbxe_news->item; if ($item) { if (!is_array($item)) { $item = array($item); } foreach ($item as $key => $val) { $obj = null; $obj->title = $val->body; $obj->date = $val->attrs->date; $obj->url = $val->attrs->url; $news[] = $obj; } return $news; } } }
/** * check easy install * @return void */ function checkEasyinstall() { $lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile); if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) { return; } $oAutoinstallModel = getModel('autoinstall'); $params = array(); $params["act"] = "getResourceapiLastupdate"; $body = XmlGenerater::generate($params); $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml"); $xml_lUpdate = new XmlParser(); $lUpdateDoc = $xml_lUpdate->parse($buff); $updateDate = $lUpdateDoc->response->updatedate->body; if (!$updateDate) { $this->_markingCheckEasyinstall(); return; } $item = $oAutoinstallModel->getLatestPackage(); if (!$item || $item->updatedate < $updateDate) { $oController = getAdminController('autoinstall'); $oController->_updateinfo(); } $this->_markingCheckEasyinstall(); }
/** * @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; }
/** * @brief 일반 요청시 출력 **/ function dispPageIndex() { // 템플릿에서 사용할 변수를 Context::set() if ($this->module_srl) { Context::set('module_srl', $this->module_srl); } // 캐시 파일 지정 $cache_file = sprintf("%sfiles/cache/page/%d.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType()); $interval = (int) $this->module_info->page_caching_interval; if ($interval > 0) { if (!file_exists($cache_file)) { $mtime = 0; } else { $mtime = filemtime($cache_file); } if ($mtime + $interval * 60 > time()) { $page_content = FileHandler::readFile($cache_file); } else { $oWidgetController =& getController('widget'); $page_content = $oWidgetController->transWidgetCode($this->module_info->content); FileHandler::writeFile($cache_file, $page_content); } } else { if (file_exists($cache_file)) { FileHandler::removeFile($cache_file); } $page_content = $this->module_info->content; } Context::set('module_info', $this->module_info); Context::set('page_content', $page_content); $this->setTemplateFile('content'); }
function _getWidgetContent() { // Arrange a widget ryeolro if ($this->module_info->mcontent) { $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType()); $interval = (int) $this->module_info->page_caching_interval; if ($interval > 0) { if (!file_exists($cache_file) || filesize($cache_file) < 1) { $mtime = 0; } else { $mtime = filemtime($cache_file); } if ($mtime + $interval * 60 > $_SERVER['REQUEST_TIME']) { $page_content = FileHandler::readFile($cache_file); $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content); } else { $oWidgetController = getController('widget'); $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent); FileHandler::writeFile($cache_file, $page_content); } } else { if (file_exists($cache_file)) { FileHandler::removeFile($cache_file); } $page_content = $this->module_info->mcontent; } } else { $page_content = $this->module_info->content; } return $page_content; }
function _getWidgetContent() { // Arrange a widget ryeolro if ($this->module_info->mcontent) { $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType()); $interval = (int) $this->module_info->page_caching_interval; if ($interval > 0) { if (!file_exists($cache_file) || filesize($cache_file) < 1) { $mtime = 0; } else { $mtime = filemtime($cache_file); } if ($mtime + $interval * 60 > time()) { $page_content = FileHandler::readFile($cache_file); $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content); } else { $oWidgetController =& getController('widget'); $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent); FileHandler::writeFile($cache_file, $page_content); } } else { if (file_exists($cache_file)) { FileHandler::removeFile($cache_file); } $page_content = $this->module_info->mcontent; } } else { preg_match_all('!(<img)([^\\>]*)(widget=)([^\\>]*?)(\\>)!is', $this->module_info->content, $matches); $page_content = ''; for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $page_content .= preg_replace('/ style\\=\\"([^\\"]+)\\" /i', ' style="overflow:hidden;clear:both;margin:0 0 20px 0; _margin-right:10px;" ', $matches[0][$i]) . "\n\n"; } } return $page_content; }
function getLicenseFromAgency($prodid, &$has_license = TRUE, &$expiration = NULL) { $has_license = TRUE; $oLicenseModel =& getModel('license'); $config = $oLicenseModel->getModuleConfig(); if ($prodid == 'nstore') { $user_id = $config->user_id; $serial_number = $config->serial_number; } else { if ($prodid == 'nstore_digital') { $user_id = $config->d_user_id; $serial_number = $config->d_serial_number; } else { $user_id = $config->e_user_id; $serial_number = $config->e_serial_number; } } $cache_file = $this->checkLicense($prodid, $user_id, $serial_number); if (file_exists($cache_file)) { $oXml = new XmlParser(); $buff = $oXml->parse(FileHandler::readFile($cache_file)); // user $userObj = $buff->drm->user; if ($userObj) { $user = $userObj->body; if ($user != $user_id) { $this->checkLicense($prodid, $user_id, $serial_number, TRUE); return TRUE; } } // serial $serialObj = $buff->drm->serial; if ($serialObj) { $serial = $serialObj->body; if ($serial != $serial_number) { $this->checkLicense($prodid, $user_id, $serial_number, TRUE); return TRUE; } } // license $licenseObj = $buff->drm->license; if ($licenseObj) { $license = $licenseObj->body; if ($license == 'none') { $url = getUrl('act', 'dispLicenseAdminConfig'); Context::set(sprintf('%s_MESSAGE_TYPE', strtoupper($prodid)), 'error'); Context::set(sprintf('%s_MESSAGE', strtoupper($prodid)), Context::getLang('not_registered')); $has_license = FALSE; } } // expiration $expirationObj = $buff->drm->expiration; if ($expirationObj) { $expiration = $expirationObj->body; } } return FALSE; }
/** * Load a xml file specified by a filename and parse it to Return the resultant data object * @param string $filename a file path of file * @return array Returns a data object containing data extracted from a xml file or NULL if a specified file does not exist */ function loadXmlFile($filename) { if (!file_exists($filename)) { return; } $buff = FileHandler::readFile($filename); $oXmlParser = new XmlParser(); return $oXmlParser->parse($buff); }
function dispNcenterliteAdminConfig() { $oModuleModel = getModel('module'); $oNcenterliteModel = getModel('ncenterlite'); $oLayoutModel = getModel('layout'); $config = $oNcenterliteModel->getConfig(); Context::set('config', $config); $layout_list = $oLayoutModel->getLayoutList(); Context::set('layout_list', $layout_list); $mobile_layout_list = $oLayoutModel->getLayoutList(0, 'M'); Context::set('mlayout_list', $mobile_layout_list); $skin_list = $oModuleModel->getSkins($this->module_path); Context::set('skin_list', $skin_list); $mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins"); Context::set('mskin_list', $mskin_list); if (!$skin_list[$config->skin]) { $config->skin = 'default'; } Context::set('colorset_list', $skin_list[$config->skin]->colorset); if (!$mskin_list[$config->mskin]) { $config->mskin = 'default'; } Context::set('mcolorset_list', $mskin_list[$config->mskin]->colorset); $security = new Security(); $security->encodeHTML('config..'); $security->encodeHTML('skin_list..title'); $security->encodeHTML('colorset_list..name', 'colorset_list..title'); $mid_list = $oModuleModel->getMidList(null, array('module_srl', 'mid', 'browser_title', 'module')); Context::set('mid_list', $mid_list); // 사용환경정보 전송 확인 $ncenterlite_module_info = $oModuleModel->getModuleInfoXml('ncenterlite'); $agreement_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/ncenterlite/ncenterlite-', $ncenterlite_module_info->version)); $agreement_ver_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/ncenterlite/ncenterlite_ver-', $ncenterlite_module_info->version)); if (file_exists($agreement_file)) { $agreement = FileHandler::readFile($agreement_file); Context::set('_ncenterlite_env_agreement', $agreement); $agreement_ver = FileHandler::readFile($agreement_ver_file); if ($agreement == 'Y') { $_ncenterlite_iframe_url = 'http://sosifam.com/index.php?mid=ncenterlite_iframe'; if (!$agreement_ver) { $_host_info = urlencode($_SERVER['HTTP_HOST']) . '-NC' . $ncenterlite_module_info->version . '-PHP' . phpversion() . '-XE' . __XE_VERSION__; } Context::set('_ncenterlite_iframe_url', $_ncenterlite_iframe_url . '&_host=' . $_host_info); Context::set('ncenterlite_module_info', $ncenterlite_module_info); } FileHandler::writeFile($agreement_ver_file, 'Y'); } else { Context::set('_ncenterlite_env_agreement', 'NULL'); } }
/** * @brief liveXE 30일 내의 인기 태그 추출 **/ function makeTagCache($module_srl, $list_cnt = 15, $period = 30) { $cache_file = sprintf('%sfiles/cache/liveXE/%d.txt', _XE_PATH_, $module_srl); if (!file_exists($cache_file) || filemtime($cache_file) < time() - 60 * 5) { $args->module_srl = $module_srl; $args->list_count = $list_cnt; $args->date = date("YmdHis", time() - 60 * 60 * 24 * $period); $output = executeQueryArray('livexe.getPopularTags', $args); if (!$output->toBool() || !$output->data) { return array(); } $tags = array(); $max = 0; $min = 99999999; foreach ($output->data as $key => $val) { $tag = trim($val->tag); if (!$tag) { continue; } $count = $val->count; if ($max < $count) { $max = $count; } if ($min > $count) { $min = $count; } $tags[] = $val; } $mid2 = $min + (int) (($max - $min) / 2); $mid1 = $mid2 + (int) (($max - $mid2) / 2); $mid3 = $min + (int) (($mid2 - $min) / 2); $output = null; foreach ($tags as $key => $item) { if ($item->count > $mid1) { $rank = 1; } elseif ($item->count > $mid2) { $rank = 2; } elseif ($item->count > $mid3) { $rank = 3; } else { $rank = 4; } $tags[$key]->rank = $rank; } shuffle($tags); FileHandler::writeFile($cache_file, serialize($tags)); } $tags = unserialize(FileHandler::readFile($cache_file)); return $tags; }
/** * Returns table information * * Used for finding column type info (string/numeric) <br /> * Obtains the table info from XE's XML schema files * * @param object $query_id * @param bool $table_name * @return array */ function getTableInfo($query_id, $table_name) { $column_type = array(); $module = ''; $id_args = explode('.', $query_id); if (count($id_args) == 2) { $target = 'modules'; $module = $id_args[0]; $id = $id_args[1]; } else { if (count($id_args) == 3) { $target = $id_args[0]; $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); if (!isset($targetList[$target])) { return; } $module = $id_args[1]; $id = $id_args[2]; } } // get column properties from the table $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name); if (!file_exists($table_file)) { $searched_list = FileHandler::readDir(_XE_PATH_ . 'modules'); $searched_count = count($searched_list); for ($i = 0; $i < $searched_count; $i++) { $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name); if (file_exists($table_file)) { break; } } } if (file_exists($table_file)) { $table_xml = FileHandler::readFile($table_file); $xml_parser = new XmlParser(); $table_obj = $xml_parser->parse($table_xml); if ($table_obj->table) { if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) { $table_obj->table->column = array($table_obj->table->column); } foreach ($table_obj->table->column as $k => $v) { $column_type[$v->attrs->name] = $v->attrs->type; } } } return $column_type; }
/** * @brief 포인트를 구해옴 **/ function getPoint($member_srl, $from_db = false) { $member_srl = abs($member_srl); $path = sprintf('./files/member_extra_info/point/%s', getNumberingPath($member_srl)); if (!is_dir($path)) { FileHandler::makeDir($path); } $cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl); if (!$from_db && file_exists($cache_filename)) { return trim(FileHandler::readFile($cache_filename)); } // DB에서 가져옴 $args->member_srl = $member_srl; $output = executeQuery('point.getPoint', $args); $point = (int) $output->data->point; FileHandler::writeFile($cache_filename, $point); return $point; }
/** * @brief 계층구조 추출 * document_category테이블을 이용해서 위키 문서의 계층 구조도를 그림 * document_category테이블에 등록되어 있지 않은 경우 depth = 0 으로 하여 신규 생성 **/ function getWikiTreeList() { header("Content-Type: text/xml; charset=UTF-8"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $oModuleModel =& getModel('module'); $mid = Context::get('mid'); $cache_file = sprintf('%sfiles/cache/wiki/%d.xml', _XE_PATH_, $this->module_srl); if ($this->grant->write_document || !file_exists($cache_file)) { FileHandler::writeFile($cache_file, $this->loadWikiTreeList($this->module_srl)); } print FileHandler::readFile($cache_file); Context::close(); exit; }
/** * @brief Display Super Admin Dashboard **/ function dispTextmessageAdminIndex() { $oTextmessageModel = getModel('textmessage'); $config = $oTextmessageModel->getConfig(); if (!$config) { Context::set('isSetupCompleted', false); } else { Context::set('isSetupCompleted', true); } Context::set('config', $config); //Retrieve recent news and set them into context $newest_news_url = sprintf("http://www.coolsms.co.kr/?module=newsagency&act=getNewsagencyArticle&inst=notice&loc=%s", _XE_LOCATION_); $cache_file = sprintf("%sfiles/cache/cool_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_); if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) { // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page // Ensure to access the textmessage registration page even though news cannot be displayed FileHandler::writeFile($cache_file, ''); FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl(''))); } if (file_exists($cache_file)) { $oXml = new XmlParser(); $buff = $oXml->parse(FileHandler::readFile($cache_file)); $item = $buff->zbxe_news->item; if ($item) { if (!is_array($item)) { $item = array($item); } foreach ($item as $key => $val) { $obj = new stdClass(); $obj->title = $val->body; $obj->date = $val->attrs->date; $obj->url = $val->attrs->url; $news[] = $obj; } Context::set('news', $news); } Context::set('released_version', $buff->zbxe_news->attrs->released_version); Context::set('download_link', $buff->zbxe_news->attrs->download_link); } $this->setTemplateFile('index'); }
/** * Delete if action is registerd to be encrypted by SSL. * * @param string $action act name * @return void */ public static function subtractSSLAction($action) { if (self::isExistsSSLAction($action)) { $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); $buff = FileHandler::readFile(self::$_instance->sslActionCacheFile); $buff = str_replace($sslActionCacheString, '', $buff); FileHandler::writeFile(self::$_instance->sslActionCacheFile, $buff); } }
/** * parse syntax. * @param string $buff template file * @return string compiled result in case of success or NULL in case of error */ protected function parse($buff = null) { if (is_null($buff)) { if (!is_readable($this->file)) { return; } // read tpl file $buff = FileHandler::readFile($this->file); } // HTML tags to skip if (is_null($this->skipTags)) { $this->skipTags = array('marquee'); } // reset config for this buffer (this step is necessary because we use a singleton for every template) $previous_config = clone $this->config; $this->config = new stdClass(); // detect existence of autoescape config $this->config->autoescape = strpos($buff, ' autoescape="') === FALSE ? NULL : 'off'; // replace comments $buff = preg_replace('@<!--//.*?-->@s', '', $buff); // replace value of src in img/input/script tag $buff = preg_replace_callback('/<(?:img|input|script)(?:[^<>]*?)(?(?=cond=")(?:cond="[^"]+"[^<>]*)+|)[^<>]* src="(?!(?:https?|file):\\/\\/|[\\/\\{])([^"]+)"/is', array($this, '_replacePath'), $buff); // replace loop and cond template syntax $buff = $this->_parseInline($buff); // include, unload/load, import $buff = preg_replace_callback('/{(@[\\s\\S]+?|(?=[\\$\\\\]\\w+|_{1,2}[A-Z]+|[!\\(+-]|\\w+(?:\\(|::)|\\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\\(["\']([^"\']+)["\'])(.*?)(?(2)\\)--|\\/)>|<!--(@[a-z@]*)([\\s\\S]*?)-->(\\s*)/', array($this, '_parseResource'), $buff); // remove block which is a virtual tag $buff = preg_replace('@</?block\\s*>@is', '', $buff); // form auto generation $temp = preg_replace_callback('/(<form(?:<\\?php.+?\\?>|[^<>]+)*?>)(.*?)(<\\/form>)/is', array($this, '_compileFormAuthGeneration'), $buff); if ($temp) { $buff = $temp; } // prevent from calling directly before writing into file $buff = '<?php if(!defined("__XE__"))exit;?>' . $buff; // remove php script reopening $buff = preg_replace(array('/(\\n|\\r\\n)+/', '/(;)?( )*\\?\\>\\<\\?php([\\n\\t ]+)?/'), array("\n", ";\n"), $buff); // restore config to previous value $this->config = $previous_config; return $buff; }
/** * Change resource file path in Layout file * @param string $file * @return void */ function _changeFilepathInSource($file, $source, $target) { $content = FileHandler::readFile($file); $content = str_replace($source, $target, $content); FileHandler::writeFile($file, $content); }
function dispTextyleToolLayoutConfigEdit() { $oTextyleModel =& getModel('textyle'); $skin_path = $oTextyleModel->getTextylePath($this->module_srl); $skin_file_list = $oTextyleModel->getTextyleUserSkinFileList($this->module_srl); $skin_file_content = array(); foreach ($skin_file_list as $file) { if (preg_match('/^textyle/', $file)) { $skin_file_content[$file] = FileHandler::readFile($skin_path . $file); } } foreach ($skin_file_list as $file) { if (!in_array($file, $skin_file_content)) { $skin_file_content[$file] = FileHandler::readFile($skin_path . $file); } } Context::set('skin_file_content', $skin_file_content); $user_image_path = sprintf("%suser_images/", $oTextyleModel->getTextylePath($this->module_srl)); $user_image_list = FileHandler::readDir($user_image_path); Context::set('user_image_path', $user_image_path); Context::set('user_image_list', $user_image_list); }
/** * Import data in module.xml format * @param int $key * @param int $cur * @param string $index_file * @param int $module_srl * @return int */ function importModule($key, $cur, $index_file, $module_srl) { // Pre-create the objects needed $this->oXmlParser = new XmlParser(); // Get category information of the target module $oDocumentController = getController('document'); $oDocumentModel = getModel('document'); $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } // Extract category information $category_file = preg_replace('/index$/i', 'category.xml', $index_file); if (file_exists($category_file)) { $buff = FileHandler::readFile($category_file); // Create the xmlParser object $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); $categories = $xmlDoc->items->category; if ($categories) { if (!is_array($categories)) { $categories = array($categories); } $match_sequence = array(); foreach ($categories as $k => $v) { $category = trim(base64_decode($v->body)); if (!$category || $category_titles[$category]) { continue; } $sequence = $v->attrs->sequence; $parent = $v->attrs->parent; $obj = null; $obj->title = $category; $obj->module_srl = $module_srl; if ($parent) { $obj->parent_srl = $match_sequence[$parent]; } $output = $oDocumentController->insertCategory($obj); if ($output->toBool()) { $match_sequence[$sequence] = $output->get('category_srl'); } } $oDocumentController = getController('document'); $oDocumentController->makeCategoryFile($module_srl); } FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } $ek_args->module_srl = $module_srl; $output = executeQueryArray('document.getDocumentExtraKeys', $ek_args); if ($output->data) { foreach ($output->data as $key => $val) { $extra_keys[$val->eid] = true; } } if (!$cur) { $cur = 0; } // Open an index file $f = fopen($index_file, "r"); // Pass if already read for ($i = 0; $i < $cur; $i++) { fgets($f, 1024); } // Read each line until the condition meets for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) { if (feof($f)) { break; } // Find a location $target_file = trim(fgets($f, 1024)); if (!file_exists($target_file)) { continue; } // Importing data from now on $fp = fopen($target_file, "r"); if (!$fp) { continue; } $obj = new stdClass(); $obj->module_srl = $module_srl; $obj->document_srl = getNextSequence(); $files = array(); $extra_vars = array(); $started = false; $buff = array(); // Start from the body data while (!feof($fp)) { $str = fgets($fp, 1024); // Prepare an item if (trim($str) == '<post>') { $started = true; // Trackback inserted } else { if (substr($str, 0, 11) == '<trackbacks') { $obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl); continue; // Comments inserted } else { if (substr($str, 0, 9) == '<comments') { $obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl); continue; // Attachment inserted } else { if (substr($str, 0, 9) == '<attaches') { $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files); continue; // When starting extra variabls } elseif (trim($str) == '<extra_vars>') { $extra_vars = $this->importExtraVars($fp); continue; } } } } if ($started) { $buff[] = $str; } } $xmlDoc = $this->oXmlParser->parse(implode('', $buff)); $category = base64_decode($xmlDoc->post->category->body); if ($category_titles[$category]) { $obj->category_srl = $category_titles[$category]; } $obj->member_srl = 0; $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body) == 'Y' ? 'Y' : 'N'; $obj->status = base64_decode($xmlDoc->post->is_secret->body) == 'Y' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); $obj->title = base64_decode($xmlDoc->post->title->body); $obj->content = base64_decode($xmlDoc->post->content->body); $obj->readed_count = base64_decode($xmlDoc->post->readed_count->body); $obj->voted_count = base64_decode($xmlDoc->post->voted_count->body); $obj->blamed_count = base64_decode($xmlDoc->post->blamed_count->body); $obj->password = base64_decode($xmlDoc->post->password->body); $obj->user_name = base64_decode($xmlDoc->post->user_name->body); $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body); if (!$obj->user_name) { $obj->user_name = $obj->nick_name; } $obj->user_id = base64_decode($xmlDoc->post->user_id->body); $obj->email_address = base64_decode($xmlDoc->post->email->body); $obj->homepage = base64_decode($xmlDoc->post->homepage->body); if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) { $obj->homepage = 'http://' . $obj->homepage; } $obj->tags = base64_decode($xmlDoc->post->tags->body); $obj->regdate = base64_decode($xmlDoc->post->regdate->body); $obj->last_update = base64_decode($xmlDoc->post->update->body); $obj->last_updater = base64_decode($xmlDoc->post->last_updater->body); if (!$obj->last_update) { $obj->last_update = $obj->regdate; } $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body); $obj->list_order = $obj->update_order = $obj->document_srl * -1; $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body) != 'N' ? 'ALLOW' : 'DENY'; $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body) != 'N' ? 'Y' : 'N'; $obj->notify_message = base64_decode($xmlDoc->post->is_notice->body); // Change content information (attachment) if (count($files)) { foreach ($files as $key => $val) { $obj->content = preg_replace('/(src|href)\\=(["\']?)' . preg_quote($key) . '(["\']?)/i', '$1="' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?).\\/files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?)files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); } } $output = executeQuery('document.insertDocument', $obj); if ($output->toBool() && $obj->tags) { $tag_list = explode(',', $obj->tags); $tag_count = count($tag_list); for ($i = 0; $i < $tag_count; $i++) { $args = new stdClass(); $args->tag_srl = getNextSequence(); $args->module_srl = $module_srl; $args->document_srl = $obj->document_srl; $args->tag = trim($tag_list[$i]); $args->regdate = $obj->regdate; if (!$args->tag) { continue; } $output = executeQuery('tag.insertTag', $args); } } // Add extra variables if (count($extra_vars)) { foreach ($extra_vars as $key => $val) { if (!$val->value) { continue; } unset($e_args); $e_args->module_srl = $module_srl; $e_args->document_srl = $obj->document_srl; $e_args->var_idx = $val->var_idx; $e_args->value = $val->value; $e_args->lang_code = $val->lang_code; $e_args->eid = $val->eid; // Create a key for extra vars if not exists (except vars for title and content) if (!preg_match('/^(title|content)_(.+)$/i', $e_args->eid) && !$extra_keys[$e_args->eid]) { unset($ek_args); $ek_args->module_srl = $module_srl; $ek_args->var_idx = $val->var_idx; $ek_args->var_name = $val->eid; $ek_args->var_type = 'text'; $ek_args->var_is_required = 'N'; $ek_args->var_default = ''; $ek_args->eid = $val->eid; $output = executeQuery('document.insertDocumentExtraKey', $ek_args); $extra_keys[$ek_args->eid] = true; } $output = executeQuery('document.insertDocumentExtraVar', $e_args); } } fclose($fp); FileHandler::removeFile($target_file); } fclose($f); // Sync category counts if (count($category_list)) { foreach ($category_list as $key => $val) { $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); } } return $idx - 1; }
/** * @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'); }
/** * Send a message (DB controll) * @param int $sender_srl member_srl of sender * @param int $receiver_srl member_srl of receiver_srl * @param string $title * @param string $content * @param boolean $sender_log (default true) * @return Object **/ function sendMessage($sender_srl, $receiver_srl, $title, $content, $sender_log = true) { $content = removeHackTag($content); $title = htmlspecialchars($title); // messages to save in the sendor's message box $sender_args->sender_srl = $sender_srl; $sender_args->receiver_srl = $receiver_srl; $sender_args->message_type = 'S'; $sender_args->title = $title; $sender_args->content = $content; $sender_args->readed = 'N'; $sender_args->regdate = date("YmdHis"); $sender_args->related_srl = getNextSequence(); $sender_args->message_srl = getNextSequence(); $sender_args->list_order = getNextSequence() * -1; // messages to save in the receiver's message box $receiver_args->message_srl = $sender_args->related_srl; $receiver_args->related_srl = 0; $receiver_args->list_order = $sender_args->related_srl * -1; $receiver_args->sender_srl = $sender_srl; if (!$receiver_args->sender_srl) { $receiver_args->sender_srl = $receiver_srl; } $receiver_args->receiver_srl = $receiver_srl; $receiver_args->message_type = 'R'; $receiver_args->title = $title; $receiver_args->content = $content; $receiver_args->readed = 'N'; $receiver_args->regdate = date("YmdHis"); $oDB =& DB::getInstance(); $oDB->begin(); // messages to save in the sendor's message box if ($sender_srl && $sender_log) { $output = executeQuery('communication.sendMessage', $sender_args); if (!$output->toBool()) { $oDB->rollback(); return $output; } } // messages to save in the receiver's message box $output = executeQuery('communication.sendMessage', $receiver_args); if (!$output->toBool()) { $oDB->rollback(); return $output; } // create a flag that message is sent (in file format) $flag_path = './files/member_extra_info/new_message_flags/' . getNumberingPath($receiver_srl); FileHandler::makeDir($flag_path); $flag_file = sprintf('%s%s', $flag_path, $receiver_srl); $flag_count = FileHandler::readFile($flag_file); FileHandler::writeFile($flag_file, ++$flag_count); $oDB->commit(); return new Object(0, 'success_sended'); }
/** * Remove admin icon * @return object|void */ function procAdminRemoveIcons() { $iconname = Context::get('iconname'); $file_exist = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $iconname); if ($file_exist) { @FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $iconname); } else { return new Object(-1, 'fail_to_delete'); } $this->setMessage('success_deleted'); }
/** * @brief 전체 태그중 인기 태그 return * mid : 대상 플래닛 (null이면 전체 플래닛) * shuffle : 태그 결과값에 rank를 부여하고 shuffle * list_coutn : 추출 대상 수 **/ function getPopularTags($shuffle = false, $list_count = 100) { if (!$this->isExists()) { return; } if (!$this->isHome()) { $args->mid = $this->getMid(); } $cache_file = sprintf('%sfiles/cache/planet/%s/%d.%d.txt', _XE_PATH_, getNumberingPath($this->getModuleSrl(), 3), $shuffle ? 1 : 0, $list_count); if (!file_exists($cache_file) || filemtime($cache_file) < time() - 60 * 5) { $args->list_count = $list_count; // 24시간 이내의 태그중에서 인기 태그를 추출 $args->date = date("YmdHis", time() - 60 * 60 * 24); $output = executeQueryArray('planet.getPlanetPopularTags', $args); if (!$output->toBool() || !$output->data) { return array(); } $tags = array(); $max = 0; $min = 99999999; foreach ($output->data as $key => $val) { $tag = $val->tag; $count = $val->count; if ($max < $count) { $max = $count; } if ($min > $count) { $min = $count; } $tags[] = $val; } if ($shuffle) { $mid2 = $min + (int) (($max - $min) / 2); $mid1 = $mid2 + (int) (($max - $mid2) / 2); $mid3 = $min + (int) (($mid2 - $min) / 2); $output = null; foreach ($tags as $key => $item) { if ($item->count > $mid1) { $rank = 1; } elseif ($item->count > $mid2) { $rank = 2; } elseif ($item->count > $mid3) { $rank = 3; } else { $rank = 4; } $tags[$key]->rank = $rank; } shuffle($tags); } FileHandler::writeFile($cache_file, serialize($tags)); } else { $tags = unserialize(FileHandler::readFile($cache_file)); } return $tags; }
function getXmlFileContent($xml_file) { return FileHandler::readFile($xml_file); }
/** * @brief module.xml 형식의 데이터 import **/ function importModule($key, $cur, $index_file, $module_srl) { // 필요한 객체 미리 생성 $this->oXmlParser = new XmlParser(); // 타겟 모듈의 카테고리 정보 구함 $oDocumentController =& getController('document'); $oDocumentModel =& getModel('document'); $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } // 먼저 카테고리 정보를 입력함 $category_file = preg_replace('/index$/i', 'category.xml', $index_file); if (file_exists($category_file)) { $buff = FileHandler::readFile($category_file); // xmlParser객체 생성 $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); $categories = $xmlDoc->items->category; if ($categories) { if (!is_array($categories)) { $categories = array($categories); } $match_sequence = array(); foreach ($categories as $k => $v) { $category = trim(base64_decode($v->body)); if (!$category || $category_titles[$category]) { continue; } $sequence = $v->attrs->sequence; $parent = $v->attrs->parent; $obj = null; $obj->title = $category; $obj->module_srl = $module_srl; if ($parent) { $obj->parent_srl = $match_sequence[$parent]; } $output = $oDocumentController->insertCategory($obj); if ($output->toBool()) { $match_sequence[$sequence] = $output->get('category_srl'); } } $oDocumentController =& getController('document'); $oDocumentController->makeCategoryFile($module_srl); } FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } $ek_args->module_srl = $module_srl; $output = executeQueryArray('document.getDocumentExtraKeys', $ek_args); if ($output->data) { foreach ($output->data as $key => $val) { $extra_keys[$val->eid] = true; } } if (!$cur) { $cur = 0; } // index파일을 염 $f = fopen($index_file, "r"); // 이미 읽혀진 것은 패스 for ($i = 0; $i < $cur; $i++) { fgets($f, 1024); } // 라인단위로 읽어들이면서 $cur보다 커지고 $cur+$this->unit_count개보다 작으면 중지 for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) { if (feof($f)) { break; } // 정해진 위치를 찾음 $target_file = trim(fgets($f, 1024)); if (!file_exists($target_file)) { continue; } // 이제부터 데이터를 가져오면서 처리 $fp = fopen($target_file, "r"); if (!$fp) { continue; } $obj = null; $obj->module_srl = $module_srl; $obj->document_srl = getNextSequence(); $files = array(); $extra_vars = array(); $started = false; $buff = null; // 본문 데이터부터 처리 시작 while (!feof($fp)) { $str = fgets($fp, 1024); // 한 아이템 준비 시작 if (trim($str) == '<post>') { $started = true; // 엮인글 입력 } else { if (substr($str, 0, 11) == '<trackbacks') { $obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl); continue; // 댓글 입력 } else { if (substr($str, 0, 9) == '<comments') { $obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl); continue; // 첨부파일 입력 } else { if (substr($str, 0, 9) == '<attaches') { $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files); continue; // 추가 변수 시작 일 경우 } elseif (trim($str) == '<extra_vars>') { $extra_vars = $this->importExtraVars($fp); continue; } } } } if ($started) { $buff .= $str; } } $xmlDoc = $this->oXmlParser->parse($buff); $category = base64_decode($xmlDoc->post->category->body); if ($category_titles[$category]) { $obj->category_srl = $category_titles[$category]; } $obj->member_srl = 0; $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body) == 'Y' ? 'Y' : 'N'; $obj->is_secret = base64_decode($xmlDoc->post->is_secret->body) == 'Y' ? 'Y' : 'N'; $obj->title = base64_decode($xmlDoc->post->title->body); $obj->content = base64_decode($xmlDoc->post->content->body); $obj->readed_count = base64_decode($xmlDoc->post->readed_count->body); $obj->voted_count = base64_decode($xmlDoc->post->voted_count->body); $obj->password = base64_decode($xmlDoc->post->password->body); $obj->user_name = $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body); $obj->user_id = base64_decode($xmlDoc->post->user_id->body); $obj->email_address = base64_decode($xmlDoc->post->email->body); $obj->homepage = base64_decode($xmlDoc->post->homepage->body); if ($obj->homepage && !preg_match('/^http:\\/\\//i', $obj->homepage)) { $obj->homepage = 'http://' . $obj->homepage; } $obj->tags = base64_decode($xmlDoc->post->tags->body); $obj->regdate = base64_decode($xmlDoc->post->regdate->body); $obj->last_update = base64_decode($xmlDoc->post->update->body); if (!$obj->last_update) { $obj->last_update = $obj->regdate; } $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body); $obj->list_order = $obj->update_order = $obj->document_srl * -1; $obj->allow_comment = base64_decode($xmlDoc->post->allow_comment->body) != 'N' ? 'Y' : 'N'; $obj->lock_comment = base64_decode($xmlDoc->post->lock_comment->body) == 'Y' ? 'Y' : 'N'; $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body) != 'N' ? 'Y' : 'N'; $obj->notify_message = base64_decode($xmlDoc->post->is_notice->body); // content 정보 변경 (첨부파일) if (count($files)) { foreach ($files as $key => $val) { $obj->content = preg_replace('/(src|href)\\=(["\']?)' . preg_quote($key) . '(["\']?)/i', '$1="' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?).\\/files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?)files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); } } $output = executeQuery('document.insertDocument', $obj); if ($output->toBool() && $obj->tags) { $tag_list = explode(',', $obj->tags); $tag_count = count($tag_list); for ($i = 0; $i < $tag_count; $i++) { $args = null; $args->tag_srl = getNextSequence(); $args->module_srl = $module_srl; $args->document_srl = $obj->document_srl; $args->tag = trim($tag_list[$i]); $args->regdate = $obj->regdate; if (!$args->tag) { continue; } $output = executeQuery('tag.insertTag', $args); } } // 확장변수 추가 if (count($extra_vars)) { foreach ($extra_vars as $key => $val) { if (!$val->value) { continue; } unset($e_args); $e_args->module_srl = $module_srl; $e_args->document_srl = $obj->document_srl; $e_args->var_idx = $val->var_idx; $e_args->value = $val->value; $e_args->lang_code = $val->lang_code; $e_args->eid = $val->eid; // 등록된 확장변수 키가 없으면 생성(제목/내용 언어별 변수는 제외) if (!preg_match('/^(title|content)_(.+)$/i', $e_args->eid) && !$extra_keys[$e_args->eid]) { unset($ek_args); $ek_args->module_srl = $module_srl; $ek_args->var_idx = $val->var_idx; $ek_args->var_name = $val->eid; $ek_args->var_type = 'text'; $ek_args->var_is_required = 'N'; $ek_args->var_default = ''; $ek_args->eid = $val->eid; $output = executeQuery('document.insertDocumentExtraKey', $ek_args); $extra_keys[$ek_args->eid] = true; } $output = executeQuery('document.insertDocumentExtraVar', $e_args); } } fclose($fp); FileHandler::removeFile($target_file); } fclose($f); // 카테고리별 개수 동기화 if (count($category_list)) { foreach ($category_list as $key => $val) { $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); } } return $idx - 1; }
/** * Creates a table by using xml file path * @param string $file_name xml schema file path * @return void|object */ function createTableByXmlFile($file_name) { if (!file_exists($file_name)) { return; } // read xml file $buff = FileHandler::readFile($file_name); return $this->_createTable($buff); }
/** * @brief Language Settings menu, the output */ function displayLangSelect() { $childs = array(); $this->lang = FileHandler::readFile('./files/cache/addons/mobile/setLangType/personal_settings/' . md5(trim($_SERVER['HTTP_USER_AGENT']) . trim($_SERVER['HTTP_PHONE_NUMBER']) . trim($_SERVER['HTTP_HTTP_PHONE_NUMBER'])) . '.php'); if ($this->lang) { $this->lang = str_replace(array('<?php /**', '**/ ?>'), array('', ''), $this->lang); Context::setLangType($this->lang); } $lang_supported = Context::get('lang_supported'); $lang_type = Context::getLangType(); $obj = array(); $obj['link'] = $obj['text'] = Context::getLang('president_lang') . ' : ' . $lang_supported[$lang_type]; $obj['href'] = getUrl('sel_lang', $lang_type); $childs[] = $obj; if (is_array($lang_supported)) { foreach ($lang_supported as $key => $val) { $obj = array(); $obj['link'] = $obj['text'] = $val; $obj['href'] = getUrl('sel_lang', $key); $childs[] = $obj; } } $this->setChilds($childs); $this->display(); }
function dispAttendanceAdminList() { /*attendance model 객체 생성*/ $oAttendanceModel = getModel('attendance'); Context::set('Model', $oAttendanceModel); $selected_date = Context::get('selected_date'); //선택한 날짜 받아오기 $type = Context::get('type'); /*attendance admin model 객체 생성*/ $oAttendanceAdminModel = getAdminModel('attendance'); Context::set('oAttendanceAdminModel', $oAttendanceAdminModel); if ($type != 'config' && $type != 'time') { $user_data = $oAttendanceAdminModel->getAttendanceMemberList(20, $type); Context::set('user_data', $user_data); } // 멤버모델 객체 생성 $oMemberModel = getModel('member'); $group_list = $oMemberModel->getGroups(); Context::set('group_list', $group_list); /*날짜 관련*/ if (!$selected_date) { $selected_date = zDate(date('YmdHis'), "Ymd"); } $year = substr($selected_date, 0, 4); $month = substr($selected_date, 4, 2); $day = substr($selected_date, 6, 2); $end_day = date('t', mktime(0, 0, 0, $month, 1, $year)); $oMemberModel = getModel('member'); Context::set('end_day', $end_day); Context::set('year', $year); Context::set('selected', $selected_date); Context::set('month', $month); Context::set('day', $day); Context::set('ipaddress', $_SERVER['REMOTE_ADDR']); Context::set('oMemberModel', $oMemberModel); //module의 설정값 가져오기 $oModuleModel = getModel('module'); $config = $oModuleModel->getModuleConfig('attendance'); $oModuleAdminModel = getAdminModel('module'); Context::set('config', $config); $start_time = new stdClass(); $start_time->hour = substr($config->start_time, 0, 2); $start_time->min = substr($config->start_time, 2, 2); $end_time = new stdClass(); $end_time->hour = substr($config->end_time, 0, 2); $end_time->min = substr($config->end_time, 2, 2); Context::set('start_time', $start_time); Context::set('end_time', $end_time); // 스킨 목록을 구해옴 $oModuleModel = getModel('module'); $module_info = $oModuleModel->getModuleInfoByMid('attendance'); $skin_list = $oModuleModel->getSkins($this->module_path); Context::set('skin_list', $skin_list); $mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins"); Context::set('mskin_list', $mskin_list); // 레이아웃 목록을 구해옴 $oLayoutModel = getModel('layout'); $layout_list = $oLayoutModel->getLayoutList(); Context::set('layout_list', $layout_list); $mobile_layout_list = $oLayoutModel->getLayoutList(0, "M"); Context::set('mlayout_list', $mobile_layout_list); // 모듈 카테고리 목록을 구함 $module_category = $oModuleModel->getModuleCategories(); Context::set('module_category', $module_category); // 공통 모듈 권한 설정 페이지 호출 $skin_content = $oModuleAdminModel->getModuleSkinHTML($module_info->module_srl); Context::set('skin_content', $skin_content); Context::set('module_info', $module_info); Context::set('module_srl', $module_info->module_srl); // 사용환경정보 전송 확인 $attendance_module_info = $oModuleModel->getModuleInfoXml('attendance'); $agreement_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/cache/attendance/attendance-', $attendance_module_info->version)); if (file_exists($agreement_file)) { $agreement = FileHandler::readFile($agreement_file); Context::set('_attendance_env_agreement', $agreement); if ($agreement == 'Y') { $_attendance_iframe_url = 'http://sosifam.com/index.php?mid=attendance_iframe'; $_host_info = urlencode($_SERVER['HTTP_HOST']) . '-NC' . $attendance_module_info->version . '-PHP' . phpversion() . '-XE' . __XE_VERSION__; Context::set('_attendance_iframe_url', $_attendance_iframe_url . '&_host=' . $_host_info); Context::set('attendance_module_info', $attendance_module_info); } } else { Context::set('_attendance_env_agreement', 'NULL'); } /*템플릿 설정*/ $this->setTemplatePath($this->module_path . 'tpl'); $this->setTemplateFile('index'); }
/** * @brief css나 js파일을 묶어서 하나의 파일로 만들고 gzip 압축이나 헤더등을 통제하기 위해서 php파일을 별도로 만들어서 진행함 **/ function makeOptimizedFile($path, $filename, $targets, $type) { /** * 실제 css나 js의 내용을 합친 것을 구함 **/ // 대상 파일의 내용을 구해오고 css 파일일 경우 url()내의 경로를 변경 foreach ($targets as $file) { $str = FileHandler::readFile($file['file']); $str = Context::convertEncodingStr($str); // css 일경우 background:url() 변경 / media 적용 if ($type == 'css') { $str = $this->replaceCssPath($file['file'], $str); if ($file['media'] != 'all') { $str = '@media ' . $file['media'] . ' {' . "\n" . $str . "\n" . '}'; } } $content_buff .= $str . "\n"; } if ($type == 'css') { $content_buff = '@charset "UTF-8";' . "\n" . $content_buff; } $content_filename = substr($filename, 0, -4); FileHandler::writeFile($path . '/' . $content_filename, $content_buff); /** * 캐시 타임을 제대로 이용하기 위한 헤더 파일 구함 **/ // 확장자별 content-type 체크 if ($type == 'css') { $content_type = 'text/css'; } elseif ($type == 'js') { $content_type = 'text/javascript'; } // 캐시를 위한 처리 $unique = crc32($content_filename); $size = filesize($path . '/' . $content_file); $mtime = filemtime($path . '/' . $content_file); // js, css 파일을 php를 통해서 출력하고 이 출력시에 헤더값을 조작하여 캐싱과 압축전송이 되도록 함 (IE6는 CSS파일일 경우 gzip압축하지 않음) $header_buff = '<?php $content_filename = "' . $content_filename . '"; $mtime = ' . $mtime . '; $cached = false; $type = "' . $type . '"; if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { $time = strtotime(preg_replace("/;.*$/", "", $_SERVER["HTTP_IF_MODIFIED_SINCE"])); if($mtime == $time) { header("HTTP/1.1 304"); $cached = true; } } if( preg_match("/MSIE 6.0/i",$_SERVER["HTTP_USER_AGENT"]) || strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip")===false || !function_exists("ob_gzhandler") ) { $size = filesize($content_filename); } else { $f = fopen($content_filename,"r"); $buff = fread($f, filesize($content_filename)); fclose($f); $buff = ob_gzhandler($buff, 5); $size = strlen($buff); header("Content-Encoding: gzip"); } header("Content-Type: ' . $content_type . '; charset=UTF-8"); header("Date: ' . substr(gmdate('r'), 0, -5) . 'GMT"); header("Expires: ' . substr(gmdate('r', strtotime('+1 MONTH')), 0, -5) . 'GMT"); header("Cache-Control: private, max-age=2592000"); header("Pragma: cache"); header("Last-Modified: ' . substr(gmdate('r', $mtime), 0, -5) . 'GMT"); header("ETag: \\"' . dechex($unique) . '-".dechex($size)."-' . dechex($mtime) . '\\""); if(!$cached) { if(empty($buff)) { $f = fopen($content_filename,"r"); fpassthru($f); } else print $buff; } ?>'; FileHandler::writeFile($path . '/' . $filename, $header_buff); }