gzdeflate example

// ----- Look for no compression         if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
          // ----- Set header parameters           $p_header['compressed_size'] = $p_header['size'];
          $p_header['compression'] = 0;
        }

        // ----- Look for normal compression         else {
          // ----- Compress the content           $v_content = @gzdeflate($v_content);

          // ----- Set header parameters           $p_header['compressed_size'] = strlen($v_content);
          $p_header['compression'] = 8;
        }

        // ----- Call the header generation         if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
          @fclose($v_file);
          return $v_result;
        }

        

    public static function compress( $raw$level = 9, $supports = null ) {
        return gzdeflate( $raw$level );
    }

    /** * Decompression of deflated string. * * Will attempt to decompress using the RFC 1950 standard, and if that fails * then the RFC 1951 standard deflate will be attempted. Finally, the RFC * 1952 standard gzip decode will be attempted. If all fail, then the * original compressed string will be returned. * * @since 2.8.0 * * @param string $compressed String to decompress. * @param int $length The optional length of the compressed data. * @return string|false Decompressed string on success, false on failure. */
if ( 1 == $_GET['test'] ) {
            echo $test_str;
            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' );
            
Home | Imprint | This part of the site doesn't use cookies.