Пример #1
0
# End of configuration.
/*****************************************************************
* Initialize admin script
******************************************************************/
# Setup error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
# Define a path to us
define('ADMIN_URI', $_SERVER['PHP_SELF']);
# Define the current admin version
define('ADMIN_VERSION', '1.4.1');
# Start buffering
ob_start();
# Set up equivalents to glype's /includes/init.php constants
# that might be available in the settings file
define('GLYPE_URL', pathToURL(dirname(ADMIN_GLYPE_SETTINGS) . '/..'));
define('GLYPE_ROOT', str_replace('\\', '/', dirname(dirname(realpath(ADMIN_GLYPE_SETTINGS)))));
# And backwards compatibility (will be removed at some point)
function findURL()
{
    return GLYPE_URL;
}
define('LCNSE_KEY', '');
define('proxyPATH', GLYPE_ROOT . '/');
# Load current settings
$settingsLoaded = file_exists(ADMIN_GLYPE_SETTINGS) && @(include ADMIN_GLYPE_SETTINGS);
# Extract the "action" from the query string
$action = isset($_SERVER['QUERY_STRING']) && preg_match('#^([a-z-]+)#', $_SERVER['QUERY_STRING'], $tmp) ? $tmp[1] : '';
$cache_bust = filemtime(__FILE__) + filemtime(ADMIN_GLYPE_SETTINGS);
# SHORTCUTS
# Make a newline
Пример #2
0
 function dirToURL($path)
 {
     return pathToURL($path);
 }
