Example #1
0
 function xpress_block_header_cache_read($mydirname)
 {
     $xml_name = 'block_header.xml';
     $xml_data = xpress_cache_read($mydirname, $xml_name);
     $GLOBALS['DO_LIBXML_PATCH'] = get_xpress_mod_config($mydirname, 'libxml_patch');
     // The character-code not treatable exists when 'XML_unserialize' of PHP5 processes EUC-JP.
     // And, the result is returned by character-code UTF-8.
     // Measures
     // After the character-code is converted into UTF-8, XML_unserialize will be processed.
     if (strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false && version_compare(PHP_VERSION, '5.0.0', '>')) {
         $xml_data = str_replace('<?xml version="1.0" encoding="EUC-JP" ?>', '<?xml version="1.0" encoding="UTF-8" ?>', $xml_data);
         $ans = mb_convert_variables('UTF-8', 'EUC-JP', &$xml_data);
         //EUC-JP to UTF-8
         $ret = @xpress_XML_unserialize($xml_data);
         $ans = mb_convert_variables('EUC-JP', 'UTF-8', &$ret);
         //UTF-8 to EUC-JP
     } else {
         $ret = xpress_XML_unserialize($xml_data);
     }
     return $ret;
 }
Example #2
0
 function xpress_block_cache_refresh($mydirname)
 {
     global $xoops_db;
     $mid = get_xpress_modid();
     // It is a block that needs cache arranged outside the module.
     // Only the block arranged outside the module is detected here.
     $newblocks = get_xoops_prefix() . "newblocks";
     $block_module_link = get_xoops_prefix() . "block_module_link";
     $sql = "SELECT * FROM {$newblocks} LEFT JOIN {$block_module_link} ON {$newblocks}.bid = {$block_module_link}.block_id ";
     $sql .= "WHERE {$newblocks}.mid = {$mid} AND {$newblocks}.visible = 1 AND {$block_module_link}.module_id != {$mid} ";
     $sql .= "GROUP BY {$newblocks}.bid";
     $blocks = $xoops_db->get_results($sql);
     require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
     foreach ($blocks as $block) {
         $func_file = $block->func_file;
         $call_theme_function_name = str_replace(".php", "", $func_file);
         $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
         $cache_title = str_replace(".php", "", $func_file);
         $blockID = $block->bid;
         $options = explode("|", $block->options);
         $block_theme_file = get_block_file_path($mydirname, $inc_theme_file_name);
         require_once $block_theme_file['file_path'];
         $render = $call_theme_function_name($options);
         //The block name and the called function name should be assumed to be the same name.
         $render_array['block'] = $render;
         $render_array['block']['options'] = $block->options;
         if (!empty($block_theme_file['error'])) {
             $render_array['block']['err_message'] = $block_theme_file['error'];
         }
         if (cache_is_writable()) {
             if (xpress_block_cache_found($mydirname, $cache_title . $blockID)) {
                 $render_serialize = xpress_XML_serialize($render_array);
                 $render_md5 = md5($render_serialize);
                 $cache_serialize = xpress_cache_read($mydirname, $cache_title . $blockID . '.xml');
                 $cache_md5 = md5($cache_serialize);
                 if ($render_md5 != $cache_md5) {
                     xpress_block_cache_write($mydirname, $cache_title . $blockID, $render_array);
                 }
             } else {
                 xpress_block_cache_write($mydirname, $cache_title . $blockID, $render_array);
             }
         }
     }
 }