Ejemplo n.º 1
0
 /**
  * Grab details from WP and the ZenCache plugin itself,
  *    after the main query is loaded (if at all possible).
  *
  * This is where we have a chance to grab any values we need from WordPress; or from the QC plugin.
  *    It is EXTREMEMLY important that we NOT attempt to grab any object references here.
  *    Anything acquired in this phase should be stored as a scalar value.
  *    See {@link output_buffer_callback_handler()} for further details.
  *
  * @since 140422 First documented version.
  *
  * @attaches-to `wp` hook.
  */
 public function wp_main_query_postload()
 {
     if (empty($this->postload['wp_main_query'])) {
         return;
     }
     // Nothing to do in this case.
     if ($this->is_wp_loaded_query || is_admin()) {
         return;
     }
     // Nothing to do.
     if (!is_main_query()) {
         return;
     }
     // Not main query.
     $this->is_wp_loaded_query = TRUE;
     $this->is_404 = is_404();
     $this->is_user_logged_in = is_user_logged_in();
     $this->content_url = rtrim(content_url(), '/');
     $this->is_maintenance = function_exists('is_maintenance') && is_maintenance();
     $_this = $this;
     // Reference for the closure below.
     add_action('template_redirect', function () use($_this) {
         // Move this AFTER `redirect_canonical` to avoid buggy WP behavior.
         // See <https://github.com/websharks/zencache/issues/209#issuecomment-46999230>
         $_this->is_a_wp_content_type = $_this->is_404 || $_this->is_maintenance || is_front_page() || is_home() || is_singular() || is_archive() || is_post_type_archive() || is_tax() || is_search() || is_feed();
     }, 11);
 }
 function ws_plugin__qcache_builder($buffer = FALSE)
 {
     if (defined("QUICK_CACHE_ALLOWED") && !QUICK_CACHE_ALLOWED) {
         return $buffer;
     } else {
         if (isset($_SERVER["QUICK_CACHE_ALLOWED"]) && !$_SERVER["QUICK_CACHE_ALLOWED"]) {
             return $buffer;
         } else {
             if (isset($_GET["qcAC"]) && !$_GET["qcAC"]) {
                 return $buffer;
             } else {
                 if (defined("DONOTCACHEPAGE")) {
                     return $buffer;
                 } else {
                     if (QUICK_CACHE_DONT_CACHE_WHEN_LOGGED_IN && function_exists("is_user_logged_in") && is_user_logged_in()) {
                         return $buffer;
                     }
                 }
             }
         }
     }
     /* Do NOT cache. * Re-checking this here ( when possible ) because it's so important! */
     /*
     										Now, we need to make sure NO theme and/or other plugins have used `ob_start("ob_gzhandler")`, or another form of gzip after the first phase of Quick Cache.
     										In other words, we must NOT store a cache of already-compressed data. This often occurs when a theme attempts to use `ob_start("ob_gzhandler")` in `/header.php`.
     										That should NOT be done in `/header.php`. If you must use `ob_start("ob_gzhandler")`, place it in: `/wp-config.php` so it's the top-level output buffer.
     										*Note* If `zlib.output_compression` is enabled, we should EXPECT to see `zlib_get_coding_type()`. It's fine to use `zlib.output_compression`.
     										* Using `zlib.output_compression` is preferred over `ob_start("ob_gzhandler")`, even when it's used inside `/wp-config.php`. */
     if (function_exists("zlib_get_coding_type") && zlib_get_coding_type() === "gzip" && !QUICK_CACHE_DETECTED_ZLIB_OC) {
         if (!headers_sent() && ($_decoded = ws_plugin__qcache_gzdecode($buffer))) {
             $buffer = $_decoded;
             /* OK, now we'll use the decoded version. */
             header("Content-Encoding:");
             /* And ditch this header. */
         } else {
             /* If headers were already sent, it's too late. */
             return $buffer;
         }
         /* Unable to cache this. */
     }
     /*
     										Resume buffer scans. Buffer should be in an uncompressed format now. */
     if (!strlen($buffer = trim($buffer))) {
         return $buffer;
     } else {
         if (strlen($buffer) <= 2000 && preg_match("/\\<h1\\>Error/i", $buffer)) {
             return $buffer;
         } else {
             if ($GLOBALS["QUICK_CACHE_STATUS"] && preg_match("/^5/", $GLOBALS["QUICK_CACHE_STATUS"])) {
                 return $buffer;
             }
         }
     }
     /* Do NOT cache. */
     /**/
     foreach ($headers = headers_list() as $i => $header) {
         if (preg_match("/^Retry-After\\:/i", $header) || preg_match("/^Status\\: 5/i", $header)) {
             return $buffer;
         } else {
             if (preg_match("/^Content-Type\\:/i", $header)) {
                 $content_type = $header;
             }
         }
         /* The "last" one. */
     }
     /**/
     /* Disables caching when a PHP routine sets an incompatible Content-Type. */
     if ($content_type && !preg_match("/xhtml|html|xml/i", $content_type)) {
         return $buffer;
     } else {
         if (function_exists("is_maintenance") && is_maintenance()) {
             return $buffer;
         } else {
             if (function_exists("did_action") && did_action("wm_head")) {
                 return $buffer;
             }
         }
     }
     /* Do NOT cache. */
     /**/
     if (!is_dir(WP_CONTENT_DIR . "/cache")) {
         @mkdir(WP_CONTENT_DIR . "/cache", 0777, true);
     }
     /**/
     if (is_dir(WP_CONTENT_DIR . "/cache") && is_writable(WP_CONTENT_DIR . "/cache")) {
         $total_time = number_format(microtime(true) - QUICK_CACHE_TIMER, 5, ".", "");
         /**/
         $cache = $buffer . "\n<!-- This Quick Cache file was built for ( " . QUICK_CACHE_FILE_DESC . " ) in " . $total_time . " seconds, on " . date("M jS, Y \\a\\t g:i a T") . ". -->";
         $cache .= "\n<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on " . date("M jS, Y \\a\\t g:i a T", strtotime("+" . QUICK_CACHE_EXPIRATION . " seconds")) . " -->";
         /**/
         if (QUICK_CACHE_USE_FLOCK_OR_SEM === "sem" && function_exists("sem_get") && ($mutex = @sem_get(1976, 1, 0644 | IPC_CREAT, 1)) && @sem_acquire($mutex) && ($cached = true)) {
             file_put_contents(QUICK_CACHE_FILE, serialize($headers) . "<!--headers-->" . $cache) . sem_release($mutex);
         } else {
             if (($mutex = @fopen(WP_CONTENT_DIR . "/cache/qc-l-mutex.lock", "w")) && @flock($mutex, LOCK_EX) && ($cached = true)) {
                 file_put_contents(QUICK_CACHE_FILE, serialize($headers) . "<!--headers-->" . $cache) . flock($mutex, LOCK_UN);
             }
         }
         /**/
         return $cached ? $cache : $buffer . "\n<!-- Quick Cache: failed to write cache, unable to obtain a mutex lock at the moment. Quick Cache will try again later. -->";
     } else {
         return $buffer . "\n<!-- Quick Cache: failed to write cache. The cache/ directory is either non-existent ( and could not be created ) or it is not writable. -->";
     }
 }
