]> granicus.if.org Git - php/commitdiff
- Change to new layout wich has some more flags that will be used for perms
authorMarcus Boerger <helly@php.net>
Sat, 13 Jan 2007 16:17:04 +0000 (16:17 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 13 Jan 2007 16:17:04 +0000 (16:17 +0000)
- Update/simplify tests

37 files changed:
ext/phar/phar.c
ext/phar/tests/009.phpt
ext/phar/tests/010.phpt
ext/phar/tests/011.phpt
ext/phar/tests/012.phpt
ext/phar/tests/013.phpt
ext/phar/tests/014.phpt
ext/phar/tests/015.phpt
ext/phar/tests/015b.phpt
ext/phar/tests/016.phpt
ext/phar/tests/016b.phpt
ext/phar/tests/017.phpt
ext/phar/tests/018.phpt
ext/phar/tests/019.phpt
ext/phar/tests/019b.phpt
ext/phar/tests/019c.phpt
ext/phar/tests/020.phpt
ext/phar/tests/021.phpt
ext/phar/tests/022.phpt
ext/phar/tests/023.phpt
ext/phar/tests/024.phpt
ext/phar/tests/025.phpt
ext/phar/tests/026.phpt
ext/phar/tests/027.phpt
ext/phar/tests/028.phpt
ext/phar/tests/029.phpt
ext/phar/tests/030.phpt
ext/phar/tests/delete_in_phar.phpt
ext/phar/tests/delete_in_phar_b.phpt
ext/phar/tests/delete_in_phar_confirm.phpt
ext/phar/tests/open_for_write_existing.phpt
ext/phar/tests/open_for_write_existing_b.phpt
ext/phar/tests/open_for_write_newfile.phpt
ext/phar/tests/open_for_write_newfile_b.phpt
ext/phar/tests/phar_oo_001.phpt
ext/phar/tests/phar_oo_test.inc
ext/phar/tests/phar_test.inc [new file with mode: 0755]

index ffb924ebb9ed36848684586bc5ac8a748923b241..9edae0d4d0e4117f570d4967cccaaf74cb67fc68 100644 (file)
 #define PHAR_API_MAJORVER_MASK    0xF000
 #define PHAR_API_VER_MASK         0xFFF0
 
-#define PHAR_HDR_ANY_COMPRESSED   0x0001
-#define PHAR_HDR_SIGNATURE        0x0008
+#define PHAR_HDR_COMPRESSION_MASK 0x000F
+#define PHAR_HDR_COMPRESSED_NONE  0x000F
+#define PHAR_HDR_COMPRESSED_GZ    0x0001
+#define PHAR_HDR_COMPRESSED_BZ2   0x0002
+#define PHAR_HDR_SIGNATURE        0x0010
 
 #define PHAR_SIG_MD5              0x0001
 #define PHAR_SIG_SHA1             0x0002
 
 /* flags byte for each file adheres to these bitmasks.
    All unused values are reserved */
-#define PHAR_ENT_COMPRESSION_MASK 0x0F
-#define PHAR_ENT_COMPRESSED_NONE  0x00
-#define PHAR_ENT_COMPRESSED_GZ    0x01
-#define PHAR_ENT_COMPRESSED_BZ2   0x02
+#define PHAR_ENT_COMPRESSION_MASK 0x000F
+#define PHAR_ENT_COMPRESSED_NONE  0x0000
+#define PHAR_ENT_COMPRESSED_GZ    0x0001
+#define PHAR_ENT_COMPRESSED_BZ2   0x0002
 
 /* an entry has been marked as deleted from a writeable phar */
 #define PHAR_ENT_DELETED         0x10
@@ -112,15 +115,17 @@ typedef union _phar_archive_object  phar_archive_object;
 typedef union _phar_entry_object    phar_entry_object;
 
 /* entry for one file in a phar file */
-typedef struct _phar_manifest_entry {
-       php_uint32               filename_len;
-       char                     *filename;
+typedef struct _phar_entry_info {
+       /* first bytes are exactly as in file */
        php_uint32               uncompressed_filesize;
        php_uint32               timestamp;
-       long                     offset_within_phar;
        php_uint32               compressed_filesize;
        php_uint32               crc32;
-       char                     flags;
+       php_uint32               flags;
+       /* remainder */
+       php_uint32               filename_len;
+       char                     *filename;
+       long                     offset_within_phar;
        zend_bool                crc_checked;
        php_stream               *fp;
        php_stream               *temp_file;
@@ -136,8 +141,8 @@ typedef struct _phar_archive_data {
        char                     version[12];
        size_t                   internal_file_start;
        size_t                   halt_offset;
-       zend_bool                has_compressed_files;
        HashTable                manifest;
+       php_uint32               flags;
        php_uint32               min_timestamp;
        php_uint32               max_timestamp;
        php_stream               *fp;
@@ -569,10 +574,9 @@ static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alia
        char b32[4], *buffer, *endbuffer, *savebuf;
        phar_archive_data *mydata = NULL;
        phar_entry_info entry;
-       php_uint32 manifest_len, manifest_count, manifest_index, tmp_len, sig_flags;
-       php_uint16 manifest_tag;
+       php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
+       php_uint16 manifest_ver;
        long offset;
-       int compressed = 0;
        int register_alias, sig_len;
        char *signature = NULL;
 
@@ -636,22 +640,26 @@ static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alia
                MAPPHAR_FAIL("in phar \"%s\", manifest claims to have zero entries.  Phars must have at least 1 entry");
        }
 
-       /* extract API version and global compressed flag */
-       manifest_tag = (((unsigned char)buffer[0]) <<  8)
-               + ((unsigned char)buffer[1]);
+       /* extract API version, lowest nibble currently unused */
+       manifest_ver = (((unsigned char)buffer[0]) <<  8)
+                    + ((unsigned char)buffer[1]);
        buffer += 2;
-       if ((manifest_tag & PHAR_API_VER_MASK) < PHAR_API_VERSION ||
-                   (manifest_tag & PHAR_API_MAJORVER_MASK) != PHAR_API_MAJORVERSION)
+       if ((manifest_ver & PHAR_API_VER_MASK) < PHAR_API_VERSION ||
+                   (manifest_ver & PHAR_API_MAJORVER_MASK) != PHAR_API_MAJORVERSION)
        {
                efree(savebuf);
                php_stream_close(fp);
-               php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "phar \"%s\" is API version %1.u.%1.u.%1.u, and cannot be processed", fname, manifest_tag >> 12, (manifest_tag >> 8) & 0xF, (manifest_tag >> 4) & 0x0F);
+               php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "phar \"%s\" is API version %1.u.%1.u.%1.u, and cannot be processed", fname, manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0x0F);
                return FAILURE;
        }
 
+       PHAR_GET_32(buffer, manifest_flags);
+
+       manifest_flags &= ~PHAR_ENT_COMPRESSION_MASK; 
+
        /* The lowest nibble contains the phar wide flags. The any compressed can */
        /* be ignored on reading because it is being generated anyways. */
-       if (manifest_tag & PHAR_HDR_SIGNATURE) {
+       if (manifest_flags & PHAR_HDR_SIGNATURE) {
                unsigned char buf[1024];
                int read_size, len;
                char sig_buf[8], *sig_ptr = sig_buf;
@@ -817,7 +825,7 @@ static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alia
                if (entry.filename_len == 0) {
                        MAPPHAR_FAIL("zero-length filename encountered in phar \"%s\"");
                }
-               if (buffer + entry.filename_len + 16 + 1 > endbuffer) {
+               if (buffer + entry.filename_len + 20 > endbuffer) {
                        MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
                }
                entry.filename = estrndup(buffer, entry.filename_len);
@@ -836,21 +844,19 @@ static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alia
                }
                PHAR_GET_32(buffer, entry.compressed_filesize);
                PHAR_GET_32(buffer, entry.crc32);
+               PHAR_GET_32(buffer, entry.flags);
                entry.offset_within_phar = offset;
                offset += entry.compressed_filesize;
-               entry.flags = *buffer++;
                switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
                case PHAR_ENT_COMPRESSED_GZ:
 #if !HAVE_ZLIB
                        MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
 #endif
-                       compressed = 1;
                        break;
                case PHAR_ENT_COMPRESSED_BZ2:
 #if !HAVE_BZ2
                        MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
 #endif
-                       compressed = 1;
                        break;
                default:
                        if (entry.uncompressed_filesize != entry.compressed_filesize) {
@@ -858,15 +864,16 @@ static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alia
                        }
                        break;
                }
+               manifest_flags |= (entry.flags & PHAR_ENT_COMPRESSION_MASK);
                entry.crc_checked = 0;
                entry.fp = NULL;
                zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
        }
 
-       snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_tag >> 12, (manifest_tag >> 8) & 0xF, (manifest_tag >> 4) & 0xF);
+       snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0xF);
        mydata->internal_file_start = halt_offset + manifest_len + 4;
        mydata->halt_offset = halt_offset;
