Exemplo n.º 1
0
 /**
  * Options page
  *
  * @return void
  */
 function options()
 {
     /**
      * Check for page cache availability
      */
     if ($this->_config->get_boolean('pgcache.enabled')) {
         if (!$this->advanced_cache_installed()) {
             $this->_errors[] = sprintf('Page caching is not available: %s is not installed. Either the <strong>%s</strong> directory is not write-able or another caching plugin installed. This error message will automatically disappear once the change is successfully made.', W3TC_ADDIN_FILE_ADVANCED_CACHE, WP_CONTENT_DIR);
         } elseif (!$this->advanced_cache_check()) {
             $this->_errors[] = sprintf('Page caching is not available. The current add-in %s is either 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 (!defined('WP_CACHE') || !WP_CACHE) {
             $this->_errors[] = sprintf('Page caching is not available: please add: <strong>define(\'WP_CACHE\', true);</strong> to <strong>%swp-config.php</strong>. This error message will automatically disappear once the change is successfully made.', ABSPATH);
         } elseif ($this->_config->get_string('pgcache.engine') == 'file_generic' && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/PgCache.php';
             $w3_plugin_pgcache =& W3_Plugin_PgCache::instance();
             if ($w3_plugin_pgcache->check_rules_core()) {
                 if (!$this->test_rewrite_pgcache()) {
                     $this->_errors[] = '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.';
                 }
             } elseif ($this->_config->get_boolean('notes.pgcache_rules_core')) {
                 $this->_errors[] = sprintf('Disk enhanced page caching is not active. To enable it, add the following rules into the server configuration file (<strong>%s</strong>) of the site above the WordPress directives %s <textarea class="w3tc-rules" cols="120" rows="10" readonly="readonly">%s</textarea>. Or if permission allow this can be done automatically, by clicking here: %s. %s', w3_get_pgcache_rules_core_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_pgcache->generate_rules_core()), $this->button_link('auto-install', sprintf('admin.php?page=%s&pgcache_write_rules_core', $this->_page)), $this->button_hide_note('Hide this message', 'pgcache_rules_core'));
             }
             if ($this->_config->get_boolean('notes.pgcache_rules_legacy') && $w3_plugin_pgcache->check_rules_legacy()) {
                 $this->_errors[] = sprintf('Legacy Page 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_LEGACY, W3TC_MARKER_END_PGCACHE_LEGACY, $this->button_link('auto-remove', sprintf('admin.php?page=%s&pgcache_remove_rules_legacy', $this->_page)), $this->button_hide_note('Hide this message', 'pgcache_rules_legacy'));
             }
             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', sprintf('admin.php?page=%s&pgcache_remove_rules_wpsc', $this->_page)), $this->button_hide_note('Hide this message', 'pgcache_rules_wpsc'));
             }
             if ($this->_config->get_boolean('notes.pgcache_rules_cache') && !$w3_plugin_pgcache->check_rules_cache()) {
                 $this->_errors[] = sprintf('Disk enhanced page caching 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>. This can be done automatically, by clicking here: %s. %s', w3_get_pgcache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_pgcache->generate_rules_cache()), $this->button_link('auto-install', sprintf('admin.php?page=%s&pgcache_write_rules_cache', $this->_page)), $this->button_hide_note('Hide this message', 'pgcache_rules_cache'));
             }
         }
     }
     /**
      * Check for browser cache availability
      */
     if ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
         require_once W3TC_LIB_W3_DIR . '/Plugin/BrowserCache.php';
         $w3_plugin_browsercache =& W3_Plugin_BrowserCache::instance();
         if ($this->_config->get_boolean('notes.browsercache_rules_cache') && !$w3_plugin_browsercache->check_rules_cache()) {
             $this->_errors[] = sprintf('Browser caching 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>. Or if permission allow this can be done automatically, by clicking here: %s. %s', w3_get_browsercache_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_browsercache->generate_rules_cache()), $this->button_link('auto-install', sprintf('admin.php?page=%s&browsercache_write_rules_cache', $this->_page)), $this->button_hide_note('Hide this message', 'browsercache_rules_cache'));
         }
         if ($this->_config->get_boolean('notes.browsercache_rules_no404wp') && $this->_config->get_boolean('browsercache.no404wp') && !$w3_plugin_browsercache->check_rules_no404wp()) {
             $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>. Or if permission allow this can be done automatically, by clicking here: %s. %s', w3_get_browsercache_rules_no404wp_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_browsercache->generate_rules_no404wp()), $this->button_link('auto-install', sprintf('admin.php?page=%s&browsercache_write_rules_no404wp', $this->_page)), $this->button_hide_note('Hide this message', 'browsercache_rules_no404wp'));
         }
     }
     /**
      * Check for minify availability
      */
     if ($this->_config->get_boolean('minify.enabled')) {
         if ($this->_config->get_boolean('minify.rewrite') && $this->_config->get_boolean('config.check') && w3_can_check_rules()) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
             $w3_plugin_minify =& W3_Plugin_Minify::instance();
             if ($w3_plugin_minify->check_rules_core()) {
                 if (!$this->test_rewrite_minify()) {
                     $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 configuration.';
                 }
             } elseif ($this->_config->get_boolean('notes.minify_rules_core')) {
                 $this->_errors[] = sprintf('Minify 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>. This can be done automatically, by clicking here: %s. %s', w3_get_minify_rules_core_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_minify->generate_rules_core()), $this->button_link('auto-install', sprintf('admin.php?page=%s&minify_write_rules_core', $this->_page)), $this->button_hide_note('Hide this message', 'minify_rules_core'));
             }
             if ($this->_config->get_boolean('notes.minify_rules_legacy') && $w3_plugin_minify->check_rules_legacy()) {
                 $this->_errors[] = sprintf('Legacy Minify 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_minify_rules_core_path(), W3TC_MARKER_BEGIN_MINIFY_LEGACY, W3TC_MARKER_END_MINIFY_LEGACY, $this->button_link('auto-remove', sprintf('admin.php?page=%s&minify_remove_rules_legacy', $this->_page)), $this->button_hide_note('Hide this message', 'minify_rules_legacy'));
             }
             if ($this->_config->get_string('minify.engine') == 'file' && $this->_config->get_boolean('notes.minify_rules_cache') && !$w3_plugin_minify->check_rules_cache()) {
                 $this->_errors[] = sprintf('Minify 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>. This can be done automatically, by clicking here: %s. %s', w3_get_minify_rules_cache_path(), $this->button('view code', '', 'w3tc-show-rules'), htmlspecialchars($w3_plugin_minify->generate_rules_cache()), $this->button_link('auto-install', sprintf('admin.php?page=%s&minify_write_rules_cache', $this->_page)), $this->button_hide_note('Hide this message', 'minify_rules_cache'));
             }
         }
         /**
          * 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 database cache availability
      */
     if ($this->_config->get_boolean('dbcache.enabled')) {
         if (!$this->db_installed()) {
             $this->_errors[] = sprintf('Database caching is not available: %s is not installed. Either the <strong>%s</strong> directory is not write-able or another caching plugin is installed. This error message will automatically disappear once the change is successfully made.', W3TC_ADDIN_FILE_DB, WP_CONTENT_DIR);
         } elseif (!$this->db_check()) {
             $this->_errors[] = sprintf('Database caching is not available. The current add-in %s is either 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->objectcache_installed()) {
             $this->_errors[] = sprintf('Object caching is not available: %s is not installed. Either the <strong>%s</strong> directory is not write-able or another caching plugin is installed. This error message will automatically disappear once the change is successfully made.', W3TC_ADDIN_FILE_OBJECT_CACHE, WP_CONTENT_DIR);
         } elseif (!$this->objectcache_check()) {
             $this->_errors[] = sprintf('Object caching is not available. The current add-in %s is either 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)) {
             $this->_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_stat = stat(WP_CONTENT_DIR);
         $wp_content_mode = $wp_content_stat['mode'] & 0777;
         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>. %s', WP_CONTENT_DIR, WP_CONTENT_DIR, $this->button_hide_note('Hide this message', 'wp_content_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', sprintf('admin.php?page=%s&update_upload_path', $this->_page)));
             }
         }
         /**
          * Check CDN settings
          */
         $cdn_engine = $this->_config->get_string('cdn.engine');
         switch (true) {
             case $cdn_engine == 'mirror' && !count($this->_config->get_array('cdn.mirror.domain')):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Replace default hostname with"</strong> field must be populated.';
                 break;
             case $cdn_engine == 'netdna' && !count($this->_config->get_array('cdn.netdna.domain')):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Replace default hostname with"</strong> field must be populated.';
                 break;
             case $cdn_engine == 'cotendo' && !count($this->_config->get_array('cdn.cotendo.domain')):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Replace default hostname with"</strong> field must be populated.';
                 break;
             case $cdn_engine == 'ftp' && !count($this->_config->get_array('cdn.ftp.domain')):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Replace default hostname with"</strong> field must be populated. Enter <acronym title="Content Delivery Network">CDN</acronym> provider hostname. <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') == ''):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Access key", "Secret key" and "Bucket"</strong> fields must be populated.';
                 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'))):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields must be populated.';
                 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'))):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields must be populated.';
                 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'))):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields must be populated.';
                 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') == ''):
                 $this->_errors[] = 'Content Delivery Network Error: The <strong>"Account name", "Account key" and "Container"</strong> fields must be populated.';
                 break;
         }
     }
     /**
      * Preview mode
      */
     if (w3_is_preview_config()) {
         $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', sprintf('admin.php?page=%s&preview_deploy', $this->_page)), $this->button_link('disable', sprintf('admin.php?page=%s&preview_save&preview=0', $this->_page)), $this->button_link('Preview', w3_get_home_url() . '/?w3tc_preview=1', true));
     }
     /**
      * Show tab
      */
     switch ($this->_page) {
         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_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_faq':
             $this->options_faq();
             break;
         case 'w3tc_support':
             require_once W3TC_LIB_W3_DIR . '/Request.php';
             $request_type = W3_Request::get_string('request_type');
             if (!$request_type || !isset($this->_request_types[$request_type])) {
                 $this->options_support_select();
             } else {
                 $payment = W3_Request::get_boolean('payment');
                 if (isset($this->_request_prices[$request_type]) && !$payment) {
                     $this->options_support_payment();
                 } else {
                     $this->options_support();
                 }
             }
             break;
         case 'w3tc_support_select':
             $this->options_support_select();
             break;
         case 'w3tc_support_payment':
             $this->options_support_payment();
             break;
         case 'w3tc_install':
             $this->options_install();
             break;
         case 'w3tc_about':
             $this->options_about();
             break;
     }
 }
Exemplo n.º 2
0
    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;
        }
        /**
         * Check for page cache availability
         */
        $wp_config_edit = false;
        /**
         * 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.', 'w3-total-cache'), 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.', 'w3-total-cache'), 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.', 'w3-total-cache'), 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.', 'w3-total-cache'), implode(', ', $objectcache_memcached_servers));
            }
        }
        if (count($memcaches_errors)) {
            $memcache_error = __('The following memcached servers are not responding or not running:</p><ul>', 'w3-total-cache');
            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.', 'w3-total-cache');
            $this->_errors[] = $memcache_error;
        }
        /**
         * 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', 'w3-total-cache'), w3_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', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'zlib_output_compression'));
        }
        /**
         * Check wp-content permissions
         */
        if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_perms')) {
            w3_require_once(W3TC_INC_DIR . '/functions/file.php');
            $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', 'w3-total-cache'), WP_CONTENT_DIR, WP_CONTENT_DIR, base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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', 'w3-total-cache'), WP_CONTENT_DIR, base_convert($current_perm, 10, 8), $perm, WP_CONTENT_DIR, w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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>.', 'w3-total-cache'), $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.', 'w3-total-cache'), $upload_path, w3_button_link(__('update the path', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_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>', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    break;
                case $cdn_engine == 'netdna':
                    $fields = array();
                    if ($this->_config->get_string('cdn.netdna.authorization_key') == '') {
                        $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
                    }
                    if (!count($this->_config->get_array('cdn.netdna.domain'))) {
                        $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
                    }
                    if ($fields) {
                        $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
                    }
                    if ($this->_config->get_string('cdn.netdna.authorization_key') != '' && sizeof(explode('+', $this->_config->get_string('cdn.netdna.authorization_key'))) != 3) {
                        $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
                    } elseif ($this->_config->get_integer('cdn.netdna.zone_id', 0) <= 0) {
                        $error .= __('You need to select / create a pull zone.', 'w3-total-cache');
                    }
                    break;
                case $cdn_engine == 'maxcdn':
                    $fields = array();
                    if ($this->_config->get_string('cdn.maxcdn.authorization_key') == '') {
                        $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
                    }
                    if (!count($this->_config->get_array('cdn.maxcdn.domain'))) {
                        $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
                    }
                    if ($fields) {
                        $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
                    }
                    if ($this->_config->get_string('cdn.maxcdn.authorization_key') != '' && sizeof(explode('+', $this->_config->get_string('cdn.maxcdn.authorization_key'))) != 3) {
                        $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
                    } elseif ($this->_config->get_integer('cdn.maxcdn.zone_id', 0) <= 0) {
                        $error .= __('You need to select / create a pull zone.', 'w3-total-cache');
                    }
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    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.', 'w3-total-cache');
                    break;
                case $cdn_engine == 'akamai' && !count($this->_config->get_array('cdn.akamai.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: ', 'w3-total-cache') . $error . __(' <a href="?page=w3tc_cdn#configuration">Specify it here</a>.', 'w3-total-cache');
            }
        }
        /**
         * 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.', 'w3-total-cache'), w3_button_link(__('deploy', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_preview_deploy', $this->_page), 'w3tc')), w3_button_link(__('disable', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_preview_disable', $this->_page), 'w3tc'))) . '<br /><span class="description">' . sprintf(__('To preview any changed settings (without deploying): %s', 'w3-total-cache'), w3tc_get_preview_link()) . '</span>';
        }
        /**
         *
         */
        if ($this->_config->get_boolean('notes.root_rules') && count($this->_rule_errors_root) > 0) {
            $this->_rule_errors_root_hide = w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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>.', 'w3-total-cache'), base_convert(w3_get_file_permissions(w3_get_wp_config_path()), 10, 8));
            } else {
                $core_config_perms = sprintf(__('File permissions are <strong>%s</strong>', 'w3-total-cache'), 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>.', 'w3-total-cache'), 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>', 'w3-total-cache'), 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>.', 'w3-total-cache'), base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8));
            }
            $tech_message .= '<li>' . sprintf(__('File: <strong>%s</strong> %s File owner: %s', 'w3-total-cache'), 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-total-cache'), 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', 'w3-total-cache'), WP_CONTENT_DIR, $wp_content_perms, w3_get_file_owner(WP_CONTENT_DIR)) . '</li>';
            $tech_message .= '<li>' . sprintf(__('Owner of current file: %s', 'w3-total-cache'), 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>', 'w3-total-cache');
            }
            $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', 'w3-total-cache'), $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, w3_button(__('View technical information', 'w3-total-cache'), '', '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. ', 'w3-total-cache');
                    $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;
        }
        $this->view();
    }
 /**
  * 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;
     }
 }