/**
  * Serves the cache page or starts the output buffer. Ignore URLs matching
  * the ignore list, and ignores if there are session messages.
  *
  * @see StaticCache_ob_end_flush()
  */
 public function action_init()
 {
     /**
      * Allows plugins to add to the ignore list. An array of all URLs to ignore
      * is passed to the filter.
      *
      * @filter staticcache_ignore an array of URLs to ignore
      */
     $ignore_array = Plugins::filter('staticcache_ignore', explode(',', Options::get('staticcache__ignore_list')));
     // sanitize the ignore list for preg_match
     $ignore_list = implode('|', array_map(create_function('$a', 'return preg_quote(trim($a), "@");'), $ignore_array));
     $request = Site::get_url('host') . $_SERVER['REQUEST_URI'];
     $request_method = $_SERVER['REQUEST_METHOD'];
     /* don't cache PUT or POST requests, pages matching ignore list keywords,
      * nor pages with session messages, nor loggedin users
      */
     if ($request_method == 'PUT' || $request_method == 'POST' || preg_match("@.*({$ignore_list}).*@i", $request) || Session::has_messages() || User::identify()->loggedin) {
         return;
     }
     $request_id = self::get_request_id();
     $query_id = self::get_query_id();
     if (Cache::has(array(self::GROUP_NAME, $request_id))) {
         $cache = Cache::get(array(self::GROUP_NAME, $request_id));
         if (isset($cache[$query_id])) {
             global $profile_start;
             // send the cached headers
             foreach ($cache[$query_id]['headers'] as $header) {
                 header($header);
             }
             // check for compression
             // @todo directly send compressed data to browser if webserver is not compressing.
             if (isset($cache[$query_id]['compressed']) && $cache[$query_id]['compressed'] == true) {
                 echo gzuncompress($cache[$query_id]['body']);
             } else {
                 echo $cache[$query_id]['body'];
             }
             // record hit and profile data
             $this->record_stats('hit', $profile_start);
             exit;
         }
     }
     // record miss
     $this->record_stats('miss');
     // register hook
     Plugins::register(array('StaticCache', 'store_final_output'), 'filter', 'final_output', 16);
 }
示例#2
0
        $commenter_name = $user->username;
    }
    $commenter_email = $user->email;
    $commenter_url = Site::get_url('habari');
} elseif (isset($_COOKIE[$cookie])) {
    list($commenter_name, $commenter_email, $commenter_url) = explode('#', $_COOKIE[$cookie]);
} else {
    $commenter_name = '';
    $commenter_email = '';
    $commenter_url = '';
}
?>

<div class="commentform">
<h4 id="respond" class="reply"><?php 
_e('Leave a Reply');
?>
</h4>
<?php 
if (Session::has_messages()) {
    Session::messages_out();
}
?>

<?php 
$post->comment_form()->out();
?>
    
</div>

<!-- /commentsform -->