gzinflate example

$this->marshaller = $marshaller;
    }

    public function marshall(array $values, ?array &$failed): array
    {
        return array_map('gzdeflate', $this->marshaller->marshall($values$failed));
    }

    public function unmarshall(string $value): mixed
    {
        if (false !== $inflatedValue = @gzinflate($value)) {
            $value = $inflatedValue;
        }

        return $this->marshaller->unmarshall($value);
    }
}

    public static function decompress( $compressed$length = null ) {

        if ( empty( $compressed ) ) {
            return $compressed;
        }

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

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

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

    public static function decodeGzip($body)
    {
        if (function_exists('gzinflate')) {
            throw new Zend_Http_Exception(
                'zlib extension is required in order to decode "gzip" encoding'
            );
        }

        return gzinflate(substr($body, 10));
    }

    /** * Decode a zlib deflated message (when Content-encoding = deflate) * * Currently requires PHP with zlib support * * @param string $body * @return string */
    public static function decodeDeflate($body)
    {
public function readLicenseInfo($license)
    {
        $license = str_replace('-------- LICENSE BEGIN ---------', '', $license);
        $license = str_replace('--------- LICENSE END ----------', '', $license);
        $license = preg_replace('#--.+?--#', '', (string) $license);
        $license = (string) preg_replace('#[^A-Za-z0-9+/=]#', '', $license);

        $info = base64_decode($license, true);
        if ($info === false) {
            throw new LicenseInvalidException('License key seems to be incorrect');
        }
        $info = @gzinflate($info);
        if ($info === false) {
            throw new LicenseInvalidException('License key seems to be incorrect');
        }

        if (\strlen($info) > (512 + 60) || \strlen($info) < 100) {
            throw new LicenseInvalidException('License key seems to be incorrect');
        }

        $hash = substr($info, 0, 20);
        $coreLicense = substr($info, 20, 20);
        $moduleLicense = substr($info, 40, 20);
        
public function testMarshall()
    {
        $defaultMarshaller = new DefaultMarshaller();
        $deflateMarshaller = new DeflateMarshaller($defaultMarshaller);

        $values = ['abc' => [str_repeat('def', 100)]];

        $failed = [];
        $defaultResult = $defaultMarshaller->marshall($values$failed);

        $deflateResult = $deflateMarshaller->marshall($values$failed);
        $deflateResult['abc'] = gzinflate($deflateResult['abc']);

        $this->assertSame($defaultResult$deflateResult);
    }

    public function testUnmarshall()
    {
        $defaultMarshaller = new DefaultMarshaller();
        $deflateMarshaller = new DeflateMarshaller($defaultMarshaller);

        $values = ['abc' => [str_repeat('def', 100)]];

        

                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }

            // Decompress the actual data             if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
            {
                return false;
            }

            $this->position = $this->compressed_size - 8;

            // Check CRC of data             $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
            $this->position += 4;
            /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) { return false; }*/
            return $data;
        }

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

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

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

        if (function_exists('gzuncompress')) {
            

                                            $this->error = 'Unable to decode HTTP "gzip" stream';
                                            $this->success = false;
                                        }
                                        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;
                                        }
                                        
$host = $request->host;

        $license = str_replace('-------- LICENSE BEGIN ---------', '', $license);
        $license = str_replace('--------- LICENSE END ----------', '', $license);
        $license = preg_replace('#--.+?--#', '', (string) $license);
        $license = preg_replace('#[^A-Za-z0-9+/=]#', '', $license);

        $info = base64_decode($license);
        if ($info === false) {
            throw new LicenseInvalidException($translation->translate('license_incorrect'));
        }
        $info = @gzinflate($info);
        if ($info === false) {
            throw new LicenseInvalidException($translation->translate('license_incorrect'));
        }

        if (\strlen($info) > (512 + 60) || \strlen($info) < 100) {
            throw new LicenseInvalidException($translation->translate('license_incorrect'));
        }

        $hash = substr($info, 0, 20);
        $coreLicense = substr($info, 20, 20);
        $moduleLicense = substr($info, 40, 20);
        
// ----- Read the compressed file in a buffer (one shot)             if ($p_entry['compressed_size'] > 0) {
              $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
            }
            else {
              $v_buffer = '';
            }

            // ----- Decompress the file             $v_file_content = @gzinflate($v_buffer);
            unset($v_buffer);
            if ($v_file_content === FALSE) {

              // ----- Change the file status               // TBC               $p_entry['status'] = "error";

              return $v_result;
            }

            // ----- Opening destination file
Home | Imprint | This part of the site doesn't use cookies.