Remove support for variable variables from parser, typechecker and frontend
[hiphop-php.git] / hphp / test / zend / good / ext / phar / tests / files / phar_test.inc
blob806b309b532350820000aff56c7a6b0049cb1b73
1 <?php
3 if (function_exists('date_default_timezone_set')) {
4         date_default_timezone_set('UTC');
7 $manifest = (binary)'';
8 $gflags = 0;
10 foreach($files as $name => $cont)
12         global $gflags, $files;
14         $comp = NULL;
15         $crc32= NULL;
16         $clen = NULL;
17         $ulen = NULL;
18         $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
19         $flags= 0;
20         $perm = 0x000001B6;
21         $meta = NULL;
23         // overwrite if array
24         if (is_array($cont))
25   {
26     if (isset($cont['comp']))  $comp  = $cont['comp'];
27     if (isset($cont['crc32'])) $crc32 = $cont['crc32'];
28     if (isset($cont['clen']))  $clen  = $cont['clen'];
29     if (isset($cont['ulen']))  $ulen  = $cont['ulen'];
30     if (isset($cont['time']))  $time  = $cont['time'];
31     if (isset($cont['flags'])) $flags = $cont['flags'];
32     if (isset($cont['perm']))  $perm  = $cont['perm'];
33     if (isset($cont['meta']))  $meta  = $cont['meta'];
34     if (isset($cont['cont']))  $cont  = $cont['cont'];
35         }
37         // create if not yet done
38         if (empty($comp)) $comp = $cont;
39         if (empty($ulen)) $ulen = strlen($cont);
40         if (empty($clen)) $clen = strlen($comp);
41         if (empty($crc32))$crc32= crc32((binary)$cont);
42         if (isset($meta)) $meta = serialize($meta);
44         // write manifest entry
45         $manifest .= pack('V', strlen($name)) . (binary)$name;
46         $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
48         // globals
49         $gflags |= $flags;
50         $files[$name] = $comp;
53 if (!isset($alias)) $alias = 'hio';
55 if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
57 $manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
58 $file = (binary)$file;
59 $file .= pack('V', strlen($manifest)) . $manifest;
61 foreach($files as $cont)
63         $file .= (binary)$cont;
66 file_put_contents($fname, $file);
68 if (@$gzip) {
69         $fp = gzopen($fname, 'w');
70         fwrite($fp, $file);
71         fclose($fp);
74 if (@$bz2) {
75         $fp = bzopen($fname, 'w');
76         fwrite($fp, $file);
77         fclose($fp);