2007-01-13 16:17:04 +00:00
|
|
|
<?php
|
|
|
|
|
2007-01-21 20:22:36 +00:00
|
|
|
if (function_exists('date_default_timezone_set')) {
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
|
|
|
|
2007-01-13 16:17:04 +00:00
|
|
|
$manifest = '';
|
2007-01-21 16:58:23 +00:00
|
|
|
$glags = 0;
|
2007-01-13 16:17:04 +00:00
|
|
|
|
|
|
|
foreach($files as $name => $cont)
|
|
|
|
{
|
2007-01-21 16:58:23 +00:00
|
|
|
global $gflags, $files;
|
|
|
|
|
|
|
|
$comp = NULL;
|
|
|
|
$crc32= NULL;
|
|
|
|
$clen = NULL;
|
|
|
|
$ulen = NULL;
|
2007-01-21 15:57:12 +00:00
|
|
|
$time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
|
2007-01-21 16:58:23 +00:00
|
|
|
$flags= 0;
|
2007-01-21 15:57:12 +00:00
|
|
|
$perm = 0x000001B6;
|
2007-01-21 20:12:50 +00:00
|
|
|
$meta = NULL;
|
2007-01-21 16:58:23 +00:00
|
|
|
|
|
|
|
// overwrite if array
|
2007-01-21 15:57:12 +00:00
|
|
|
if (is_array($cont))
|
|
|
|
{
|
2007-01-21 16:58:23 +00:00
|
|
|
foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what)
|
2007-01-21 15:57:12 +00:00
|
|
|
{
|
|
|
|
if (isset($cont[$what]))
|
|
|
|
{
|
|
|
|
$$what = $cont[$what];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-21 16:58:23 +00:00
|
|
|
|
|
|
|
// create if not yet done
|
|
|
|
if (empty($comp)) $comp = $cont;
|
|
|
|
if (empty($ulen)) $ulen = strlen($cont);
|
|
|
|
if (empty($clen)) $clen = strlen($comp);
|
|
|
|
if (empty($crc32))$crc32= crc32($cont);
|
2007-01-21 20:12:50 +00:00
|
|
|
if (isset($meta)) $meta = serialize($meta);
|
2007-01-21 16:58:23 +00:00
|
|
|
|
|
|
|
// write manifest entry
|
2007-01-13 16:17:04 +00:00
|
|
|
$manifest .= pack('V', strlen($name)) . $name;
|
2007-01-21 20:12:50 +00:00
|
|
|
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
|
2007-01-21 16:58:23 +00:00
|
|
|
|
|
|
|
// globals
|
|
|
|
$gflags |= $flags;
|
|
|
|
$files[$name] = $comp;
|
2007-01-13 16:17:04 +00:00
|
|
|
}
|
2007-01-21 16:58:23 +00:00
|
|
|
|
2007-01-13 16:17:04 +00:00
|
|
|
$alias = 'hio';
|
2007-01-29 03:59:55 +00:00
|
|
|
|
|
|
|
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
|
2008-01-19 18:30:30 +00:00
|
|
|
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
|
2007-01-13 16:17:04 +00:00
|
|
|
$file .= pack('V', strlen($manifest)) . $manifest;
|
2007-01-21 16:58:23 +00:00
|
|
|
|
2007-01-13 16:17:04 +00:00
|
|
|
foreach($files as $cont)
|
|
|
|
{
|
2007-01-21 16:58:23 +00:00
|
|
|
$file .= $cont;
|
2007-01-13 16:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file_put_contents($fname, $file);
|
|
|
|
|
2008-01-09 08:45:00 +00:00
|
|
|
if (@$gzip) {
|
|
|
|
$fp = gzopen($fname, 'w');
|
|
|
|
fwrite($fp, $file);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
|
2008-01-09 08:48:56 +00:00
|
|
|
if (@$bz2) {
|
|
|
|
$fp = bzopen($fname, 'w');
|
|
|
|
fwrite($fp, $file);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
|
2007-01-13 16:17:04 +00:00
|
|
|
?>
|