-       mydata->has_compressed_files = compressed;
+       mydata->flags = manifest_flags;
        mydata->fp = fp;
        mydata->fname = estrndup(fname, fname_len);
        mydata->fname_len = fname_len;
@@ -1218,35 +1225,35 @@ static php_stream_ops phar_ops = {
        phar_stream_close, /* close */
        phar_stream_flush, /* flush */
        "phar stream",
-       phar_stream_seek, /* seek */
-       NULL, /* cast */
-       phar_stream_stat, /* stat */
+       phar_stream_seek,  /* seek */
+       NULL,              /* cast */
+       phar_stream_stat,  /* stat */
        NULL, /* set option */
 };
 
 static php_stream_ops phar_dir_ops = {
-       phar_dir_write, /* write (does nothing) */
-       phar_dir_read,  /* read */
+       phar_dir_write, /* write */
+       phar_dir_read,  /* read  */
        phar_dir_close, /* close */
-       phar_dir_flush, /* flush (does nothing) */
-       "phar stream",
-       phar_dir_seek, /* seek */
-       NULL, /* cast */
-       phar_dir_stat, /* stat */
+       phar_dir_flush, /* flush */
+       "phar dir",
+       phar_dir_seek,  /* seek */
+       NULL,           /* cast */
+       phar_dir_stat,  /* stat */
        NULL, /* set option */
 };
 
 static php_stream_wrapper_ops phar_stream_wops = {
     phar_wrapper_open_url,
-    NULL, /* phar_wrapper_close */
-    NULL, /* phar_wrapper_stat, */
-    phar_wrapper_stat, /* stat_url */
+    NULL,                  /* phar_wrapper_close */
+    NULL,                  /* phar_wrapper_stat, */
+    phar_wrapper_stat,     /* stat_url */
     phar_wrapper_open_dir, /* opendir */
     "phar",
-    phar_wrapper_unlink, /* unlink */
-    NULL, /* rename */
-    NULL, /* create directory */
-    NULL /* remove directory */
+    phar_wrapper_unlink,   /* unlink */
+    NULL,                  /* rename */
+    NULL,                  /* create directory */
+    NULL,                  /* remove directory */
 };
 
 php_stream_wrapper php_stream_phar_wrapper =  {
@@ -1692,7 +1699,7 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
        phar_entry_info *entry;
        int alias_len, fname_len, halt_offset, restore_alias_len, global_flags = 0;
        char *fname, *alias;
-       char *manifest, entry_buffer[20];
+       char manifest[18], entry_buffer[20];
        off_t manifest_ftell;
        long offset;
        php_uint32 copy, loc, new_manifest_count;
@@ -1746,7 +1753,7 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                }
                /* after excluding deleted files, calculate manifest size in bytes and number of entries */
                ++new_manifest_count;
