Exemplo n.º 1
0
 /**
  * Returns the current template directory
  *
  * @since 1.0
  * @see get_option
  * @todo This is dirrrty dirrrty code. Fix ASAP.
  *
  * @param string $view Name of the current view
  * @param string $prefix String to prefix to the cache ID, defaults to template name
  * @return string
  */
 public static function load($view = 'chrono', $prefix = '')
 {
     if (empty($prefix)) {
         $prefix = get_option('template');
     }
     $current = Templates::get_current();
     $view_file = $view . '.php';
     $cache = new CacheHandler();
     $cache->begin_caching($prefix . $_SERVER['REQUEST_URI']);
     if (file_exists($current['Template Dir'] . '/' . $view_file)) {
         require_once $current['Template Dir'] . '/' . $view_file;
     } else {
         require_once $current['Template Dir'] . '/index.php';
     }
     $cache->end_caching($prefix . $_SERVER['REQUEST_URI']);
 }
Exemplo n.º 2
0
 function read($session_key)
 {
     if (!$session_key || !$this->session_started) {
         return;
     }
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'object:' . $session_key;
         $output->data = $oCacheHandler->get($cache_key);
     }
     if (!$output->data) {
         $args->session_key = $session_key;
         $columnList = array('session_key', 'cur_mid', 'val');
         $output = executeQuery('session.getSession', $args, $columnList);
         // Confirm there is a table created if read error occurs
         if (!$output->toBool()) {
             $oDB =& DB::getInstance();
             if (!$oDB->isTableExists('session')) {
                 $oDB->createTableByXmlFile($this->module_path . 'schemas/session.xml');
             }
             if (!$oDB->isColumnExists("session", "cur_mid")) {
                 $oDB->addColumn('session', "cur_mid", "varchar", 128);
             }
             $output = executeQuery('session.getSession', $args);
         }
         // Check if there is a table created in case there is no "cur_mid" value in the sessions information
         if (!isset($output->data->cur_mid)) {
             $oDB =& DB::getInstance();
             if (!$oDB->isColumnExists("session", "cur_mid")) {
                 $oDB->addColumn('session', "cur_mid", "varchar", 128);
             }
         }
     }
     return $output->data->val;
 }
Exemplo n.º 3
0
 /**
  * Check if a row of today's counter status exists 
  *
  * @param integer $site_srl Site_srl
  * @return bool
  */
 function isInsertedTodayStatus($site_srl = 0)
 {
     $args = new stdClass();
     $args->regdate = date('Ymd');
     $insertedTodayStatus = false;
     $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'counter:insertedTodayStatus:' . $site_srl . '_' . $args->regdate;
         $insertedTodayStatus = $oCacheHandler->get($cache_key);
     }
     if ($insertedTodayStatus === false) {
         if ($site_srl) {
             $args->site_srl = $site_srl;
             $output = executeQuery('counter.getSiteTodayStatus', $args);
         } else {
             $output = executeQuery('counter.getTodayStatus', $args);
         }
         $insertedTodayStatus = !!$output->data->count;
         if ($insertedTodayStatus && $oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, TRUE);
             $_old_date = date('Ymd', strtotime('-1 day'));
             $oCacheHandler->delete('counter:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
         }
     }
     return $insertedTodayStatus;
 }
Exemplo n.º 4
0
 /**
  * Get one of layout information created in the DB
  * Return DB info + XML info of the generated layout
  * @param int $layout_srl
  * @return object info of layout
  **/
 function getLayout($layout_srl)
 {
     // cache controll
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'object:' . $layout_srl;
         $layout_info = $oCacheHandler->get($cache_key);
     }
     if (!$layout_info) {
         // Get information from the DB
         $args->layout_srl = $layout_srl;
         $output = executeQuery('layout.getLayout', $args);
         if (!$output->data) {
             return;
         }
         // Return xml file informaton after listing up the layout and extra_vars
         $layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
         // If deleted layout files, delete layout instance
         // if (!$layout_info) {
         // $oLayoutController = &getAdminController('layout');
         // $oLayoutController->deleteLayout($layout_srl);
         // return;
         // }
         //insert in cache
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $layout_info);
         }
     }
     return $layout_info;
 }
Exemplo n.º 5
0
 /**
  * Regenerate all cache files
  * @return void
  */
 function procAdminRecompileCacheFile()
 {
     // rename cache dir
     $temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME'];
     FileHandler::rename('./files/cache', $temp_cache_dir);
     FileHandler::makeDir('./files/cache');
     // remove module extend cache
     FileHandler::removeFile(_XE_PATH_ . 'files/config/module_extend.php');
     // remove debug files
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
     $oModuleModel = getModel('module');
     $module_list = $oModuleModel->getModuleList();
     // call recompileCache for each module
     foreach ($module_list as $module) {
         $oModule = NULL;
         $oModule = getClass($module->module);
         if (method_exists($oModule, 'recompileCache')) {
             $oModule->recompileCache();
         }
     }
     // remove cache
     $truncated = array();
     $oObjectCacheHandler = CacheHandler::getInstance('object');
     $oTemplateCacheHandler = CacheHandler::getInstance('template');
     if ($oObjectCacheHandler->isSupport()) {
         $truncated[] = $oObjectCacheHandler->truncate();
     }
     if ($oTemplateCacheHandler->isSupport()) {
         $truncated[] = $oTemplateCacheHandler->truncate();
     }
     if (count($truncated) && in_array(FALSE, $truncated)) {
         return new Object(-1, 'msg_self_restart_cache_engine');
     }
     // remove cache dir
     $tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
     if ($tmp_cache_list) {
         foreach ($tmp_cache_list as $tmp_dir) {
             if ($tmp_dir) {
                 FileHandler::removeDir('./files/' . $tmp_dir);
             }
         }
     }
     // remove duplicate indexes (only for CUBRID)
     $db_type = Context::getDBType();
     if ($db_type == 'cubrid') {
         $db = DB::getInstance();
         $db->deleteDuplicateIndexes();
     }
     // check autoinstall packages
     $oAutoinstallAdminController = getAdminController('autoinstall');
     $oAutoinstallAdminController->checkInstalled();
     $this->setMessage('success_updated');
 }
Exemplo n.º 6
0
 /**
  * Regenerate all cache files
  * @return void
  */
 function procAdminRecompileCacheFile()
 {
     // rename cache dir
     $temp_cache_dir = './files/cache_' . time();
     FileHandler::rename('./files/cache', $temp_cache_dir);
     FileHandler::makeDir('./files/cache');
     // remove debug files
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
     $oModuleModel =& getModel('module');
     $module_list = $oModuleModel->getModuleList();
     // call recompileCache for each module
     foreach ($module_list as $module) {
         $oModule = null;
         $oModule =& getClass($module->module);
         if (method_exists($oModule, 'recompileCache')) {
             $oModule->recompileCache();
         }
     }
     // remove cache
     $truncated = array();
     $oObjectCacheHandler =& CacheHandler::getInstance('object');
     $oTemplateCacheHandler =& CacheHandler::getInstance('template');
     if ($oObjectCacheHandler->isSupport()) {
         $truncated[] = $oObjectCacheHandler->truncate();
     }
     if ($oTemplateCacheHandler->isSupport()) {
         $truncated[] = $oTemplateCacheHandler->truncate();
     }
     if (count($truncated) && in_array(false, $truncated)) {
         return new Object(-1, 'msg_self_restart_cache_engine');
     }
     // remove cache dir
     $tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
     if ($tmp_cache_list) {
         foreach ($tmp_cache_list as $tmp_dir) {
             if ($tmp_dir) {
                 FileHandler::removeDir('./files/' . $tmp_dir);
             }
         }
     }
     // remove duplicate indexes (only for CUBRID)
     $db_type =& Context::getDBType();
     if ($db_type == 'cubrid') {
         $db =& DB::getInstance();
         $db->deleteDuplicateIndexes();
     }
     $this->setMessage('success_updated');
 }
Exemplo n.º 7
0
 function clearSumCache()
 {
     if ($_POST['option_clear_sum'] == 'on') {
         $qry = DBFactory::getDBQuery();
         $qry->execute("DELETE FROM kb3_sum_alliance");
         $qry->execute("DELETE FROM kb3_sum_corp");
         $qry->execute("DELETE FROM kb3_sum_pilot");
         // Clear page and query cache as well since they also contain the
         // summaries.
         CacheHandler::removeByAge('SQL', 0, true);
         CacheHandler::removeByAge('store', 0, true);
         $_POST['option_clear_sum'] == 'off';
     }
 }