Ejemplo n.º 3
0
 *    Anything acquired in this phase should be stored as a scalar value.
 *    See {@link outputBufferCallbackHandler()} for further details.
 *
 * @since 150422 Rewrite.
 *
 * @attaches-to `wp` hook.
 */
$self->wpMainQueryPostload = function () use($self) {
    if (empty($self->postload['wp_main_query'])) {
        return;
        // Nothing to do in this case.
    }
    if ($self->is_wp_loaded_query || is_admin()) {
        return;
        // Nothing to do.
    }
    if (!is_main_query()) {
        return;
        // Not main query.
    }
    $self->is_wp_loaded_query = true;
    $self->is_404 = is_404();
    $self->is_user_logged_in = is_user_logged_in();
    $self->content_url = rtrim(content_url(), '/');
    $self->is_maintenance = $self->functionIsPossible('is_maintenance') && is_maintenance();
    $_self = $self;
    // Reference for the closure below.
    add_action('template_redirect', function () use($_self) {
        $_self->is_a_wp_content_type = $_self->is_404 || $_self->is_maintenance || is_front_page() || is_home() || is_singular() || is_archive() || is_post_type_archive() || is_tax() || is_search() || is_feed();
    }, 11);
};
Ejemplo n.º 4
0
?>

<body id="<?php 
echo G\getTemplateUsed();
?>
" class="<?php 
echo $body_class;
?>
">

<?php 
echo CHV\getSetting('analytics_code');
?>