-               offset += 21 + entry->filename_len;
+               offset += 4 + entry->filename_len + sizeof(entry_buffer);
 
                /* compress as necessary */
                if (entry->flags & PHAR_ENT_MODIFIED) {
@@ -1768,7 +1775,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                        }
                } else {
                        if (-1 == php_stream_seek(oldfile, entry->offset_within_phar + data->phar->internal_file_start, SEEK_SET)) {
-                               efree(manifest);
                                if (oldfile) {
                                        php_stream_close(oldfile);
                                }
@@ -1782,7 +1788,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                if (entry->flags & PHAR_ENT_COMPRESSION_MASK) {
                        filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
                        if (!filter) {
-                               efree(manifest);
                                if (oldfile) {
                                        php_stream_close(oldfile);
                                }
@@ -1816,38 +1821,34 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                        entry->temp_file = compfile;
                        entry->compressed_filesize = copy;
                        entry->flags |= PHAR_ENT_MODIFIED;
-                       global_flags |= PHAR_HDR_ANY_COMPRESSED;
+                       global_flags |= (entry->flags & PHAR_ENT_COMPRESSION_MASK);
                }
        }
        
+       global_flags |= PHAR_HDR_SIGNATURE;
+
        /* write out manifest pre-header */
-       /*  4: manifest length, 4: manifest entry count, 2: phar version,
-           4: alias length, the rest is the alias itself
-       */
+       /*  4: manifest length
+        *  4: manifest entry count
+        *  2: phar version
+        *  4: phar global flags
+        *  4: alias length, the rest is the alias itself
+        */
        restore_alias_len = data->phar->alias_len;
-       if (data->phar->explicit_alias) {
-               manifest = (char *) emalloc(14 + data->phar->alias_len);
-               phar_set_32(manifest, offset + data->phar->alias_len + 10); /* manifest length */
-               phar_set_32(manifest+4, new_manifest_count);
-               phar_set_32(manifest+10, data->phar->alias_len);
-               memcpy(manifest + 14, data->phar->alias, data->phar->alias_len);
-       } else {
-               /* alias was assigned at runtime, do not add to new phar */
-               manifest = (char *) emalloc(14);
-               phar_set_32(manifest, offset + 10); /* manifest length */
-               phar_set_32(manifest+4, new_manifest_count);
-               phar_set_32(manifest+10, 0);
+       if (!data->phar->explicit_alias) {
                data->phar->alias_len = 0;
        }
 
-       global_flags |= PHAR_HDR_SIGNATURE;
-
+       phar_set_32(manifest, offset + data->phar->alias_len + sizeof(manifest) - 4); /* manifest length */
+       phar_set_32(manifest+4, new_manifest_count);
        *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF);
-       *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0) | (global_flags & 0x0F));
+       *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0));
+       phar_set_32(manifest+10, global_flags);
+       phar_set_32(manifest+14, data->phar->alias_len);
 
        /* write the manifest header */
