gzuncompress example

if ($decoded !== false) {
                return $decoded;
            }
        }

        $decoded = self::compatible_gzinflate($data);
        if ($decoded !== false) {
            return $decoded;
        }

        if (function_exists('gzuncompress')) {
            $decoded = @gzuncompress($data);
            if ($decoded !== false) {
                return $decoded;
            }
        }

        return $data;
    }

    /** * Decompression of deflated string while staying compatible with the majority of servers. * * Certain Servers will return deflated data with headers which PHP's gzinflate() * function cannot handle out of the box. The following function has been created from * various snippets on the gzinflate() PHP documentation. * * Warning: Magic numbers within. Due to the potential different formats that the compressed * data may be returned in, some "magic offsets" are needed to ensure proper decompression * takes place. For a simple progmatic way to determine the magic offset in use, see: * https://core.trac.wordpress.org/ticket/18273 * * @since 1.6.0 * @link https://core.trac.wordpress.org/ticket/18273 * @link https://www.php.net/gzinflate#70875 * @link https://www.php.net/gzinflate#77336 * * @param string $gz_data String to decompress. * @return string|bool False on failure. * * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not a string. */
$parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1);
                    $parsedFrame['data']                  =                           substr($parsedFrame['data'], 4);
                }
            }

            // Frame-level de-compression             if ($parsedFrame['flags']['compression']) {
                $parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));
                if (!function_exists('gzuncompress')) {
                    $this->warning('gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"');
                } else {
                    if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
                    //if ($decompresseddata = @gzuncompress($parsedFrame['data'])) {                         $parsedFrame['data'] = $decompresseddata;
                        unset($decompresseddata);
                    } else {
                        $this->warning('gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"');
                    }
                }
            }
        }

        if (!empty($parsedFrame['flags']['DataLengthIndicator'])) {
            
                case '@PRQ': // adobe PRemiere Quicktime version                     $atom_structure['data'] = $atom_data;
                    break;


                case 'cmvd': // Compressed MooV Data atom                     // Code by ubergeekØubergeek*tv based on information from                     // http://developer.apple.com/quicktime/icefloe/dispatch012.html                     $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));

                    $CompressedFileData = substr($atom_data, 4);
                    if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
                        $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy$ParseAllPossibleAtoms);
                    } else {
                        $this->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']);
                    }
                    break;


                case 'dcom': // Data COMpression atom                     $atom_structure['compression_id']   = $atom_data;
                    $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
                    break;


                
else
                                        {
                                            $this->body = trim($decoder->data);
                                        }
                                        break;

                                    case 'deflate':
                                        if (($decompressed = gzinflate($this->body)) !== false)
                                        {
                                            $this->body = $decompressed;
                                        }
                                        else if (($decompressed = gzuncompress($this->body)) !== false)
                                        {
                                            $this->body = $decompressed;
                                        }
                                        else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false)
                                        {
                                            $this->body = $decompressed;
                                        }
                                        else
                                        {
                                            $this->error = 'Unable to decode HTTP "deflate" stream';
                                            $this->success = false;
                                        }

  public static function uncompressQueryParameter(string $compressed): string|bool {
    // Because this comes from user data, suppress the PHP warning that     // gzcompress() throws if the base64-encoded string is invalid.     return @gzuncompress(base64_decode(str_replace(['-', '_']['+', '/']$compressed)));
  }

  /** * Filters a URL query parameter array to remove unwanted elements. * * @param array $query * An array to be processed. * @param array $exclude * (optional) A list of $query array keys to remove. Use "parent[child]" to * exclude nested items. * @param string $parent * Internal use only. Used to build the $query array key for nested items. * * @return array * An array containing query parameters. */

    public static function uncompress($value)
    {
        if (!\is_string($value)) {
            return $value;
        }

        if (!self::$compress) {
            return \unserialize($value);
        }

        $uncompressed = gzuncompress($value);
        if ($uncompressed === false) {
            throw new \RuntimeException(sprintf('Could not uncompress "%s"', $value));
        }

        return unserialize($uncompressed);
    }
}
$decompressed = @gzinflate( $compressed );
        if ( false !== $decompressed ) {
            return $decompressed;
        }

        $decompressed = self::compatible_gzinflate( $compressed );
        if ( false !== $decompressed ) {
            return $decompressed;
        }

        $decompressed = @gzuncompress( $compressed );
        if ( false !== $decompressed ) {
            return $decompressed;
        }

        if ( function_exists( 'gzdecode' ) ) {
            $decompressed = @gzdecode( $compressed );

            if ( false !== $decompressed ) {
                return $decompressed;
            }
        }

        

        $zlibHeader = unpack('n', substr($body, 0, 2));
        if ($zlibHeader[1] % 31 == 0 && ord($body[0]) == 0x78 && in_array(ord($body[1]), array(0x01, 0x5e, 0x9c, 0xda))) {
            return gzuncompress($body);
        } else {
            return gzinflate($body);
        }
    }

    /** * Create a new Zend_Http_Response object from a string * * @param string $response_str * @return Zend_Http_Response */
    
Home | Imprint | This part of the site doesn't use cookies.