<?php 
if (!is_maintenance()) {
    ?>
<header id="top-bar" class="top-bar<?php 
    if (in_array($body_class, ['landing', 'split'])) {
        echo ' transparent';
    }
    ?>
">
	<?php 
    if (is_private_gate()) {
        ?>
	<div class="c24 center-box content-width">
	<?php 
    }
    ?>
    <div class="content-width">
Ejemplo n.º 5
0
 public function output_buffer_callback_handler($buffer)
 {
     if (defined('DONOTCACHEPAGE')) {
         return $buffer;
     }
     if (isset($_SERVER['DONOTCACHEPAGE'])) {
         return $buffer;
     }
     if (isset($_GET['qcAC']) && !$_GET['qcAC']) {
         return $buffer;
     }
     if (defined('QUICK_CACHE_ALLOWED') && !QUICK_CACHE_ALLOWED) {
         return $buffer;
     }
     if (isset($_SERVER['QUICK_CACHE_ALLOWED']) && !$_SERVER['QUICK_CACHE_ALLOWED']) {
         return $buffer;
     }
     if (!QUICK_CACHE_WHEN_LOGGED_IN && $this->is_like_user_logged_in()) {
         return $buffer;
     }
     // Just to make sure.
     if (!QUICK_CACHE_WHEN_LOGGED_IN && function_exists('is_user_logged_in') && is_user_logged_in()) {
         return $buffer;
     }
     if (function_exists('zlib_get_coding_type') && zlib_get_coding_type() && (!($zlib_oc = ini_get('zlib.output_compression')) || !preg_match('/^(?:1|on|yes|true)$/i', $zlib_oc))) {
         throw new \exception(__('Unable to cache already-compressed output. Please use `mod_deflate` w/ Apache; or use `zlib.output_compression` in your `php.ini` file. Quick Cache is NOT compatible with `ob_gzhandler()` and others like this.', $this->text_domain));
     }
     if (function_exists('is_maintenance') && is_maintenance()) {
         return $buffer;
     }
     # http://wordpress.org/extend/plugins/maintenance-mode
     if (function_exists('did_action') && did_action('wm_head')) {
         return $buffer;
     }
     # http://wordpress.org/extend/plugins/wp-maintenance-mode
     $buffer = trim($buffer);
     // Trim buffer.
     $cache = $buffer;
     // Initialize cache value.
     $buffer_length = strlen($buffer);
     // Call this ONE time here.
     $headers = headers_list();
     // Need these headers below.
     $content_type = '';
     // Initialize possible content type.
     if (!$buffer_length) {
         return $buffer;
     }
     // Don't cache an empty buffer.
     if (strpos($buffer, '<body id="error-page">') !== FALSE) {
         return $buffer;
     }
     // Don't cache WP errors.
     foreach ($headers as $_header) {
         if (preg_match('/^(?:Retry\\-After\\:|Status\\:\\s+[^2]|HTTP\\/1\\.[01]\\s+[^2])/i', $_header)) {
             return $buffer;
         }
         // Don't cache errors (anything that's NOT a 2xx status).
         if (stripos($_header, 'Content-Type:') === 0) {
             $content_type = $_header;
         }
         // Last one.
     }
     unset($_header);
     // Just a little houskeeping.
     if ($content_type) {
         // If we found a Content-Type; make sure it's XML/HTML code.
         if (!preg_match('/xhtml|html|xml|' . preg_quote(__NAMESPACE__, '/') . '/i', $content_type)) {
             return $buffer;
         }
     }
     // Caching occurs here; we're good-to-go now :-)
     if (!is_dir(QUICK_CACHE_DIR) && mkdir(QUICK_CACHE_DIR, 0775, TRUE)) {
         if (is_writable(QUICK_CACHE_DIR) && !is_file(QUICK_CACHE_DIR . '/.htaccess')) {
             file_put_contents(QUICK_CACHE_DIR . '/.htaccess', 'deny from all');
         }
     }
     if (!is_dir(QUICK_CACHE_DIR) || !is_writable(QUICK_CACHE_DIR)) {
         // Must have this directory.
         throw new \exception(sprintf(__('Cache directory not writable. Quick Cache needs this directory please: `%1$s`. Set permissions to `755` or higher; `777` might be needed in some cases.', $this->text_domain), QUICK_CACHE_DIR));
     }
     if (QUICK_CACHE_DEBUGGING_ENABLE) {
         $total_time = number_format(microtime(TRUE) - $this->timer, 5, '.', '');
         $cache .= "\n" . '<!-- ' . htmlspecialchars(sprintf(__('Quick Cache file built for (%1$s%2$s) in %3$s seconds, on: %4$s.', $this->text_domain), $this->salt_location, $this->md5_4 ? '; ' . sprintf(__('user token: %1$s', $this->text_domain), substr($this->md5_4, 0, 8)) : '', $total_time, date('M jS, Y @ g:i a T'))) . ' -->';
         $cache .= "\n" . '<!-- ' . htmlspecialchars(sprintf(__('This Quick Cache file will auto-expire (and be rebuilt) on: %1$s (based on your configured expiration time).', $this->text_domain), date('M jS, Y @ g:i a T', strtotime('+' . QUICK_CACHE_MAX_AGE)))) . ' -->';
     }
     $cache_file_tmp = $this->cache_file . '.' . uniqid('', TRUE) . '.tmp';
     // Cache creation is atomic; e.g. tmp file w/ rename.
     if (file_put_contents($cache_file_tmp, serialize($headers) . '<!--headers-->' . $cache) && rename($cache_file_tmp, $this->cache_file)) {
         return $cache;
     }
     // Return the newly built cache; with possible debug information also.
     @unlink($cache_file_tmp);
     // Clean this up (if it exists); and throw an exception with information for the site owner.
     throw new \exception(sprintf(__('Quick Cache: failed to write cache file for: `%1$s`; possible permissions issue (or race condition), please check your cache directory: `%2$s`.', $this->text_domain), $_SERVER['REQUEST_URI'], QUICK_CACHE_DIR));
 }
<?php

/*
If you would like to edit this file, copy it to your current theme's directory and edit it there.
Theme My Login will always look in your theme's directory first, before using this default template.
*/
?>
<div class="login<?php 
echo function_exists('is_maintenance') && is_maintenance() ? ' maintenance_active' : '';
?>
" id="theme-my-login<?php 
$template->the_instance();
?>
">
	<?php 
$template->the_action_template_message('lostpassword');
?>
	<?php 
$template->the_errors();
?>
	<form name="lostpasswordform" id="lostpasswordform<?php 
$template->the_instance();
?>
" action="<?php 
$template->the_action_url('lostpassword');
?>
" method="post">
		<p>
			<label for="user_login<?php 
$template->the_instance();
?>
Ejemplo n.º 7
0
 /**
  * Grab details from WP and the Comet Cache plugin itself,
  *    after the main query is loaded (if at all possible).
  *
  * This is where we have a chance to grab any values we need from WordPress; or from the CC plugin.
  *    It is EXTREMEMLY important that we NOT attempt to grab any object references here.
  *    Anything acquired in this phase should be stored as a scalar value.
  *    See {@link outputBufferCallbackHandler()} for further details.
  *
  * @since 150422 Rewrite.
  *
  * @attaches-to `wp` hook.
  */
 public function wpMainQueryPostload()
 {
     if (empty($this->postload['wp_main_query'])) {
         return;
         // Nothing to do in this case.
     }
     if ($this->is_wp_loaded_query || is_admin()) {
         return;
         // Nothing to do.
     }
     if (!is_main_query()) {
         return;
         // Not main query.
     }
     $this->is_wp_loaded_query = true;
     $this->is_404 = is_404();
     $this->is_user_logged_in = is_user_logged_in();
     $this->content_url = rtrim(content_url(), '/');
     $this->is_maintenance = $this->functionIsPossible('is_maintenance') && is_maintenance();
     add_action('template_redirect', function () {
         $this->is_a_wp_content_type = $this->is_404 || $this->is_maintenance || is_front_page() || is_home() || is_singular() || is_archive() || is_post_type_archive() || is_tax() || is_search() || is_feed();
     }, 11);
 }
Ejemplo n.º 8
0
?>
" />
			<input type="hidden" name="instance" value="<?php 
$template->the_instance();
?>
" />
			<input type="hidden" name="action" value="login" />
		</p>
	</form>
	<?php 
$template->the_action_links(array('login' => false));
?>
	
	
	<?php 
if (function_exists('is_maintenance') && is_maintenance()) {
    ?>
	<a href="<?php 
    echo get_option('home');
    ?>
/"><i class="fa fa-angle-double-left"></i> Go Back</a>
<?php 
} else {
    ?>
	<a href="<?php 
    echo get_option('home');
    ?>
/">Return to website <i class="fa fa-angle-double-right"></i></a>
<?php 
}
?>
Ejemplo n.º 9
0
 /**
  * Grab details from WP and the Quick Cache plugin itself,
  *    after the main query is loaded (if at all possible).
  *
  * This is where we have a chance to grab any values we need from WordPress; or from the QC plugin.
  *    It is EXTREMEMLY important that we NOT attempt to grab any object references here.
  *    Anything acquired in this phase should be stored as a scalar value.
  *    See {@link output_buffer_callback_handler()} for further details.
  *
  * @since 140422 First documented version.
  *
  * @attaches-to `wp` hook.
  */
 public function wp_main_query_postload()
 {
     if (empty($this->postload['wp_main_query'])) {
         return;
     }
     // Nothing to do in this case.
     if ($this->is_wp_loaded_query || is_admin()) {
         return;
     }
     // Nothing to do.
     if (!is_main_query()) {
         return;
     }
     // Not the main query.
     $this->is_wp_loaded_query = TRUE;
     $this->is_404 = is_404();
     $this->site_url = site_url();
     $this->home_url = home_url();
     $this->is_user_logged_in = is_user_logged_in();
     $this->is_maintenance = function_exists('is_maintenance') && is_maintenance();
     $this->is_a_wp_content_type = $this->is_404 || $this->is_maintenance || is_front_page() || is_home() || is_singular() || is_archive() || is_post_type_archive() || is_tax() || is_search() || is_feed();
     if (function_exists('\\' . __NAMESPACE__ . '\\plugin')) {
         $this->plugin_file = plugin()->file;
     }
 }