Exemplo n.º 8
0
 /**
  * Get an image.
  *
  * Returns an image resource or false on failure. Fetches the image from
  * CCP if needed.
  * @param integer $id
  * @param integer $size
  * @return resource Image resource or false on failure.
  */
 static function get($id, $size = 64)
 {
     $id = (int) $id;
     $size = (int) $size;
     if ($size != 32 && $size != 64) {
         return false;
     }
     if (!$id) {
         return imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
     }
     // If it's in the cache then read it from there.
     if (CacheHandler::exists("{$id}_{$size}.png", "img")) {
         return imagecreatefrompng(CacheHandler::getInternal("{$id}_{$size}.png", "img"));
     } else {
         $img = self::fetchImage($id, $size);
         imagepng($img, CacheHandler::getInternal("{$id}_{$size}.png", "img"));
         return $img ? $img : imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
     }
 }
 function procMagiccontentSetup()
 {
     $req = Context::getRequestVars();
     $widget_sequence = $req->widget_sequence;
     $is_complete = $req->is_complete;
     unset($req->is_complete);
     unset($req->widget_sequence);
     unset($req->act);
     foreach ($req as $key => $value) {
         if ($value == '') {
             unset($req->{$key});
         }
     }
     $serialize_data = serialize($req);
     $args = new stdClass();
     $args->data = $serialize_data;
     $args->widget_sequence = $widget_sequence;
     $args->is_complete = $is_complete;
     if ($is_complete == 1) {
         $dargs = new stdClass();
         $dargs->widget_sequence = $widget_sequence;
         $dargs->is_complete = 0;
         $output = executeQuery('magiccontent.deleteMagicContentData', $dargs);
     }
     $oMagiccontentModel =& getModel('magiccontent');
     if ($oMagiccontentModel->getSetupData($widget_sequence, $is_complete) === false) {
         $args->data_srl = getNextSequence();
         $output = executeQuery('magiccontent.insertMagicContentData', $args);
     } else {
         $output = executeQuery('magiccontent.updateMagicContentData', $args);
     }
     $oCacheHandler = CacheHandler::getInstance('template');
     if ($oCacheHandler->isSupport()) {
         $key = 'widget_cache:' . $widget_sequence;
         $oCacheHandler->delete($key);
     }
     $lang_type = Context::getLangType();
     $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
     FileHandler::removeFile($cache_file);
     return new Object(0, 'success');
 }
Exemplo n.º 10
0
 /**
  * Get data from database, and set the value to documentItem object
  * @param bool $load_extra_vars
  * @return void
  */
 function _loadFromDB($load_extra_vars = true)
 {
     if (!$this->document_srl) {
         return;
     }
     // cache controll
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport() && !count($this->columnList)) {
         $cache_key = 'object_document_item:' . $this->document_srl;
         $output = $oCacheHandler->get($cache_key);
     }
     if (!$output) {
         $args->document_srl = $this->document_srl;
         $output = executeQuery('document.getDocument', $args, $this->columnList);
         //insert in cache
         if ($output->data->document_srl && $oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $output);
         }
     }
     $this->setAttribute($output->data, $load_extra_vars);
 }
 function procAjaxboardAdminDeleteAjaxboard()
 {
     $module_srl = Context::get('module_srl');
     $oModuleController = getController('module');
     $output = $oModuleController->deleteModule($module_srl);
     if (!$output->toBool()) {
         return $output;
     }
     $oCacheHandler = CacheHandler::getInstance('object', NULL, true);
     if ($oCacheHandler->isSupport()) {
         $object_key = 'module_ajaxboard_module_srls';
         $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
         $oCacheHandler->delete($cache_key);
         $object_key = 'module_ajaxboard_linked_info';
         $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
         $oCacheHandler->delete($cache_key);
         $object_key = 'module_ajaxboard_notify_info';
         $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
         $oCacheHandler->delete($cache_key);
     }
     $this->setMessage('success_deleted');
     $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAjaxboardAdminContent'));
 }
Exemplo n.º 12
0
 /**
  * Get data from database, and set the value to documentItem object
  * @param bool $load_extra_vars
  * @return void
  */
 function _loadFromDB($load_extra_vars = true)
 {
     if (!$this->document_srl) {
         return;
     }
     $document_item = false;
     $cache_put = false;
     $columnList = array();
     $this->columnList = array();
     // cache controll
     $oCacheHandler = CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
         $document_item = $oCacheHandler->get($cache_key);
         if ($document_item !== false) {
             $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
         }
     }
     $args = new stdClass();
     $args->document_srl = $this->document_srl;
     $output = executeQuery('document.getDocument', $args, $columnList);
     if ($document_item === false) {
         $document_item = $output->data;
         //insert in cache
         if ($document_item && $oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $document_item);
         }
     } else {
         $document_item->readed_count = $output->data->readed_count;
         $document_item->voted_count = $output->data->voted_count;
         $document_item->blamed_count = $output->data->blamed_count;
         $document_item->comment_count = $output->data->comment_count;
         $document_item->trackback_count = $output->data->trackback_count;
     }
     $this->setAttribute($document_item, $load_extra_vars);
 }
 /**
  * @brief Delete comment
  **/
 function deleteReview($review_srl, $is_admin = false, $isMoveToTrash = false)
 {
     // create the comment model object
     $oCommentModel =& getModel('store_review');
     // check if comment already exists
     $comment = $oCommentModel->getReview($review_srl);
     if ($comment->review_srl != $review_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $item_srl = $comment->item_srl;
     // call a trigger (before)
     $output = ModuleHandler::triggerCall('store_review.deleteReview', 'before', $comment);
     if (!$output->toBool()) {
         return $output;
     }
     // check if child comment exists on the comment
     $child_count = $oCommentModel->getChildCommentCount($review_srl);
     if ($child_count > 0) {
         return new Object(-1, 'fail_to_delete_have_children');
     }
     // check if permission is granted
     if (!$is_admin && !$comment->isGranted()) {
         return new Object(-1, 'msg_not_permitted');
     }
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     // Delete
     $args->review_srl = $review_srl;
     $output = executeQuery('store_review.deleteReview', $args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $output = executeQuery('store_review.deleteReviewList', $args);
     // update the number of comments
     $comment_count = $oCommentModel->getReviewCount($item_srl);
     /*
     		// create the controller object of the document
     		$oDocumentController = &getController('document');
     		// update comment count of the article posting
     		$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false);
     		if(!$output->toBool()) {
     			$oDB->rollback();
     			return $output;
     		}
     */
     // call a trigger (after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('store_review.deleteReview', 'after', $comment);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     if (!$isMoveToTrash) {
         $this->_deleteDeclaredComments($args);
         $this->_deleteVotedComments($args);
     }
     // commit
     $oDB->commit();
     $output->add('item_srl', $item_srl);
     //remove from cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('commentList');
     }
     return $output;
 }
Exemplo n.º 14
0
 /**
  * @brief 자식 게시판 정보 반환
  * @param int $module_srl
  * @return array
  */
 function getAttachInfo($module_srl)
 {
     if (!$module_srl) {
         return array();
     }
     // 캐시 및 메모리 키값을 위한 해시 생성
     $hash_id = md5('module_srl:' . $module_srl);
     // 메모리에서 자식 게시판 정보 불러오기
     $attach_info = $GLOBALS['__timeline__']['attach_info'][$hash_id];
     // 메모리에 값이 없는 경우
     if (is_null($attach_info)) {
         $attach_info = FALSE;
         $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
         // 캐시에서 자식 게시판 정보 불러오기
         if ($oCacheHandler->isSupport()) {
             $object_key = 'attach_info:' . $hash_id;
             $cache_key = $oCacheHandler->getGroupKey('timeline', $object_key);
             $attach_info = $oCacheHandler->get($cache_key);
         }
         // 저장된 캐시가 없거나 캐시를 사용할 수 없는 경우
         if ($attach_info === FALSE) {
             $attach_info = array();
             $args = new stdClass();
             $args->module_srl = $module_srl;
             // DB에서 자식 게시판 정보 불러오기
             $output = executeQueryArray('timeline.getAttachInfo', $args);
             foreach ($output->data as $item) {
                 $attach_info[] = $item->target_srl;
             }
             // 캐시 저장
             if ($oCacheHandler->isSupport()) {
                 $oCacheHandler->put($cache_key, $attach_info);
             }
         }
         // 메모리 저장
         $GLOBALS['__timeline__']['attach_info'][$hash_id] = $attach_info;
     }
     return $attach_info;
 }
