function gzip_uncompress($data) { $filename = gzip_tempnam(); if (!($fp = fopen($filename, 'wb'))) trigger_error(sprintf('%s failed', 'fopen'), E_USER_ERROR); fwrite($fp, $data, strlen($data)); if (!fclose($fp)) trigger_error(sprintf('%s failed', 'fclose'), E_USER_ERROR); if (!($fp = gzopen($filename, 'rb'))) trigger_error(sprintf('%s failed', 'gzopen'), E_USER_ERROR); $unz = ''; while ($buf = gzread($fp, 4096)) $unz .= $buf; if (!gzclose($fp)) trigger_error(sprintf("%s failed", 'gzclose'), E_USER_ERROR); unlink($filename); return $unz; }
function gzip_uncompress($data) { $filename = gzip_tempnam(); if (!($fp = fopen($filename, "wb"))) { die("fopen failed"); } fwrite($fp, $data, strlen($data)); if (!fclose($fp)) { die("fclose failed"); } if (!($fp = gzopen($filename, "rb"))) { die("gzopen failed"); } $unz = ''; while ($buf = gzread($fp, 4096)) { $unz .= $buf; } if (!gzclose($fp)) { die("gzclose failed"); } unlink($filename); return $unz; }