Php Warning Gzuncompress Data Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or gzdecode(): data error posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss gzuncompress online Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only call to undefined function gzuncompress() takes a minute: Sign up Why PHP's gzuncompress() function can go wrong? up vote 2 down vote favorite PHP has its own function to work with gzip archives. I wrote the following code: error_reporting(E_ALL); $f = file_get_contents('http://spiderbites.nytimes.com/sitemaps/www.nytimes.com/sitemap.xml.gz'); echo $f; $f
Gzuncompress Php
= gzuncompress($f); echo "
"; echo $f; First echo normally outputs the compressed file with proper header (at least first two bytes are correct). If I'd download this file with my browser I can unzip it easily. However gzuncompress thrown Warning: gzuncompress(): data error in /home/path/to/script.php on line 5 Can anyone point me to the right direction to solve this problem? EDIT: The part of phpinfo() output php gzip unzip share|improve this question edited Dec 29 '14 at 16:55 asked Dec 29 php decompress gzip '14 at 16:32 Vlada Katlinskaya 382212 You could use ob_gzhandler() to let PHP do the work for you using because the function gzuncompress() will return an error if the uncompressed data is more than 32768 times the length of the compressed input data or more than the optional parameter length. Or you can use the optional parameter to define the length. That should be an easy fix. –unixmiah Dec 29 '14 at 16:37 @unixmiah in my case size of the file is 4169 (compressed) / 88406 (uncompressed) so the ratio is far from 32768 (real ratio is about 21). –Vlada Katlinskaya Dec 29 '14 at 16:43 have you edited the php.ini and enabled the zip libraries? if you haven't do so and restart your web server after doing that to take the changes you've made. –unixmiah Dec 29 '14 at 16:47 @unixmiah I included phpinfo() screenshot to make this point clear. As I can see - everything is enabled. Right? –Vlada Katlinskaya Dec 29 '14 at 16:55 1 @VladaKatlinskaya: Look at mario's answer. –GiamPy Dec 29 '14 at 16:56 | show 1 more comment 2 Answers 2 active oldest votes up vote 4 down vote accepted Or you could just use the right decompression function, gzdecode(). share|improve this answer answered Dec 29 '14 at 16:52 mario 105k14138224 He's totally right, tested it myself. It works. –GiamPy Dec 29 '
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an gzcompress vs gzdeflate Apache module Session Security Filesystem Security Database Security Error Reporting Using Register
Php Gzinflate
Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms
Php Gunzip
Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services http://stackoverflow.com/questions/27692527/why-phps-gzuncompress-function-can-go-wrong Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related http://php.net/manual/en/function.gzuncompress.php Extensions Web Services Windows Only Extensions XML Manipulation GUI Extensions Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box gzwrite » « gztell PHP Manual Function Reference Compression and Archive Extensions Zlib Zlib Functions Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug gzuncompress (PHP 4 >= 4.0.1, PHP 5, PHP 7)gzuncompress — Uncompress a compressed string Description string gzuncompress ( string $data [, int $length = 0 ] ) This function uncompress a compressed string. Parameters data The data compressed by gzcompress(). length The maximum length of data to decode. Return Values The original uncompressed data or FALSE on error. The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input data or more than the optional parameter length. Examples Example #1 gzuncompress() example $compressed error in /data/multiserv/users/162000/projects/678352/www/analytic/core/Archive/Single.php https://forum.piwik.org/t/error-gzuncompress/2440 on line 270 Whats wrong? jstock 2010-08-06 http://grokbase.com/t/php/php-bugs/033y27qn9p/22967-new-gzuncompress-data-error-while-trying-to-uncompress-true-gzip-data 19:40:10 UTC #2 I have checked out my copy of PIWIK the function you are having a problem with gzuncompress() is not piwik specific, it is a PHP data error function. it is possible that the version of PHP running on your web server does not support this function. For more information please see this pagewww.php.net/manual/en/function.gzuncompress.php I would suggest that you ask your hosting company about php warning gzuncompress this function. jabberwack 2010-08-07 07:48:33 UTC #3 Ok, thank you. Do you know a free webspace that goes Piwik? vipsoft 2010-08-07 16:28:05 UTC #4 Can you patch your copy of core/Archive/Single.php, and report back? Index: Single.php =================================================================== --- Single.php (revision 2891) +++ Single.php (working copy) @@ -267,7 +267,13 @@ // uncompress when selecting from the BLOB table if($typeValue == 'blob' && $db->hasBlobDataType()) { - $value = gzuncompress($value); + $tmp = @gzuncompress($value); + if(empty($tmp)) + { + var_dump($value); + die; + } + $value = $tmp; } if($typeValue == 'numeric' Home Categories FAQ/Guidelines Terms of Service Privacy Policy Powered by Discourse, best viewed with JavaScript enabled pm From: atz at atz dot msk dot ruOperating system: FreeBSD 5.0-RELEASEPHP version: 4CVS-2003-03-30 (stable)PHP Bug Type: Zlib RelatedBug description: "gzuncompress data error" while trying to uncompress TRUE gzip dataI'am trying to fetch data with fsockopen and etc.from URLhttp://suncity.combats.ru/inf.pl?login=atzORhttp://capitalcity.combats.ru/inf.pl?login=atzAnd as result in variable named $Data i have a compressedgzip data from that url with "Content-encoding: gzip".But! When i try togzuncompress($Data)the php returnsWarning: gzuncompress(): data errorgzinflate($Data)Warning: gzinflate(): data errorI'm try to do following:$fp = fopen("gzipped","w");fwrite($fp, $Data, strlen($Data));fclose($fp);$buffer = "";$gzfp = gzopen("gzipped","r");while (!gzeof($gzfp)) {$buffer .= gzread($gzfp, 1024);}gzclose($gzfp);And as result i have normal UNCOMPRESSED datain varaiable named $buffer.Why gzuncompress do not uncompress $Data whilegzopen do this success?Is this a bug?--Edit bug report at http://bugs.php.net/?id=22967&edit=1--Try a CVS snapshot: http://bugs.php.net/fix.php?id=22967&r=trysnapshotFixed in CVS: http://bugs.php.net/fix.php?id=22967&r=fixedcvsFixed in release: http://bugs.php.net/fix.php?id=22967&r=alreadyfixedNeed backtrace: http://bugs.php.net/fix.php?id=22967&r=needtraceTry newer version: http://bugs.php.net/fix.php?id=22967&r=oldversionNot developer issue: http://bugs.php.net/fix.php?id=22967&r=supportExpected behavior: http://bugs.php.net/fix.php?id=22967&r=notwrongNot enough info: http://bugs.php.net/fix.php?id=22967&r=notenoughinfoSubmitted twice: http://bugs.php.net/fix.php?id=22967&r=submittedtwiceregister_globals: http://bugs.php.net/fix.php?id=22967&r=globalsPHP 3 support discontinue