Exemplo n.º 15
0
<?php

require_once 'include/CacheHandler.php';
$cacheObj = new CacheHandler();
$results = $cacheObj->getFromCache();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB10lEQVQ4jX1TO2tUQRQelIgiGEt7CwVBhLvzzcZq73xnA4uQbht/QFBLFQnaWIivxcZXE8TCJkSw8REfnWkiRhEiCMEHgkERjGHnjKLCXovcXTfX3D1wiuGc78E3M8bkldVqm6O48bIOHs0fadWZslLighJZaXs8isRs29v9/4Fj6hIl/gwg+Nn2thUFV5R4ueKTnT1wliRDSrwaqF7HpUAEJTqROKmCuWVJhlfVPU4NBBPvlW6q7/xLiRNKzGTN5kajxJfB6vaYEp1CHl9VbCvSXTNB7HgUXFbiYiQmVTCvxO98+a4Sz9cP1Z0zxhgTPK4r8TQSt5VYUY+FSHdT6/asCs4Xw1TBfaV7sJZAbCu/yntKeyt4HFK6Z0pkeXhHYx2VSMwaY0ygPVJwYJeU9oUSn5S4kTX3bFKxE7nqR2OMaY8mu/P5jBIfig4mvtf2bQ/E2yiYXk3ZPenZ9u6N0j5W4rXW7I4g9nAxg0X17ngg3nUHfQ4+Z6N7ty5LMqyCeRUcVMFcjyD6SkM9Forp/iOwSzGtjuXOumEuRl9prHnOgS4NxJ0gOFNw0O2OEg+j4EB22mwo/VRZkgz1EwSiHWmvttPKrlLQukQjI1tiWh371nDbBu39BUbXq0cwWvsKAAAAAElFTkSuQmCC" rel="icon" type="image/x-icon" />    
    <title>Idea House</title>

    <link rel="stylesheet" href="salvattore.css">
    <link rel="stylesheet" href="normalize.css">
    <link rel="stylesheet" href="styles.css">    
</head>
<body>

<h1>Idea House</h1>

<div id="timeline" data-columns="4">
    <?php 
foreach ($results as $result) {
    ?>
        <div class="item line-<?php 
    echo $result['metadata']['data_source'];
    ?>
Exemplo n.º 16
0
 /**
  * Delete a category
  * @param int $category_srl
  * @return object
  */
 function deleteCategory($category_srl)
 {
     $args = new stdClass();
     $args->category_srl = $category_srl;
     $oDocumentModel = getModel('document');
     $category_info = $oDocumentModel->getCategory($category_srl);
     // Display an error that the category cannot be deleted if it has a child
     $output = executeQuery('document.getChildCategoryCount', $args);
     if (!$output->toBool()) {
         return $output;
     }
     if ($output->data->count > 0) {
         return new Object(-1, 'msg_cannot_delete_for_child');
     }
     // Delete a category information
     $output = executeQuery('document.deleteCategory', $args);
     if (!$output->toBool()) {
         return $output;
     }
     $this->makeCategoryFile($category_info->module_srl);
     // remvove cache
     $oCacheHandler = CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $page = 0;
         while (true) {
             $args = new stdClass();
             $args->category_srl = $category_srl;
             $args->list_count = 100;
             $args->page = ++$page;
             $output = executeQuery('document.getDocumentList', $args, array('document_srl'));
             if ($output->data == array()) {
                 break;
             }
             foreach ($output->data as $val) {
                 //remove document item from cache
                 $cache_key = 'document_item:' . getNumberingPath($val->document_srl) . $val->document_srl;
                 $oCacheHandler->delete($cache_key);
             }
         }
     }
     // Update category_srl of the documents in the same category to 0
     $args = new stdClass();
     $args->target_category_srl = 0;
     $args->source_category_srl = $category_srl;
     $output = executeQuery('document.updateDocumentCategory', $args);
     return $output;
 }
Exemplo n.º 17
0
 /**
  * @brief Remove extra vars from the module
  **/
 function deleteModuleExtraVars($module_srl)
 {
     $args->module_srl = $module_srl;
     return executeQuery('module.deleteModuleExtraVars', $args);
     //remove from cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'object:module_extra_vars_' . $module_srl;
         $oCacheHandler->delete($cache_key);
     }
 }
Exemplo n.º 18
0
 /**
  * Return the URL for the alliance's portrait. If the alliance has a
  * portrait in the board's img/alliances directory, that portrait will be
  * used
  *
  * @param integer $size The desired portrait size.
  * @return string URL for a portrait.
  */
 function getPortraitURL($size = 128)
 {
     if (isset($this->imgurl[$size])) {
         return $this->imgurl[$size];
     }
     if (file_exists("img/alliances/" . $this->getUnique() . ".png")) {
         if ($size == 128) {
             $this->imgurl[$size] = IMG_HOST . "/img/alliances/" . $this->getUnique() . ".png";
         } else {
             if (CacheHandler::exists($this->getUnique() . "_{$size}.png", 'img')) {
                 $this->imgurl[$size] = KB_HOST . "/" . CacheHandler::getExternal($this->getUnique() . "_{$size}.png", 'img');
             } else {
                 $this->imgurl[$size] = KB_HOST . '/?a=thumb&amp;type=alliance&amp;id=' . $this->getUnique() . '&amp;size=' . $size;
             }
         }
         $this->putCache();
     } else {
         if ($this->getExternalID()) {
             $this->imgurl[$size] = imageURL::getURL('Alliance', $this->getExternalID(), $size);
             $this->putCache();
         } else {
             $this->imgurl[$size] = imageURL::getURL('Alliance', 1, $size);
         }
     }
     return $this->imgurl[$size];
 }
Exemplo n.º 19
0
 /**
  * Update layout information
  * Apply a title of the new layout and extra vars
  * @return Object
  */
 function procLayoutAdminUpdate()
 {
     // Consider the rest of items as extra vars, except module, act, layout_srl, layout, and title  .. Some gurida ..
     $extra_vars = Context::getRequestVars();
     unset($extra_vars->module);
     unset($extra_vars->act);
     unset($extra_vars->layout_srl);
     unset($extra_vars->layout);
     unset($extra_vars->title);
     unset($extra_vars->apply_layout);
     unset($extra_vars->apply_mobile_view);
     $is_sitemap = $extra_vars->is_sitemap;
     unset($extra_vars->is_sitemap);
     $args = Context::gets('layout_srl', 'title');
     // Get layout information
     $oLayoutModel = getModel('layout');
     $oMenuAdminModel = getAdminModel('menu');
     $layout_info = $oLayoutModel->getLayout($args->layout_srl);
     if ($layout_info->menu) {
         $menus = get_object_vars($layout_info->menu);
     }
     if (count($menus)) {
         foreach ($menus as $menu_id => $val) {
             $menu_srl = Context::get($menu_id);
             if (!$menu_srl) {
                 continue;
             }
             // if menu is -1, get default menu in site
             if ($menu_srl == -1) {
                 $oModuleModel = getModel('module');
                 $start_module = $oModuleModel->getSiteInfo(0, $columnList);
                 $tmpArgs->url = $start_module->mid;
                 $tmpArgs->site_srl = 0;
                 $output = executeQuery('menu.getMenuItemByUrl', $tmpArgs);
                 if (!$output->toBool()) {
                     return new Object(-1, 'fail_to_update');
                 }
                 $menu_srl = $output->data->menu_srl;
             }
             $output = $oMenuAdminModel->getMenu($menu_srl);
             $menu_srl_list[] = $menu_srl;
             $menu_name_list[$menu_srl] = $output->title;
             $apply_layout = Context::get('apply_layout');
             $apply_mobile_view = Context::get('apply_mobile_view');
             if ($apply_layout == 'Y' || $apply_mobile_view == 'Y') {
                 $menu_args = new stdClass();
                 $menu_args->menu_srl = $menu_srl;
                 $menu_args->site_srl = $layout_info->site_srl;
                 $output = executeQueryArray('layout.getLayoutModules', $menu_args);
                 if ($output->data) {
                     $modules = array();
                     for ($i = 0; $i < count($output->data); $i++) {
                         $modules[] = $output->data[$i]->module_srl;
                     }
                     if (count($modules)) {
                         $update_args = new stdClass();
                         $update_args->module_srls = implode(',', $modules);
                         if ($apply_layout == "Y") {
                             $update_args->layout_srl = $args->layout_srl;
                         }
                         if ($layout_info->layout_type == "M") {
                             if (Context::get('apply_mobile_view') == "Y") {
                                 $update_args->use_mobile = "Y";
                             }
                             $output = executeQuery('layout.updateModuleMLayout', $update_args);
                         } else {
                             $output = executeQuery('layout.updateModuleLayout', $update_args);
                         }
                         $oCacheHandler = CacheHandler::getInstance('object', null, true);
                         if ($oCacheHandler->isSupport()) {
                             $oCacheHandler->invalidateGroupKey('site_and_module');
                         }
                     }
                 }
             }
         }
     }
     $tmpDir = sprintf('./files/attach/images/%s/tmp', $args->layout_srl);
     // Separately handle if a type of extra_vars is an image
     if ($layout_info->extra_var) {
         foreach ($layout_info->extra_var as $name => $vars) {
             if ($vars->type != 'image') {
                 continue;
             }
             $fileName = $extra_vars->{$name};
             if ($vars->value == $fileName) {
                 continue;
             }
             FileHandler::removeFile($vars->value);
             if (!$fileName) {
                 continue;
             }
             $pathInfo = pathinfo($fileName);
             $tmpFileName = sprintf('%s/tmp/%s', $pathInfo['dirname'], $pathInfo['basename']);
             if (!FileHandler::moveFile($tmpFileName, $fileName)) {
                 unset($extra_vars->{$name});
             }
         }
     }
     // Save header script into "config" of layout module
     $oModuleModel = getModel('module');
     $oModuleController = getController('module');
     $layout_config = new stdClass();
     $layout_config->header_script = Context::get('header_script');
     $oModuleController->insertModulePartConfig('layout', $args->layout_srl, $layout_config);
     // Save a title of the menu
     $extra_vars->menu_name_list = $menu_name_list;
     // Variable setting for DB insert
     $args->extra_vars = serialize($extra_vars);
     $output = $this->updateLayout($args);
     if (!$output->toBool()) {
         return $output;
     }
     FileHandler::removeDir($tmpDir);
     if (!$is_sitemap) {
         return $this->setRedirectUrl(Context::get('error_return_url'), $output);
     } else {
         $context = Context::getInstance();
         $context->setRequestMethod('JSON');
         $this->setMessage('success');
     }
 }