Пример #3
0
 /**
  * @desc  Functiuon to get thumbnail for media ID
  * @return string
  * @author		Peter Ivanov
  * @version 1.0
  * @since Version 1.0
  * @todo add thumbs support for videos
  */
 function mediaGetThumbnailForMediaId($id, $size_width = 128, $size_height = false)
 {
     if (!is_array($id)) {
         if (intval($id) == 0) {
             return false;
         }
         $cache_group = 'media/' . $id;
     } else {
         $cache_group = 'media/global';
     }
     $args = func_get_args();
     //p($id);
     foreach ($args as $k => $v) {
         $function_cache_id = $function_cache_id . serialize($k) . serialize($v);
     }
     $function_cache_id = __FUNCTION__ . md5($function_cache_id);
     $cache_content = $this->cacheGetContentAndDecode($function_cache_id, $cache_group);
     if ($cache_content != false) {
         if (trim(strval($cache_content)) == 'false') {
             return false;
         } else {
             return $cache_content;
         }
     }
     $size = $size_width;
     if ($size_height == false) {
         $size_height = $size;
     }
     $this->load->library('image_lib');
     global $cms_db_tables;
     $table = $cms_db_tables['table_media'];
     //	p ( $id );
     if ($id != 'no_picture') {
         if (intval($id) == 0) {
             return 'Error, please enter valid media $id, this one is invalid: ' . $id;
         }
     }
     $id_orig = $id;
     if (is_array($id)) {
         //p($id);
         if (isset($id_orig['no_picture'])) {
             $id = 'no_picture';
         }
         if (trim($id_orig["no_picture_to_table"]) != '') {
             $generate_no_picture_image_to_table = $id_orig["no_picture_to_table"];
         }
     }
     $media_url = CI::model('core')->mediaGetUrlDir();
     if ($id != 'no_picture') {
         $media_get = array();
         //$media_get = $this->mediaGet ( $to_table = false, $to_table_id = false, $media_type = false, $order_direction = 'DESC', $no_cache = false, $id );
         //	$media_get = $media_get ["pictures"];
         $media_get['id'] = $id;
         //$media_get = $this->getDbData ( $table, $media_get, false, false, $orderby, $cache_group, $debug = false );
         //
         $media_get1 = $this->mediaGetById($id);
         $media_get[0] = $media_get1;
         //var_dump ( $media_get );
         if (!empty($media_get)) {
             foreach ($media_get as $item) {
                 switch ($item['media_type']) {
                     case 'picture':
                         $file_path = MEDIAFILES . 'pictures/original/' . $item['filename'];
                         if (is_file($file_path) == true and trim($item['filename']) != '') {
                             if ($size == 'original') {
                                 $file_path = MEDIAFILES . 'pictures/original/' . $item['filename'];
                                 $src = pathToURL($file_path);
                                 $this->cacheWriteAndEncode($src, $function_cache_id, $cache_group);
                                 return $src;
                             }
                             $origina_filename = $item['filename'];
                             $the_original_dir = MEDIAFILES . $test1;
                             $the_original_dir = dirname($file_path);
                             $the_original_dir = $the_original_dir . '/';
                             $the_original_dir = reduce_double_slashes($the_original_dir);
                             $new_filename = $the_original_dir . $size . '_' . $size_height . '/' . $origina_filename;
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace('(', '-', $new_filename);
                             $new_filename = str_ireplace(')', '-', $new_filename);
                             $new_filename = str_ireplace('{', '-', $new_filename);
                             $new_filename = str_ireplace('}', '-', $new_filename);
                             $new_filename = str_ireplace('%', '-', $new_filename);
                             $new_filename = str_ireplace('%', '-', $new_filename);
                             if (!is_dir($the_original_dir . $size . '_' . $size_height)) {
                                 @mkdir_recursive($the_original_dir . $size . '_' . $size_height . '/');
                             } else {
                                 if (!is_writable($the_original_dir . $size . '_' . $size_height)) {
                                 }
                             }
                             $new_filename_url = $the_original_dir . $size . '_' . $size_height . '/' . $origina_filename;
                             $new_filename_url = str_ireplace(MEDIAFILES, $media_url, $new_filename_url);
                             //p($new_filename);
                             //p($file_path);
                             $new_filename_url = pathToURL($new_filename);
                             if (is_file($new_filename) == TRUE) {
                                 $src = $new_filename_url;
                             } else {
                                 $config['image_library'] = 'gd2';
                                 $config['source_image'] = $file_path;
                                 $config['create_thumb'] = false;
                                 $config['new_image'] = $new_filename;
                                 $config['maintain_ratio'] = TRUE;
                                 $config['width'] = $size;
                                 $config['height'] = $size_height;
                                 $config['quality'] = '100%';
                                 //	p ( $new_filename, 1 );
                                 $src = $new_filename_url;
                                 $this->image_lib->initialize($config);
                                 if (!$this->image_lib->resize()) {
                                     echo $this->image_lib->display_errors();
                                 }
                                 //	$this->image_lib->resize ();
                             }
                         } else {
                             $generate_no_picture_image = true;
                             $generate_no_picture_image_to_table = $item['to_table'];
                         }
                         break;
                     case 'video':
                         $media_get_vid_thumbnail = array();
                         //$media_get = $this->mediaGet ( $to_table = false, $to_table_id = false, $media_type = false, $order_direction = 'DESC', $no_cache = false, $id );
                         //	$media_get = $media_get ["pictures"];
                         $media_get_vid_thumbnail['to_table_id'] = $item['id'];
                         $media_get_vid_thumbnail['to_table'] = 'table_media';
                         $media_get_vid_thumbnail['media_type'] = 'picture';
                         $media_get_vid_thumbnail_orderby = array();
                         $media_get_vid_thumbnail_orderby[0] = 'media_order';
                         $media_get_vid_thumbnail_orderby[1] = 'DESC';
                         $media_get_vid_thumbnail = $this->getDbData($table, $media_get_vid_thumbnail, false, false, $media_get_vid_thumbnail_orderby, $cache_group = false, $debug = false);
                         if (!empty($media_get_vid_thumbnail)) {
                             $file_path = MEDIAFILES . 'pictures/original/' . $media_get_vid_thumbnail[0]['filename'];
                         } else {
                             $file_path = MEDIAFILES . 'pictures/original/' . $item['filename'];
                             $media_get_vid_thumbnail[0]['filename'] = $item['filename'];
                         }
                         //	p($file_path);
                         $file_path = normalize_path($file_path, false);
                         if (is_file($file_path) == true) {
                             //
                             //$test1 = str_ireplace ( $media_url, '', $file_path );
                             //	print 'test1 is'. $test1;
                             $origina_filename = $media_get_vid_thumbnail[0]['filename'];
                             //$test1
                             $the_original_dir = MEDIAFILES . $test1;
                             $the_original_dir = dirname($file_path);
                             $the_original_dir2 = dirname($the_original_dir);
                             $the_original_dir2 = $the_original_dir2 . '/';
                             $the_original_dir = $the_original_dir . '/';
                             $the_original_dir = reduce_double_slashes($the_original_dir);
                             $new_filename = $the_original_dir2 . $size . '_' . $size_height . '/' . $origina_filename;
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace(' ', '-', $new_filename);
                             $new_filename = str_ireplace('(', '-', $new_filename);
                             $new_filename = str_ireplace(')', '-', $new_filename);
                             $new_filename = str_ireplace('{', '-', $new_filename);
                             $new_filename = str_ireplace('}', '-', $new_filename);
                             $new_filename = str_ireplace('%', '-', $new_filename);
                             $new_filename = str_ireplace('%', '-', $new_filename);
                             if (is_dir($the_original_dir2 . $size . '_' . $size_height . '/') == false) {
                                 mkdir_recursive($the_original_dir2 . $size . '_' . $size_height . '/');
                             }
                             $new_filename_url = $the_original_dir2 . $size . '_' . $size_height . '/' . $origina_filename;
                             $new_filename_url = str_ireplace(MEDIAFILES, $media_url, $new_filename_url);
                             //p($new_filename_url);
                             $new_filename_url = pathToURL($new_filename);
                             if (is_file($new_filename) == TRUE) {
                                 $src = $new_filename_url;
                             } else {
                                 $config['image_library'] = 'gd2';
                                 $config['source_image'] = $file_path;
                                 $config['create_thumb'] = false;
                                 $config['new_image'] = $new_filename;
                                 $config['maintain_ratio'] = TRUE;
                                 $config['width'] = $size;
                                 $config['height'] = $size_height;
                                 $config['quality'] = '100%';
                                 $src = $new_filename_url;
                                 $this->image_lib->initialize($config);
                                 $this->image_lib->resize();
                             }
                             $src = str_ireplace(' ', '-', $src);
                             $src = str_ireplace('(', '-', $src);
                             $src = str_ireplace(')', '-', $src);
                             $src = str_ireplace('{', '-', $src);
                             $src = str_ireplace('}', '-', $src);
                             $src = str_ireplace('%', '-', $src);
                             $src = str_ireplace('%', '-', $src);
                             //	$data = array ();
                             //	$data ['url'] = $this->mediaGetUrlDir () . 'pictures/original/' . $item ['filename'];
                             ////	$data ['id'] = $item ['id'];
                             //	$data ['filename'] = $item ['filename'];
                             //	$media_get_to_return [] = $data;
                         } else {
                             //$ids_to_delete [] = $item ['id'];
                             $src = $media_url . 'pictures/no_video.png';
                             //return $src;
                             $test1 = str_ireplace($media_url, '', $src);
                         }
                         break;
                     default:
                         break;
                 }
                 //$media_get_to_return[] = $item;
             }
         } else {
             $generate_no_picture_image = true;
         }
     } else {
         $generate_no_picture_image = true;
     }
     if ($generate_no_picture_image == true) {
         $src = $media_url . 'pictures/no.gif';
         $test1 = str_ireplace($media_url, '', $src);
         $test1_local = MEDIAFILES . $test1;
         if ($generate_no_picture_image_to_table != false) {
             $tt_no_image = MEDIAFILES . 'pictures/no_' . $generate_no_picture_image_to_table . '.gif';
             if (is_file($tt_no_image) == true) {
                 $test1 = 'pictures/no_' . $generate_no_picture_image_to_table . '.gif';
                 $test1 = str_ireplace($media_url, '', $test1);
                 $test1_local = MEDIAFILES . $test1;
             }
         }
         if (is_file($test1_local) == true) {
             $the_original_dir = $test1_local;
             $the_original_dir = dirname($the_original_dir);
             $the_original_dir = $the_original_dir . '/';
             $the_original_dir = reduce_double_slashes($the_original_dir);
             $origina_filename = str_ireplace($the_original_dir, '', MEDIAFILES . $test1);
             $new_filename = $the_original_dir . $size . '_' . $size_height . '/' . $origina_filename;
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace(' ', '-', $new_filename);
             $new_filename = str_ireplace('(', '-', $new_filename);
             $new_filename = str_ireplace(')', '-', $new_filename);
             $new_filename = str_ireplace('{', '-', $new_filename);
             $new_filename = str_ireplace('}', '-', $new_filename);
             $new_filename = str_ireplace('%', '-', $new_filename);
             $new_filename = str_ireplace('%', '-', $new_filename);
             @mkdir_recursive($the_original_dir . $size . '_' . $size_height . '/');
             $new_filename_url = $the_original_dir . $size . '_' . $size_height . '/' . $origina_filename;
             $new_filename_url = str_ireplace(MEDIAFILES, $media_url, $new_filename_url);
             $new_filename_url = pathToURL($new_filename);
             if (is_file($new_filename) == TRUE) {
                 $src = $new_filename_url;
             } else {
                 $config['image_library'] = 'gd2';
                 $config['source_image'] = MEDIAFILES . $test1;
                 $config['create_thumb'] = false;
                 $config['new_image'] = $new_filename;
                 $config['maintain_ratio'] = TRUE;
                 $config['width'] = $size;
                 $config['height'] = $size;
                 $config['quality'] = '100%';
                 $src = $new_filename_url;
                 $this->image_lib->initialize($config);
                 $this->image_lib->resize();
             }
         }
     }
     if ($src != '') {
         //
         //$this->cacheWriteAndEncode ( $src, $function_cache_id, $cache_group = 'global' );
         $this->cacheWriteAndEncode($src, $function_cache_id, $cache_group);
         return $src;
     } else {
         $this->cacheWriteAndEncode('false', $function_cache_id, $cache_group);
         return false;
     }
 }
