function xpress_block_header_cash_write($mydirname,$block_header) { $xml = xpress_XML_serialize($block_header); $xml_name = 'block_header.xml'; if (WPLANG == 'ja_EUC'){ $xml = str_replace('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="EUC-JP" ?>' , $xml); } if(cache_is_writable()) xpress_cache_write($mydirname,$xml_name,$xml); }
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); } } } }
/** * version_feed_data() - Returns latest version feed data. * * @link http://tarskitheme.com/version.atom * @since 2.0 * @return string $atomdata */ function version_feed_data() { ob_start(); // Thanks to Simon Willison for the inspiration $cachefile = TARSKICACHE . "/version.atom"; $cachetime = 60 * 60; // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && file_get_contents($cachefile)) { $atomdata = file_get_contents($cachefile); } else { if (function_exists('curl_init')) { // If libcurl is installed, use that $ch = curl_init(TARSKIVERSIONFILE); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); $atomdata = curl_exec($ch); curl_close($ch); } elseif (ini_get('allow_url_fopen')) { // Otherwise try file_get_contents() $ctx = stream_context_create(array('http' => array('timeout' => 1.0))); $atomdata = @file_get_contents(TARSKIVERSIONFILE, false, $ctx); } if (!empty($atomdata) && cache_is_writable("version.atom")) { $fp = fopen($cachefile, "w"); if ($fp) { fwrite($fp, $atomdata); fclose($fp); } } } return $atomdata; $atomdata = ob_get_contents(); ob_end_clean(); return $atomdata; }
?> /> <?php _e('Update notification on (recommended)', 'tarski'); ?> </label> <label for="update-off"><input type="radio" id="update-off" name="update_notification" value ="off" <?php if (!get_tarski_option('update_notification')) { echo 'checked="checked" '; } ?> /> <?php _e('Update notification off', 'tarski'); ?> </label> <?php if (!cache_is_writable() && get_tarski_option('update_notification')) { ?> <p class="tip"><?php printf(__('The version check could not be cached. To enable caching, follow the tutorial on the %s page.', 'tarski'), '<a href="http://tarskitheme.com/help/updates/notifier/">' . __('update notifier', 'tarski') . '</a>'); ?> </p> <?php } ?> <?php } else { ?> <h3><?php _e('Update Notification', 'tarski'); ?> </h3>
/** * version_feed_data() - Returns latest version feed data. * * @link http://tarskitheme.com/version.atom * @since 2.0 * @return string */ function version_feed_data() { // Thanks to Simon Willison for the inspiration $cachefile = TARSKICACHE . "/version.atom"; $cachetime = 60 * 60; // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && file_get_contents($cachefile)) { $atomdata = file_get_contents($cachefile); } else { $response = wp_remote_get(TARSKIVERSIONFILE); $code = wp_remote_retrieve_response_code(&$response); $atomdata = ''; if (200 == $code) { $atomdata = wp_remote_retrieve_body(&$response); if (cache_is_writable("version.atom")) { $fp = fopen($cachefile, "w"); if ($fp) { fwrite($fp, $atomdata); fclose($fp); } } } else { $this->status = 'no_connection'; } } $this->feed_data = $atomdata; return $this->feed_data; }
/> <?php _e('Update notification on (recommended)', 'tarski'); ?> </label> <label for="update-off"><input type="radio" id="update-off" name="update_notification" value ="off" <?php if (!get_tarski_option('update_notification')) { echo 'checked="checked" '; } ?> /> <?php _e('Update notification off', 'tarski'); ?> </label> <?php if (!cache_is_writable('version.atom') && get_tarski_option('update_notification')) { ?> <p><?php printf(__('The version check could not be cached. To enable caching, follow the tutorial on the %s page.', 'tarski'), '<a href="http://tarskitheme.com/help/updates/notifier/">' . __('update notifier', 'tarski') . '</a>'); ?> </p> <?php } ?> <?php } else { ?> <h4><?php _e('Update Notification', 'tarski'); ?> </h4>