Exemplo n.º 20
0
 /**
  * @brief Execute update
  */
 function moduleUpdate()
 {
     $oDB =& DB::getInstance();
     // 2008. 10. 27 module_part_config Add a multi-index to the table and check all information of module_configg
     if (!$oDB->isIndexExists("module_part_config", "idx_module_part_config")) {
         $oModuleModel = getModel('module');
         $oModuleController = getController('module');
         $modules = $oModuleModel->getModuleList();
         foreach ($modules as $key => $module_info) {
             $module = $module_info->module;
             if (!in_array($module, array('point', 'trackback', 'layout', 'rss', 'file', 'comment', 'editor'))) {
                 continue;
             }
             $config = $oModuleModel->getModuleConfig($module);
             $module_config = null;
             switch ($module) {
                 case 'point':
                     $module_config = $config->module_point;
                     unset($config->module_point);
                     break;
                 case 'trackback':
                 case 'rss':
                 case 'file':
                 case 'comment':
                 case 'editor':
                     $module_config = $config->module_config;
                     unset($config->module_config);
                     if (is_array($module_config) && count($module_config)) {
                         foreach ($module_config as $key => $val) {
                             if (isset($module_config[$key]->module_srl)) {
                                 unset($module_config[$key]->module_srl);
                             }
                         }
                     }
                     break;
                 case 'layout':
                     $tmp = $config->header_script;
                     if (is_array($tmp) && count($tmp)) {
                         foreach ($tmp as $k => $v) {
                             if (!$v && !trim($v)) {
                                 continue;
                             }
                             $module_config[$k]->header_script = $v;
                         }
                     }
                     $config = null;
                     break;
             }
             $oModuleController->insertModuleConfig($module, $config);
             if (is_array($module_config) && count($module_config)) {
                 foreach ($module_config as $module_srl => $module_part_config) {
                     $oModuleController->insertModulePartConfig($module, $module_srl, $module_part_config);
                 }
             }
         }
         $oDB->addIndex("module_part_config", "idx_module_part_config", array("module", "module_srl"));
     }
     // 2008. 11. 13 drop index(unique_mid). Add a column and index on site_srl and mid columns
     if (!$oDB->isIndexExists('modules', "idx_site_mid")) {
         $oDB->dropIndex("modules", "unique_mid", true);
         $oDB->addColumn('modules', 'site_srl', 'number', 11, 0, true);
         $oDB->addIndex("modules", "idx_site_mid", array("site_srl", "mid"), true);
     }
     // document extra vars
     if (!$oDB->isTableExists('document_extra_vars')) {
         $oDB->createTableByXmlFile('./modules/document/schemas/document_extra_vars.xml');
     }
     if (!$oDB->isTableExists('document_extra_keys')) {
         $oDB->createTableByXmlFile('./modules/document/schemas/document_extra_keys.xml');
     }
     // Move permission, skin info, extection info, admin ID of all modules to the table, grants
     if ($oDB->isColumnExists('modules', 'grants')) {
         $oModuleController = getController('module');
         $oDocumentController = getController('document');
         // Get a value of the current system language code
         $lang_code = Context::getLangType();
         // Get module_info of all modules
         $output = executeQueryArray('module.getModuleInfos');
         if (count($output->data)) {
             foreach ($output->data as $module_info) {
                 // Separate information about permission granted to the module, extra vars, skin vars, super-admin's authority
                 $module_srl = trim($module_info->module_srl);
                 // grant an authority
                 $grants = unserialize($module_info->grants);
                 if ($grants) {
                     $oModuleController->insertModuleGrants($module_srl, $grants);
                 }
                 // Insert skin vars
                 $skin_vars = unserialize($module_info->skin_vars);
                 if ($skin_vars) {
                     $oModuleController->insertModuleSkinVars($module_srl, $skin_vars);
                 }
                 // Insert super admin's ID
                 $admin_id = trim($module_info->admin_id);
                 if ($admin_id && $admin_id != 'Array') {
                     $admin_ids = explode(',', $admin_id);
                     if (count($admin_id)) {
                         foreach ($admin_ids as $admin_id) {
                             $oModuleController->insertAdminId($module_srl, $admin_id);
                         }
                     }
                 }
                 // Save extra configurations for each module(column data which doesn't exist in the defaut modules)
                 $extra_vars = unserialize($module_info->extra_vars);
                 $document_extra_keys = null;
                 if ($extra_vars->extra_vars && count($extra_vars->extra_vars)) {
                     $document_extra_keys = $extra_vars->extra_vars;
                     unset($extra_vars->extra_vars);
                 }
                 if ($extra_vars) {
                     $oModuleController->insertModuleExtraVars($module_srl, $extra_vars);
                 }
                 /**
                  * Move document extra vars(it should have conducted in the documents module however extra vars in modules table should be listed up in this module)
                  */
                 // Insert extra vars if planet module is
                 if ($module_info->module == 'planet') {
                     if (!$document_extra_keys || !is_array($document_extra_keys)) {
                         $document_extra_keys = array();
                     }
                     $planet_extra_keys->name = 'postscript';
                     $planet_extra_keys->type = 'text';
                     $planet_extra_keys->is_required = 'N';
                     $planet_extra_keys->search = 'N';
                     $planet_extra_keys->default = '';
                     $planet_extra_keys->desc = '';
                     $document_extra_keys[20] = $planet_extra_keys;
                 }
                 // Register keys for document extra vars
                 if (count($document_extra_keys)) {
                     foreach ($document_extra_keys as $var_idx => $val) {
                         $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $val->name, $val->type, $val->is_required, $val->search, $val->default, $val->desc, 'extra_vars' . $var_idx);
                     }
                     // 2009-04-14 Fixed a bug that only 100 extra vars are moved
                     $oDocumentModel = getModel('document');
                     $total_count = $oDocumentModel->getDocumentCount($module_srl);
                     if ($total_count > 0) {
                         $per_page = 100;
                         $total_pages = (int) (($total_count - 1) / $per_page) + 1;
                         // Get extra vars if exist
                         $doc_args = null;
                         $doc_args->module_srl = $module_srl;
                         $doc_args->list_count = $per_page;
                         $doc_args->sort_index = 'list_order';
                         $doc_args->order_type = 'asc';
                         for ($doc_args->page = 1; $doc_args->page <= $total_pages; $doc_args->page++) {
                             $output = executeQueryArray('document.getDocumentList', $doc_args);
                             if ($output->toBool() && $output->data && count($output->data)) {
                                 foreach ($output->data as $document) {
                                     if (!$document) {
                                         continue;
                                     }
                                     foreach ($document as $key => $var) {
                                         if (strpos($key, 'extra_vars') !== 0 || !trim($var) || $var == 'N;') {
                                             continue;
                                         }
                                         $var_idx = str_replace('extra_vars', '', $key);
                                         $oDocumentController->insertDocumentExtraVar($module_srl, $document->document_srl, $var_idx, $var, 'extra_vars' . $var_idx, $lang_code);
                                     }
                                 }
                             }
                         }
                         // for total_pages
                     }
                     // if count
                 }
                 // Additional variables of the module, remove
                 $module_info->grant = null;
                 $module_info->extra_vars = null;
                 $module_info->skin_vars = null;
                 $module_info->admin_id = null;
                 executeQuery('module.updateModule', $module_info);
                 $oCacheHandler = CacheHandler::getInstance('object', null, true);
                 if ($oCacheHandler->isSupport()) {
                     $oCacheHandler->invalidateGroupKey('site_and_module');
                 }
             }
         }
         // Various column drop
         $oDB->dropColumn('modules', 'grants');
         $oDB->dropColumn('modules', 'admin_id');
         $oDB->dropColumn('modules', 'skin_vars');
         $oDB->dropColumn('modules', 'extra_vars');
     }
     // Rights of all modules/skins transferring the information into a table Update grants
     if (!$oDB->isColumnExists('sites', 'default_language')) {
         $oDB->addColumn('sites', 'default_language', 'varchar', 255, 0, false);
     }
     // extra_vars * Remove Column
     for ($i = 1; $i <= 20; $i++) {
         if (!$oDB->isColumnExists("documents", "extra_vars" . $i)) {
             continue;
         }
         $oDB->dropColumn('documents', 'extra_vars' . $i);
     }
     // Enter the main site information sites on the table
     $args = new stdClass();
     $args->site_srl = 0;
     $output = $oDB->executeQuery('module.getSite', $args);
     if (!$output->data) {
         // Basic mid, language Wanted
         $mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args);
         $domain = Context::getDefaultUrl();
         $url_info = parse_url($domain);
         $domain = $url_info['host'] . (!empty($url_info['port']) && $url_info['port'] != 80 ? ':' . $url_info['port'] : '') . $url_info['path'];
         $site_args->site_srl = 0;
         $site_args->index_module_srl = $mid_output->data->module_srl;
         $site_args->domain = $domain;
         $site_args->default_language = config('locale.default_lang');
         $output = executeQuery('module.insertSite', $site_args);
         if (!$output->toBool()) {
             return $output;
         }
     }
     if ($oDB->isIndexExists('sites', 'idx_domain')) {
         $oDB->dropIndex('sites', 'idx_domain');
     }
     if (!$oDB->isIndexExists('sites', 'unique_domain')) {
         $this->updateForUniqueSiteDomain();
         $oDB->addIndex('sites', 'unique_domain', array('domain'), true);
     }
     if (!$oDB->isColumnExists("modules", "use_mobile")) {
         $oDB->addColumn('modules', 'use_mobile', 'char', 1, 'N');
     }
     if (!$oDB->isColumnExists("modules", "mlayout_srl")) {
         $oDB->addColumn('modules', 'mlayout_srl', 'number', 11, 0);
     }
     if (!$oDB->isColumnExists("modules", "mcontent")) {
         $oDB->addColumn('modules', 'mcontent', 'bigtext');
     }
     if (!$oDB->isColumnExists("modules", "mskin")) {
         $oDB->addColumn('modules', 'mskin', 'varchar', 250);
     }
     if (!$oDB->isColumnExists("modules", "is_skin_fix")) {
         $oDB->addColumn('modules', 'is_skin_fix', 'char', 1, 'N');
         $output = executeQuery('module.updateSkinFixModules');
     }
     if (!$oDB->isColumnExists("module_config", "site_srl")) {
         $oDB->addColumn('module_config', 'site_srl', 'number', 11, 0, true);
     }
     FileHandler::makeDir('./files/ruleset');
     $args->skin = '.';
     $output = executeQueryArray('module.getModuleSkinDotList', $args);
     if ($output->data && count($output->data) > 0) {
         foreach ($output->data as $item) {
             $skin_path = explode('.', $item->skin);
             if (count($skin_path) != 2) {
                 continue;
             }
             if (is_dir(sprintf(_XE_PATH_ . 'themes/%s/modules/%s', $skin_path[0], $skin_path[1]))) {
                 unset($args);
                 $args->skin = $item->skin;
                 $args->new_skin = implode('|@|', $skin_path);
                 $output = executeQuery('module.updateSkinAll', $args);
             }
         }
     }
     // XE 1.7
     if (!$oDB->isColumnExists("modules", "is_mskin_fix")) {
         $oDB->addColumn('modules', 'is_mskin_fix', 'char', 1, 'N');
         $output = executeQuery('module.updateMobileSkinFixModules');
     }
     $oModuleModel = getModel('module');
     $moduleConfig = $oModuleModel->getModuleConfig('module');
     if (!$moduleConfig->isUpdateFixedValue) {
         $output = executeQuery('module.updateSkinFixModules');
         $output = executeQuery('module.updateMobileSkinFixModules');
         $oModuleController = getController('module');
         if (!$moduleConfig) {
             $moduleConfig = new stdClass();
         }
         $moduleConfig->isUpdateFixedValue = TRUE;
         $output = $oModuleController->updateModuleConfig('module', $moduleConfig);
     }
     return new Object(0, 'success_updated');
 }
Exemplo n.º 21
0
 /**
  * @brief Reset points for each module
  */
 function procPointAdminReset()
 {
     $module_srl = Context::get('module_srls');
     if (!$module_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     // In case of batch configuration of several modules
     if (preg_match('/^([0-9,]+)$/', $module_srl)) {
         $module_srl = explode(',', $module_srl);
     } else {
         $module_srl = array($module_srl);
     }
     // Save configurations
     $oModuleController = getController('module');
     for ($i = 0; $i < count($module_srl); $i++) {
         $srl = trim($module_srl[$i]);
         if (!$srl) {
             continue;
         }
         $args = new stdClass();
         $args->module = 'point';
         $args->module_srl = $srl;
         executeQuery('module.deleteModulePartConfig', $args);
     }
     $oCacheHandler = CacheHandler::getInstance('object', null, true);
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('site_and_module');
     }
     $this->setMessage('success_updated');
 }
