note 50692 added to function.gzcompress
| From: | ez at daoldskool dot org | Date: | Mon, 07 Mar 2005 15:20:31 +0000 |
| Subject: | note 50692 added to function.gzcompress | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86049@lists.php.net to get a copy of this message | ||
postmaster at ak-dev dot com & chris at mad-teaparty dot com were both wrong : their function
seem to generate a valid file but while decompressing it with pure gnu gzip program on a linux
machine i always got a ugly
"gunzip: catalog.xml.gz: unexpected end of file" or
"gunzip: catalog.xml.gz: not in gzip format"
so here is the ULTIMATE gz workaround :
function gzip($data = "", $level = 6, $filename = "", $comments = "")
{
$flags = (empty($comment)? 0 : 16) + (empty($filename)? 0 : 8);
$mtime = time();
return (pack("C1C1C1C1VC1C1", 0x1f, 0x8b, 8, $flags, $mtime, 2, 0xFF) .
(empty($filename) ? "" : $filename . "\0") .
(empty($comment) ? "" : $comment . "\0") .
gzdeflate($data, $level) .
pack("VV", crc32($data), strlen($data)));
}
coming straight out of the PEAR File_Archive package (http://pear.php.net/package/File_Archive)
i redesign it as a single function if u don't want to use the whole PEAR class for your
convenience
----
Manual Page -- http://www.php.net/manual/en/function.gzcompress.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50692
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50692&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50692&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50692&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50692&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50692&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50692&report=yes
Search -- http://master.php.net/manage/user-notes.php