-       if (14 + data->phar->alias_len != php_stream_write(newfile, manifest, 14 + data->phar->alias_len)) {
-               efree(manifest);
+       if (sizeof(manifest) != php_stream_write(newfile, manifest, sizeof(manifest))
+       || data->phar->alias_len != php_stream_write(newfile, data->phar->alias, data->phar->alias_len)) {
                if (oldfile) {
                        php_stream_close(oldfile);
                }
@@ -1875,7 +1876,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                phar_set_32(entry_buffer, entry->filename_len);
                if (4 != php_stream_write(newfile, entry_buffer, 4)
                || entry->filename_len != php_stream_write(newfile, entry->filename, entry->filename_len)) {
-                       efree(manifest);
                        if (oldfile) {
                                php_stream_close(oldfile);
                        }
@@ -1888,16 +1888,15 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                        4: creation timestamp
                        4: compressed filesize
                        4: crc32
-                       1: flags (compression or not)
+                       4: flags
                */
                copy = time(NULL);
                phar_set_32(entry_buffer, entry->uncompressed_filesize);
                phar_set_32(entry_buffer+4, copy);
                phar_set_32(entry_buffer+8, entry->compressed_filesize);
                phar_set_32(entry_buffer+12, entry->crc32);
-               entry_buffer[16] = (char) entry->flags;
-               if (17 != php_stream_write(newfile, entry_buffer, 17)) {
-                       efree(manifest);
+               phar_set_32(entry_buffer+16, entry->flags);
+               if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer))) {
                        if (oldfile) {
                                php_stream_close(oldfile);
                        }
@@ -1924,7 +1923,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                        file = entry->temp_file;
                } else {
                        if (-1 == php_stream_seek(oldfile, entry->offset_within_phar + data->phar->internal_file_start, SEEK_SET)) {
-                               efree(manifest);
                                if (oldfile) {
                                        php_stream_close(oldfile);
                                }
@@ -1939,7 +1937,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
                entry->offset_within_phar = offset;
                offset += entry->compressed_filesize;
                if (entry->compressed_filesize != php_stream_copy_to_stream(file, newfile, entry->compressed_filesize)) {
-                       efree(manifest);
                        if (oldfile) {
                                php_stream_close(oldfile);
                        }
@@ -2007,7 +2004,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
        php_stream_rewind(newfile);
        file = php_stream_open_wrapper(data->phar->fname, "wb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
        if (!file) {
-               efree(manifest);
                if (oldfile) {
                        php_stream_close(oldfile);
                }
@@ -2018,7 +2014,6 @@ static int phar_flush(phar_entry_data *data TSRMLS_DC) /* {{{ */
        php_stream_copy_to_stream(newfile, file, PHP_STREAM_COPY_ALL);
        php_stream_close(newfile);
        php_stream_close(file);
-       efree(manifest);
 
        file = php_stream_open_wrapper(data->phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
 
@@ -2164,11 +2159,13 @@ static void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stre
  */
 static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
 {
-       phar_entry_data *data;
+       phar_entry_data *data = (phar_entry_data *)stream->abstract;
+
        /* If ssb is NULL then someone is misbehaving */
-       if (!ssb) return -1;
+       if (!ssb) {
+               return -1;
+       }
 
-       data = (phar_entry_data *)stream->abstract;
        phar_dostat(data->phar, data->internal_file, ssb, 0, data->phar->alias, data->phar->alias_len TSRMLS_CC);
        return 0;
 }
@@ -2179,11 +2176,13 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
  */
 static int phar_dir_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
 {
-       phar_entry_data *data;
+       phar_entry_data *data = (phar_entry_data *)stream->abstract;
+
        /* If ssb is NULL then someone is misbehaving */
-       if (!ssb) return -1;
+       if (!ssb) {
+               return -1;
+       }
 
-       data = (phar_entry_data *)stream->abstract;
        phar_dostat(data->phar, data->internal_file, ssb, 0, data->phar->alias, data->phar->alias_len TSRMLS_CC);
        return 0;
 }
index b2c9fd7f855030856f926252d16585cedd5e0f3a..d594e88f4f11bd804d4b29c146187cbcc212b4f5 100644 (file)
@@ -9,7 +9,7 @@ phar.require_hash=0
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
-$file .= pack('VVnV', 500, 500, 0x0800, 0) . str_repeat('A', 500);
+$file .= pack('VVnVV', 500, 500, 0x0900, 0x00000000, 0) . str_repeat('A', 500);
 file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
 include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
 ?>
index b675180c8e7f249feba3283e09722482179a032b..008bdc8feee4fd51231b4a8d2605c1214c6ae5ea 100644 (file)
@@ -12,8 +12,8 @@ __HALT_COMPILER(); ?>";
 
 // this fails because the manifest length does not include the other 10 byte manifest data
 
-$manifest = pack('V', 1) . 'a' . pack('VVVVC', 0, time(), 0, crc32(''), 0);
-$file .= pack('VVnV', strlen($manifest), 1, 0x0800, 3) . 'hio' . $manifest;
+$manifest = pack('V', 1) . 'a' . pack('VVVVV', 0, time(), 0, crc32(''), 0x00000000);
+$file .= pack('VVnVV', strlen($manifest), 1, 0x0900, 0x00000000, 3) . 'hio' . $manifest;
 
 file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
 include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
index 7c7ca1da066637c384f858dee95004ea3f46c43f..1ff2a32f97b6171c851ec273d0d19acbf23f0930 100644 (file)
@@ -17,10 +17,10 @@ $files['a'] = 'a';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len+1, crc32($cont), 0);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), $len+1, crc32($cont), 0x00000000);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 529f52035864efa54cd0d9c680182678b99bbce7..f090f2ff1207a749a48aeee22a324f04e86e7391 100644 (file)
@@ -6,27 +6,17 @@ Phar::mapPhar valid file
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+include $fname;
 echo file_get_contents('phar://hio/a');
 ?>
 --CLEAN--
index f5eab6165588bfd436edbbc69b93b3474cb79f6a..3327e53db9a0d296fde2fe75ebee82088607720b 100644 (file)
@@ -6,6 +6,8 @@ Phar::mapPhar filesize mismatch
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -16,10 +18,10 @@ $files['a'] = 'a';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont)+1;
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), $len, crc32($cont), 0x00000000);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index cf414f782646dbfffd9e781e11f692f756acca7d..ea27faaf7e1d657b96916d3ebcbe3c7261646180 100644 (file)
@@ -16,10 +16,10 @@ $files['a'] = 'a';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont.'X'), 0);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), $len, crc32($cont.'X'), 0x00000000);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 14103ea0b27766b48b13d9bc9ec40808c7582bb6..32c06fdfd7b4f9fa6aba187e470d76bdd8d0a87d 100644 (file)
@@ -16,10 +16,10 @@ $files['a'] = 'a';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), 3, crc32($cont), 0x01);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), 3, crc32($cont), 0x00000001);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000001, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index caf9da7d137bf6eb2f2609ca5f0ecfb618182c02..1a92dd87852d849800e33aff593fe9aabf83cd00 100755 (executable)
@@ -15,10 +15,10 @@ $files = array();
 $files['a'] = array('Hello World', pack('H*', '425a6839314159265359d872012f00000157800010400000400080060490002000220686d420c988c769e8281f8bb9229c28486c39009780'));
 $manifest = '';
 foreach($files as $name => $cont) {
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', strlen($cont[0]), time(), strlen($cont[1]), crc32($cont[0]), 0x02);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', strlen($cont[0]), time(), strlen($cont[1]), crc32($cont[0]), 0x00000002);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000002, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 5f308ca6144a71c51860bb9c229201d4db9f896f..8ffc97bc7333a294f9b8726d7405c33b66da81a5 100644 (file)
@@ -13,19 +13,19 @@ __HALT_COMPILER(); ?>";
 // file length is too short
 
 $files = array();