Exemplo n.º 22
0
                                         $page_error[] = "Could not unlink " . $curFile;
                                     }
                                 }
                             }
                         }
                         if ($readingZip->getErrors()) {
                             $page_error[] = $readingZip->getErrors();
                         } else {
                             Config::set('upd_CodeVersion', $piece['version']);
                             $qry = DBFactory::getDBQuery(true);
                             $qry->execute("INSERT INTO `kb3_config` (cfg_site, cfg_key, cfg_value) " . "SELECT cfg_site, 'upd_codeVersion', '{$piece['version']}' FROM `kb3_config` " . "GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '{$piece['version']}';");
                             $codeversion = $piece['version'];
                         }
                         //kill the template and page caches
                         CacheHandler::removeByAge('store', 0, true);
                         CacheHandler::removeByAge('templates_c', 0, true);
                         break;
                     }
                 }
             }
         }
     }
 }
 //if we've finished an action, reparse the xml
 if (isset($_GET['db_apply_ref']) || isset($_GET['db_dl_ref']) || isset($_GET['code_apply_ref']) || isset($_GET['code_dl_ref'])) {
     $parser->retrieveData();
 }
 //list the db updates
 $db = $parser->getDBInfo();
 $lowestDB = $parser->getLowestDBVersion();
 if ($parser->getLatestDBVersion() > $dbversion) {
Exemplo n.º 23
0
 function _clearMemberCache($member_srl, $site_srl = 0)
 {
     $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
     if ($oCacheHandler->isSupport()) {
         $object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_' . $site_srl;
         $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
         $oCacheHandler->delete($cache_key);
         if ($site_srl !== 0) {
             $object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_0';
             $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
             $oCacheHandler->delete($cache_key);
         }
     }
     $oCacheHandler = CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
         $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
         $oCacheHandler->delete($cache_key);
     }
 }
Exemplo n.º 24
0
 /**
  * compiles specified tpl file and execution result in Context into resultant content
  * @param string $tpl_path path of the directory containing target template file
  * @param string $tpl_filename target template file's name
  * @param string $tpl_file if specified use it as template file's full path
  * @return string Returns compiled result in case of success, NULL otherwise
  */
 public function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     $buff = false;
     // store the starting time for debug information
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // initiation
     $this->init($tpl_path, $tpl_filename, $tpl_file);
     // if target file does not exist exit
     if (!$this->file || !file_exists($this->file)) {
         return "Err : '{$this->file}' template file does not exists.";
     }
     // for backward compatibility
     if (is_null(self::$rootTpl)) {
         self::$rootTpl = $this->file;
     }
     $source_template_mtime = filemtime($this->file);
     $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime;
     // cache control
     $oCacheHandler = CacheHandler::getInstance('template');
     // get cached buff
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'template:' . $this->file;
         $buff = $oCacheHandler->get($cache_key, $latest_mtime);
     } else {
         if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) {
             $buff = 'file://' . $this->compiled_file;
         }
     }
     if ($buff === FALSE) {
         $buff = $this->parse();
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $buff);
         } else {
             FileHandler::writeFile($this->compiled_file, $buff);
         }
     }
     $output = $this->_fetch($buff);
     if ($__templatehandler_root_tpl == $this->file) {
         $__templatehandler_root_tpl = null;
     }
     // store the ending time for debug information
     if (__DEBUG__ == 3) {
         $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
Exemplo n.º 25
0
 /**
  * Delete cached group data
  * @return void
  */
 function _deleteMemberGroupCache($site_srl = 0)
 {
     //remove from cache
     $oCacheHandler = CacheHandler::getInstance('object', null, true);
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('member');
     }
 }
Exemplo n.º 26
0
 /**
  * Delete all comments of the specific module
  * @return object
  */
 function deleteModuleComments($module_srl)
 {
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $output = executeQuery('comment.deleteModuleComments', $args);
     if (!$output->toBool()) {
         return $output;
     }
     $output = executeQuery('comment.deleteModuleCommentsList', $args);
     //remove from cache
     $oCacheHandler = CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         // Invalidate newest comments. Per document cache is invalidated inside document admin controller.
         $oCacheHandler->invalidateGroupKey('newestCommentsList');
     }
     return $output;
 }
