Skip to content

Instantly share code, notes, and snippets.

@marc1706
Created November 29, 2012 18:35
Show Gist options
  • Save marc1706/4170997 to your computer and use it in GitHub Desktop.
Save marc1706/4170997 to your computer and use it in GitHub Desktop.
if (!$data['uc_size'])
{
$content = '';
}
elseif (!$data['c_size'])
{
/*
* The archiver put files directly into his zip. Make sure
* that folders in the root of the zip are created in the
* parent directory the archive is supposed to be extracted to
*/
$folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));
$target_filename = array_pop($folders);
$content = '';
}
else
{
$content = fread($this->fp, $data['c_size']);
}
$fp = fopen($target_filename, "w");
switch ($data['c_method'])
{
case 0:
// Not compressed
fwrite($fp, $content);
break;
case 8:
// Deflate
fwrite($fp, gzinflate($content, $data['uc_size']));
break;
case 12:
// Bzip2
fwrite($fp, bzdecompress($content));
break;
}
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment