/**
  * Removes Page Cache cache directives
  *
  * @param Util_Environment_Exceptions $exs
  * @throws Util_WpFile_FilesystemOperationException with S/FTP form if it can't get the required filesystem credentials
  */
 private function rules_cache_remove($exs)
 {
     // apache's cache files are not used when core rules disabled
     if (!Util_Environment::is_nginx()) {
         return;
     }
     Util_Rule::remove_rules($exs, Util_Rule::get_pgcache_rules_cache_path(), W3TC_MARKER_BEGIN_PGCACHE_CACHE, W3TC_MARKER_END_PGCACHE_CACHE);
 }
 /**
  * Returns true if we can modify rules
  *
  * @param string  $path
  * @return boolean
  */
 public static function can_modify_rules($path)
 {
     if (Util_Environment::is_wpmu()) {
         if (Util_Environment::is_apache() || Util_Environment::is_litespeed() || Util_Environment::is_nginx()) {
             switch ($path) {
                 case Util_Rule::get_pgcache_rules_cache_path():
                 case Util_Rule::get_minify_rules_core_path():
                 case Util_Rule::get_minify_rules_cache_path():
                     return true;
             }
         }
         return false;
     }
     return true;
 }
 /**
  * Send support request action
  *
  * @return void
  */
 function w3tc_support_send_details()
 {
     $c = Dispatcher::config();
     $post = array();
     foreach ($_GET as $p => $v) {
         $post[$p] = $v;
     }
     $post['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $post['version'] = W3TC_VERSION;
     $license_level = 'community';
     if (Util_Environment::is_w3tc_pro($c)) {
         $license_level = 'pro';
     } elseif (Util_Environment::is_w3tc_enterprise($c)) {
         $license_level = 'enterprise';
     }
     $post['license_level'] = $license_level . ' ' . $c->get_string('plugin.license_key');
     /**
      * Add attachments
      */
     $attachments = array();
     $attach_files = array(Util_Environment::wp_config_path(), Util_Rule::get_pgcache_rules_core_path(), Util_Rule::get_pgcache_rules_cache_path(), Util_Rule::get_browsercache_rules_cache_path(), Util_Rule::get_browsercache_rules_no404wp_path(), Util_Rule::get_minify_rules_core_path(), Util_Rule::get_minify_rules_cache_path());
     /**
      * Attach config files
      */
     if ($handle = opendir(W3TC_CONFIG_DIR)) {
         while (($entry = @readdir($handle)) !== false) {
             if ($entry == '.' || $entry == '..' || $entry == 'index.html') {
                 continue;
             }
             $attach_file[] = W3TC_CONFIG_DIR . '/' . $entry;
         }
         closedir($handle);
     }
     foreach ($attach_files as $attach_file) {
         if ($attach_file && file_exists($attach_file) && !in_array($attach_file, $attachments)) {
             $attachments[] = array('filename' => basename($attach_file), 'content' => file_get_contents($attach_file));
         }
     }
     /**
      * Attach server info
      */
     $server_info = print_r($this->get_server_info(), true);
     $server_info = str_replace("\n", "\r\n", $server_info);
     $attachments[] = array('filename' => 'server_info.txt', 'content' => $server_info);
     /**
      * Attach phpinfo
      */
     ob_start();
     phpinfo();
     $php_info = ob_get_contents();
     ob_end_clean();
     $attachments[] = array('filename' => 'php_info.html', 'content' => $php_info);
     /**
      * Attach self-test
      */
     ob_start();
     $this->self_test();
     $self_test = ob_get_contents();
     ob_end_clean();
     $attachments[] = array('filename' => 'self_test.html', 'content' => $self_test);
     $post['attachments'] = $attachments;
     $response = wp_remote_post(W3TC_SUPPORT_REQUEST_URL, array('body' => $post, 'timeout' => $c->get_integer('timelimit.email_send')));
     if (!is_wp_error($response)) {
         $result = $response['response']['code'] == 200 && $response['body'] == 'ok';
     } else {
         $result = false;
     }
     echo $result ? 'ok' : 'error';
 }
 /**
  * Checks if rules file present and creates it if not
  */
 function _check_rules_present()
 {
     if (Util_Environment::is_nginx()) {
         return;
     }
     // nginx store it in a single file
     $filename = Util_Rule::get_pgcache_rules_cache_path();
     if (file_exists($filename)) {
         return;
     }
     // we call it as little times as possible
     // its expensive, but have to restore lost .htaccess file
     $e = Dispatcher::component('PgCache_Environment');
     try {
         $e->fix_on_wpadmin_request($this->_config, true);
     } catch (\Exception $ex) {
     }
 }