Exemplo n.º 27
0
 /**
  * Parse loaded template
  *
  * @param integer $level Current level of parsing
  * @param array $tags Leave blank, used for recursion
  * @param boolean $parent_block If parent tag is block element
  */
 public function parse($tags = array())
 {
     global $section, $action, $language, $template_path, $system_template_path;
     if (!$this->active && empty($tags)) {
         return;
     }
     // get language handler for later
     $language_handler = MainLanguageHandler::getInstance();
     // take the tag list for parsing
     $tag_array = empty($tags) ? $this->engine->document->tagChildren : $tags;
     // start parsing tags
     $count = count($tag_array);
     for ($i = 0; $i < $count; $i++) {
         $tag = $tag_array[$i];
         // if tag has eval set
         if (isset($tag->tagAttrs['cms:eval']) || isset($tag->tagAttrs['eval'])) {
             // get evaluation values
             if (isset($tag->tagAttrs['eval'])) {
                 $value = $tag->tagAttrs['eval'];
             } else {
                 $value = $tag->tagAttrs['cms:eval'];
             }
             $eval_params = explode(',', $value);
             foreach ($eval_params as $param) {
                 // prepare module includes for evaluation
                 $settings = array();
                 if (!is_null($this->module)) {
                     $settings = $this->module->settings;
                 }
                 $params = $this->params;
                 $to_eval = $tag->tagAttrs[$param];
                 $tag->tagAttrs[$param] = eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';');
             }
             // unset param
             unset($tag->tagAttrs['cms:eval']);
         }
         if (isset($tag->tagAttrs['cms:optional'])) {
             // get evaluation values
             $optional_params = explode(',', $tag->tagAttrs['cms:optional']);
             foreach ($optional_params as $param) {
                 // prepare module includes for evaluation
                 $settings = array();
                 if (!is_null($this->module)) {
                     $settings = $this->module->settings;
                 }
                 $params = $this->params;
                 $to_eval = $tag->tagAttrs[$param];
                 $value = eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';');
                 if ($value == false) {
                     unset($tag->tagAttrs[$param]);
                 } else {
                     $tag->tagAttrs[$param] = $value;
                 }
             }
             // unset param
             unset($tag->tagAttrs['cms:optional']);
         }
         // implement tooltip
         if (isset($tag->tagAttrs['cms:tooltip'])) {
             if (!is_null($this->module)) {
                 $value = $this->module->getLanguageConstant($tag->tagAttrs['cms:tooltip']);
             } else {
                 $value = $language_handler->getText($tag->tagAttrs['cms:tooltip']);
             }
             $tag->tagAttrs['data-tooltip'] = $value;
             unset($tag->tagAttrs['cms:tooltip']);
         }
         // implement constants
         if (isset($tag->tagAttrs['cms:constant'])) {
             $params = explode(',', $tag->tagAttrs['cms:constant']);
             if (count($params) > 0) {
                 foreach ($params as $param) {
                     if (!is_null($this->module)) {
                         $tag->tagAttrs[$param] = $this->module->getLanguageConstant($tag->tagAttrs[$param]);
                     } else {
                         $tag->tagAttrs[$param] = $language_handler->getText($tag->tagAttrs[$param]);
                     }
                 }
             }
             unset($tag->tagAttrs['cms:constant']);
         }
         // check if specified tag shouldn't be cached
         $skip_cache = false;
         if (isset($tag->tagAttrs['skip_cache'])) {
             // unset param
             unset($tag->tagAttrs['skip_cache']);
             // get cache handler
             $cache = CacheHandler::getInstance();
             // only if current URL is being cached, we start dirty area
             if ($cache->isCaching()) {
                 $cache->startDirtyArea();
                 $skip_cache = true;
                 // reconstruct template for cache,
                 // ugly but we are not doing it a lot
                 $data = $this->getDataForCache($tag);
                 $cache->setCacheForDirtyArea($data);
             }
         }
         // now parse the tag
         switch ($tag->tagName) {
             // handle tag used for setting session variable
             case '_session':
             case 'cms:session':
                 $name = $tag->tagAttrs['name'];
                 // allow setting referral only once per seesion
                 if (isset($tag->tagAttrs['once'])) {
                     $only_once = in_array($tag->tagAttrs['once'], array(1, 'yes'));
                 } else {
                     $only_once = false;
                 }
                 $should_set = $only_once && !isset($_SESSION[$name]) || !$only_once;
                 // store value
                 if (!in_array($name, $this->protected_variables) && $should_set) {
                     $_SESSION[$name] = $tag->tagAttrs['value'];
                 }
                 break;
                 // transfer control to module
             // transfer control to module
             case '_module':
             case 'cms:module':
                 if (class_exists($tag->tagAttrs['name'])) {
                     $module = call_user_func(array($tag->tagAttrs['name'], 'getInstance'));
                     $module->transferControl($tag->tagAttrs, $tag->tagChildren);
                 }
                 break;
                 // load other template
             // load other template
             case '_template':
             case 'cms:template':
                 $file = $tag->tagAttrs['file'];
                 $path = key_exists('path', $tag->tagAttrs) ? $tag->tagAttrs['path'] : '';
                 if (!is_null($this->module)) {
                     $path = preg_replace('/^%module%/i', $this->module->path, $path);
                     $path = preg_replace('/^%templates%/i', $template_path, $path);
                 }
                 $new = new TemplateHandler($file, $path);
                 $new->setLocalParams($this->params);
                 $new->parse();
                 break;
                 // raw text copy
             // raw text copy
             case '_raw':
             case 'cms:raw':
                 if (key_exists('file', $tag->tagAttrs)) {
                     // if file attribute is specified
                     $file = $tag->tagAttrs['file'];
                     $path = key_exists('path', $tag->tagAttrs) ? $tag->tagAttrs['path'] : $template_path;
                     $text = file_get_contents($path . $file);
                 } elseif (key_exists('text', $tag->tagAttrs)) {
                     // if text attribute is specified
                     $text = $tag->tagAttrs['text'];
                 } else {
                     // in any other case we display data inside tag
                     $text = $tag->tagData;
                 }
                 echo $text;
                 break;
                 // multi language constants
             // multi language constants
             case '_text':
             case 'cms:text':
                 $constant = $tag->tagAttrs['constant'];
                 $language = key_exists('language', $tag->tagAttrs) ? $tag->tagAttrs['language'] : $language;
                 $text = "";
                 // check if constant is module based
                 if (key_exists('module', $tag->tagAttrs)) {
                     if (class_exists($tag->tagAttrs['module'])) {
                         $module = call_user_func(array($tag->tagAttrs['module'], 'getInstance'));
                         $text = $module->getLanguageConstant($constant, $language);
                     }
                 } else {
                     // use default language handler
                     $text = MainLanguageHandler::getInstance()->getText($constant, $language);
                 }
                 echo $text;
                 break;
                 // support for markdown
             // support for markdown
             case 'cms:markdown':
                 $char_count = isset($tag->tagAttrs['chars']) ? fix_id($tag->tagAttrs['chars']) : null;
                 $end_with = isset($tag->tagAttrs['end_with']) ? fix_id($tag->tagAttrs['end_with']) : null;
                 $name = isset($tag->tagAttrs['param']) ? $tag->tagAttrs['param'] : null;
                 $multilanguage = isset($tag->tagAttrs['multilanguage']) ? $tag->tagAttrs['multilanguage'] == 'yes' : false;
                 // get content for parsing
                 if (is_null($name)) {
                     $content = $tag->tagData;
                 }
                 $content = $multilanguage ? $this->params[$name][$language] : $this->params[$name];
                 // convert to HTML
                 $content = Markdown($content);
                 // limit words if specified
                 if (!is_null($char_count)) {
                     if (is_null($end_with)) {
                         $content = limit_words($content, $char_count);
                     } else {
                         $content = limit_words($content, $char_count, $end_with);
                     }
                 }
                 echo $content;
                 break;
                 // call section specific data
             // call section specific data
             case '_section_data':
             case 'cms:section_data':
                 if (!is_null($this->module)) {
                     $file = $this->module->getSectionFile($section, $action, $language);
                     $new = new TemplateHandler(basename($file), dirname($file) . '/');
                     $new->setLocalParams($this->params);
                     $new->setMappedModule($this->module);
                     $new->parse();
                 } else {
                     // log error
                     trigger_error('Mapped module is not loaded! File: ' . $this->file, E_USER_WARNING);
                 }
                 break;
                 // print multilanguage data
             // print multilanguage data
             case '_language_data':
             case 'cms:language_data':
                 $name = isset($tag->tagAttrs['param']) ? $tag->tagAttrs['param'] : null;
                 if (!isset($this->params[$name]) || !is_array($this->params[$name]) || is_null($name)) {
                     break;
                 }
                 $template = new TemplateHandler('language_data.xml', $system_template_path);
                 $template->setMappedModule($this->module);
                 foreach ($this->params[$name] as $lang => $data) {
                     $params = array('param' => $name, 'language' => $lang, 'data' => $data);
                     $template->restoreXML();
                     $template->setLocalParams($params);
                     $template->parse();
                 }
                 break;
                 // replace tag data string with matching params
             // replace tag data string with matching params
             case '_replace':
             case 'cms:replace':
                 $pool = isset($tag->tagAttrs['param']) ? $this->params[$tag->tagAttrs['param']] : $this->params;
                 $keys = array_keys($pool);
                 $values = array_values($pool);
                 foreach ($keys as $i => $key) {
                     $keys[$i] = "%{$key}%";
                 }
                 // we can't replact string with array, only matching data types
                 foreach ($values as $i => $value) {
                     if (is_array($value)) {
                         unset($keys[$i]);
                         unset($values[$i]);
                     }
                 }
                 echo str_replace($keys, $values, $tag->tagData);
                 break;
                 // conditional tag
             // conditional tag
             case '_if':
             case 'cms:if':
                 $settings = !is_null($this->module) ? $this->module->settings : array();
                 $params = $this->params;
                 $condition = true;
                 // check if section is specified and matches
                 if (isset($tag->tagAttrs['section'])) {
                     $condition &= $tag->tagAttrs['section'] == $section;
                 }
                 // check if action is specified and matches
                 if (isset($tag->tagAttrs['action'])) {
                     $condition &= $tag->tagAttrs['action'] == $action;
                 }
                 // check custom condition
                 if (isset($tag->tagAttrs['condition'])) {
                     $to_eval = $tag->tagAttrs['condition'];
                     $eval_result = eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';') == true;
                     $condition &= $eval_result;
                 }
                 // parse children
                 if ($condition) {
                     $this->parse($tag->tagChildren);
                 }
                 break;
                 // conditional tag parsed for desktop version
             // conditional tag parsed for desktop version
             case 'cms:desktop':
                 if (_DESKTOP_VERSION) {
                     $this->parse($tag->tagChildren);
                 }
                 break;
                 // conditional tag parsed for mobile version
             // conditional tag parsed for mobile version
             case 'cms:mobile':
                 if (_MOBILE_VERSION) {
                     $this->parse($tag->tagChildren);
                 }
                 break;
                 // conditional tag parsed for users that are logged in
             // conditional tag parsed for users that are logged in
             case 'cms:user':
                 if ($_SESSION['logged']) {
                     $this->parse($tag->tagChildren);
                 }
                 break;
                 // conditional tag parsed for guests
             // conditional tag parsed for guests
             case 'cms:guest':
                 if (!$_SESSION['logged']) {
                     $this->parse($tag->tagChildren);
                 }
                 break;
                 // variable
             // variable
             case '_var':
             case 'cms:var':
                 $settings = array();
                 if (!is_null($this->module)) {
                     $settings = $this->module->settings;
                 }
                 $params = $this->params;
                 $to_eval = $tag->tagAttrs['name'];
                 echo eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';');
                 break;
                 // support for script tag
             // support for script tag
             case 'cms:script':
                 if (class_exists('head_tag')) {
                     $head_tag = head_tag::getInstance();
                     $head_tag->addTag('script', $tag->tagAttrs);
                 }
                 break;
                 // support for collection module
             // support for collection module
             case 'cms:collection':
                 if (array_key_exists('include', $tag->tagAttrs) && class_exists('collection')) {
                     $scripts = fix_chars(explode(',', $tag->tagAttrs['include']));
                     $collection = collection::getInstance();
                     $collection->includeScript($scripts);
                 }
                 break;
                 // support for link tag
             // support for link tag
             case 'cms:link':
                 if (class_exists('head_tag')) {
                     $head_tag = head_tag::getInstance();
                     $head_tag->addTag('link', $tag->tagAttrs);
                 }
                 break;
                 // support for parameter based choice
             // support for parameter based choice
             case 'cms:choice':
                 $param_value = null;
                 if (array_key_exists('param', $tag->tagAttrs)) {
                     // grap param value from GET or POST parameters
                     $param_name = fix_chars($tag->tagAttrs['param']);
                     $param_value = isset($_REQUEST[$param_name]) ? fix_chars($_REQUEST[$param_name]) : null;
                 } else {
                     if (array_key_exists('value', $tag->tagAttrs)) {
                         // use param value specified
                         $param_value = fix_chars($tag->tagAttrs['value']);
                     }
                 }
                 // parse only option
                 foreach ($tag->tagChildren as $option) {
                     if (!$option->tagName == 'option') {
                         continue;
                     }
                     $option_value = isset($option->tagAttrs['value']) ? $option->tagAttrs['value'] : null;
                     $option_default = isset($option->tagAttrs['default']) ? $option->tagAttrs['default'] == 1 : false;
                     // values match or option is default, parse its content
                     if ($option_value == $param_value || $option_default) {
                         $this->parse($option->tagChildren);
                         break;
                     }
                 }
                 break;
                 // default action for parser, draw tag
             // default action for parser, draw tag
             default:
                 if (in_array($tag->tagName, array_keys($this->handlers))) {
                     // custom tag handler is set...
                     $handle = $this->handlers[$tag->tagName];
                     $obj = $handle['object'];
                     $function = $handle['function'];
                     $obj->{$function}($tag->tagAttrs, $tag->tagChildren);
                 } else {
                     // default tag handler
                     echo '<' . $tag->tagName . $this->getTagParams($tag->tagAttrs) . '>';
                     if (count($tag->tagChildren) > 0) {
                         $this->parse($tag->tagChildren);
                     }
                     if (count($tag->tagData) > 0) {
                         echo $tag->tagData;
                     }
                     $close_tag = $this->close_all_tags ? true : !in_array($tag->tagName, $this->tags_without_end);
                     if ($close_tag) {
                         echo '</' . $tag->tagName . '>';
                     }
                 }
                 break;
         }
         // end cache dirty area if initialized
         if ($skip_cache) {
             $cache->endDirtyArea();
         }
     }
 }