-$files['a'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
-$files['b'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
-$files['c'] = array('*', '*', 0x00);
-$files['d'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
+$files['a'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00000001);
+$files['b'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00000001);
+$files['c'] = array('*', '*',                                           0x00000000);
+$files['d'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00000001);
 $manifest = '';
 foreach($files as $name => $cont) {
        $ulen = strlen($cont[0]);
        $clen = strlen($cont[1]);
        $manifest .= pack('V', strlen($name)) . $name 
-                 . pack('VVVVC', $ulen, time(), $clen, crc32($cont[0]), $cont[2]);
+                 . pack('VVVVV', $ulen, time(), $clen, crc32($cont[0]), $cont[2]);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000001, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 2f5d3beaee7c9c475e1bda633c385c46254e38fa..322ec4ea5054c994459148171c05c24622731d15 100755 (executable)
@@ -17,10 +17,10 @@ $files['a'] = 'a';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), 1, crc32($cont), 0x01);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), 1, crc32($cont), 0x00000001);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000001, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 1a50759255d480e4aa376a4284ca97909a29f1e5..197649d451bbc53227ebf378c0cda45c15c68fb0 100644 (file)
@@ -16,10 +16,10 @@ $files['a'] = 'abc';
 $manifest = '';
 foreach($files as $name => $cont) {
        $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x01);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVV', $len, time(), $len, crc32($cont), 0x00000001);
 }
 $alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000001, strlen($alias)) . $alias . $manifest;
 $file .= pack('V', strlen($manifest)) . $manifest;
 foreach($files as $cont)
 {
index 3171271b0aab76711420fa39b82b088b43dd7ccb..e30b42917109f9d344801f4a400e9f0ff481b431 100644 (file)
@@ -6,6 +6,8 @@ Phar: opendir test, root directory
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -13,20 +15,7 @@ __HALT_COMPILER(); ?>";
 $files = array();
 $files['a'] = 'a';
 $files['b/a'] = 'b';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= chr(0) . chr(4) . chr(0); // 'a' gzdeflated
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include 'phar_test.inc';
 include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
 $dir = opendir('phar://hio/');
 while (false !== ($a = readdir($dir))) {
index dcaeedb07c297c7ab1951b36163dec665d5789b1..818dfd7ec54fbbadc65cbf797145e5bfb8094aac 100644 (file)
@@ -6,6 +6,8 @@ Phar: opendir test, subdirectory
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -15,21 +17,8 @@ $files['a'] = 'a';
 $files['b/a'] = 'b';
 $files['b/c/d'] = 'c';
 $files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+include $fname;
 $dir = opendir('phar://hio/b');
 while (false !== ($a = readdir($dir))) {
        var_dump($a);
index 95b0bd696a1c62c837f6d16959626bee827c1290..f1e6455a80ccbf519bd8266e4b240134d6becf11 100755 (executable)
@@ -6,6 +6,8 @@ Phar: opendir test, recurse into
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -15,21 +17,8 @@ $files['a'] = 'a';
 $files['b/a'] = 'b';
 $files['b/c/d'] = 'c';
 $files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+include $fname;
 
 function dump($phar, $base)
 {
index be82aa7bf43a56ac2fa1a749217de1af3215eccf..a9c4bbcf4aefe43e9a92b8fc0b7f7bc26de12bf4 100755 (executable)
@@ -6,6 +6,8 @@ Phar: opendir test, recurse into
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -15,21 +17,8 @@ $files['a'] = 'a';
 $files['b/a'] = 'b';
 $files['b/c/d'] = 'c';
 $files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+include $fname;
 
 function dump($phar, $base)
 {
index 15c55a7c8563533b00c8dc9eba220d6b42a49cc7..ca0d92e0c79b91c6a97fcf3d6555c8c8f3a23ae3 100644 (file)
@@ -6,30 +6,21 @@ Phar: url stat
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
 
+$pfile = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
 $files = array();
 $files['a'] = 'a';
 $files['b/a'] = 'b';
 $files['b/c/d'] = 'c';
 $files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
+include $fname;
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
 var_dump(stat('phar://hio/a'), stat('phar://hio/b'));
 ?>
 --CLEAN--
index 7ff9e1b9f9db819e7c11a9ee552532c336ff7172..e7844d00002166932e77bb061383ec50630f6b10 100644 (file)
@@ -6,6 +6,8 @@ Phar: stream stat
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
@@ -15,21 +17,11 @@ $files['a'] = 'a';
 $files['b/a'] = 'b';
 $files['b/c/d'] = 'c';
 $files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+
+include $fname;
+
 $fp = fopen('phar://hio/a', 'r');
 var_dump(fstat($fp));
 fclose($fp);
index ae8b8499652c64d2ee886f9550c45a34c53927cc..70210e1cc701b470f4ccd7773ce04c0033765225 100644 (file)
@@ -6,27 +6,19 @@ Phar: stream stat
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a'] = 'abcdefg';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+include 'phar_test.inc';
+
+include $fname;
+
 $fp = fopen('phar://hio/a', 'r');
 var_dump(ftell($fp));
 echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
index c7a21184c2ab3ddcbf9e1e6086543f3a939b93e9..a6d674af45893f6b700ad00d03185a8f83fbb46b 100755 (executable)
@@ -6,30 +6,20 @@ Phar: phar:// file_get_contents
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include 'phar_test.inc';
 
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php'));
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php'));
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php'));
+var_dump(file_get_contents($pname . '/a.php'));
+var_dump(file_get_contents($pname . '/b.php'));
+var_dump(file_get_contents($pname . '/b/c.php'));
 
 ?>
 ===DONE===
index 97460669c1460bc8888f50c0de647c91a461c2e6..29cd595c618f13114ab88b5d4c6d34252d130049 100755 (executable)
@@ -6,30 +6,20 @@ Phar: phar:// include
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include 'phar_test.inc';
 
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
 
 ?>
 ===DONE===
index a591d59fee27754ca7b4d4553b3488392bb43631..b85c85b470da8884dce5864315d98e68b84727b9 100755 (executable)
@@ -6,30 +6,20 @@ Phar: phar:// include (repeated names)
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a'] = '<?php echo "This is a\n"; ?>';
 $files['b'] = '<?php echo "This is b\n"; ?>';
 $files['b/b'] = '<?php echo "This is b/b\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include 'phar_test.inc';
 
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/b';
+include $pname . '/a';
+include $pname . '/b';
+include $pname . '/b/b';
 
 ?>
 ===DONE===
index 7eb2f90b67ac732ae61e3e17a1b3880824d22944..606fa40ee050139bd991b5fede67bb4d56a289d9 100755 (executable)
@@ -17,20 +17,7 @@ $files['b/c.php'] = '<?php echo "This is b/c\n"; require "'.$pname.'/b/d.php"; ?
 $files['b/d.php'] = '<?php echo "This is b/d\n"; require "'.$pname.'/e.php"; ?>';    
 $files['e.php']   = '<?php echo "This is e\n"; ?>';                                  
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents($fname, $file);
+include 'phar_test.inc';
 
 require $pname . '/a.php';
 
index 2640e2b453ec42505edf12e04fb9d1ecae7f0fb5..7dc7913ccd16746a75c0cd57635de9a6d52a1191 100755 (executable)
@@ -17,20 +17,7 @@ $files['b/c.php'] = '<?php echo "This is b/c\n"; require "'.$pname.'/b/d.php"; ?
 $files['b/d.php'] = '<?php echo "This is b/d\n"; require "'.$pname.'/e.php"; ?>';    
 $files['e.php']   = '<?php echo "This is e\n"; ?>';                                  
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents($fname, $file);
+include 'phar_test.inc';
 
 function dump($phar, $base)
 {
index 723192ef5066db2999b35dff5ecf23a3bc998436..c4e4abb32f09657fa5d7914275450fd3c3e8cbd7 100755 (executable)
@@ -7,7 +7,7 @@ phar.require_hash=0
 --FILE--
 <?php
 $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://test';
+$pname = 'phar://hio';
 $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
 
 $files = array();
@@ -17,22 +17,9 @@ $files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?
 $files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';    
 $files['e.php']   = '<?php echo "This is e\n"; ?>';                                  
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents($fname, $file);
-
-Phar::loadPhar($fname, 'test');
+Phar::loadPhar($fname, 'hio');
 
 include $fname;
 
index bd7528537ad601f7f3b9ec51fb6df8286d331e44..155a9760b1661d5a903add9875bea62e19bbae27 100755 (executable)
@@ -8,7 +8,8 @@ phar.require_hash=0
 <?php
 $fname1 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
 $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
-$pname = 'phar://test';
+$fname = $fname1;
+$pname = 'phar://hio';
 $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
 
 $files = array();
@@ -18,23 +19,11 @@ $files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?
 $files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';    
 $files['e.php']   = '<?php echo "This is e\n"; ?>';                                  
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents($fname1, $file);
 file_put_contents($fname2, $file);
 
-var_dump(Phar::loadPhar($fname1, 'test'));
+var_dump(Phar::loadPhar($fname1, 'hio'));
 var_dump(Phar::loadPhar($fname1, 'copy'));
 var_dump(Phar::loadPhar($fname2, 'copy'));
 
index 0767e3997d95dd4b25db6b00deb8663c904a0270..f8f9c12a26ae6db76b9ad216c216fd2f7781327d 100755 (executable)
@@ -17,20 +17,7 @@ $files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?
 $files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';    
 $files['e.php']   = '<?php echo "This is e\n"; ?>';                                  
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'alias';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents($fname, $file);
+include 'phar_test.inc';
 
 Phar::loadPhar($fname);
 
index 1a00893cc5a79e23a42d1ea21a3008f38b6a306f..f6c0c7ae15838a08f75627aae03b2b8a836fa99d 100644 (file)
@@ -7,37 +7,26 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-unlink('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php');
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+unlink($pname . '/b/c.php');
 ?>
 ===AFTER===
 <?php
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
 ?>
 
 ===DONE===
index ba18174bbf9e1a988579de200081701116e5b37c..c967644d990eabf2d4299cc227b5ae4508327bce 100755 (executable)
@@ -7,37 +7,26 @@ phar.readonly=1
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-unlink('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php');
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+unlink($pname . '/b/c.php');
 ?>
 ===AFTER===
 <?php
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
 ?>
 
 ===DONE===
index 69a802fad2dd7ed44ae9feffa40ea027db88fcfb..ada9bebeb53cf11895463c68bf8ff32efc35178e 100644 (file)
@@ -7,34 +7,23 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-$md5 = md5_file(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
-unlink('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php');
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+$md5 = md5_file($fname);
+unlink($pname . '/b/c.php');
 clearstatcache();
-$md52 = md5_file(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
+$md52 = md5_file($fname);
 if ($md5 == $md52) echo 'file was not modified';
 ?>
 ===AFTER===
index 93a1539e93bd8a046ac2b85051bf7a3a20ff0618..a1ab33a6b7d5b7e6bd5994e2cfbbbc9c41dbd7e9 100644 (file)
@@ -7,31 +7,20 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-$fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php', 'wb');
+$fp = fopen($pname . '/b/c.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include $pname . '/b/c.php';
 ?>
 
 ===DONE===
index 26631f4864ee966c019a317f11bc385d4bb546cc..552d31ef3067c573b7f4f5adc2ea5c40c3701e86 100755 (executable)
@@ -7,31 +7,20 @@ phar.readonly=1
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-$fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php', 'wb');
+$fp = fopen($pname . '/b/c.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include $pname . '/b/c.php';
 ?>
 ===DONE===
 --CLEAN--
index 5d6922945c5fd6d1d2d4b9f3ce039b4ab99f3e88..0594103f17ac9e9103becb14bd36b1cbdde0342a 100644 (file)
@@ -7,32 +7,21 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
+include 'phar_test.inc';
 
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-$fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/new.php', 'wb');
+$fp = fopen($pname . '/b/new.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/new.php';
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
 ?>
 
 ===DONE===
index 993b67e0d87c9823638227f0b9f349940a5192a5..ce91f378f63c8c8f24f0969db603b3db8ea8f27c 100755 (executable)
@@ -7,32 +7,21 @@ phar.readonly=1
 phar.require_hash=0
 --FILE--
 <?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
 $file = "<?php __HALT_COMPILER(); ?>";
 
 $files = array();
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-$fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/new.php', 'wb');
+include 'phar_test.inc';
+
+$fp = fopen($pname . '/b/new.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/new.php';
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
 ?>
 
 ===DONE===
index 90cf3e991d8fd9375746d81a408a1bc289e207e4..ee006e83e27b3bc378d1a621952d6cd4471f4a00 100755 (executable)
@@ -38,7 +38,7 @@ unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
 __halt_compiler();
 ?>
 --EXPECT--
-string(5) "0.8.0"
+string(5) "0.9.0"
 int(5)
 string(49) "Cannot call method on an uninitialzed Phar object"
 ===DONE===
index 164264f55692a5efced3fda7f1000cad29c338b5..9863e8da9379ec35a2360f23968fdd24865de20b 100755 (executable)
@@ -43,19 +43,7 @@ EOF;
                break;
 }
 
-$manifest = '';
-foreach($files as $name => $cont) {
-       $len = strlen($cont);
-       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, mktime (12, 0, 0, 3, 1, 2006), $len, crc32($cont), 0x00);
-}
-$alias = 'alias';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
-       $file .= $cont;
-}
-
-file_put_contents($fname, $file);
+$ftime = mktime(12, 0, 0, 3, 1, 2006);
+include 'phar_test.inc';
 
 ?>
\ No newline at end of file
diff --git a/ext/phar/tests/phar_test.inc b/ext/phar/tests/phar_test.inc
new file mode 100755 (executable)
index 0000000..2ead4d4
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+$manifest = '';
+
+foreach($files as $name => $cont)
+{
+       $ulen = strlen($cont);
+       $clen = $ulen;
+       $time = isset($ftime) ? $ftime : mktime(12, 0, 0, 3, 1, 2006);
+       $manifest .= pack('V', strlen($name)) . $name;
+       $manifest .= pack('VVVVV', $ulen, $time, $clen, crc32($cont), 0x00000000);
+}
+$alias = 'hio';
+$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest;
+$file .= pack('V', strlen($manifest)) . $manifest;
+foreach($files as $cont)
+{
+       $file .= $cont;
+}
+
+file_put_contents($fname, $file);
+
+?>
\ No newline at end of file