Changeset 719
- Timestamp:
- Apr 26, 2011, 3:38:22 PM (14 years ago)
- Location:
- trunk/xpressme_integration_kit/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/include/xpress_block_header.php
r683 r719 18 18 $xml = str_replace('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="EUC-JP" ?>' , $xml); 19 19 } 20 xpress_cache_write($mydirname,$xml_name,$xml); 20 if(cache_is_writable()) 21 xpress_cache_write($mydirname,$xml_name,$xml); 21 22 } 22 23 function xpress_block_header_cache_read($mydirname) -
trunk/xpressme_integration_kit/include/xpress_block_render.php
r716 r719 68 68 { 69 69 $xoopsDB =& Database::getInstance(); 70 $modules_tbl = $xoopsDB->prefix('modules'); 70 $modules_tbl = $xoopsDB->prefix('modules'); 71 71 72 72 $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; … … 87 87 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 88 88 89 $module_tbl = $xoopsDB->prefix($wp_prefix).'_options'; 90 $theme_name = ''; 89 $module_tbl = $xoopsDB->prefix($wp_prefix).'_options'; 90 $theme_name = ''; 91 91 92 92 $sql = "SELECT option_value FROM $module_tbl WHERE option_name LIKE 'template'"; … … 139 139 function xpress_block_render($mydirname,$block_function_name,$options) 140 140 { 141 global $wpdb,$xoops_config ;141 global $wpdb,$xoops_config,$xoopsUserIsAdmin; 142 142 $func_file = $block_function_name; 143 143 $call_theme_function_name = str_replace(".php", "", $block_function_name); … … 148 148 $this_block_url = '/' . $mydirname . '/'; 149 149 $call_url = $_SERVER['REQUEST_URI']; 150 150 $block['err_message'] = ''; 151 151 152 if (strstr($call_url , $this_block_url) !== false && strstr($call_url , $this_block_url . 'admin/') === false){ 152 153 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); … … 154 155 $block = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. 155 156 if (!empty($block_theme_file['error'])) 156 $block['err_message'] = $block_theme_file['error']; 157 } else { 158 global $xoops_config,$xoopsUserIsAdmin; 159 $cache_dir = $xoops_config->xoops_cache_path; 160 if(!is_writable($cache_dir)){ 161 $block['err_message'] = _MB_XP2_CACHE_NOT_WRITABLE ; 162 if($xoopsUserIsAdmin) 163 $block['err_message'] .= " ($cache_dir)"; 157 $block['err_message'] .= $block_theme_file['error']; 158 } else { 159 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 160 $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 161 $block = $xml['block']; 164 162 } else { 165 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 166 $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 167 $block = $xml['block']; 168 } else { 169 $block['err_message'] = sprintf(_MB_XP2_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname .'</a>'); 170 } 163 $block['err_message'] .= sprintf(_MB_XP2_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname .'</a>'); 164 } 165 } 166 167 if(!cache_is_writable()){ 168 $block['err_message'] ='<span style="color:#ff0000">'; 169 $block['err_message'] .= _MB_XP2_CACHE_NOT_WRITABLE ; 170 if($xoopsUserIsAdmin){ 171 $block['err_message'] .= " ($cache_dir)"; 172 $block['err_message'] .= '</span>'; 171 173 } 172 174 } … … 253 255 if (!empty($block_theme_file['error'])) 254 256 $render_array['block']['err_message'] = $block_theme_file['error']; 255 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 256 $render_serialize = xpress_XML_serialize($render_array); 257 $render_md5 = md5($render_serialize); 258 259 $cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml'); 260 $cache_md5 = md5($cache_serialize); 261 262 if ($render_md5 != $cache_md5){ 257 if(cache_is_writable()){ 258 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 259 $render_serialize = xpress_XML_serialize($render_array); 260 $render_md5 = md5($render_serialize); 261 262 $cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml'); 263 $cache_md5 = md5($cache_serialize); 264 265 if ($render_md5 != $cache_md5){ 266 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 267 } 268 } else { 263 269 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 264 270 } 265 } else {266 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array);267 271 } 268 272 } -
trunk/xpressme_integration_kit/include/xpress_cache.php
r657 r719 1 1 <?php 2 2 3 // is_writable() doesn't operate normally on the windows filesystem 4 if(!function_exists("cache_is_writable")): 5 function cache_is_writable(){ 6 global $xoops_config; 7 $cache_dir = $xoops_config->xoops_cache_path . '/'; 8 $filename = $cache_dir .'xpress_cache_test.txt'; 9 $fp = @fopen($filename, "w"); 10 if ($fp == false) return false; 11 fclose($fp); 12 return true; 13 } 14 endif; 15 3 16 if(!function_exists("xpress_cache_found")): 4 17 function xpress_cache_found($filename)
Note: See TracChangeset
for help on using the changeset viewer.