Пример #4
0
 function index()
 {
     $module_info = url_param('module_info', true);
     if ($module_info) {
         if ($_POST['module']) {
             $_POST['module'] = str_replace('..', '', $_POST['module']);
             $try_config_file = MODULES_DIR . '' . $_POST['module'] . '_config.php';
             if (is_file($try_config_file)) {
                 include $try_config_file;
                 if ($config['icon'] == false) {
                     $config['icon'] = MODULES_DIR . '' . $_POST['module'] . '.png';
                     $config['icon'] = pathToURL($config['icon']);
                 }
                 print json_encode($config);
                 exit;
             }
         }
     }
     $is_iframe = url_param('iframe');
     $base64 = url_param('base64', true);
     $admin = url_param('admin', true);
     $mod1 = url_param('module_name', true);
     $decode_vars = url_param('decode_vars', true);
     $reload_module = url_param('reload_module', true);
     $mod_to_edit = url_param('module_to_edit', true);
     $element_id = url_param('element_id', true);
     if ($mod1 != false) {
         $mod1 = urldecode($mod1);
     }
     $mod_iframe = false;
     if ($mod_to_edit != false) {
         $mod_to_edit = str_ireplace('_mw_slash_replace_', '/', $mod_to_edit);
         $mod_iframe = true;
     }
     //p($mod_to_edit);
     if ($base64 == false) {
         if ($is_iframe) {
             $data = $is_iframe;
             $data = base64_decode($data);
             $data = unserialize($data);
         } else {
             $data = $_POST;
         }
         if ($reload_module == 'edit_tag') {
             $reload_module = $_POST;
             $data = $reload_module;
             //p($data);
         }
         if ($mod1 != '') {
             $data['module'] = $mod1;
         }
         $is_page_id = url_param('page_id', true);
         if ($is_page_id != '') {
             $data['page_id'] = $is_page_id;
         }
         $is_post_id = url_param('post_id', true);
         if ($is_post_id != '') {
             $data['post_id'] = $is_post_id;
         }
         $is_category_id = url_param('category_id', true);
         if ($is_category_id != '') {
             $data['category_id'] = $is_category_id;
         }
         $is_rel = url_param('rel', true);
         if ($is_rel != '') {
             $data['rel'] = $is_rel;
             if ($is_rel == 'page') {
                 $test = get_ref_page();
                 if (!empty($test)) {
                     if ($data['page_id'] == false) {
                         $data['page_id'] = $test['id'];
                     }
                 }
                 //p($test);
             }
             if ($is_rel == 'post') {
                 //$refpage = get_ref_page ();
                 $refpost = get_ref_post();
                 if (!empty($refpost)) {
                     if ($data['post_id'] == false) {
                         $data['post_id'] = $refpost['id'];
                     }
                 }
             }
             if ($is_rel == 'category') {
                 //$refpage = get_ref_page ();
                 $refpost = get_ref_post();
                 if (!empty($refpost)) {
                     if ($data['post_id'] == false) {
                         $data['post_id'] = $refpost['id'];
                     }
                 }
             }
         }
         $tags = false;
         if ($data['mw_params_module'] != false) {
             if (trim($data['mw_params_module']) != '') {
                 $data['module'] = $data['mw_params_module'];
             }
         }
         //p($data);
         foreach ($data as $k => $v) {
             $tags .= "{$k}=\"{$v}\" ";
         }
         $tags = "<microweber {$tags}></microweber>";
     } else {
         if ($base64 == 'undefined') {
             exit;
         }
         //$base64 = base64_decode ( $base64 );
         if (is_string($base64) == false) {
             //	$base64 = false;
         }
         //$base64 = unserialize($base64);
         //p ( $base64 );
         //
     }
     if ($base64 != false) {
         $tags = $base64;
         if ($mod_iframe == true) {
             $mod_iframe = 'quick_edit="true"';
         }
         $tags = "<microweber module='{$mod_to_edit}' module_id='{$element_id}' {$mod_iframe} ></microweber>";
     }
     //p ( $tags );
     //exit;
     $opts = array();
     $opts['admin'] = $admin;
     if ($base64 != false or $is_iframe != false) {
         $opts['do_not_wrap'] = true;
     }
     $res = CI::model('template')->parseMicrwoberTags($tags, $opts);
     if ($admin == true) {
         $is_admin = is_admin();
         if ($is_admin == false) {
             $go = site_url('login');
             safe_redirect($go);
         }
         $opts['no_cache'] = true;
         $res_1 = CI::view('admin/module_admin', true, true);
         $res_1 = CI::model('template')->parseMicrwoberTags($res_1, $opts);
     }
     if ($res_1) {
         $res = str_replace('{content}', $res, $res_1);
     }
     print $res;
     exit;
     //  phpinfo();
 }
