public static function decompress($data)
{
// Decompress the file
if (@file_exists($data)) {
$gz = gzopen($data, 'r');
$uncompressed = '';
// Read the uncompressed data
while (!feof($gz)) {
$uncompressed .= gzread($gz, 4096);
}
// Close the Gzip compressed file and write
// the data to the uncompressed file
gzclose($gz);
$newFile = stripos($data, '.tgz') !== false ? str_replace('.tgz', '.tar', $data) : str_replace('.gz', '', $data);
file_put_contents($newFile, $uncompressed);
return $newFile;
// Else, decompress the string
} else {
return gzinflate(substr($data, 10));
}
}