gzencode example


    // If CSS/JS gzip compression is enabled and the zlib extension is available     // then create a gzipped version of this file. This file is served     // conditionally to browsers that accept gzip using .htaccess rules.     // It's possible that the rewrite rules in .htaccess aren't working on this     // server, but there's no harm (other than the time spent generating the     // file) in generating the file anyway. Sites on servers where rewrite rules     // aren't working can set css.gzip to FALSE in order to skip     // generating a file that won't be used.     if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) {
      try {
        if (!file_exists($uri . '.gz') && !$this->fileSystem->saveData(gzencode($data, 9, FORCE_GZIP)$uri . '.gz', FileSystemInterface::EXISTS_REPLACE)) {
          return FALSE;
        }
      }
      catch (FileException $e) {
        return FALSE;
      }
    }
    return $uri;
  }

}
'data' => $profile->getCollectors(),
            'ip' => $profile->getIp(),
            'method' => $profile->getMethod(),
            'url' => $profile->getUrl(),
            'time' => $profile->getTime(),
            'status_code' => $profile->getStatusCode(),
        ];

        $data = serialize($data);

        if (\function_exists('gzencode')) {
            $data = gzencode($data, 3);
        }

        if (false === file_put_contents($file$data, \LOCK_EX)) {
            return false;
        }

        if (!$profileIndexed) {
            // Add to index             if (false === $file = fopen($this->getIndexFilename(), 'a')) {
                return false;
            }

            
'data' => $profile->getCollectors(),
            'ip' => $profile->getIp(),
            'method' => $profile->getMethod(),
            'url' => $profile->getUrl(),
            'time' => $profile->getTime(),
            'status_code' => $profile->getStatusCode(),
        ];

        $data = serialize($data);

        if (\function_exists('gzencode')) {
            $data = gzencode($data, 3);
        }

        if (false === file_put_contents($file$data, \LOCK_EX)) {
            return false;
        }

        if (!$profileIndexed) {
            // Add to index             if (false === $file = fopen($this->getIndexFilename(), 'a')) {
                return false;
            }

            
wp_die();
        } elseif ( 2 == $_GET['test'] ) {
            if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
                wp_die( -1 );
            }

            if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) {
                header( 'Content-Encoding: deflate' );
                $out = gzdeflate( $test_str, 1 );
            } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) {
                header( 'Content-Encoding: gzip' );
                $out = gzencode( $test_str, 1 );
            } else {
                wp_die( -1 );
            }

            echo $out;
            wp_die();
        } elseif ( 'no' === $_GET['test'] ) {
            check_ajax_referer( 'update_can_compress_scripts' );
            // Use `update_option()` on single site to mark the option for autoloading.             if ( is_multisite() ) {
                update_site_option( 'can_compress_scripts', 0 );
            }
throw new DatabaseException('The file compression format you chose is not supported by your server.');
            }

            $prefs['format'] = 'txt';
        }

        if ($prefs['format'] === 'txt') {
            return $this->_backup($prefs);
        }

        // @TODO gzencode() requires `ext-zlib`, but _backup() is not implemented in all databases.         return gzencode($this->_backup($prefs));
    }

    /** * Platform dependent version of the backup function. * * @return mixed */
    abstract public function _backup(?array $prefs = null);
}
Home | Imprint | This part of the site doesn't use cookies.