Exemplo n.º 28
0
 /**
  * @brief Widget cache handling
  */
 function getCache($widget, $args, $lang_type = null, $ignore_cache = false)
 {
     // If the specified language specifies the current language
     if (!$lang_type) {
         $lang_type = Context::getLangType();
     }
     // widget, the cache number and cache values are set
     $widget_sequence = $args->widget_sequence;
     $widget_cache = $args->widget_cache;
     /**
      * Even if the cache number and value of the cache and return it to extract data
      */
     if (!$ignore_cache && (!$widget_cache || !$widget_sequence)) {
         $oWidget = $this->getWidgetObject($widget);
         if (!$oWidget || !method_exists($oWidget, 'proc')) {
             return;
         }
         $widget_content = $oWidget->proc($args);
         $oModuleController = getController('module');
         $oModuleController->replaceDefinedLangCode($widget_content);
         return $widget_content;
     }
     $oCacheHandler = CacheHandler::getInstance('template');
     if ($oCacheHandler->isSupport()) {
         $key = 'widget_cache:' . $widget_sequence;
         $cache_body = $oCacheHandler->get($key);
         $cache_body = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $cache_body);
     }
     if ($cache_body) {
         return $cache_body;
     } else {
         /**
          * Cache number and cache values are set so that the cache file should call
          */
         FileHandler::makeDir($this->cache_path);
         // Wanted cache file
         $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
         // If the file exists in the cache, the file validation
         if (!$ignore_cache && file_exists($cache_file)) {
             $filemtime = filemtime($cache_file);
             // Should be modified compared to the time of the cache or in the future if creating more than widget.controller.php file a return value of the cache
             if ($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_ . 'modules/widget/widget.controller.php')) {
                 $cache_body = FileHandler::readFile($cache_file);
                 $cache_body = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $cache_body);
                 return $cache_body;
             }
         }
         // cache update and cache renewal of the file mtime
         touch($cache_file);
         $oWidget = $this->getWidgetObject($widget);
         if (!$oWidget || !method_exists($oWidget, 'proc')) {
             return;
         }
         $widget_content = $oWidget->proc($args);
         $oModuleController = getController('module');
         $oModuleController->replaceDefinedLangCode($widget_content);
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($key, $widget_content, $widget_cache * 60);
         } else {
             FileHandler::writeFile($cache_file, $widget_content);
         }
     }
     return $widget_content;
 }
Exemplo n.º 29
0
 /**
  * Control the order of extra variables
  * @return void|object
  */
 function procDocumentAdminMoveExtraVar()
 {
     $type = Context::get('type');
     $module_srl = Context::get('module_srl');
     $var_idx = Context::get('var_idx');
     if (!$type || !$module_srl || !$var_idx) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oModuleModel = getModel('module');
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
     if (!$module_info->module_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oDocumentModel = getModel('document');
     $extra_keys = $oDocumentModel->getExtraKeys($module_srl);
     if (!$extra_keys[$var_idx]) {
         return new Object(-1, 'msg_invalid_request');
     }
     if ($type == 'up') {
         $new_idx = $var_idx - 1;
     } else {
         $new_idx = $var_idx + 1;
     }
     if ($new_idx < 1) {
         return new Object(-1, 'msg_invalid_request');
     }
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $args->var_idx = $new_idx;
     $output = executeQuery('document.getDocumentExtraKeys', $args);
     if (!$output->toBool()) {
         return $output;
     }
     if (!$output->data) {
         return new Object(-1, 'msg_invalid_request');
     }
     unset($args);
     // update immediately if there is no idx to change
     if (!$extra_keys[$new_idx]) {
         $args = new stdClass();
         $args->module_srl = $module_srl;
         $args->var_idx = $var_idx;
         $args->new_idx = $new_idx;
         $output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('document.updateDocumentExtraVarIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         // replace if exists
     } else {
         $args = new stdClass();
         $args->module_srl = $module_srl;
         $args->var_idx = $new_idx;
         $args->new_idx = -10000;
         $output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('document.updateDocumentExtraVarIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $args->var_idx = $var_idx;
         $args->new_idx = $new_idx;
         $output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('document.updateDocumentExtraVarIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $args->var_idx = -10000;
         $args->new_idx = $var_idx;
         $output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('document.updateDocumentExtraVarIdx', $args);
         if (!$output->toBool()) {
             return $output;
         }
     }
     $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
     if ($oCacheHandler->isSupport()) {
         $object_key = 'module_document_extra_keys:' . $module_srl;
         $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
         $oCacheHandler->delete($cache_key);
     }
 }
Exemplo n.º 30
0
 /**
  * @brief get a comment list of the doc in corresponding woth document_srl.
  **/
 function getReviewList($module_srl, $item_srl, $page = 0, $is_admin = false, $count = 0)
 {
     // cache controll
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $object_key = 'object:' . $item_srl . '_' . $page . '_' . ($is_admin ? 'Y' : 'N') . '_' . $count;
         $cache_key = $oCacheHandler->getGroupKey('reviewList', $object_key);
         $output = $oCacheHandler->get($cache_key);
     }
     if (!$output) {
         /*
         		$oStoreModel = getModel('nstore_digital');
         		$oItemInfo = $oStoreModel->getItemInfo($item_srl);
         		$module_srl = $oItemInfo->module_srl;
         */
         if (!$count) {
             /*
             $comment_config = $this->getCommentConfig($module_srl);
             $comment_count = $comment_config->comment_count;
             */
             if (!$comment_count) {
                 $comment_count = 50;
             }
         } else {
             $comment_count = $count;
         }
         // get a very last page if no page exists
         //if(!$page) $page = (int)( ($oDocument->getCommentCount()-1) / $comment_count) + 1;
         if (!$page) {
             $page = 1;
         }
         // get a list of comments
         $args = new stdClass();
         $args->item_srl = $item_srl;
         $args->list_count = $comment_count;
         $args->page = $page;
         $args->page_count = 10;
         $output = executeQueryArray('store_review.getReviewPageList', $args);
         // return if an error occurs in the query results
         if (!$output->toBool()) {
             return $output;
         }
         // insert data into CommentPageList table if the number of results is different from stored comments
         if (!$output->data) {
             $this->fixCommentList($module_srl, $item_srl);
             $output = executeQueryArray('store_review.getReviewPageList', $args);
             if (!$output->toBool()) {
                 return $output;
             }
         }
         //insert in cache
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $output);
         }
     }
     return $output;
 }