Пример #1
0
/**
 * Returns path of pgcache cache rules file
 * Moved to separate file to not load rule.php for each disk enhanced request
 *
 * @return string
 */
function w3_get_pgcache_rules_cache_path()
{
    switch (true) {
        case w3_is_apache():
        case w3_is_litespeed():
            if (w3_is_network()) {
                $url = w3_get_home_url();
                $match = null;
                if (preg_match('~http(s)?://(.+?)(/)?$~', $url, $match)) {
                    $home_path = $match[2];
                    return W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . $home_path . '/.htaccess';
                }
            }
            return W3TC_CACHE_PAGE_ENHANCED_DIR . '/.htaccess';
        case w3_is_nginx():
            return w3_get_nginx_rules_path();
    }
    return false;
}
Пример #2
0
 /**
  * Returns allow-origin rules
  *
  * @param bool $cdnftp
  * @return string
  */
 public function allow_origin($cdnftp = false)
 {
     switch (true) {
         case w3_is_apache():
         case w3_is_litespeed():
             $r = "<IfModule mod_headers.c>\n";
             $r .= "    Header set Access-Control-Allow-Origin \"*\"\n";
             $r .= "</IfModule>\n";
             if (!$cdnftp) {
                 return $r;
             } else {
                 return "<FilesMatch \"\\.(ttf|ttc|otf|eot|woff|font.css)\$\">\n" . $r . "</FilesMatch>\n";
             }
         case w3_is_nginx():
             $r = "   add_header Access-Control-Allow-Origin \"*\";\n";
             if (!$cdnftp) {
                 return $r;
             } else {
                 return "location ~ \\.(ttf|ttc|otf|eot|woff|font.css)\$ {\n" . $r . "}\n";
             }
     }
     return '';
 }
 /**
  * Generate rules related to prevent for media 404 error by WP
  *
  * @param W3_Config $config
  * @return string
  */
 private function rules_no404wp_generate($config)
 {
     switch (true) {
         case w3_is_apache():
         case w3_is_litespeed():
             return $this->rules_no404wp_generate_apache($config);
         case w3_is_nginx():
             return $this->rules_no404wp_generate_nginx($config);
     }
     return false;
 }
Пример #4
0
 /**
  * Returns rules
  *
  * @param bool $cdnftp
  * @return string
  */
 function generate_rules($cdnftp = false)
 {
     switch (true) {
         case w3_is_apache():
         case w3_is_litespeed():
             return $this->generate_rules_apache($cdnftp);
         case w3_is_nginx():
             return $this->generate_rules_nginx($cdnftp);
     }
     return false;
 }
Пример #5
0
 /**
  * Returns page key
  *
  * @param string $mobile_group
  * @param string $referrer_group
  * @param string $encryption
  * @param string $compression
  * @param string $content_type
  * @param string $request_uri
  * @return string
  */
 function _get_page_key($mobile_group = '', $referrer_group = '', $encryption = '', $compression = '', $content_type = '', $request_uri = '')
 {
     if ($request_uri) {
         $key = substr($request_uri, strtolower(substr($request_uri, 0, 8)) == 'https' ? 8 : 7);
     } else {
         $key = $this->_request_host . $this->_request_uri;
     }
     // replace fragment
     $key = preg_replace('~#.*$~', '', $key);
     if ($this->_enhanced_mode) {
         // URL decode
         $key = urldecode($key);
         // replace double slashes
         $key = preg_replace('~[/\\\\]+~', '/', $key);
         // replace query string
         $key = preg_replace('~\\?.*$~', '', $key);
         // replace index.php
         $key = str_replace('/index.php', '/', $key);
         // trim slash
         $key = ltrim($key, '/');
         if ($key && substr($key, -1) != '/') {
             $key .= '/';
         }
         $key .= '_index';
     } else {
         if ($this->_check_query_string()) {
             // replace query string
             $key = preg_replace('~\\?.*$~', '', $key);
         }
         $key = md5($key);
     }
     /**
      * Append mobile group
      */
     if ($mobile_group) {
         $key .= '_' . $mobile_group;
     }
     /**
      * Append referrer group
      */
     if ($referrer_group) {
         $key .= '_' . $referrer_group;
     }
     /**
      * Append encryption
      */
     if ($encryption) {
         $key .= '_' . $encryption;
     }
     if (w3_is_preview_mode()) {
         $key .= '_preview';
     }
     if ($this->_enhanced_mode) {
         /**
          * Append HTML extension.
          * For nginx - we create .xml cache entries and redirect to them
          */
         if (w3_is_nginx() && substr($content_type, 0, 8) == 'text/xml' && $this->_config->get_boolean('pgcache.cache.nginx_handle_xml')) {
             $key .= '.xml';
         } else {
             $key .= '.html';
         }
     }
     /**
      * Append compression
      */
     if ($compression) {
         $key .= '_' . $compression;
     }
     return $key;
 }
Пример #6
0
/**
 * @param SelfTestExceptions $exs
 * @param string $path
 * @param string $rules
 * @param string $start
 * @param string $end
 * @param array $order
 */
