private function _load_sitemap_from_cache($module_name, $sitemap_name)
 {
     if ('yes' != $this->options['enable_cache'] || $this->_debug) {
         // cache is not enabled or debug is enabled
         return false;
     }
     $cache_status = $this->cache->get_cache_status($module_name, $sitemap_name);
     if (!$cache_status) {
         // cache is invalid
         return false;
     } else {
         if ($cache_status == '304') {
             // http cache can be used, we don't need to output anything except
             // for some headers
             $this->_send_headers(array_merge(array('status' => 304), $this->cache->get_headers()));
         } else {
             if ($cache_status == '200') {
                 // file cache is ok, output the cached sitemap
                 $this->_send_headers($this->cache->get_headers());
                 $cache_file = $this->cache->get_cache_file();
                 if ($this->_is_gzip_ok() && !self::is_gzipped()) {
                     // when server or script is not already gzipping, and gzip is
                     // allowed, we simply read the cached file without any
                     // additional compression because cached sitemap files are
                     // stored as gzipped files.
                     readfile($cache_file);
                 } else {
                     // if we can't use a gzipped file, decompress before reading it
                     readgzfile($cache_file);
                 }
             }
         }
     }
     if (in_array($cache_status, array('200', '304'))) {
         $this->log_success(sprintf(__('Successfully served a cached version of <em>%s.xml</em>.', $this->domain), $sitemap_name));
         $this->commit_logs();
         return true;
     }
 }
Пример #2
0
 private function _load_sitemap_from_cache($module_name, $sitemap_name)
 {
     // cache is not enabled or debug is enabled
     if ('yes' != $this->options['enable_cache'] || $this->_debug) {
         return false;
     }
     $cache_status = $this->sitemap_cache->get_cache_status($module_name, $sitemap_name);
     // cache is invalid
     if (!$cache_status) {
         return false;
     } elseif (!empty($_GET['generate']) && current_user_can('manage_options')) {
         // @since 1.4.0 admin is regenerating the sitemap, no cache should
         // be used, even when cache status is valid. We need to do this
         // here because we want to regenerate the sitemap, which requires
         // the cache file, but it is only determined after running
         // BWP_GXS_CACHE::get_cache_status(). This should be fixed in
         // future versions.
         return false;
     } elseif ($cache_status == '304') {
         // http cache can be used, we don't need to output anything except
         // for some headers
         // @link http://edn.embarcadero.com/article/38123
         $this->_send_headers(array_merge(array('status' => 304), $this->sitemap_cache->get_headers()));
     } elseif ($cache_status == '200') {
         // file cache is ok, output the cached sitemap
         $this->_send_headers($this->sitemap_cache->get_headers());
         $cache_file = $this->sitemap_cache->get_cache_file();
         // when server or script is not already gzipping, and gzip is
         // allowed, we simply read the cached file without any additional
         // compression because cached sitemap files are stored as gzipped
         // files.
         if ($this->_is_gzip_ok() && !self::is_gzipped()) {
             readfile($cache_file);
         } else {
             // if we can't use a gzipped file, decompress before reading it
             readgzfile($cache_file);
         }
     }
     if (in_array($cache_status, array('200', '304'))) {
         $this->log_success(sprintf(__('Successfully served a cached version of <em>%s.xml</em>.', $this->domain), $sitemap_name));
         $this->commit_logs();
         return true;
     }
 }