Пример #5
0
 /**
  * @desc  parses the mw tags
  * @param $layout - string
  * @param $options
  * $options ['admin'] - loads the module admin
  * @return string
  * @author	Microweber Dev Team
  * @version 1.0
  * @since Version 1.0
  */
 function parseMicrwoberTags($layout, $options = false)
 {
     /*		$function_cache_id = false;
     		
     		//$args = func_get_args ();
     		if (! empty ( $options )) {
     			foreach ( $options as $k => $v ) {
     				
     				$function_cache_id = $function_cache_id . serialize ( $k ) . serialize ( $v );
     			
     			}
     		}
     		
     		$function_cache_id = __FUNCTION__ . md5 ( $layout ) . md5 ( $function_cache_id );
     		
     		$cache_group = 'extract_tags';
     		
     		//$cache_content = CI::model ( 'core' )->cacheGetContent ( $function_cache_id, $cache_group );
     		
     		if (($cache_content) != false) {
     			
     			//return $cache_content;
     		
     		}*/
     //echo memory_get_usage() . "\n"; // 36640
     /*$cache_id =  md5 ( $layout ) . md5 ( serialize ( $options ) );
     		$cache_group = 'blocks/'.DIRECTORY_SEPARATOR.intval(PAGE_ID).DIRECTORY_SEPARATOR.'';
     		
     		
     		
     		$cache_content = CI::model ( 'core' )->cacheGetContentAndDecode ( $cache_id, $cache_group );*/
     if ($cache_content != false) {
         //return $cache_content;
     }
     static $mem = array();
     static $mem2 = array();
     $layout_md5 = md5($layout);
     $options_md5 = md5(serialize($options));
     $check = $layout_md5 . $options_md5;
     if ($mem["{$check}"] != false) {
         return $mem[$check];
     }
     //var_dump( $this->$parse_memory);
     //$layout = str_ireplace ( '<mw', '<microweber', $layout );
     $layout = CI::model('core')->replace_in_long_text('<mw', '<microweber', $layout, $use_normal_replace = true);
     $v = $layout;
     //	$tags1 = CI::model ( 'core' )->extractTags ( $v, '*', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8' );
     if (strstr($layout, '<microweber') == true) {
         //$layout = $this->parseMicrwoberTags ( $layout, $options );
     }
     if (strstr($layout, '<mw') == true) {
         //$layout = $this->parseMicrwoberTags ( $layout, $options );
     }
     if (strstr($layout, '<nomw') == true) {
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'nomw', $selfclosing = false, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         $txt_to_replace_back = array();
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 $hash = md5($m['full_tag']);
                 $hash = 'replace_back_' . $hash;
                 $txt_to_replace_back[$hash] = $m['full_tag'];
                 $layout = str_replace($m['full_tag'], $hash, $layout);
             }
         }
     }
     if (strstr($layout, '<block') == true) {
         $editmode = CI::model('core')->is_editmode();
         //p($editmode);
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'block', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 //
                 if ($m['tag_name'] == 'block') {
                     $attr = $m['attributes'];
                     if ($attr['id'] != '') {
                         //	p($m);
                         $attr['id'] = trim($attr['id']);
                         $is_global = $attr['global'];
                         if ($is_global == false) {
                             $is_global2 = $attr['rel'];
                             if (trim($is_global2) == 'global') {
                                 $is_global = true;
                             }
                         }
                         if (PAGE_ID != false and $is_global == false) {
                             $try_file = TEMPLATE_DIR . 'blocks/' . PAGE_ID;
                             $try_file = normalize_path($try_file);
                             $try_file .= $attr['id'] . '.php';
                             //p($try_file);
                             if (is_file($try_file)) {
                             } else {
                                 $try_file = TEMPLATE_DIR . 'blocks/' . $attr['id'] . '.php';
                             }
                         } else {
                             $try_file = TEMPLATE_DIR . 'blocks/' . $attr['id'] . '.php';
                         }
                         $try_file_default = TEMPLATE_DIR . 'blocks/default.php';
                         if (is_file($try_file) == false) {
                             $is_admin = is_admin();
                             if ($is_admin == true) {
                                 $dir = dirname($try_file);
                                 if (is_dir($dir) == false) {
                                     @mkdir_recursive($dir);
                                 }
                                 if (!copy($try_file_default, $try_file)) {
                                     @touch($try_file);
                                     //echo "failed to copy $file...\n";
                                 }
                             }
                         }
                         if (is_file($try_file) == true) {
                             $arrts = array();
                             foreach ($attr as $att => $at) {
                                 $this->template[$att] = $at;
                                 $arrts[$att] = $at;
                             }
                             $this->template['params'] = $arrts;
                             $this->load->vars($this->template);
                             $module_file = $this->load->file($try_file, true);
                             //p($arrts);
                             /*	if ($editmode == true) {
                             				//p($m);
                             				$edtid_hash = base64_encode ( $m ['full_tag'] );
                             				if (strval ( $module_file ) != '') {
                             					$module_file = '<div class="editblock"  id="' . $attr ['id'] . '">' . $module_file . '</div>';
                             				} else {
                             					$module_file = false;
                             				}
                             			
                             			} else {
                             				if (strval ( $module_file ) != '') {
                             					$module_file = '<div class="editblock" id="' . $attr ['id'] . '">' . $module_file . '</div>';
                             				}
                             			}*/
                             if (strval($module_file) != '') {
                                 if ($is_global == true) {
                                     $str123 = ' rel="global" ';
                                 } else {
                                     $str123 = false;
                                 }
                                 $module_file = '<div class="editblock" ' . $str123 . '   id="' . $attr['id'] . '">' . $module_file . '</div>';
                             } else {
                                 //$module_file = false;
                                 $module_file = '<div class="editblock" ' . $str123 . '   id="' . $attr['id'] . '">' . '</div>';
                             }
                             if (strstr($module_file, '<block') == true) {
                                 $module_file = self::parseMicrwoberTags($module_file, $options);
                             }
                             $layout = str_replace_count($m['full_tag'], $module_file, $layout, 1);
                             //$layout = str_replace ( $m ['full_tag'], '', $layout );
                             $layout = str_replace_count('</block>', '', $layout, 1);
                             //$layout = str_replace ( '</microweber>', '', $layout );
                         }
                     }
                 }
             }
         }
     }
     //
     if (strstr($layout, '<microweber') == true) {
         $editmode = CI::model('core')->is_editmode();
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'microweber', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 if ($m['tag_name'] == 'microweber') {
                     $attr = $m['attributes'];
                     if ($attr['module'] != '') {
                         $mmd5 = md5($attr['module']);
                         $check_if_uninstalled = MODULES_DIR . '_system/' . $mmd5 . '.php';
                         if (is_dir(MODULES_DIR . '_system/') == false) {
                             touch(MODULES_DIR . '_system/');
                         }
                         if (is_file($check_if_uninstalled) == true) {
                             //	$attr ['module'] = false;
                         }
                     }
                     if (strval($attr['module']) == '') {
                         $attr['module'] = 'non_existing';
                     }
                     //p($attr ['module']);
                     if ($attr['module'] != '') {
                         $attr['module'] = trim($attr['module']);
                         $attr['module'] = str_replace('\\', '/', $attr['module']);
                         $attr['module'] = reduce_double_slashes($attr['module']);
                         $try_file1 = MODULES_DIR . '' . $attr['module'] . '.php';
                         $try_file = MODULES_DIR . 'modules/' . $attr['module'] . '.php';
                         if ($options['admin'] == true) {
                             $try_file1 = MODULES_DIR . 'admin/' . $attr['module'] . '.php';
                             $try_filefront = MODULES_DIR . '' . $attr['module'] . '.php';
                             if (strstr($attr['module'], 'admin') == false) {
                                 $try_file1 = MODULES_DIR . 'admin/' . $attr['module'] . '.php';
                             } else {
                                 $try_file1 = MODULES_DIR . '' . $attr['module'] . '.php';
                             }
                         }
                         $try_file1 = normalize_path($try_file1, false);
                         //$a = is_file ( $try_file1 );
                         //p($try_file1);
                         //p($a);
                         if (is_file($try_file1) == false) {
                             if (is_file($try_file) == true) {
                                 $try_config_file = DEFAULT_TEMPLATE_DIR . 'modules/' . $attr['module'] . '_config.php';
                             } else {
                                 if ($options['admin'] == true) {
                                     if (strstr($attr['module'], 'admin') == false) {
                                         $try_file = MODULES_DIR . 'admin/' . '' . 'default' . '.php';
                                     } else {
                                         $try_file = MODULES_DIR . '' . '' . 'default' . '.php';
                                     }
                                 }
                             }
                             $is_admin = is_admin();
                             if ($is_admin == true) {
                                 $try_file1 = $try_filefront;
                                 $try_config_file = MODULES_DIR . '' . $attr['module'] . '_config.php';
                                 $dir = dirname($try_file1);
                                 if (is_dir($dir) == false) {
                                     mkdir_recursive($dir);
                                 }
                                 //print ( "You are trying to call module that doesnt exist in $try_file1.$try_file Please create it!" );
                                 //var_dump( $try_file, $try_file1);
                                 //exit ( "Modile file not found in $try_file1. Please create it!" );
                                 //if (! copy ( $try_file, $try_file1 )) {
                                 //echo "failed to copy $file...\n";
                                 //}
                                 $error = true;
                             } else {
                                 //print ( "You are trying to call module that doesnt exist in $try_file1.$try_file Please create it!" );
                                 $error = true;
                             }
                         } else {
                             $try_config_file = MODULES_DIR . '' . $attr['module'] . '_config.php';
                         }
                         if ($error == true) {
                             $try_file1 = MODULES_DIR . 'non_existing.php';
                             $error = false;
                         }
                         //	p($try_file1);
                         if (is_file($try_file1) == true and $error == false) {
                             $arrts = array();
                             foreach ($attr as $att => $at) {
                                 $this->template[$att] = $at;
                                 //$this->template [$att] = mw_get_var($at);
                                 $arrts[$att] = $at;
                             }
                             $no_edit = false;
                             $no_admin = false;
                             $check2 = false;
                             $mem2_md5_1 = md5(serialize($m));
                             //$mem2_md5_2 = md5 ( serialize ( $arrts ) );
                             $temp2 = false;
                             $check2 = $mem2_md5_1;
                             $check2 = strval($check2);
                             //
                             $temp1 = parse_memory_storage($check2);
                             if ($temp1 != false) {
                                 //var_dump ( $temp1 );
                                 $module_file = $temp1;
                             } else {
                                 //
                                 $try_config_file = normalize_path($try_config_file);
                                 $try_config_file = rtrim($try_config_file, '\\');
                                 $cache_this = true;
                                 $force_cache_this = false;
                                 if (is_file($try_config_file)) {
                                     $config = false;
                                     include $try_config_file;
                                     if (!empty($config)) {
                                         $check_icon = MODULES_DIR . '' . $attr['module'] . '.png';
                                         $icon = pathToURL($check_icon);
                                         //p($config);
                                         $config['icon'] = $icon;
                                         $this->template['config'] = $config;
                                         if (!empty($config['options'])) {
                                             $this->setup_module_options($config['options']);
                                         }
                                         $cache_for_session = false;
                                         if ($config['no_cache'] == true) {
                                             $cache_this = false;
                                             $do_not_cache_whole_block = true;
                                             $cache_for_session = true;
                                         }
                                         if ($config['cache'] == true) {
                                             $force_cache_this = true;
                                             $cache_for_session = true;
                                         }
                                         if ($config['no_edit'] == true) {
                                             $no_edit = true;
                                         }
                                         if ($config['no_admin'] == true) {
                                             $no_admin = true;
                                         }
                                     }
                                 }
                                 if ($arrts['no_cache'] == true) {
                                     $cache_this = false;
                                 }
                                 if ($options['no_cache'] == true) {
                                     $cache_this = false;
                                 }
                                 if ($force_cache_this == false) {
                                     if (strstr($attr['module'], 'admin/') == true) {
                                         $cache_this = false;
                                     }
                                 }
                                 if ($attr['module_id'] == true) {
                                     $mod_id = $attr['module_id'];
                                 } else {
                                     $mod_id = false;
                                 }
                                 if ($options['admin'] == true) {
                                     $cache_this = false;
                                 }
                                 $params_encoded = false;
                                 if ($force_cache_this == true) {
                                     $cache_this = true;
                                 }
                                 //var_dump($force_cache_this);
                                 if ($cache_this == true) {
                                     $cache_id = md5($try_file1) . md5(serialize($arrts));
                                     if ($cache_for_session == true) {
                                         $cache_id = md5($try_file1) . sess_id() . md5(serialize($arrts));
                                     }
                                     if ($_POST) {
                                         $cache_id = $cache_id . md5(serialize($_POST));
                                     }
                                     $cache_group = 'global/blocks/';
                                     $cache_content = CI::model('core')->cacheGetContentAndDecode($cache_id, $cache_group);
                                     if ($cache_content != false) {
                                         //var_dump($cache_content);
                                         $module_file = $cache_content;
                                     } else {
                                         $this->template['params'] = $arrts;
                                         $this->load->vars($this->template);
                                         //$module_file = $this->load->file ( $try_file1, true );
                                         $module_file = CI::file($try_file1, true);
                                         CI::model('core')->cacheWriteAndEncode($module_file, $cache_id, $cache_group);
                                     }
                                 } else {
                                     $this->template['params'] = $arrts;
                                     $this->load->vars($this->template);
                                     //$module_file = $this->load->file ( $try_file1, true );
                                     $module_file = CI::file($try_file1, true);
                                 }
                                 //$params_encoded = encode_var ( $arrts );
                                 $params_encoded = 'edit_tag';
                                 $params_module = codeClean($arrts['module']);
                             }
                             //if (($attr ['module'] != 'header') and ($attr ['module'] != 'footer')) {
                             //
                             if ($editmode == true) {
                                 //	p($m);
                                 //p( $arrts);
                                 if ($no_admin == true) {
                                     $no_admin_tag = ' no_admin="true" ';
                                 } else {
                                     $no_admin_tag = '';
                                 }
                                 if ($mod_id == true) {
                                     $mod_id_tag = ' module_id="' . $mod_id . '" ';
                                 } else {
                                     $mod_id_tag = '';
                                 }
                                 //$edtid_hash = base64_encode ( $m ['full_tag'] );
                                 $edtid_hash = 'edit_tag';
                                 if (strval($module_file) != '') {
                                     if ($options['do_not_wrap'] == true) {
                                         $module_file = $module_file;
                                     } else {
                                         if ($no_edit == false) {
                                             //$module_file = '<div onmouseup="load_edit_module_by_module_id(\'' . $mod_id . '\')" mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                             $module_file = '<div mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                             //$module_file = '<div mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                         } else {
                                             $module_file = '<div  mw_params_encoded="' . $params_encoded . '" mw_params_module="' . $params_module . '"   ' . $mod_id_tag . ' ' . $no_admin_tag . '  class="module">' . $module_file . '</div>';
                                         }
                                     }
                                 } else {
                                     $module_file = false;
                                 }
                                 //	p($m ['full_tag']);
                             } else {
                                 if (strval($module_file) != '') {
                                     $module_file = '<div class="module" mw_params_encoded="' . $params_encoded . '" mw_params_module="' . $params_module . '"  >' . $module_file . '</div>';
                                 }
                             }
                             //}  ++
                             $module_file = str_replace('<mw', '<microweber', $module_file);
                             if (strstr($module_file, '<microweber') == true and $error == false) {
                                 $module_file = self::parseMicrwoberTags($module_file, $options);
                             }
                             $layout = str_replace_count($m['full_tag'], $module_file, $layout, 1);
                             //$layout = str_replace ( $m ['full_tag'], $module_file, $layout );
                             //$layout = str_replace_count ( '</microweber>', '', $layout, 1 );
                             $layout = str_replace_count('</mw>', '', $layout, 1);
                             $layout = str_replace_count('</microweber>', '', $layout, 1);
                             //$layout = str_replace ( '</mw>', '', $layout );
                             //$layout = str_replace ( '</microweber>', '', $layout );
                             //parse_memory_storage ( $check2, $layout );
                         }
                     }
                 }
             }
         }
     }
     if (strstr($layout, '<editable') == true and $error == false) {
         $editmode = CI::model('core')->is_editmode();
         //p($editmode);
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'editable', $selfclosing = false, $return_the_entire_tag = true, $charset = 'UTF-8');
         $matches = $tags;
         if (!empty($matches)) {
             foreach ($matches as $m) {
                 if ($m['tag_name'] == 'editable') {
                     $attr = $m['attributes'];
                     $get_global = false;
                     if ($editmode == true) {
                     }
                     if ($attr['rel'] == 'global') {
                         $attr['global'] = true;
                         $get_global = true;
                     }
                     if ($attr['rel'] == 'page') {
                         $attr['page'] = PAGE_ID;
                     }
                     if ($attr['rel'] == 'post') {
                         $attr['post'] = POST_ID;
                         if ($attr['post'] == false) {
                             $attr['post'] = PAGE_ID;
                             //$attr ['page'] = PAGE_ID;
                         }
                     }
                     if ($attr['rel'] == 'category') {
                         $attr['category'] = CATEGORY_ID;
                     }
                     if ($attr['rel'] == 'module') {
                         $relate_to_module = true;
                     } else {
                         $relate_to_module = false;
                     }
                     if ($relate_to_module == false) {
                         if ($attr['page']) {
                             $data = get_page($attr['page']);
                         } else {
                             if ($attr['post']) {
                                 $data = get_post($attr['post']);
                                 if ($data == false) {
                                     $data = get_page($attr['post']);
                                 }
                                 //p ( $data );
                                 //p ( $attr );
                             } else {
                                 if ($attr['category']) {
                                     $data = get_category($attr['category']);
                                 } else {
                                     if ($attr['global']) {
                                         $get_global = true;
                                     }
                                 }
                             }
                         }
                     }
                     $cf = false;
                     $field_content = false;
                     if ($get_global == true) {
                         $field_content = CI::model('core')->optionsGetByKey($attr['field'], $return_full = false, $orderby = false);
                     } else {
                         if (strstr($attr['field'], 'custom_field_') == true) {
                             $cf = str_replace('custom_field_', '', $attr['field']);
                             $field_content = $data['custom_fields'][$cf];
                         } else {
                             $field_content = $data[$attr['field']];
                         }
                     }
                     //p($m ['full_tag']);
                     if (trim($field_content) == '') {
                         $field_content = $m['contents'];
                     } else {
                         //$quote_style = ENT_COMPAT [, string $charset = 'UTF-8' ]]
                         $field_content = htmlspecialchars_decode($field_content);
                         //$field_content = html_entity_decode ( $field_content, $quote_style = ENT_COMPAT, $charset = 'UTF-8' );
                     }
                     //	$field_content = html_entity_decode ( $field_content );
                     $field_content = htmlspecialchars_decode($field_content);
                     $attrs_to_append = false;
                     if ($editmode == true) {
                         foreach ($attr as $at_key => $at_value) {
                             $attrs_to_append .= "{$at_key}='{$at_value}' ";
                         }
                         //p($attrs_to_append);
                         $layout = str_replace_count($m['full_tag'], "<div class='edit' {$attrs_to_append}>" . $field_content . '</div>', $layout, 1);
                     } else {
                         $layout = str_replace_count($m['full_tag'], $field_content, $layout, 1);
                     }
                     $layout = str_replace('<mw', '<microweber', $layout);
                     if (strstr($layout, '<microweber') == true and $error == false) {
                         $layout = self::parseMicrwoberTags($layout, $options);
                     }
                 }
             }
         }
     }
     //{SITE_URL}
     $site_url = site_url();
     //$layout = str_replace ( '{SITE_URL}', $site_url, $layout );
     $layout = CI::model('core')->replace_in_long_text('{SITE_URL}', $site_url, $layout, true);
     $layout = CI::model('core')->replace_in_long_text('{SITEURL}', $site_url, $layout, true);
     //$layout = str_replace ( '{SITEURL}', $site_url, $layout );
     //$layout = $this->badWordsRemove ( $layout );
     if (defined('POST_ID') == true) {
         //$layout = str_replace ( '{POST_ID}', POST_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{POST_ID}', POST_ID, $layout, true);
     }
     if (defined('PAGE_ID') == true) {
         //$layout = str_replace ( '{PAGE_ID}', PAGE_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{PAGE_ID}', PAGE_ID, $layout, true);
     }
     if (defined('CATEGORY_ID') == true) {
         //$layout = str_replace ( '{CATEGORY_ID}', CATEGORY_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{CATEGORY_ID}', CATEGORY_ID, $layout, true);
     }
     //	$this->load->vars ( $this->template );
     if (stristr($layout, 'content_meta_title')) {
         if (defined('POST_ID') == true) {
             $is_content = get_post(POST_ID);
             $is_content_post = $is_content;
             $layout = str_ireplace('{POST_ID}', POST_ID, $layout);
         }
         if ($is_content == false) {
             if (defined('PAGE_ID') == true) {
                 $is_content = get_page(PAGE_ID);
                 $is_content_page = $is_content;
             }
         }
         if ($is_content['content_meta_title']) {
             $content_meta_title = $is_content['content_meta_title'];
         } elseif ($is_content['content_title']) {
             $content_meta_title = codeClean($is_content['content_title']);
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_title');
         }
         $layout = str_ireplace('{content_meta_title}', $content_meta_title, $layout);
         if ($is_content['content_meta_keywords']) {
             $content_meta_title = $is_content['content_meta_keywords'];
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_keywords');
         }
         $layout = str_ireplace('{content_meta_keywords}', $content_meta_title, $layout);
         if ($is_content['content_meta_description']) {
             $content_meta_title = $is_content['content_meta_description'];
         } elseif ($is_content['content_description']) {
             $content_meta_title = codeClean($is_content['content_description']);
         } elseif ($is_content['content_body']) {
             $content_meta_title = codeClean($is_content['content_body']);
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_title');
         }
         $layout = str_ireplace('{content_description}', $content_meta_title, $layout);
     }
     if (is_file(ACTIVE_TEMPLATE_DIR . 'controllers/pre_layout_display.php')) {
         include ACTIVE_TEMPLATE_DIR . 'controllers/pre_layout_display.php';
     }
     if (strstr($layout, '<editable') == true or strstr($layout, '<mw') == true or strstr($layout, '<microweber') == true or strstr($layout, '<block') == true and $error == false) {
         $layout = self::parseMicrwoberTags($layout, $options);
     }
     if (!empty($txt_to_replace_back)) {
         foreach ($txt_to_replace_back as $k => $v) {
             //	$v = html_entity_decode($v);
             $layout = str_replace($k, $v, $layout);
         }
         $layout = str_replace('<nomw>', '', $layout);
         $layout = str_replace('</nomw>', '', $layout);
     }
     if (empty($relations)) {
         $layout = str_ireplace('</head>', $prepend_to_head . '</head>', $layout);
         //$layout= '<div class="mw_module">'.$layout.'</div>';
         $mem[$check] = $layout;
         //if ($do_not_cache_whole_block == false) {
         //CI::model ( 'core' )->cacheWriteAndEncode ( $layout, $cache_id, $cache_group );
         //}
         //CI::model ( 'core' )->cacheWrite ( $layout, $function_cache_id, $cache_group );
         return $layout;
     } else {
         //if ($do_not_cache_whole_block == false) {
         //CI::model ( 'core' )->cacheWriteAndEncode ( $v, $cache_id, $cache_group );
         //}
         //CI::model ( 'core' )->cacheWrite ( $v, $function_cache_id, $cache_group );
         $mem[$check] = $v;
         return $v;
     }
     //p($relations);
 }