function w3_add_rules($exs, $path, $rules, $start, $end, $order)
{
    $data = @file_get_contents($path);
    if ($data === false) {
        $data = '';
    }
    $rules_missing = !empty($rules) && strstr(w3_clean_rules($data), w3_clean_rules($rules)) === false;
    if (!$rules_missing) {
        return;
    }
    $replace_start = strpos($data, $start);
    $replace_end = strpos($data, $end);
    if ($replace_start !== false && $replace_end !== false && $replace_start < $replace_end) {
        $replace_length = $replace_end - $replace_start + strlen($end) + 1;
    } else {
        $replace_start = false;
        $replace_length = 0;
        $search = $order;
        foreach ($search as $string => $length) {
            $replace_start = strpos($data, $string);
            if ($replace_start !== false) {
                $replace_start += $length;
                break;
            }
        }
    }
    if ($replace_start !== false) {
        $data = w3_trim_rules(substr_replace($data, $rules, $replace_start, $replace_length));
    } else {
        $data = w3_trim_rules($data . $rules);
    }
    if (strpos($path, W3TC_CACHE_DIR) === false || w3_is_nginx()) {
        try {
            w3_wp_write_to_file($path, $data);
        } catch (FilesystemOperationException $ex) {
            if ($replace_start !== false) {
                $exs->push(new FilesystemModifyException($ex->getMessage(), $ex->credentials_form(), sprintf(__('Edit file <strong>%s
                        </strong> and replace all lines between and including <strong>%s</strong> and
                        <strong>%s</strong> markers with:', 'w3-total-caceh'), $path, $start, $end), $path, $rules));
            } else {
                $exs->push(new FilesystemModifyException($ex->getMessage(), $ex->credentials_form(), sprintf(__('Edit file <strong>%s</strong> and add the following rules
                                above the WordPress directives:', 'w3-total-cache'), $path), $path, $rules));
            }
        }
    } else {
        if (!@file_exists(dirname($path))) {
            w3_mkdir_from(dirname($path), W3TC_CACHE_DIR);
        }
        if (!@file_put_contents($path, $data)) {
            try {
                w3_wp_delete_folder(dirname($path), '', $_SERVER['REQUEST_URI']);
            } catch (FilesystemOperationException $ex) {
                $exs->push($ex);
            }
        }
    }
}
Пример #7
0
 /**
  * Checks whether canonical should be generated or not by browsercache plugin
  * @param W3_Config $config
  * @param boolean $cdnftp
  * @return string|null
  */
 public function canonical_generated_by($config, $cdnftp = false)
 {
     if (!$this->_should_canonical_be_generated($config, $cdnftp)) {
         return null;
     }
     if (w3_is_nginx()) {
         // in nginx - browsercache generates canonical if its enabled,
         // since it does not allow multiple location tags
         if ($config->get_boolean('browsercache.enabled')) {
             return 'browsercache';
         }
     }
     if ($config->get_boolean('cdn.enabled')) {
         return 'cdn';
     }
     return null;
 }
 /**
  * @return array
  */
 function remove_rules_cache_multisite_nginx_with_message()
 {
     $ftp_form = null;
     $errors = array();
     $errors_short_form = array();
     if (w3_is_multisite() && w3_is_nginx() && $this->check_rules_cache()) {
         try {
             $this->remove_rules_cache();
         } catch (Exception $e) {
             $errors[] = sprintf('To fully disable Page Cache Disc: Enhanced for Network Sites rules need to be removed. To remove them manually, edit the configuration file (<strong>%s</strong>) and remove all lines between and including <strong>%s</strong> and <strong>%s</strong> markers inclusive.', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_CACHE, W3TC_MARKER_END_PGCACHE_CACHE);
             $errors_short_form[] = sprintf('Edit file (<strong>%s</strong>) and remove all lines between and including <strong>%s</strong> and <strong>%s</strong> markers inclusive.', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_CACHE, W3TC_MARKER_END_PGCACHE_CACHE);
             if (!isset($ftp_form) && $e instanceof FilesystemCredentialException) {
                 $ftp_form = $e->ftp_form();
             }
         }
     }
     return array('errors' => $errors, 'ftp_form' => $ftp_form, 'errors_short_form' => $errors_short_form);
 }
Пример #9
0
/**
 * Returns true if we can check rules
 *
 * @return bool
 */
function w3_can_check_rules()
{
    return w3_is_apache() || w3_is_litespeed() || w3_is_nginx();
}
Пример #10
0
/**
 * Returns path of minify rules file
 *
 * @return string
 */
function w3_get_cdn_rules_path()
{
    switch (true) {
        case w3_is_apache():
        case w3_is_litespeed():
            return '.htaccess';
        case w3_is_nginx():
            return 'nginx.conf';
    }
    return false;
}
Пример #11
0
?>
            <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="<?php 
_e('Save all settings', 'w3-total-cache');
?>
" />
        </p>
        <?php 
echo $this->postbox_footer();
?>

        <?php 
echo $this->postbox_header(__('Media &amp; Other Files', 'w3-total-cache'), '', 'media');
?>
        <table class="form-table">
            <?php 
if (!w3_is_nginx()) {
    ?>
            <tr>
                <th colspan="2">
                    <?php 
    $this->checkbox('browsercache.other.last_modified');
    ?>
 <?php 
    w3_e_config_label('browsercache.other.last_modified');
    ?>
</label>
                    <br /><span class="description"><?php 
    _e('Set the Last-Modified header to enable 304 Not Modified response.', 'w3-total-cache');
    ?>
</span>
                </th>
Пример #12
0
    ?>
 disabled="disabled"<?php 
}
?>
><?php 
echo esc_textarea(implode("\r\n", $this->_config->get_array('pgcache.cache.headers')));
?>
</textarea><br />
                    <span class="description"><?php 
_e('Specify additional page headers to cache.', 'w3-total-cache');
?>
</span>
                </td>
            </tr>
            <?php 
if (w3_is_nginx() && $this->_config->get_string('pgcache.engine') == 'file_generic') {
    ?>
            <tr>
                <th><label><?php 
    _e('Handle <acronym title="Extensible Markup Language">XML</acronym> mime type', 'w3-total-cache');
    ?>
</label></th>
                <td>
                    <?php 
    $this->checkbox('pgcache.cache.nginx_handle_xml', true);
    ?>
 <?php 
    _e('Handle XML mime type', 'w3-total-cache');
    ?>
</label><br />
                    <span class="description"><?php 
Пример #13
0
/**
 * Returns true if we can modify rules
 *
 * @param string $path
 * @return boolean
 */
function w3_can_modify_rules($path)
{
    if (w3_is_network()) {
        if (w3_is_apache() || w3_is_litespeed() || w3_is_nginx()) {
            switch ($path) {
                case w3_get_pgcache_rules_cache_path():
                case w3_get_minify_rules_core_path():
                case w3_get_minify_rules_cache_path():
                    return true;
            }
        }
        return false;
    }
    return true;
}
Пример #14
0
 /**
  * Checks whether canonical should be generated or not
  * @param boolean $cdnftp
  * @return bool
  */
 private function _should_browsercache_generate_canonical($cdnftp = false)
 {
     return $this->_canonical_generation_general_check($cdnftp) && w3_is_nginx();
 }
Пример #15
0
 /**
  * Checks if the platform running WP is supported by New Relic.
  * The verifications is based on https://newrelic.com/docs/php/new-relic-for-php
  * @return array
  */
 function verify_compatibility()
 {
     $supported_string = __('Supported', 'w3-total-cache');
     $php_versions = array('5.2.x', '5.3.x', '5.4.x');
     $verified = array();
     $version = explode('.', PHP_VERSION);
     $php_version = sprintf('%s.%s.%s', $version[0], $version[1], $version[2]);
     $php_version_check = version_compare($php_version, '5.2', '>') && version_compare($php_version, '5.5', '<');
     $verified[__('PHP version', 'w3-total-cache')] = $php_version_check ? $supported_string : sprintf(__('Not supported: %s. Supported versions are %s.', 'w3-total-cache'), $php_version, implode(', ', $php_versions));
     $os_name = php_uname('s');
     switch ($os_name) {
         case 'Linux':
             /**
              * Any other version of Linux with kernel 2.6.13 or later
              * (2.6.26 and later highly recommended) and glibc 2.5 or later
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d.%d', $version[0], $version[1], $version[2]);
             $os_check = version_compare($os_version, '2.6.13', '>=');
             break;
         case 'FreeBSD':
             /**
              * You must enable the linkthr build option so that the New Relic agent will not cause your PHP to hang.
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d', $version[0], $version[1]);
             $os_check = version_compare($os_version, '7.3', '>=');
             break;
         case 'MacOS/X':
             /**
              * MacOS/X configurations do not use the standard /etc/init.d/newrelic-daemon script.
              * Instead, they use /usr/bin/newrelic-daemon-service in the same way; for example:
              * /usr/bin/newrelic-daemon-service restart.
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d', $version[0], $version[1]);
             $os_check = version_compare($os_version, '10.5', '>=');
             break;
         case 'Open Solaris':
             /**
              * snv_134b or later
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d', $version[0]);
             $os_check = version_compare($os_version, '10', '==');
             break;
         default:
             $os_check = false;
             $os_name = php_uname();
             $os_version = '';
     }
     $verified[__('Operating System', 'w3-total-cache')] = $os_check ? $supported_string : sprintf(__('Not Supported. %s %s See %s page.', 'w3-total-cache'), $os_name, $os_version, '<a href="https://newrelic.com/docs/php/new-relic-for-php#requirements">
                                     NewRelic requirements</a>');
     /**
      * Apache 2.2 or 2.4 via mod_php
      * Or any web server that supports FastCGI using php-fpm
      */
     $server = explode('/', $_SERVER['SERVER_SOFTWARE']);
     $ws_name = $server[0];
     $version = explode('.', $server[1]);
     $ws_version = sprintf('%d.%d', $version[0], $version[1]);
     switch (true) {
         case w3_is_apache():
             $ws_check = version_compare($ws_version, '2.2', '>=') || version_compare($ws_version, '2.4', '>=');
             break;
         case w3_is_nginx():
             $ws_check = php_sapi_name() == 'fpm-fcgi';
             $ws_name .= php_sapi_name();
             break;
         default:
             $ws_check = php_sapi_name() == 'fpm-fcgi';
             $ws_name = $_SERVER['SERVER_SOFTWARE'];
             $ws_version = '';
     }
     $verified[__('Web Server', 'w3-total-cache')] = $ws_check ? $supported_string : sprintf(__('Not Supported. %s %s See %s page.', 'w3-total-cache'), $ws_name, $ws_version, '<a href="https://newrelic.com/docs/php/new-relic-for-php#requirements">
                                     NewRelic requirements</a>');
     return $verified;
 }
Пример #16
0
        <p class="submit">
            <?php 
echo $this->nonce_field('w3tc');
?>
            <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="Save all settings" />
        </p>
        <?php 
echo $this->postbox_footer();
?>
        <?php 
echo $this->postbox_header('Miscellaneous');
?>
        <table class="form-table">
            <?php 
if (w3_is_nginx()) {
    ?>
            <tr>
                <th>Nginx server configuration file path</th>
                <td>
                    <input type="text" name="config.path" value="<?php 
    echo htmlspecialchars($this->_config->get_string('config.path'));
    ?>
" size="80" />
                    <br /><span class="description">If empty the default path will be used..</span>
                </td>
            </tr>
            <?php 
}
?>
            <tr>
 /**
  * Generates directives for file cache dir
  *
  * @param W3_Config $config
  * @return string
  */
 public function rules_cache_generate($config)
 {
     switch (true) {
         case w3_is_apache():
         case w3_is_litespeed():
             return $this->rules_cache_generate_apache($config);
         case w3_is_nginx():
             return $this->rules_cache_generate_nginx($config);
     }
     return '';
 }
Пример #18
0
 /**
  * Generates rules
  *
  * @return string
  */
 function generate_rules_cache()
 {
     switch (true) {
         case w3_is_apache():
             return $this->generate_rules_cache_apache();
         case w3_is_nginx():
             return $this->generate_rules_cache_nginx();
     }
     return false;
 }
Пример #19
0
 /**
  * Generate rules related to prevent for media 404 error by WP
  *
  * @return string
  */
 function generate_rules_no404wp()
 {
     switch (true) {
         case w3_is_apache():
         case w3_is_litespeed():
             return $this->generate_rules_no404wp_apache();
         case w3_is_nginx():
             return $this->generate_rules_no404wp_nginx();
     }
     return false;
 }
 /**
  * Options page
  *
  * @return void
  */
 function options()
 {
     $remove_results = array();
     $w3tc_error = array();
     w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
     $preview = $this->_config->is_preview();
     if (w3_is_network() && !$this->is_master()) {
         $this->_config_master = new W3_Config(true);
     } else {
         $this->_config_master = $this->_config;
     }
     $w3_verify = w3_instance('W3_FileVerification');
     /**
      * Check for page cache availability
      */
     $wp_config_edit = false;
     if ($this->_config->get_boolean('pgcache.enabled')) {
         if (!defined('WP_CACHE') || !WP_CACHE) {
             try {
                 $w3_plugin_admin = w3_instance('W3_Plugin_PgCacheAdmin');
                 $w3_plugin_admin->enable_wp_cache(w3_is_network() ? network_admin_url('admin.php?page=w3tc_general') : admin_url('admin.php?page=w3tc_general'));
             } catch (Exception $e) {
                 $ftp_message = '';
                 if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                     $this->_ftp_form = $e->ftp_form();
                     $ftp_message = ' Or use the <a href="#ftp_upload_form">FTP form</a> below.';
                 } elseif ($e instanceof FileOperationException) {
                     $file_operation_exception = true;
                     $wp_config_edit = true;
                 }
                 if (!$this->_disable_add_in_files_notification) {
                     $this->_errors[] = sprintf('Page caching is not available: please add: <strong>define(\'WP_CACHE\', true);</strong> to <strong>%s</strong>. %s', w3_get_wp_config_path(), $ftp_message);
                 }
             }
         }
         if (!$w3_verify->advanced_cache_check()) {
             if (!$this->_disable_add_in_files_notification) {
                 $this->_errors[] = sprintf('Page caching is not available. The current add-in %s is either missing, an incorrect file or an old version. De-activate the plugin, remove the file, then activate the plugin again.', W3TC_ADDIN_FILE_ADVANCED_CACHE);
             }
         } elseif ($this->_config->get_string('pgcache.engine') == 'file_generic' && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
             $w3_plugin_pgcache = w3_instance('W3_Plugin_PgCacheAdmin');
             if (w3_get_blog_id() == 0) {
                 if ($w3_plugin_pgcache->check_rules_core()) {
                     if ($this->_config->get_boolean('pgcache.debug') && !$this->test_rewrite_pgcache()) {
                         $url = w3_get_home_url() . '/w3tc_rewrite_test';
                         $key = sprintf('w3tc_rewrite_test_result_%s', substr(md5($url), 0, 16));
                         $result = get_transient($key);
                         $tech_message = '%s contains rules to rewrite url %2$s/w3tc_rewrite_test into %2$s/?w3tc_rewrite_test which, if handled by plugin, return "OK" message.<br/>';
                         $tech_message .= 'The plugin made a request to %s/w3tc_rewrite_test but received: <br />%s<br />';
                         $tech_message .= 'instead of "OK" response. <br />';
                         $tech_message .= 'Unfortunately disk enhanced page caching will not function without custom rewrite rules. Please ask your server administrator for assistance. Also refer to <a href="%s">the install page</a>  for the rules for your server.';
                         $tech_message = sprintf($tech_message, w3_is_nginx() ? 'nginx configuration file' : '.htaccess file', w3_get_home_url(), $result, admin_url('admin.php?page=w3tc_install'));
                         $error = 'It appears Page Cache <acronym title="Uniform Resource Locator">URL</acronym> rewriting is not working. If using apache, verify that the server configuration allows .htaccess. Or if using nginx verify all configuration files are included in the configuration file (and that you have reloaded / restarted nginx).';
                         $error .= ' <br /><a id="w3tc_read_technical_info" href="#">Technical info</a><div id="w3tc_technical_info">' . $tech_message . '</div>';
                         $this->_errors[] = $error;
                     }
                     if ($w3_plugin_pgcache->check_rules_has_legacy()) {
                         try {
                             $w3_plugin_pgcache->remove_rules_legacy();
                             $w3_plugin_pgcache->write_rules_core();
                         } catch (Exception $e) {
                             $this->_rule_errors_root[] = sprintf('Edit the configuration file (<strong>%s</strong>) and ' . 'remove all lines between and including <strong>%s</strong> and ' . '<strong>%s</strong> markers inclusive.', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_LEGACY, W3TC_MARKER_END_PGCACHE_LEGACY);
                             if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                                 $this->_ftp_form = $e->ftp_form();
                             } elseif ($e instanceof FileOperationException) {
                                 $file_operation_exception = true;
                             }
                         }
                     }
                 } else {
                     if ($w3_plugin_pgcache->check_rules_has_core()) {
                         $instructions = sprintf('replace the content of the server configuration ' . 'file <strong>%s</strong> between %s and %s markers inclusive. Required after modifying Page Cache / Browser Cache settings or plugin update', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_CORE, W3TC_MARKER_END_PGCACHE_CORE);
                     } elseif ($w3_plugin_pgcache->check_rules_has_legacy()) {
                         $legacy = true;
                         $instructions = sprintf('replace the content of the server configuration ' . 'file <strong>%s</strong> between %s and %s markers inclusive', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_LEGACY, W3TC_MARKER_END_PGCACHE_LEGACY);
                     } else {
                         $instructions = sprintf('add the following rules into the server ' . 'configuration file (<strong>%s</strong>) of the site above the ' . 'WordPress directives', w3_get_pgcache_rules_core_path());
                     }
                     if (isset($instructions)) {
                         try {
                             if (isset($legacy) && $legacy) {
                                 $w3_plugin_pgcache->remove_rules_legacy();
                             }
                             $w3_plugin_pgcache->write_rules_core();
                         } catch (Exception $e) {
                             $this->_rule_errors_root[] = sprintf('To enable Disk enhanced page caching, ' . $instructions . ' %s <textarea class="w3tc-rules"' . ' cols="120" rows="10" readonly="readonly">%s</textarea>.', $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_pgcache->generate_rules_core()));
                             if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                                 $this->_ftp_form = $e->ftp_form();
                             } elseif ($e instanceof FileOperationException) {
                                 $file_operation_exception = true;
                             }
                         }
                     }
                 }
                 if ($this->_config->get_boolean('notes.pgcache_rules_wpsc') && $w3_plugin_pgcache->check_rules_wpsc()) {
                     $this->_errors[] = sprintf('WP Super Cache rewrite rules have been found. To remove them manually, edit the configuration file (<strong>%s</strong>) and remove all lines between and including <strong>%s</strong> and <strong>%s</strong> markers inclusive. Or if permission allow this can be done automatically, by clicking here: %s. %s', w3_get_pgcache_rules_core_path(), W3TC_MARKER_BEGIN_PGCACHE_WPSC, W3TC_MARKER_END_PGCACHE_WPSC, $this->button_link('auto-remove', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_pgcache_remove_rules_wpsc', $this->_page), 'w3tc')), $this->button_hide_note('Hide this message', 'pgcache_rules_wpsc'));
                 }
             }
             if (!$w3_plugin_pgcache->check_rules_cache()) {
                 if (w3_is_nginx() && w3_get_blog_id() == 0) {
                     try {
                         $w3_plugin_pgcache->write_rules_cache(true);
                     } catch (Exception $e) {
                         $this->_rule_errors_root[] = sprintf('To enable Disk enhanced page caching, add ' . 'the following rules into the server configuration file ' . '(<strong>%s</strong>) of the site %s <textarea class="w3tc-rules" ' . 'cols="120" rows="10" readonly="readonly">%s</textarea>.', w3_get_pgcache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_pgcache->generate_rules_cache()));
                         if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                             $this->_ftp_form = $e->ftp_form();
                         } elseif ($e instanceof FileOperationException) {
                             $file_operation_exception = true;
                         }
                     }
                 } else {
                     $this->_rule_errors[] = array(sprintf('To enable Disk enhanced page caching, add ' . 'the following rules into the server configuration file ' . '(<strong>%s</strong>) of the site %s <textarea class="w3tc-rules" ' . 'cols="120" rows="10" readonly="readonly">%s</textarea>.', w3_get_pgcache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_pgcache->generate_rules_cache())), 'pgcache_write_rules_cache');
                 }
             }
         }
     } elseif (w3_get_blog_id() == 0 && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $w3_plugin_pgcache = w3_instance('W3_Plugin_PgCacheAdmin');
         $remove_results[] = $w3_plugin_pgcache->remove_rules_cache_multisite_nginx_with_message();
     }
     if (w3_get_blog_id() == 0 && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $w3_plugin_pgcache = w3_instance('W3_Plugin_PgCacheAdmin');
         $remove_results[] = $w3_plugin_pgcache->remove_rules_core_with_message(true);
     }
     /**
      * Check for minify availability
      */
     if ($this->_config->get_boolean('minify.enabled')) {
         $minify_rule_error = '';
         if ($this->_config->get_boolean('minify.rewrite') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
             $w3_plugin_minify = w3_instance('W3_Plugin_MinifyAdmin');
             if ($w3_plugin_minify->check_rules_core()) {
                 if (!$this->test_rewrite_minify() && (!w3_is_multisite() || w3_is_multisite() && w3_get_blog_id() != 0)) {
                     $this->_errors[] = 'It appears Minify <acronym title="Uniform Resource Locator">URL</acronym> rewriting is not working. If using apache, verify that the server configuration allows .htaccess. Or if using nginx verify all configuration files are included in the main configuration fail (and that you have reloaded / restarted nginx).';
                 }
                 if ($w3_plugin_minify->check_rules_has_legacy()) {
                     $this->_rule_errors[] = array(sprintf('Edit the configuration file (<strong>%s</strong>) and ' . 'remove all lines between and including <strong>%s</strong> and ' . '<strong>%s</strong> markers inclusive.', w3_get_minify_rules_core_path(), W3TC_MARKER_BEGIN_MINIFY_LEGACY, W3TC_MARKER_END_MINIFY_LEGACY), 'minify_remove_rules_legacy');
                 }
             } else {
                 if ($w3_plugin_minify->check_rules_has_core()) {
                     $minify_rule_error = sprintf('replace the content of ' . 'the server configuration file <strong>%s</strong> between %s and ' . '%s markers inclusive', w3_get_minify_rules_core_path(), W3TC_MARKER_BEGIN_MINIFY_CORE, W3TC_MARKER_END_MINIFY_CORE);
                 } elseif ($w3_plugin_minify->check_rules_has_legacy()) {
                     $minify_rule_error = sprintf('replace the content of ' . 'the server configuration file <strong>%s</strong> between %s and ' . '%s markers inclusive', w3_get_minify_rules_core_path(), W3TC_MARKER_BEGIN_MINIFY_LEGACY, W3TC_MARKER_END_MINIFY_LEGACY);
                 } else {
                     $minify_rule_error = sprintf('add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the site', w3_get_minify_rules_core_path());
                 }
                 $minify_rule_content = $w3_plugin_minify->generate_rules_core();
             }
             if ($this->_config->get_string('minify.engine') == 'file' && !$w3_plugin_minify->check_rules_cache()) {
                 if ($minify_rule_error == '') {
                     $minify_rule_error = sprintf('add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the ' . 'site', w3_get_minify_rules_cache_path());
                 }
                 $minify_rule_content .= $w3_plugin_minify->generate_rules_cache();
             }
             if ($minify_rule_error != '' && w3_get_blog_id() == 0) {
                 $this->_rule_errors[] = array(sprintf('To enable Minify, ' . $minify_rule_error . ' %s <textarea class="w3tc-rules" cols="120" rows="10" ' . 'readonly="readonly">%s</textarea>.', $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($minify_rule_content)), 'minify_write_rules');
             }
             if ((w3_is_apache() || w3_is_litespeed()) && w3_is_network() && !w3_is_subdomain_install() && !$w3_plugin_minify->check_multisite_subfolder_test_rules_cache_apache()) {
                 $minify_rule_test = sprintf('To enable Minify Rewrite Test, add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the ' . 'site', w3_get_document_root() . '/.htaccess');
                 $minify_test_rule_content = $w3_plugin_minify->generate_multisite_subfolder_rewrite_test_rules_apache();
                 $this->_rule_errors[] = array(sprintf($minify_rule_test . ' %s <textarea class="w3tc-rules" cols="120" rows="10" ' . 'readonly="readonly">%s</textarea>.', $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($minify_test_rule_content)), 'minify_write_test_rules');
             }
         }
         /**
          * Minifiers availability error handling
          */
         $minifiers_errors = array();
         if ($this->_config->get_string('minify.js.engine') == 'yuijs') {
             $path_java = $this->_config->get_string('minify.yuijs.path.java');
             $path_jar = $this->_config->get_string('minify.yuijs.path.jar');
             if (!file_exists($path_java)) {
                 $minifiers_errors[] = sprintf('YUI Compressor (JS): JAVA executable path was not found. The default minifier JSMin will be used instead.');
             } elseif (!file_exists($path_jar)) {
                 $minifiers_errors[] = sprintf('YUI Compressor (JS): JAR file path was not found. The default minifier JSMin will be used instead.');
             }
         }
         if ($this->_config->get_string('minify.css.engine') == 'yuicss') {
             $path_java = $this->_config->get_string('minify.yuicss.path.java');
             $path_jar = $this->_config->get_string('minify.yuicss.path.jar');
             if (!file_exists($path_java)) {
                 $minifiers_errors[] = sprintf('YUI Compressor (CSS): JAVA executable path was not found. The default CSS minifier will be used instead.');
             } elseif (!file_exists($path_jar)) {
                 $minifiers_errors[] = sprintf('YUI Compressor (CSS): JAR file path was not found. The default CSS minifier will be used instead.');
             }
         }
         if ($this->_config->get_string('minify.js.engine') == 'ccjs') {
             $path_java = $this->_config->get_string('minify.ccjs.path.java');
             $path_jar = $this->_config->get_string('minify.ccjs.path.jar');
             if (!file_exists($path_java)) {
                 $minifiers_errors[] = sprintf('Closure Compiler: JAVA executable path was not found. The default minifier JSMin will be used instead.');
             } elseif (!file_exists($path_jar)) {
                 $minifiers_errors[] = sprintf('Closure Compiler: JAR file path was not found. The default minifier JSMin will be used instead.');
             }
         }
         if (count($minifiers_errors)) {
             $minify_error = 'The following minifiers cannot be found or are no longer working:</p><ul>';
             foreach ($minifiers_errors as $minifiers_error) {
                 $minify_error .= '<li>' . $minifiers_error . '</li>';
             }
             $minify_error .= '</ul><p>This message will automatically disappear once the issue is resolved.';
             $this->_errors[] = $minify_error;
         }
     }
     /**
      * Check for browser cache availability
      */
     if ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $w3_plugin_browsercache = w3_instance('W3_Plugin_BrowserCacheAdmin');
         if (!$w3_plugin_browsercache->check_rules_cache()) {
             try {
                 $w3_plugin_browsercache->write_rules_cache();
             } catch (Exception $e) {
                 $this->_rule_errors_root[] = sprintf('To enable Browser caching, add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the site %s ' . '<textarea class="w3tc-rules" cols="120" rows="10" readonly="readonly">%s' . '</textarea>.', w3_get_browsercache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_browsercache->generate_rules_cache()));
                 if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                     $this->_ftp_form = $e->ftp_form();
                 } elseif ($e instanceof FileOperationException) {
                     $file_operation_exception = true;
                 }
             }
         }
         if ($this->_config->get_boolean('notes.browsercache_rules_no404wp') && $this->_config->get_boolean('browsercache.no404wp') && !$w3_plugin_browsercache->check_rules_no404wp()) {
             try {
                 $w3_plugin_browsercache->write_rules_no404wp();
             } catch (Exception $e) {
                 $ftp_message = '';
                 if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                     $this->_ftp_form = $e->ftp_form();
                     $ftp_message = ' Or try using the <a href="#ftp_upload_form">FTP form</a> below.';
                 } elseif ($e instanceof FileOperationException) {
                     $file_operation_exception = true;
                 }
                 $this->_errors[] = sprintf('"Do not process 404 errors for static objects with WordPress" feature
                                         is not active. To enable it, add the following rules into the server
                                         configuration file (<strong>%s</strong>) of the site %s
                                         <textarea class="w3tc-rules" cols="120" rows="10" readonly="readonly">%s</textarea>.
                                         <br />%s %s', w3_get_browsercache_rules_no404wp_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_browsercache->generate_rules_no404wp()), $ftp_message, $this->button_hide_note('Hide this message', 'browsercache_rules_no404wp'));
             }
         }
         $remove_results[] = $w3_plugin_browsercache->remove_rules_no404wp_with_message(true, $this->button_hide_note('Hide this message', 'browsercache_rules_no404wp'));
     } elseif (!$this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $w3_plugin_browsercache = w3_instance('W3_Plugin_BrowserCacheAdmin');
         $remove_results[] = $w3_plugin_browsercache->remove_rules_cache_with_message();
         $remove_results[] = $w3_plugin_browsercache->remove_rules_no404wp_with_message(false, $this->button_hide_note('Hide this message', 'browsercache_rules_no404wp'));
     }
     /**
      * Check for database cache availability
      */
     if ($this->_config->get_boolean('dbcache.enabled')) {
         if (!$this->_disable_add_in_files_notification && !$w3_verify->db_check()) {
             $this->_errors[] = sprintf('Database caching is not available. The current add-in %s is either missing, an incorrect file or an old version. De-activate the plugin, remove the file, then activate the plugin again.', W3TC_ADDIN_FILE_DB);
         }
     }
     /**
      * Check for object cache availability
      */
     if ($this->_config->get_boolean('objectcache.enabled')) {
         if (!$this->_disable_add_in_files_notification && !$w3_verify->objectcache_check()) {
             $this->_errors[] = sprintf('Object caching is not available. The current add-in %s is either missing, an incorrect file or an old version. De-activate the plugin, remove the file, then activate the plugin again.', W3TC_ADDIN_FILE_OBJECT_CACHE);
         }
     }
     /**
      * Check memcached
      */
     $memcaches_errors = array();
     if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'memcached') {
         $pgcache_memcached_servers = $this->_config->get_array('pgcache.memcached.servers');
         if (!$this->is_memcache_available($pgcache_memcached_servers)) {
             $memcaches_errors[] = sprintf('Page Cache: %s.', implode(', ', $pgcache_memcached_servers));
         }
     }
     if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_string('minify.engine') == 'memcached') {
         $minify_memcached_servers = $this->_config->get_array('minify.memcached.servers');
         if (!$this->is_memcache_available($minify_memcached_servers)) {
             $memcaches_errors[] = sprintf('Minify: %s.', implode(', ', $minify_memcached_servers));
         }
     }
     if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_string('dbcache.engine') == 'memcached') {
         $dbcache_memcached_servers = $this->_config->get_array('dbcache.memcached.servers');
         if (!$this->is_memcache_available($dbcache_memcached_servers)) {
             $memcaches_errors[] = sprintf('Database Cache: %s.', implode(', ', $dbcache_memcached_servers));
         }
     }
     if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get_string('objectcache.engine') == 'memcached') {
         $objectcache_memcached_servers = $this->_config->get_array('objectcache.memcached.servers');
         if (!$this->is_memcache_available($objectcache_memcached_servers)) {
             $memcaches_errors[] = sprintf('Object Cache: %s.', implode(', ', $objectcache_memcached_servers));
         }
     }
     if (count($memcaches_errors)) {
         $memcache_error = 'The following memcached servers are not responding or not running:</p><ul>';
         foreach ($memcaches_errors as $memcaches_error) {
             $memcache_error .= '<li>' . $memcaches_error . '</li>';
         }
         $memcache_error .= '</ul><p>This message will automatically disappear once the issue is resolved.';
         $this->_errors[] = $memcache_error;
     }
     /**
      * Check PHP version
      */
     if (!W3TC_PHP5 && $this->_config->get_boolean('notes.php_is_old')) {
         $this->_notes[] = sprintf('Unfortunately, <strong>PHP5</strong> is required for full functionality of this plugin; incompatible features are automatically disabled. Please upgrade if possible. %s', $this->button_hide_note('Hide this message', 'php_is_old'));
     }
     /**
      * Check CURL extension
      */
     if ($this->_config->get_boolean('notes.no_curl') && $this->_config->get_boolean('cdn.enabled') && !function_exists('curl_init')) {
         $this->_notes[] = sprintf('The <strong>CURL PHP</strong> extension is not available. Please install it to enable S3 or CloudFront functionality. %s', $this->button_hide_note('Hide this message', 'no_curl'));
     }
     /**
      * Check Zlib extension
      */
     if ($this->_config->get_boolean('notes.no_zlib') && !function_exists('gzencode')) {
         $this->_notes[] = sprintf('Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Notify the server administrator. %s', $this->button_hide_note('Hide this message', 'no_zlib'));
     }
     /**
      * Check if Zlib output compression is enabled
      */
     if ($this->_config->get_boolean('notes.zlib_output_compression') && w3_zlib_output_compression()) {
         $this->_notes[] = sprintf('Either the PHP configuration, web server configuration or a script in the WordPress installation has <strong>zlib.output_compression</strong> enabled.<br />Please locate and disable this setting to ensure proper HTTP compression behavior. %s', $this->button_hide_note('Hide this message', 'zlib_output_compression'));
     }
     /**
      * Check wp-content permissions
      */
     if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_perms')) {
         $wp_content_mode = w3_get_file_permissions(WP_CONTENT_DIR);
         if ($wp_content_mode > 0755) {
             $this->_notes[] = sprintf('<strong>%s</strong> is write-able. When finished installing the plugin,
                                     change the permissions back to the default: <strong>chmod 755 %s</strong>.
                                     Permissions are currently %s. %s', WP_CONTENT_DIR, WP_CONTENT_DIR, base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8), $this->button_hide_note('Hide this message', 'wp_content_perms'));
         }
     }
     /**
      * Check wp-content permissions
      */
     if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_changed_perms')) {
         $perm = get_transient('w3tc_prev_permission');
         $current_perm = w3_get_file_permissions(WP_CONTENT_DIR);
         if ($perm && $perm != base_convert($current_perm, 10, 8) && ($current_perm > 0755 || $perm < base_convert($current_perm, 10, 8))) {
             $this->_notes[] = sprintf('<strong>%s</strong> permissions were changed during the setup process.
                                     Permissions are currently %s.<br />To restore permissions run
                                     <strong>chmod %s %s</strong>. %s', WP_CONTENT_DIR, base_convert($current_perm, 10, 8), $perm, WP_CONTENT_DIR, $this->button_hide_note('Hide this message', 'wp_content_changed_perms'));
         }
     }
     /**
      * Check permalinks
      */
     if ($this->_config->get_boolean('notes.no_permalink_rules') && ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'file_generic' || $this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.no404wp')) && !w3_is_permalink_rules()) {
         $this->_errors[] = sprintf('The required directives for fancy permalinks could not be detected, please confirm they are available: <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">Creating and editing</a> %s', $this->button_hide_note('Hide this message', 'no_permalink_rules'));
     }
     /**
      * CDN
      */
     if ($this->_config->get_boolean('cdn.enabled')) {
         /**
          * Check upload settings
          */
         $upload_info = w3_upload_info();
         if (!$upload_info) {
             $upload_path = get_option('upload_path');
             $upload_path = trim($upload_path);
             if (empty($upload_path)) {
                 $upload_path = WP_CONTENT_DIR . '/uploads';
                 $this->_errors[] = sprintf('The uploads directory is not available. Default WordPress directories will be created: <strong>%s</strong>.', $upload_path);
             }
             if (!w3_is_multisite()) {
                 $this->_errors[] = sprintf('The uploads path found in the database (%s) is inconsistent with the actual path. Please manually adjust the upload path either in miscellaneous settings or if not using a custom path %s automatically to resolve the issue.', $upload_path, $this->button_link('update the path', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_update_upload_path', $this->_page), 'w3tc')));
             }
         }
         /**
          * Check CDN settings
          */
         $cdn_engine = $this->_config->get_string('cdn.engine');
         $error = '';
         switch (true) {
             case $cdn_engine == 'ftp' && !count($this->_config->get_array('cdn.ftp.domain')):
                 $this->_errors[] = 'A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: ' . 'The <strong>"Replace default hostname with"</strong> ' . 'field cannot be empty. Enter <acronym ' . 'title="Content Delivery Network">CDN</acronym> ' . 'provider hostname <a href="?page=w3tc_cdn#configuration">here</a>. ' . '<em>(This is the hostname used in order to view objects ' . 'in a browser.)</em>';
                 break;
             case $cdn_engine == 's3' && ($this->_config->get_string('cdn.s3.key') == '' || $this->_config->get_string('cdn.s3.secret') == '' || $this->_config->get_string('cdn.s3.bucket') == ''):
                 $error = 'The <strong>"Access key", "Secret key" and "Bucket"</strong> fields cannot be empty.';
                 break;
             case $cdn_engine == 'cf' && ($this->_config->get_string('cdn.cf.key') == '' || $this->_config->get_string('cdn.cf.secret') == '' || $this->_config->get_string('cdn.cf.bucket') == '' || $this->_config->get_string('cdn.cf.id') == '' && !count($this->_config->get_array('cdn.cf.cname'))):
                 $error = 'The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields cannot be empty.';
                 break;
             case $cdn_engine == 'cf2' && ($this->_config->get_string('cdn.cf2.key') == '' || $this->_config->get_string('cdn.cf2.secret') == '' || $this->_config->get_string('cdn.cf2.id') == '' && !count($this->_config->get_array('cdn.cf2.cname'))):
                 $error = 'The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields cannot be empty.';
                 break;
             case $cdn_engine == 'rscf' && ($this->_config->get_string('cdn.rscf.user') == '' || $this->_config->get_string('cdn.rscf.key') == '' || $this->_config->get_string('cdn.rscf.container') == '' || !count($this->_config->get_array('cdn.rscf.cname'))):
                 $error = 'The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields cannot be empty.';
                 break;
             case $cdn_engine == 'azure' && ($this->_config->get_string('cdn.azure.user') == '' || $this->_config->get_string('cdn.azure.key') == '' || $this->_config->get_string('cdn.azure.container') == ''):
                 $error = 'The <strong>"Account name", "Account key" and "Container"</strong> fields cannot be empty.';
                 break;
             case $cdn_engine == 'mirror' && !count($this->_config->get_array('cdn.mirror.domain')):
                 $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
                 break;
             case $cdn_engine == 'netdna' && !count($this->_config->get_array('cdn.netdna.domain')):
                 $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
                 break;
             case $cdn_engine == 'cotendo' && !count($this->_config->get_array('cdn.cotendo.domain')):
                 $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
                 break;
             case $cdn_engine == 'edgecast' && !count($this->_config->get_array('cdn.edgecast.domain')):
                 $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
                 break;
             case $cdn_engine == 'att' && !count($this->_config->get_array('cdn.att.domain')):
                 $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
                 break;
         }
         if ($error) {
             $this->_errors[] = 'A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: ' . $error . ' <a href="?page=w3tc_cdn#configuration">Specify it here</a>.';
         }
     }
     if (($this->_config->get_boolean('cdn.enabled') || $this->_config->get_boolean('cloudflare.enabled')) && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $service = $this->_config->get_boolean('cdn.enabled') ? 'CDN' : 'CloudFlare';
         $w3_plugin_cdnadmin = w3_instance('W3_Plugin_CdnAdmin');
         if (!$w3_plugin_cdnadmin->check_rules()) {
             try {
                 $w3_plugin_cdnadmin->write_rules();
             } catch (Exception $e) {
                 $this->_rule_errors_root[] = sprintf($service . ' requires some rules to function properly, add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the site %s ' . '<textarea class="w3tc-rules" cols="120" rows="10" readonly="readonly">%s' . '</textarea>.', w3_get_browsercache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_cdnadmin->generate_rules()));
                 if (!isset($this->_ftp_form) && $e instanceof FilesystemCredentialException) {
                     $this->_ftp_form = $e->ftp_form();
                 } elseif ($e instanceof FileOperationException) {
                     $file_operation_exception = true;
                 }
             }
         }
     } elseif (!$this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cloudflare.enabled') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         $w3_plugin_cdnadmin = w3_instance('W3_Plugin_CdnAdmin');
         $remove_results[] = $w3_plugin_cdnadmin->remove_rules_with_message();
     }
     /**
      * Preview mode
      */
     if ($this->_config->is_preview()) {
         $this->_notes[] = sprintf('Preview mode is active: Changed settings will not take effect until preview mode is %s or %s. %s any changed settings (without deploying), or make additional changes.', $this->button_link('deploy', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_preview_deploy', $this->_page), 'w3tc')), $this->button_link('disable', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_preview_disable', $this->_page), 'w3tc')), $this->button_link('Preview', w3_get_home_url() . '/?w3tc_preview=1', true));
     }
     /**
      * New Relic module
      */
     if ($this->_config->get_boolean('newrelic.enabled')) {
         /**
          * @var $w3_plugin_newrelic W3_Plugin_NewRelicAdmin
          */
         $w3_plugin_newrelic = w3_instance('W3_Plugin_NewRelicAdmin');
         if (w3_get_blog_id() == 0 && w3_is_apache()) {
             if (!$w3_plugin_newrelic->check_rules_has_core()) {
                 try {
                     $w3_plugin_newrelic->write_rules_core();
                 } catch (Exception $ex) {
                     $this->_rule_errors_root[] = sprintf(__('New Relic requires some rules to function properly, add the following rules ' . 'into the server configuration file (<strong>%s</strong>) of the site %s ', 'w3-total-cache') . '<textarea class="w3tc-rules" cols="120" rows="10" readonly="readonly">%s' . '</textarea>.', w3_get_new_relic_rules_core_path(), $this->button(__('view code', 'w3-total-cache'), '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_newrelic->generate_rules_core()));
                     if (!isset($this->_ftp_form) && $ex instanceof FilesystemCredentialException) {
                         $this->_ftp_form = $ex->ftp_form();
                     } elseif ($ex instanceof FileOperationException) {
                         $file_operation_exception = true;
                     }
                 }
             }
         }
     }
     /**
      *
      */
     if ($this->_config->get_boolean('notes.root_rules') && count($this->_rule_errors_root) > 0) {
         $this->_rule_errors_root_hide = $this->button_hide_note('Hide this message', 'root_rules');
     } else {
         $this->_rule_errors_root = array();
     }
     $this->_disable_file_operation_notification = $this->_disable_add_in_files_notification || $this->_disable_cache_write_notification;
     if (!$this->_disable_file_operation_notification && isset($file_operation_exception) && $file_operation_exception) {
         $tech_message = '<ul>';
         $core_rules_perms = '';
         if (w3_get_file_permissions(w3_get_wp_config_path()) != 0644) {
             $core_config_perms = sprintf('File permissions are <strong>%s</strong>, however they should be
                                     <strong>644</strong>.', base_convert(w3_get_file_permissions(w3_get_wp_config_path()), 10, 8));
         } else {
             $core_config_perms = sprintf('File permissions are <strong>%s</strong>', base_convert(w3_get_file_permissions(w3_get_wp_config_path()), 10, 8));
         }
         if (w3_get_file_permissions(w3_get_pgcache_rules_core_path()) != 0644) {
             $core_rules_perms = sprintf('File permissions are <strong>%s</strong>, however they should be
                                         <strong>644</strong>.', base_convert(w3_get_file_permissions(w3_get_pgcache_rules_core_path()), 10, 8));
         } else {
             $core_rules_perms = sprintf('File permissions are <strong>%s</strong>', base_convert(w3_get_file_permissions(w3_get_pgcache_rules_core_path()), 10, 8));
         }
         $wp_content_perms = '';
         if (w3_get_file_permissions(WP_CONTENT_DIR) != 0755) {
             $wp_content_perms = sprintf('Directory permissions are <strong>%s</strong>, however they should be
                                         <strong>755</strong>.', base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8));
         }
         $tech_message .= '<li>' . sprintf('File: <strong>%s</strong> %s File owner: %s', w3_get_wp_config_path(), $core_config_perms, w3_get_file_owner(w3_get_wp_config_path())) . '</li>';
         $tech_message .= '<li>' . sprintf('File: <strong>%s</strong> %s File owner: %s', w3_get_pgcache_rules_core_path(), $core_rules_perms, w3_get_file_owner(w3_get_pgcache_rules_core_path())) . '</li>';
         $tech_message .= '<li>' . sprintf('Directory: <strong>%s</strong> %s File owner: %s', WP_CONTENT_DIR, $wp_content_perms, w3_get_file_owner(WP_CONTENT_DIR)) . '</li>';
         $tech_message .= '<li>' . sprintf('Owner of current file: %s', w3_get_file_owner()) . '</li>';
         if (!(w3_get_file_owner() == w3_get_file_owner(w3_get_pgcache_rules_core_path()) && w3_get_file_owner() == w3_get_file_owner(WP_CONTENT_DIR))) {
             $tech_message .= '<li>The files and directories have different ownership, they should have the same ownership.
                               </li>';
         }
         $tech_message .= '</ul>';
         $tech_message = '<div class="w3tc-technical-info" style="display:none">' . $tech_message . '</div>';
         $w3tc_error[] = sprintf('<strong>W3 Total Cache Error:</strong> The plugin tried to edit, %s, but failed.
                             Files and directories cannot be modified. Please review your
                             <a target="_blank" href="http://codex.wordpress.org/Changing_File_Permissions">
                             file permissions</a>. A common cause is %s and %s having different ownership or permissions.
                              %s %s', $wp_config_edit ? w3_get_wp_config_path() : w3_get_pgcache_rules_core_path(), $wp_config_edit ? basename(w3_get_wp_config_path()) : basename(w3_get_pgcache_rules_core_path()), WP_CONTENT_DIR, $this->button('View technical information', '', 'w3tc-show-technical-info'), $tech_message);
     }
     /**
      * Remove functions results
      */
     if ($remove_results) {
         foreach ($remove_results as $result) {
             $this->_errors = array_merge($this->_errors, $result['errors']);
             if (!isset($this->_ftp_form) && isset($result['ftp_form'])) {
                 $extra_ftp_message = 'Please enter FTP details <a href="#ftp_upload_form">below</a> to remove the disabled modules. ';
                 $this->_ftp_form = $result['ftp_form'];
                 $this->_use_ftp_form = true;
             }
         }
         if (isset($extra_ftp_message)) {
             $this->_errors[] = $extra_ftp_message;
         }
     }
     foreach ($w3tc_error as $error) {
         array_unshift($this->_errors, $error);
     }
     if (isset($this->_ftp_form)) {
         $this->_use_ftp_form = true;
     }
     /**
      * Prepare rule errors auto-install link
      */
     if ($this->_config->get_boolean('notes.rules') && count($this->_rule_errors) > 0) {
         $autoinstall_commands = '';
         foreach ($this->_rule_errors as $error) {
             $autoinstall_commands .= ',' . $error[1];
         }
         $this->_rule_errors_autoinstall = $this->button_link('auto-install', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_rules_autoinstall&autoinstall=%s', $this->_page, $autoinstall_commands), 'w3tc'));
         $this->_rule_errors_hide = $this->button_hide_note('Hide this message', 'rules');
     }
     /*
      * Hidden pages
      */
     if (isset($_REQUEST['w3tc_dbcluster_config'])) {
         $this->dbcluster_config();
     }
     /**
      * Show tab
      */
     switch ($this->_page) {
         case 'w3tc_dashboard':
             $this->options_dashboard();
             break;
         case 'w3tc_general':
             $this->options_general();
             break;
         case 'w3tc_pgcache':
             $this->options_pgcache();
             break;
         case 'w3tc_minify':
             $this->options_minify();
             break;
         case 'w3tc_dbcache':
             $this->options_dbcache();
             break;
         case 'w3tc_objectcache':
             $this->options_objectcache();
             break;
         case 'w3tc_fragmentcache':
             $this->options_fragmentcache();
             break;
         case 'w3tc_browsercache':
             $this->options_browsercache();
             break;
         case 'w3tc_mobile':
             $this->options_mobile();
             break;
         case 'w3tc_referrer':
             $this->options_referrer();
             break;
         case 'w3tc_cdn':
             $this->options_cdn();
             break;
         case 'w3tc_monitoring':
             $this->options_monitoring();
             break;
         case 'w3tc_faq':
             $this->options_faq();
             break;
         case 'w3tc_support':
             $this->options_support();
             break;
         case 'w3tc_install':
             $this->options_install();
             break;
         case 'w3tc_about':
             $this->options_about();
             break;
     }
 }