summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
Diffstat (limited to 'ext/phar')
-rw-r--r--ext/phar/CREDITS2
-rw-r--r--ext/phar/LICENSE95
-rw-r--r--ext/phar/Makefile.frag42
-rw-r--r--ext/phar/TODO114
-rwxr-xr-xext/phar/build_precommand.php55
-rw-r--r--ext/phar/config.m430
-rw-r--r--ext/phar/config.w3246
-rw-r--r--ext/phar/dirstream.c711
-rw-r--r--ext/phar/dirstream.h47
-rw-r--r--ext/phar/func_interceptors.c1216
-rw-r--r--ext/phar/func_interceptors.h38
-rw-r--r--ext/phar/gdbhelp122
-rw-r--r--ext/phar/makestub.php109
-rw-r--r--ext/phar/package.xml1452
-rw-r--r--ext/phar/phar.c3749
-rw-r--r--ext/phar/phar/clicommand.inc351
-rw-r--r--ext/phar/phar/directorygraphiterator.inc34
-rw-r--r--ext/phar/phar/directorytreeiterator.inc54
-rw-r--r--ext/phar/phar/invertedregexiterator.inc27
-rw-r--r--ext/phar/phar/phar.inc80
-rwxr-xr-xext/phar/phar/phar.php56
-rw-r--r--ext/phar/phar/pharcommand.inc1595
-rw-r--r--ext/phar/phar_internal.h722
-rw-r--r--ext/phar/phar_object.c5487
-rw-r--r--ext/phar/phar_path_check.c185
-rw-r--r--ext/phar/phar_path_check.re97
-rw-r--r--ext/phar/pharzip.h243
-rw-r--r--ext/phar/php_phar.h47
-rw-r--r--ext/phar/shortarc.php295
-rw-r--r--ext/phar/stream.c1035
-rw-r--r--ext/phar/stream.h48
-rw-r--r--ext/phar/stub.h34
-rw-r--r--ext/phar/tar.c1319
-rw-r--r--ext/phar/tar.h101
-rw-r--r--ext/phar/tests/001.phpt12
-rw-r--r--ext/phar/tests/002.phpt17
-rw-r--r--ext/phar/tests/003.phpt13
-rw-r--r--ext/phar/tests/003a.phpt14
-rw-r--r--ext/phar/tests/004.phpt14
-rw-r--r--ext/phar/tests/005.phpt14
-rw-r--r--ext/phar/tests/006.phpt14
-rw-r--r--ext/phar/tests/007.phpt14
-rw-r--r--ext/phar/tests/008.phpt21
-rw-r--r--ext/phar/tests/009.phpt23
-rw-r--r--ext/phar/tests/010.phpt29
-rw-r--r--ext/phar/tests/011.phpt30
-rw-r--r--ext/phar/tests/012.phpt28
-rw-r--r--ext/phar/tests/013.phpt23
-rw-r--r--ext/phar/tests/014.phpt23
-rw-r--r--ext/phar/tests/015.phpt23
-rw-r--r--ext/phar/tests/015b.phpt23
-rw-r--r--ext/phar/tests/016.phpt39
-rw-r--r--ext/phar/tests/016b.phpt24
-rw-r--r--ext/phar/tests/017.phpt34
-rw-r--r--ext/phar/tests/017U.phpt34
-rw-r--r--ext/phar/tests/018.phpt36
-rw-r--r--ext/phar/tests/018U.phpt36
-rw-r--r--ext/phar/tests/019.phpt41
-rw-r--r--ext/phar/tests/019b.phpt68
-rw-r--r--ext/phar/tests/019bU.phpt70
-rw-r--r--ext/phar/tests/019c.phpt76
-rw-r--r--ext/phar/tests/019cU.phpt76
-rw-r--r--ext/phar/tests/020.phpt136
-rw-r--r--ext/phar/tests/021.phpt85
-rw-r--r--ext/phar/tests/022.phpt110
-rw-r--r--ext/phar/tests/023.phpt32
-rw-r--r--ext/phar/tests/024.phpt32
-rw-r--r--ext/phar/tests/025.phpt32
-rw-r--r--ext/phar/tests/026.phpt34
-rw-r--r--ext/phar/tests/027.phpt97
-rw-r--r--ext/phar/tests/027U.phpt97
-rw-r--r--ext/phar/tests/028.phpt47
-rw-r--r--ext/phar/tests/029.phpt50
-rw-r--r--ext/phar/tests/030.phpt48
-rw-r--r--ext/phar/tests/031.phpt31
-rw-r--r--ext/phar/tests/032.phpt29
-rw-r--r--ext/phar/tests/033.phpt47
-rw-r--r--ext/phar/tests/033a.phpt36
-rw-r--r--ext/phar/tests/addfuncs.phpt53
-rw-r--r--ext/phar/tests/alias_acrobatics.phpt46
-rw-r--r--ext/phar/tests/badparameters.phpt186
-rw-r--r--ext/phar/tests/bug13727.phpt4136
-rw-r--r--ext/phar/tests/bug13786.phpt32
-rw-r--r--ext/phar/tests/bug45218_SLOWTEST.phpt6092
-rw-r--r--ext/phar/tests/bug45218_SLOWTESTU.phpt6092
-rw-r--r--ext/phar/tests/bug46032.phpt34
-rw-r--r--ext/phar/tests/bug46060.phpt32
-rw-r--r--ext/phar/tests/bug46178.phpt20
-rw-r--r--ext/phar/tests/bug47085.phpt24
-rw-r--r--ext/phar/tests/bug48377.2.phpt25
-rw-r--r--ext/phar/tests/bug48377.phpt29
-rw-r--r--ext/phar/tests/bug52013.phpt40
-rw-r--r--ext/phar/tests/bug53872.phpt28
-rw-r--r--ext/phar/tests/bug53872/first.txt1
-rw-r--r--ext/phar/tests/bug53872/second.txt0
-rw-r--r--ext/phar/tests/bug53872/third.txt1
-rw-r--r--ext/phar/tests/bug54395.phpt16
-rw-r--r--ext/phar/tests/bug60164.phpt21
-rw-r--r--ext/phar/tests/bug60261.phpt19
-rw-r--r--ext/phar/tests/cache_list/copyonwrite1.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite10.phar.phpt24
-rw-r--r--ext/phar/tests/cache_list/copyonwrite11.phar.phpt22
-rw-r--r--ext/phar/tests/cache_list/copyonwrite12.phar.phpt24
-rw-r--r--ext/phar/tests/cache_list/copyonwrite13.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite14.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite15.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite16.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite17.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite18.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite19.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite2.phar.phpt17
-rw-r--r--ext/phar/tests/cache_list/copyonwrite20.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite21.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite22.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite23.phar.phpt17
-rw-r--r--ext/phar/tests/cache_list/copyonwrite24.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite25.phar.phpt16
-rw-r--r--ext/phar/tests/cache_list/copyonwrite3.phar.phpt16
-rw-r--r--ext/phar/tests/cache_list/copyonwrite4.phar.phpt15
-rw-r--r--ext/phar/tests/cache_list/copyonwrite4a.phpt20
-rw-r--r--ext/phar/tests/cache_list/copyonwrite5.phar.phpt27
-rw-r--r--ext/phar/tests/cache_list/copyonwrite6.phar.phpt29
-rw-r--r--ext/phar/tests/cache_list/copyonwrite7.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite8.phar.phpt14
-rw-r--r--ext/phar/tests/cache_list/copyonwrite9.phar.phpt23
-rw-r--r--ext/phar/tests/cache_list/files/blog.pharbin0 -> 468 bytes
-rw-r--r--ext/phar/tests/cache_list/files/blog.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/config.xml9
-rw-r--r--ext/phar/tests/cache_list/files/extracted.inc1
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller.pharbin0 -> 331 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller10.pharbin0 -> 591 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller11.pharbin0 -> 578 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller12.pharbin0 -> 588 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller13.pharbin0 -> 330 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller13.phar.inc14
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller14.pharbin0 -> 450 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller14.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller16.pharbin0 -> 330 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller16.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller17.pharbin0 -> 315 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller17.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller18.pharbin0 -> 331 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller18.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller19.pharbin0 -> 560 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller19.phar.inc25
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller2.pharbin0 -> 297 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller3.pharbin0 -> 437 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller4.pharbin0 -> 433 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller5.pharbin0 -> 327 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller6.pharbin0 -> 328 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller7.pharbin0 -> 329 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller8.pharbin0 -> 8970 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller8.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller9.pharbin0 -> 448 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/cache_list/files/md5.pharbin0 -> 107 bytes
-rw-r--r--ext/phar/tests/cache_list/files/nophar.pharbin0 -> 7049 bytes
-rw-r--r--ext/phar/tests/cache_list/files/nophar.phar.inc10
-rw-r--r--ext/phar/tests/cache_list/files/openssl.pharbin0 -> 6901 bytes
-rw-r--r--ext/phar/tests/cache_list/files/openssl.phar.pubkey6
-rw-r--r--ext/phar/tests/cache_list/files/phar_oo_test.inc49
-rw-r--r--ext/phar/tests/cache_list/files/phar_test.inc78
-rw-r--r--ext/phar/tests/cache_list/files/private.pem15
-rw-r--r--ext/phar/tests/cache_list/files/sha1.pharbin0 -> 111 bytes
-rw-r--r--ext/phar/tests/cache_list/files/sha256.pharbin0 -> 123 bytes
-rw-r--r--ext/phar/tests/cache_list/files/sha512.pharbin0 -> 155 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write.pharbin0 -> 285 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/write10.pharbin0 -> 324 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write10.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/write11.pharbin0 -> 284 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write11.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write12.pharbin0 -> 301 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write12.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write13.pharbin0 -> 316 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write13.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write14.pharbin0 -> 312 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write14.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/write15.pharbin0 -> 270 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write15.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write16.pharbin0 -> 327 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write16.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write17.pharbin0 -> 258 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write17.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write18.pharbin0 -> 336 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write18.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write19.pharbin0 -> 304 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write19.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write2.pharbin0 -> 425 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write2.phar.inc23
-rw-r--r--ext/phar/tests/cache_list/files/write20.pharbin0 -> 299 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write20.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write21.pharbin0 -> 297 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write21.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write22.pharbin0 -> 293 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write22.phar.inc17
-rw-r--r--ext/phar/tests/cache_list/files/write23.pharbin0 -> 366 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write23.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write24.pharbin0 -> 327 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write24.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/write25.pharbin0 -> 331 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write25.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write3.pharbin0 -> 447 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write3.phar.inc21
-rw-r--r--ext/phar/tests/cache_list/files/write4.pharbin0 -> 388 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write4.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/write5.pharbin0 -> 564 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write5.phar.inc29
-rw-r--r--ext/phar/tests/cache_list/files/write6.pharbin0 -> 675 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write6.phar.inc30
-rw-r--r--ext/phar/tests/cache_list/files/write7.pharbin0 -> 316 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write7.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/write8.pharbin0 -> 255 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write8.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/write9.pharbin0 -> 277 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write9.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/zfapp.tgzbin0 -> 1725 bytes
-rw-r--r--ext/phar/tests/cache_list/frontcontroller1.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller10.phpt25
-rw-r--r--ext/phar/tests/cache_list/frontcontroller11.phpt22
-rw-r--r--ext/phar/tests/cache_list/frontcontroller12.phpt21
-rw-r--r--ext/phar/tests/cache_list/frontcontroller13.phpt21
-rw-r--r--ext/phar/tests/cache_list/frontcontroller14.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller15.phpt21
-rw-r--r--ext/phar/tests/cache_list/frontcontroller16.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller17.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller18.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller19.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller2.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller20.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller21.phpt25
-rw-r--r--ext/phar/tests/cache_list/frontcontroller22.phpt22
-rw-r--r--ext/phar/tests/cache_list/frontcontroller23.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller24.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller25.phpt18
-rw-r--r--ext/phar/tests/cache_list/frontcontroller26.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller27.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller28.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller29.phpt17
-rw-r--r--ext/phar/tests/cache_list/frontcontroller3.phpt20
-rw-r--r--ext/phar/tests/cache_list/frontcontroller30.phpt14
-rw-r--r--ext/phar/tests/cache_list/frontcontroller31.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller32.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller33.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller34.phpt19
-rw-r--r--ext/phar/tests/cache_list/frontcontroller4.phpt15
-rw-r--r--ext/phar/tests/cache_list/frontcontroller5.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller6.phpt23
-rw-r--r--ext/phar/tests/cache_list/frontcontroller7.phpt16
-rw-r--r--ext/phar/tests/cache_list/frontcontroller8.phpt23
-rw-r--r--ext/phar/tests/cache_list/frontcontroller9.phpt20
-rw-r--r--ext/phar/tests/cached_manifest_1.phpt39
-rw-r--r--ext/phar/tests/cached_manifest_1U.phpt39
-rw-r--r--ext/phar/tests/create_new_and_modify.phpt48
-rw-r--r--ext/phar/tests/create_new_phar.phpt21
-rw-r--r--ext/phar/tests/create_new_phar_b.phpt27
-rw-r--r--ext/phar/tests/create_new_phar_c.phpt29
-rw-r--r--ext/phar/tests/create_path_error.phpt62
-rw-r--r--ext/phar/tests/delete.phpt31
-rw-r--r--ext/phar/tests/delete_in_phar.phpt48
-rw-r--r--ext/phar/tests/delete_in_phar_b.phpt46
-rw-r--r--ext/phar/tests/delete_in_phar_confirm.phpt51
-rw-r--r--ext/phar/tests/dir.phpt92
-rw-r--r--ext/phar/tests/fatal_error_webphar.phpt18
-rw-r--r--ext/phar/tests/fgc_edgecases.phpt99
-rw-r--r--ext/phar/tests/file_get_contents.phpt30
-rw-r--r--ext/phar/tests/files/blog.pharbin0 -> 523 bytes
-rw-r--r--ext/phar/tests/files/blog.phar.inc22
-rw-r--r--ext/phar/tests/files/config.xml9
-rw-r--r--ext/phar/tests/files/extracted.inc1
-rw-r--r--ext/phar/tests/files/frontcontroller.pharbin0 -> 331 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/files/frontcontroller10.pharbin0 -> 591 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/files/frontcontroller11.pharbin0 -> 578 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/files/frontcontroller12.pharbin0 -> 588 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/files/frontcontroller13.pharbin0 -> 330 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller13.phar.inc14
-rw-r--r--ext/phar/tests/files/frontcontroller14.pharbin0 -> 450 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller14.phar.inc19
-rw-r--r--ext/phar/tests/files/frontcontroller16.pharbin0 -> 330 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller16.phar.inc16
-rw-r--r--ext/phar/tests/files/frontcontroller17.pharbin0 -> 315 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller17.phar.inc16
-rw-r--r--ext/phar/tests/files/frontcontroller18.pharbin0 -> 331 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller18.phar.inc19
-rw-r--r--ext/phar/tests/files/frontcontroller19.pharbin0 -> 560 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller19.phar.inc25
-rw-r--r--ext/phar/tests/files/frontcontroller2.pharbin0 -> 297 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/files/frontcontroller3.pharbin0 -> 438 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/files/frontcontroller4.pharbin0 -> 433 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/files/frontcontroller5.pharbin0 -> 327 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/files/frontcontroller6.pharbin0 -> 328 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/files/frontcontroller7.pharbin0 -> 329 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/files/frontcontroller8.pharbin0 -> 8970 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller8.phar.inc19
-rw-r--r--ext/phar/tests/files/frontcontroller9.pharbin0 -> 448 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/files/include_path.pharbin0 -> 470 bytes
-rw-r--r--ext/phar/tests/files/include_path.phar.inc19
-rw-r--r--ext/phar/tests/files/include_path2.pharbin0 -> 6837 bytes
-rw-r--r--ext/phar/tests/files/md5.pharbin0 -> 107 bytes
-rw-r--r--ext/phar/tests/files/nophar.pharbin0 -> 7049 bytes
-rw-r--r--ext/phar/tests/files/nophar.phar.inc10
-rw-r--r--ext/phar/tests/files/notbogus.zipbin0 -> 299 bytes
-rw-r--r--ext/phar/tests/files/openssl.cnf43
-rw-r--r--ext/phar/tests/files/openssl.pharbin0 -> 6901 bytes
-rw-r--r--ext/phar/tests/files/openssl.phar.pubkey6
-rw-r--r--ext/phar/tests/files/pear2coverage.phar.phpbin0 -> 55262 bytes
-rw-r--r--ext/phar/tests/files/phar_oo_test.inc49
-rw-r--r--ext/phar/tests/files/phar_test.inc78
-rw-r--r--ext/phar/tests/files/private.pem15
-rw-r--r--ext/phar/tests/files/sha1.pharbin0 -> 111 bytes
-rw-r--r--ext/phar/tests/files/sha256.pharbin0 -> 123 bytes
-rw-r--r--ext/phar/tests/files/sha512.pharbin0 -> 155 bytes
-rw-r--r--ext/phar/tests/files/stuboflength1041.pharbin0 -> 1168 bytes
-rw-r--r--ext/phar/tests/files/stuboflength1041.phar.inc21
-rw-r--r--ext/phar/tests/files/zfapp.tgzbin0 -> 1725 bytes
-rw-r--r--ext/phar/tests/fopen.phpt43
-rw-r--r--ext/phar/tests/fopen5.2.phpt43
-rw-r--r--ext/phar/tests/fopen_edgecases.phpt124
-rw-r--r--ext/phar/tests/fopen_edgecases2.phpt44
-rw-r--r--ext/phar/tests/fopen_edgecases2U.phpt46
-rw-r--r--ext/phar/tests/front.phar.phpt25
-rw-r--r--ext/phar/tests/frontcontroller1.phpt15
-rw-r--r--ext/phar/tests/frontcontroller10.phpt24
-rw-r--r--ext/phar/tests/frontcontroller11.phpt21
-rw-r--r--ext/phar/tests/frontcontroller12.phpt20
-rw-r--r--ext/phar/tests/frontcontroller13.phpt20
-rw-r--r--ext/phar/tests/frontcontroller14.phpt15
-rw-r--r--ext/phar/tests/frontcontroller15.phpt20
-rw-r--r--ext/phar/tests/frontcontroller16.phpt17
-rw-r--r--ext/phar/tests/frontcontroller17.phpt16
-rw-r--r--ext/phar/tests/frontcontroller18.phpt16
-rw-r--r--ext/phar/tests/frontcontroller19.phpt16
-rw-r--r--ext/phar/tests/frontcontroller2.phpt16
-rw-r--r--ext/phar/tests/frontcontroller20.phpt16
-rw-r--r--ext/phar/tests/frontcontroller21.phpt24
-rw-r--r--ext/phar/tests/frontcontroller22.phpt21
-rw-r--r--ext/phar/tests/frontcontroller23.phpt17
-rw-r--r--ext/phar/tests/frontcontroller24.phpt16
-rw-r--r--ext/phar/tests/frontcontroller25.phpt17
-rw-r--r--ext/phar/tests/frontcontroller26.phpt14
-rw-r--r--ext/phar/tests/frontcontroller27.phpt16
-rw-r--r--ext/phar/tests/frontcontroller28.phpt16
-rw-r--r--ext/phar/tests/frontcontroller29.phpt16
-rw-r--r--ext/phar/tests/frontcontroller3.phpt19
-rw-r--r--ext/phar/tests/frontcontroller30.phpt12
-rw-r--r--ext/phar/tests/frontcontroller31.phpt15
-rw-r--r--ext/phar/tests/frontcontroller32.phpt15
-rw-r--r--ext/phar/tests/frontcontroller33.phpt15
-rw-r--r--ext/phar/tests/frontcontroller34.phpt18
-rw-r--r--ext/phar/tests/frontcontroller4.phpt13
-rw-r--r--ext/phar/tests/frontcontroller5.phpt14
-rw-r--r--ext/phar/tests/frontcontroller6.phpt21
-rw-r--r--ext/phar/tests/frontcontroller7.phpt14
-rw-r--r--ext/phar/tests/frontcontroller8.phpt21
-rw-r--r--ext/phar/tests/frontcontroller9.phpt19
-rw-r--r--ext/phar/tests/include_path.phpt34
-rw-r--r--ext/phar/tests/include_path_advanced.phpt12
-rw-r--r--ext/phar/tests/ini_set.phpt34
-rw-r--r--ext/phar/tests/ini_set_off.phpt88
-rw-r--r--ext/phar/tests/ini_set_offU.phpt88
-rw-r--r--ext/phar/tests/invalid_alias.phpt45
-rw-r--r--ext/phar/tests/invalid_setstubalias.phpt47
-rw-r--r--ext/phar/tests/metadata_read.phpt64
-rw-r--r--ext/phar/tests/metadata_readU.phpt64
-rw-r--r--ext/phar/tests/metadata_write.phpt65
-rw-r--r--ext/phar/tests/metadata_writeU.phpt65
-rw-r--r--ext/phar/tests/metadata_write_commit.phpt82
-rw-r--r--ext/phar/tests/metadata_write_commitU.phpt82
-rw-r--r--ext/phar/tests/mkdir.phpt47
-rw-r--r--ext/phar/tests/mounteddir.phpt118
-rw-r--r--ext/phar/tests/mounteddirU.phpt118
-rw-r--r--ext/phar/tests/nophar.phpt14
-rw-r--r--ext/phar/tests/nophar_web.phpt11
-rw-r--r--ext/phar/tests/open_for_write_existing.phpt31
-rw-r--r--ext/phar/tests/open_for_write_existing_b.phpt45
-rw-r--r--ext/phar/tests/open_for_write_existing_b_5_2.phpt43
-rw-r--r--ext/phar/tests/open_for_write_existing_c.phpt39
-rw-r--r--ext/phar/tests/open_for_write_existing_c_5_2.phpt37
-rw-r--r--ext/phar/tests/open_for_write_newfile.phpt33
-rw-r--r--ext/phar/tests/open_for_write_newfile_b.phpt52
-rw-r--r--ext/phar/tests/open_for_write_newfile_b_5_2.phpt50
-rw-r--r--ext/phar/tests/open_for_write_newfile_c.phpt46
-rw-r--r--ext/phar/tests/open_for_write_newfile_c_5_2.phpt44
-rw-r--r--ext/phar/tests/opendir.phpt44
-rw-r--r--ext/phar/tests/opendir_edgecases.phpt61
-rw-r--r--ext/phar/tests/phar_begin_setstub_commit.phpt53
-rw-r--r--ext/phar/tests/phar_begin_setstub_commitU.phpt53
-rw-r--r--ext/phar/tests/phar_buildfromdirectory1.phpt28
-rw-r--r--ext/phar/tests/phar_buildfromdirectory2-win.phpt30
-rw-r--r--ext/phar/tests/phar_buildfromdirectory2.phpt30
-rw-r--r--ext/phar/tests/phar_buildfromdirectory3.phpt27
-rw-r--r--ext/phar/tests/phar_buildfromdirectory4.phpt51
-rw-r--r--ext/phar/tests/phar_buildfromdirectory5.phpt50
-rw-r--r--ext/phar/tests/phar_buildfromdirectory6.phpt40
-rw-r--r--ext/phar/tests/phar_buildfromiterator1.phpt28
-rw-r--r--ext/phar/tests/phar_buildfromiterator10.phpt104
-rw-r--r--ext/phar/tests/phar_buildfromiterator2.phpt26
-rw-r--r--ext/phar/tests/phar_buildfromiterator3.phpt54
-rw-r--r--ext/phar/tests/phar_buildfromiterator4.phpt83
-rw-r--r--ext/phar/tests/phar_buildfromiterator5.phpt59
-rw-r--r--ext/phar/tests/phar_buildfromiterator6.phpt60
-rw-r--r--ext/phar/tests/phar_buildfromiterator7.phpt60
-rw-r--r--ext/phar/tests/phar_buildfromiterator8.phpt95
-rw-r--r--ext/phar/tests/phar_buildfromiterator9.phpt65
-rw-r--r--ext/phar/tests/phar_bz2.phpt65
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt42
-rw-r--r--ext/phar/tests/phar_construct_invalidurl.phpt30
-rw-r--r--ext/phar/tests/phar_convert_again.phpt205
-rw-r--r--ext/phar/tests/phar_convert_repeated.phpt149
-rw-r--r--ext/phar/tests/phar_convert_repeated_b.phpt118
-rw-r--r--ext/phar/tests/phar_convert_tar.phpt57
-rw-r--r--ext/phar/tests/phar_convert_tar2.phpt64
-rw-r--r--ext/phar/tests/phar_convert_tar3.phpt65
-rw-r--r--ext/phar/tests/phar_convert_zip.phpt56
-rw-r--r--ext/phar/tests/phar_copy.phpt84
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt45
-rw-r--r--ext/phar/tests/phar_createdefaultstub.phpt929
-rw-r--r--ext/phar/tests/phar_ctx_001.phpt100
-rw-r--r--ext/phar/tests/phar_decompress.phpt69
-rw-r--r--ext/phar/tests/phar_dir_iterate.phpt32
-rw-r--r--ext/phar/tests/phar_dotted_path.phpt41
-rw-r--r--ext/phar/tests/phar_extract.phpt150
-rw-r--r--ext/phar/tests/phar_extract2.phpt60
-rw-r--r--ext/phar/tests/phar_extract3.phpt46
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_001.phpt26
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_001a.phpt28
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_002.phpt31
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_002a.phpt32
-rw-r--r--ext/phar/tests/phar_get_supportedcomp1.phpt22
-rw-r--r--ext/phar/tests/phar_get_supportedcomp2.phpt20
-rw-r--r--ext/phar/tests/phar_get_supportedcomp3.phpt20
-rw-r--r--ext/phar/tests/phar_get_supportedcomp4.phpt16
-rw-r--r--ext/phar/tests/phar_gobyebye-win32.phpt48
-rw-r--r--ext/phar/tests/phar_gobyebye.phpt47
-rw-r--r--ext/phar/tests/phar_gzip.phpt62
-rw-r--r--ext/phar/tests/phar_gzipU.phpt57
-rw-r--r--ext/phar/tests/phar_isvalidpharfilename.phpt140
-rw-r--r--ext/phar/tests/phar_magic.phpt34
-rw-r--r--ext/phar/tests/phar_metadata_read.phpt98
-rw-r--r--ext/phar/tests/phar_metadata_readU.phpt98
-rw-r--r--ext/phar/tests/phar_metadata_write.phpt74
-rw-r--r--ext/phar/tests/phar_metadata_writeU.phpt74
-rw-r--r--ext/phar/tests/phar_mount.phpt63
-rw-r--r--ext/phar/tests/phar_offset_check.phpt78
-rw-r--r--ext/phar/tests/phar_offset_get_error.phpt51
-rw-r--r--ext/phar/tests/phar_oo_001.phpt57
-rw-r--r--ext/phar/tests/phar_oo_001U.phpt57
-rw-r--r--ext/phar/tests/phar_oo_002.phpt140
-rw-r--r--ext/phar/tests/phar_oo_002U.phpt140
-rw-r--r--ext/phar/tests/phar_oo_003.phpt45
-rw-r--r--ext/phar/tests/phar_oo_004.phpt129
-rw-r--r--ext/phar/tests/phar_oo_004U.phpt129
-rw-r--r--ext/phar/tests/phar_oo_005.phpt64
-rw-r--r--ext/phar/tests/phar_oo_005U.phpt63
-rw-r--r--ext/phar/tests/phar_oo_005_5.2.phpt63
-rw-r--r--ext/phar/tests/phar_oo_006.phpt52
-rw-r--r--ext/phar/tests/phar_oo_007.phpt87
-rw-r--r--ext/phar/tests/phar_oo_008.phpt119
-rw-r--r--ext/phar/tests/phar_oo_009.phpt56
-rw-r--r--ext/phar/tests/phar_oo_010.phpt55
-rw-r--r--ext/phar/tests/phar_oo_011.phpt36
-rw-r--r--ext/phar/tests/phar_oo_011b.phpt39
-rw-r--r--ext/phar/tests/phar_oo_012.phpt37
-rw-r--r--ext/phar/tests/phar_oo_012_confirm.phpt40
-rw-r--r--ext/phar/tests/phar_oo_012b.phpt42
-rw-r--r--ext/phar/tests/phar_oo_compressallbz2.phpt66
-rw-r--r--ext/phar/tests/phar_oo_compressallgz.phpt71
-rw-r--r--ext/phar/tests/phar_oo_compressed_001.phpt68
-rw-r--r--ext/phar/tests/phar_oo_compressed_001b.phpt68
-rw-r--r--ext/phar/tests/phar_oo_compressed_002.phpt73
-rw-r--r--ext/phar/tests/phar_oo_compressed_002b.phpt73
-rw-r--r--ext/phar/tests/phar_oo_getcontents.phpt39
-rw-r--r--ext/phar/tests/phar_oo_getcontentsgz.phpt34
-rw-r--r--ext/phar/tests/phar_oo_getmodified.phpt36
-rw-r--r--ext/phar/tests/phar_oo_iswriteable.phpt84
-rw-r--r--ext/phar/tests/phar_oo_nosig.phpt24
-rw-r--r--ext/phar/tests/phar_oo_uncompressall.phpt80
-rw-r--r--ext/phar/tests/phar_running.phpt29
-rw-r--r--ext/phar/tests/phar_setalias.phpt36
-rw-r--r--ext/phar/tests/phar_setalias2.phpt51
-rw-r--r--ext/phar/tests/phar_setdefaultstub.phpt944
-rw-r--r--ext/phar/tests/phar_setsignaturealgo1.phpt70
-rw-r--r--ext/phar/tests/phar_setsignaturealgo2.phpt90
-rw-r--r--ext/phar/tests/phar_stub.phpt92
-rw-r--r--ext/phar/tests/phar_stub_error.phpt56
-rw-r--r--ext/phar/tests/phar_stub_write.phpt64
-rw-r--r--ext/phar/tests/phar_stub_write_file.phpt65
-rw-r--r--ext/phar/tests/phar_unlinkarchive.phpt108
-rw-r--r--ext/phar/tests/pharfileinfo_chmod.phpt33
-rw-r--r--ext/phar/tests/pharfileinfo_compression.phpt94
-rw-r--r--ext/phar/tests/pharfileinfo_construct.phpt54
-rw-r--r--ext/phar/tests/pharfileinfo_destruct.phpt25
-rw-r--r--ext/phar/tests/pharfileinfo_getcrc32.phpt49
-rw-r--r--ext/phar/tests/pharfileinfo_setmetadata.phpt53
-rw-r--r--ext/phar/tests/phpinfo_001.phpt68
-rw-r--r--ext/phar/tests/phpinfo_002.phpt44
-rw-r--r--ext/phar/tests/phpinfo_003.phpt44
-rw-r--r--ext/phar/tests/phpinfo_004.phpt75
-rw-r--r--ext/phar/tests/readfile.phpt30
-rw-r--r--ext/phar/tests/readfile_edgecases.phpt63
-rw-r--r--ext/phar/tests/readfile_edgecasesU.phpt61
-rw-r--r--ext/phar/tests/refcount1.phpt62
-rw-r--r--ext/phar/tests/refcount1_5_2.phpt64
-rw-r--r--ext/phar/tests/rename.phpt32
-rw-r--r--ext/phar/tests/rename_dir.phpt33
-rw-r--r--ext/phar/tests/rename_dir_and_mount.phpt65
-rw-r--r--ext/phar/tests/rmdir.phpt35
-rw-r--r--ext/phar/tests/security.phpt36
-rw-r--r--ext/phar/tests/stat.phpt225
-rw-r--r--ext/phar/tests/stat2.phpt61
-rw-r--r--ext/phar/tests/stat2_5.3.phpt61
-rw-r--r--ext/phar/tests/tar/033.phpt50
-rw-r--r--ext/phar/tests/tar/033a.phpt45
-rw-r--r--ext/phar/tests/tar/alias_acrobatics.phpt46
-rw-r--r--ext/phar/tests/tar/all.phpt59
-rw-r--r--ext/phar/tests/tar/allU.phpt59
-rw-r--r--ext/phar/tests/tar/badalias.phpt25
-rw-r--r--ext/phar/tests/tar/badchecksum.phpt30
-rw-r--r--ext/phar/tests/tar/bignames.phpt57
-rw-r--r--ext/phar/tests/tar/bignames_overflow.phpt40
-rw-r--r--ext/phar/tests/tar/bug49910.phpt50
-rw-r--r--ext/phar/tests/tar/create_new_and_modify.phpt45
-rw-r--r--ext/phar/tests/tar/create_new_phar_b.phpt27
-rw-r--r--ext/phar/tests/tar/delete.phpt32
-rw-r--r--ext/phar/tests/tar/delete_in_phar.phpt49
-rw-r--r--ext/phar/tests/tar/delete_in_phar_b.phpt49
-rw-r--r--ext/phar/tests/tar/delete_in_phar_confirm.phpt52
-rw-r--r--ext/phar/tests/tar/dir.phpt45
-rw-r--r--ext/phar/tests/tar/exists_as_phar.phpt38
-rw-r--r--ext/phar/tests/tar/files/Net_URL-1.0.15.tgzbin0 -> 6303 bytes
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgzbin0 -> 1284 bytes
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey9
-rw-r--r--ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgzbin0 -> 30191 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias1.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias2.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias3.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias4.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias5.phar.tarbin0 -> 3584 bytes
-rw-r--r--ext/phar/tests/tar/files/biglink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/corrupt_tarmaker.php.inc177
-rw-r--r--ext/phar/tests/tar/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/tar/files/frontcontroller.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller10.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller11.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller2.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller5.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller6.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller7.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller8.phar.inc13
-rw-r--r--ext/phar/tests/tar/files/frontcontroller8.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/tar/files/frontcontroller9.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/links.phar.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/links.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/make.dangerous.tar.php.inc170
-rw-r--r--ext/phar/tests/tar/files/make_invalid_tar.php.inc9
-rw-r--r--ext/phar/tests/tar/files/subdirlink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/tarmaker.php.inc169
-rw-r--r--ext/phar/tests/tar/files/tinylink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/trunc.tarbin0 -> 800 bytes
-rw-r--r--ext/phar/tests/tar/frontcontroller1.phar.phpt15
-rw-r--r--ext/phar/tests/tar/frontcontroller10.phar.phpt24
-rw-r--r--ext/phar/tests/tar/frontcontroller11.phar.phpt21
-rw-r--r--ext/phar/tests/tar/frontcontroller12.phar.phpt20
-rw-r--r--ext/phar/tests/tar/frontcontroller13.phar.phpt20
-rw-r--r--ext/phar/tests/tar/frontcontroller14.phar.phpt15
-rw-r--r--ext/phar/tests/tar/frontcontroller15.phar.phpt20
-rw-r--r--ext/phar/tests/tar/frontcontroller16.phar.phpt17
-rw-r--r--ext/phar/tests/tar/frontcontroller17.phar.phpt16
-rw-r--r--ext/phar/tests/tar/frontcontroller18.phar.phpt16
-rw-r--r--ext/phar/tests/tar/frontcontroller19.phar.phpt16
-rw-r--r--ext/phar/tests/tar/frontcontroller2.phar.phpt16
-rw-r--r--ext/phar/tests/tar/frontcontroller20.phar.phpt16
-rw-r--r--ext/phar/tests/tar/frontcontroller21.phar.phpt24
-rw-r--r--ext/phar/tests/tar/frontcontroller3.phar.phpt19
-rw-r--r--ext/phar/tests/tar/frontcontroller4.phar.phpt13
-rw-r--r--ext/phar/tests/tar/frontcontroller5.phar.phpt14
-rw-r--r--ext/phar/tests/tar/frontcontroller6.phar.phpt21
-rw-r--r--ext/phar/tests/tar/frontcontroller7.phar.phpt14
-rw-r--r--ext/phar/tests/tar/frontcontroller8.phar.phpt21
-rw-r--r--ext/phar/tests/tar/frontcontroller9.phar.phpt19
-rw-r--r--ext/phar/tests/tar/links.phpt35
-rw-r--r--ext/phar/tests/tar/links2.phpt35
-rw-r--r--ext/phar/tests/tar/links3.phpt21
-rw-r--r--ext/phar/tests/tar/links4.phpt21
-rw-r--r--ext/phar/tests/tar/links5.phpt21
-rw-r--r--ext/phar/tests/tar/links6.phpt29
-rw-r--r--ext/phar/tests/tar/open_for_write_existing.phpt42
-rw-r--r--ext/phar/tests/tar/open_for_write_existing_b.phpt59
-rw-r--r--ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt57
-rw-r--r--ext/phar/tests/tar/open_for_write_existing_c.phpt53
-rw-r--r--ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt51
-rw-r--r--ext/phar/tests/tar/open_for_write_newfile.phpt44
-rw-r--r--ext/phar/tests/tar/open_for_write_newfile_b.phpt64
-rw-r--r--ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt62
-rw-r--r--ext/phar/tests/tar/open_for_write_newfile_c.phpt57
-rw-r--r--ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt55
-rw-r--r--ext/phar/tests/tar/phar_begin_setstub_commit.phpt54
-rw-r--r--ext/phar/tests/tar/phar_begin_setstub_commitU.phpt54
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator4.phpt66
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator5.phpt59
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator6.phpt60
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator7.phpt60
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator8.phpt73
-rw-r--r--ext/phar/tests/tar/phar_buildfromiterator9.phpt65
-rw-r--r--ext/phar/tests/tar/phar_commitwrite.phpt47
-rw-r--r--ext/phar/tests/tar/phar_convert_phar.phpt58
-rw-r--r--ext/phar/tests/tar/phar_convert_phar2.phpt62
-rw-r--r--ext/phar/tests/tar/phar_convert_phar3.phpt62
-rw-r--r--ext/phar/tests/tar/phar_convert_phar4.phpt71
-rw-r--r--ext/phar/tests/tar/phar_copy.phpt56
-rw-r--r--ext/phar/tests/tar/phar_magic.phpt36
-rw-r--r--ext/phar/tests/tar/phar_setalias.phpt51
-rw-r--r--ext/phar/tests/tar/phar_setalias2.phpt53
-rw-r--r--ext/phar/tests/tar/phar_setdefaultstub.phpt80
-rw-r--r--ext/phar/tests/tar/phar_setsignaturealgo2.phpt91
-rw-r--r--ext/phar/tests/tar/phar_stub.phpt75
-rw-r--r--ext/phar/tests/tar/phar_stub_error.phpt55
-rw-r--r--ext/phar/tests/tar/refcount1.phpt74
-rw-r--r--ext/phar/tests/tar/refcount1_5_2.phpt64
-rw-r--r--ext/phar/tests/tar/rename.phpt42
-rw-r--r--ext/phar/tests/tar/rename_dir.phpt42
-rw-r--r--ext/phar/tests/tar/require_hash.phpt57
-rw-r--r--ext/phar/tests/tar/rmdir.phpt46
-rw-r--r--ext/phar/tests/tar/tar_001.phpt31
-rw-r--r--ext/phar/tests/tar/tar_002.phpt34
-rw-r--r--ext/phar/tests/tar/tar_003.phpt71
-rw-r--r--ext/phar/tests/tar/tar_004.phpt42
-rw-r--r--ext/phar/tests/tar/tar_004U.phpt42
-rw-r--r--ext/phar/tests/tar/tar_bz2.phpt63
-rw-r--r--ext/phar/tests/tar/tar_bz2U.phpt63
-rw-r--r--ext/phar/tests/tar/tar_gzip.phpt55
-rw-r--r--ext/phar/tests/tar/tar_gzipU.phpt55
-rw-r--r--ext/phar/tests/tar/tar_makebz2.phpt40
-rw-r--r--ext/phar/tests/tar/tar_makegz.phpt41
-rw-r--r--ext/phar/tests/tar/tar_nohash.phpt23
-rw-r--r--ext/phar/tests/tar/tar_nostub.phpt49
-rw-r--r--ext/phar/tests/tar/tar_openssl_hash.phpt22
-rw-r--r--ext/phar/tests/tar/truncated.phpt22
-rw-r--r--ext/phar/tests/test_alias_unset.phpt45
-rw-r--r--ext/phar/tests/test_signaturealgos.phpt39
-rw-r--r--ext/phar/tests/test_unset.phpt42
-rw-r--r--ext/phar/tests/webphar_compilefail.phpt17
-rw-r--r--ext/phar/tests/withphar.phpt14
-rw-r--r--ext/phar/tests/withphar_web.phpt16
-rw-r--r--ext/phar/tests/zf_test.phpt50
-rw-r--r--ext/phar/tests/zip/033.phpt56
-rw-r--r--ext/phar/tests/zip/033a.phpt45
-rw-r--r--ext/phar/tests/zip/alias_acrobatics.phpt46
-rw-r--r--ext/phar/tests/zip/all.phpt66
-rw-r--r--ext/phar/tests/zip/allU.phpt65
-rw-r--r--ext/phar/tests/zip/badalias.phpt25
-rw-r--r--ext/phar/tests/zip/bug48791.phpt15
-rw-r--r--ext/phar/tests/zip/bzip2.phpt83
-rw-r--r--ext/phar/tests/zip/corrupt_001.phpt23
-rw-r--r--ext/phar/tests/zip/corrupt_002.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_003.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_004.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_005.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_006.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_007.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_008.phpt101
-rw-r--r--ext/phar/tests/zip/corrupt_009.phpt17
-rw-r--r--ext/phar/tests/zip/corrupt_010.phpt17
-rw-r--r--ext/phar/tests/zip/create_new_and_modify.phpt45
-rw-r--r--ext/phar/tests/zip/create_new_phar_b.phpt27
-rw-r--r--ext/phar/tests/zip/delete.phpt31
-rw-r--r--ext/phar/tests/zip/delete_in_phar.phpt49
-rw-r--r--ext/phar/tests/zip/delete_in_phar_b.phpt48
-rw-r--r--ext/phar/tests/zip/delete_in_phar_confirm.phpt53
-rw-r--r--ext/phar/tests/zip/dir.phpt43
-rw-r--r--ext/phar/tests/zip/exists_as_phar.phpt38
-rw-r--r--ext/phar/tests/zip/files/badalias1.phar.zipbin0 -> 353 bytes
-rw-r--r--ext/phar/tests/zip/files/badalias2.phar.zipbin0 -> 353 bytes
-rw-r--r--ext/phar/tests/zip/files/badalias3.phar.zipbin0 -> 353 bytes
-rw-r--r--ext/phar/tests/zip/files/badalias4.phar.zipbin0 -> 353 bytes
-rw-r--r--ext/phar/tests/zip/files/badalias5.phar.zipbin0 -> 353 bytes
-rw-r--r--ext/phar/tests/zip/files/bz2_alias.phar.zipbin0 -> 105534 bytes
-rw-r--r--ext/phar/tests/zip/files/bzip2.zipbin0 -> 603 bytes
-rw-r--r--ext/phar/tests/zip/files/cdir_offset.zipbin0 -> 191 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup1.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup10.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup14.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup18.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup19.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup2.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup3.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup4.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup5.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup6.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup7.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup9.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup97.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsup98.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/compress_unsupunknown.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/corrupt2.php.inc60
-rw-r--r--ext/phar/tests/zip/files/corrupt3.php.inc9
-rw-r--r--ext/phar/tests/zip/files/corrupt_count1.php.inc11
-rw-r--r--ext/phar/tests/zip/files/corrupt_zipmaker.php.inc332
-rw-r--r--ext/phar/tests/zip/files/count1.zipbin0 -> 191 bytes
-rw-r--r--ext/phar/tests/zip/files/count2.zipbin0 -> 191 bytes
-rw-r--r--ext/phar/tests/zip/files/disknumber.zipbin0 -> 105 bytes
-rw-r--r--ext/phar/tests/zip/files/encrypted.zipbin0 -> 191 bytes
-rw-r--r--ext/phar/tests/zip/files/extralen_toolong.zipbin0 -> 112 bytes
-rw-r--r--ext/phar/tests/zip/files/filecomment.zipbin0 -> 191 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.zipbin0 -> 804 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.zipbin0 -> 796 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.zipbin0 -> 783 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.zipbin0 -> 793 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.zipbin0 -> 677 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.zipbin0 -> 818 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.zipbin0 -> 813 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.zipbin0 -> 707 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.zipbin0 -> 708 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.zipbin0 -> 709 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.inc13
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.zipbin0 -> 896 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.zipbin0 -> 923 bytes
-rw-r--r--ext/phar/tests/zip/files/make_invalid_tar.php.inc12
-rw-r--r--ext/phar/tests/zip/files/metadata.phar.inc11
-rw-r--r--ext/phar/tests/zip/files/metadata.phar.zipbin0 -> 779 bytes
-rw-r--r--ext/phar/tests/zip/files/nozipend.zipbin0 -> 169 bytes
-rw-r--r--ext/phar/tests/zip/files/odt.odtbin0 -> 8873 bytes
-rw-r--r--ext/phar/tests/zip/files/stdin.zipbin0 -> 186 bytes
-rw-r--r--ext/phar/tests/zip/files/test.odtbin0 -> 8303 bytes
-rw-r--r--ext/phar/tests/zip/files/truncfilename.zipbin0 -> 190 bytes
-rw-r--r--ext/phar/tests/zip/files/zip.zipbin0 -> 619 bytes
-rw-r--r--ext/phar/tests/zip/files/zipmaker.php.inc70
-rw-r--r--ext/phar/tests/zip/files/zlib_alias.phar.zipbin0 -> 624 bytes
-rw-r--r--ext/phar/tests/zip/frontcontroller1.phar.phpt16
-rw-r--r--ext/phar/tests/zip/frontcontroller10.phar.phpt24
-rw-r--r--ext/phar/tests/zip/frontcontroller11.phar.phpt22
-rw-r--r--ext/phar/tests/zip/frontcontroller12.phar.phpt21
-rw-r--r--ext/phar/tests/zip/frontcontroller13.phar.phpt21
-rw-r--r--ext/phar/tests/zip/frontcontroller14.phar.phpt16
-rw-r--r--ext/phar/tests/zip/frontcontroller15.phar.phpt21
-rw-r--r--ext/phar/tests/zip/frontcontroller16.phar.phpt18
-rw-r--r--ext/phar/tests/zip/frontcontroller17.phar.phpt17
-rw-r--r--ext/phar/tests/zip/frontcontroller18.phar.phpt17
-rw-r--r--ext/phar/tests/zip/frontcontroller19.phar.phpt17
-rw-r--r--ext/phar/tests/zip/frontcontroller2.phar.phpt17
-rw-r--r--ext/phar/tests/zip/frontcontroller20.phar.phpt17
-rw-r--r--ext/phar/tests/zip/frontcontroller21.phar.phpt25
-rw-r--r--ext/phar/tests/zip/frontcontroller3.phar.phpt20
-rw-r--r--ext/phar/tests/zip/frontcontroller4.phar.phpt14
-rw-r--r--ext/phar/tests/zip/frontcontroller5.phar.phpt15
-rw-r--r--ext/phar/tests/zip/frontcontroller6.phar.phpt22
-rw-r--r--ext/phar/tests/zip/frontcontroller7.phar.phpt15
-rw-r--r--ext/phar/tests/zip/frontcontroller8.phar.phpt21
-rw-r--r--ext/phar/tests/zip/frontcontroller9.phar.phpt19
-rw-r--r--ext/phar/tests/zip/getalias.phpt59
-rw-r--r--ext/phar/tests/zip/largezip.phpt29
-rw-r--r--ext/phar/tests/zip/metadata_write_commit.phpt88
-rw-r--r--ext/phar/tests/zip/metadata_write_commitU.phpt88
-rw-r--r--ext/phar/tests/zip/notphar.phpt24
-rw-r--r--ext/phar/tests/zip/odt.phpt35
-rw-r--r--ext/phar/tests/zip/open_for_write_existing.phpt39
-rw-r--r--ext/phar/tests/zip/open_for_write_existing_b.phpt55
-rw-r--r--ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt53
-rw-r--r--ext/phar/tests/zip/open_for_write_existing_c.phpt49
-rw-r--r--ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt47
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile.phpt42
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile_b.phpt63
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt61
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile_c.phpt57
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt55
-rw-r--r--ext/phar/tests/zip/phar_begin_setstub_commit.phpt71
-rw-r--r--ext/phar/tests/zip/phar_begin_setstub_commitU.phpt71
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator4.phpt66
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator5.phpt59
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator6.phpt60
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator7.phpt60
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator8.phpt73
-rw-r--r--ext/phar/tests/zip/phar_buildfromiterator9.phpt65
-rw-r--r--ext/phar/tests/zip/phar_commitwrite.phpt47
-rw-r--r--ext/phar/tests/zip/phar_convert_phar.phpt57
-rw-r--r--ext/phar/tests/zip/phar_copy.phpt55
-rw-r--r--ext/phar/tests/zip/phar_magic.phpt44
-rw-r--r--ext/phar/tests/zip/phar_magicU.phpt41
-rw-r--r--ext/phar/tests/zip/phar_oo_compressallbz2.phpt70
-rw-r--r--ext/phar/tests/zip/phar_oo_compressallgz.phpt58
-rw-r--r--ext/phar/tests/zip/phar_setalias.phpt62
-rw-r--r--ext/phar/tests/zip/phar_setalias2.phpt49
-rw-r--r--ext/phar/tests/zip/phar_setdefaultstub.phpt80
-rw-r--r--ext/phar/tests/zip/phar_setsignaturealgo2.phpt115
-rw-r--r--ext/phar/tests/zip/phar_stub.phpt75
-rw-r--r--ext/phar/tests/zip/phar_stub_error.phpt55
-rw-r--r--ext/phar/tests/zip/refcount1.phpt70
-rw-r--r--ext/phar/tests/zip/refcount1_5_2.phpt64
-rw-r--r--ext/phar/tests/zip/rename.phpt34
-rw-r--r--ext/phar/tests/zip/rename_dir.phpt34
-rw-r--r--ext/phar/tests/zip/rmdir.phpt38
-rw-r--r--ext/phar/tests/zip/unixzip.phpt29
-rw-r--r--ext/phar/tests/zip/zlib.phpt19
-rw-r--r--ext/phar/util.c2385
-rw-r--r--ext/phar/zip.c1514
840 files changed, 67366 insertions, 0 deletions
diff --git a/ext/phar/CREDITS b/ext/phar/CREDITS
new file mode 100644
index 0000000..b54c6e8
--- /dev/null
+++ b/ext/phar/CREDITS
@@ -0,0 +1,2 @@
+PHP Archive
+Gregory Beaver, Marcus Boerger
diff --git a/ext/phar/LICENSE b/ext/phar/LICENSE
new file mode 100644
index 0000000..50770e3
--- /dev/null
+++ b/ext/phar/LICENSE
@@ -0,0 +1,95 @@
+--------------------------------------------------------------------
+ The PHP License, version 3.01
+Copyright (c) 1999 - 2005 The PHP Group. All rights reserved.
+--------------------------------------------------------------------
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The name "PHP" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact group@php.net.
+
+ 4. Products derived from this software may not be called "PHP", nor
+ may "PHP" appear in their name, without prior written permission
+ from group@php.net. You may indicate that your software works in
+ conjunction with PHP by saying "Foo for PHP" instead of calling
+ it "PHP Foo" or "phpfoo"
+
+ 5. The PHP Group may publish revised and/or new versions of the
+ license from time to time. Each version will be given a
+ distinguishing version number.
+ Once covered code has been published under a particular version
+ of the license, you may always continue to use it under the terms
+ of that version. You may also choose to use such covered code
+ under the terms of any subsequent version of the license
+ published by the PHP Group. No one other than the PHP Group has
+ the right to modify the terms applicable to covered code created
+ under this License.
+
+ 6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes PHP software, freely available from
+ <http://www.php.net/software/>".
+
+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------
+
+This software consists of voluntary contributions made by many
+individuals on behalf of the PHP Group.
+
+The PHP Group can be contacted via Email at group@php.net.
+
+For more information on the PHP Group and the PHP project,
+please see <http://www.php.net>.
+
+PHP includes the Zend Engine, freely available at
+<http://www.zend.com>.
+
+---------------------------------------------------------------------
+phar_tar_octal() based on an implementation Copyright (c) 2003-2007 Tim Kientzle
+from libarchive, licensed with this license:
+
+ Copyright (c) 2003-2007 Tim Kientzle
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag
new file mode 100644
index 0000000..b1c820f
--- /dev/null
+++ b/ext/phar/Makefile.frag
@@ -0,0 +1,42 @@
+$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
+ @(cd $(top_srcdir); $(RE2C) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re)
+
+pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
+
+PHP_PHARCMD_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0'
+PHP_PHARCMD_EXECUTABLE = ` \
+ if test -x "$(top_builddir)/$(SAPI_CLI_PATH)"; then \
+ $(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \
+ if test "x$(PHP_MODULES)" != "x"; then \
+ $(top_srcdir)/build/shtool echo -n -- " -d extension_dir=$(top_builddir)/modules"; \
+ for i in bz2 zlib phar; do \
+ if test -f "$(top_builddir)/modules/$$i.la"; then \
+ . $(top_builddir)/modules/$$i.la; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
+ fi; \
+ done; \
+ fi; \
+ else \
+ $(top_srcdir)/build/shtool echo -n -- "$(PHP_EXECUTABLE)"; \
+ fi;`
+PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";`
+
+$(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc
+ -@test -d $(builddir)/phar || mkdir $(builddir)/phar
+ -@test -f $(builddir)/phar/phar.inc || cp $(srcdir)/phar/phar.inc $(builddir)/phar/phar.inc
+
+$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
+ -@echo "Generating phar.php"
+ @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php
+
+$(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
+ -@echo "Generating phar.phar"
+ -@rm -f $(builddir)/phar.phar
+ -@rm -f $(srcdir)/phar.phar
+ @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
+ -@chmod +x $(builddir)/phar.phar
+
+install-pharcmd: pharcmd
+ -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
+ $(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)
+ -@rm -f $(INSTALL_ROOT)$(bindir)/phar
+ $(LN_S) -f $(bindir)/phar.phar $(INSTALL_ROOT)$(bindir)/phar
diff --git a/ext/phar/TODO b/ext/phar/TODO
new file mode 100644
index 0000000..db00140
--- /dev/null
+++ b/ext/phar/TODO
@@ -0,0 +1,114 @@
+Version 1.0.0
+
+ X make permissions in the lowest bits of flags to simplify using them [Greg]
+ X implement ini handler for phar.readonly and phar.require_hash that allows
+ enabling it on PHP_INI_ALL if it is disabled in the system, but does not
+ allow disabling it if it is enabled in the system [Greg]
+ X implement reading in metadata in manifest as <len32><metadata...> [Marcus]
+ X implement writing out of metadata to new manifest [Marcus]
+ X if SPL is disabled, enable only static methods of class Phar and disable
+ class PharFileInfo completely [Marcus]
+ X implement in-phar locking, so that a file that is opened for reading can't
+ have a handle opened for writing [Marcus/Greg]
+ X docs on file format/manifest description [Greg]
+ X docs on uses [Greg]
+ X stream context for specifying compression of a file [Marcus]
+ X stream context for specifying meta-data [Greg]
+ X Phar->begin()/Phar->commit() for specifying a new stub to the phar,
+ and deferring flush until all modifications are complete [Greg]
+ X Phar->getStub() for retrieving the stub of the phar [Marcus]
+ X add setUncompressed(), setCompressedGZ() and setCompressedBZ2() to
+ PharFileInfo class [Greg]
+ X add uncompressAllFiles(), compressAllFilesGZ() and compressAllFilesBZ2()
+ to Phar class [Greg]
+ X add PharFileInfo::setMetaData($metadata) [Marcus]
+ X add PharFileInfo::getMetaData() [Marcus]
+ X always throw exceptions from the Phar object, and E_RECOVERABLE_ERROR from
+ streams interface [Greg]
+ X Phar archive metadata Phar::setMetaData($metadata) Phar::getMetaData()
+ [Greg]
+ X support rename() in stream wrapper [Greg]
+ X update docs to reflect changes in error handling [Greg]
+ X fix 011.phpt, 029.phpt for uncaught exceptions causing bad cleanup
+ [Marcus/Greg]
+
+Version 1.1.0
+
+ X Ability to connect a phar file 'phar://whatever' to a directory. That way
+ all access to that phar archive are directed to the extracted directory.
+ This allows to have the installed files and the archive keep the same
+ includes. [Marcus]
+ X add SHA-2 (256, 512) support [Marcus]
+ X setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512
+ Phar::PGP to choose the kind of signature to use (PGP falls back to SHA1)
+ [Greg]
+
+Version 1.2.0
+
+ X add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
+ X add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
+ X fix Phar::CanWrite() [Marcus]
+ X add preliminary phar command (phar.php) [Marcus]
+ X add phar command (phar.phar) [Marcus]
+ X list all available compression methods using
+ Phar::getSupportedCompression() [Marcus]
+ X Remove RINIT [Marcus]
+
+Version 1.2.1
+
+ X Add Phar::getAlias() [Marcus]
+ X Add Phar::setAlias() [Greg]
+ X Make -a optional in pack subcommand of phar.phar [Marcus]
+ X Make Phar::loadPhar() and Phar::mapPhar() ignore extracted archives
+
+Version 2.0.0
+
+ X implement webPhar() rewrite as a callback that returns FALSE to deny
+ access, or a string representing a file within the archive to access. If
+ unknown, the callback should return the original request uri [Greg]
+ X rework filename detection so that alias is always checked first [Greg]
+ X make aliases containing '/' or '\' invalid [Greg]
+ X implement manual mounting of external phar archives to locations inside a
+ phar path, $phar->mount('/path/to/external.phar', 'internal/path');
+ this would traverse external.phar's manifest, and add each entry as a
+ virtual entry just like automatic mounting of internal phars [Greg]
+ X implement manual mounting of external paths to a directory inside a phar
+ path. Because the mapping would be to an external directory, write access
+ would be allowed always. This allows storing sqlite databases, cache, or
+ template files in a location external to the phar. Copy of the files
+ would need to be performed in an installation step, phar would not attempt
+ to do this for performance and security reasons. [Greg]
+ X implement opendir support for mounted paths [Greg]
+ X make convertToZip/convertToTar rename files [Steph]
+ X make convertTo*() with full file compression rename to append .gz or .bz2
+ [Steph]
+ X don't automatically add a stub to .zip or .tar files [Steph]
+ X don't allow a stub or alias to be added to a .zip/.tar that does not have
+ ".phar" in the filename (or already have stub/alias) [Steph]
+ X allow read/write on .tar/.zip files that do not contain a stub or alias [Steph/Greg]
+ X prevent manual addition of stub via $a['.phar/stub.php'] = '<?php my stub'; [Greg]
+ X investigate potential collision between SPL's DirectoryIterator flags and
+ those in phar_archive_data [Steph]
+ X compression should work for non-phar archives [Steph]
+ X implement initial support for simple zip/tar archives (PharData) [Steph]
+ X make createDefaultStub() setDefaultStub() and have it file format-specific
+ [Steph]
+ X convertTo*() should always use the default stub [Steph]
+ X ability to store empty directories [Greg]
+ X tar support [Greg]
+ X zip support [Greg]
+ X Phar::copy($from, $to); [Greg]
+ X Phar::delete($what) [Greg]
+ X Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ X Layout: Option to compress all content rather than single files. (tar/phar
+ only) [Greg]
+ X clean crap paths like phar://blah.phar/file//../to\\here.php [Greg]
+
+Version 2.1.0
+ * implement write support for mounted files even if phar.readonly=1
+ * implement automatic "mounting" of internal phar archives so that
+ phar:///path/to/archive.phar/internal.phar/file opens internal.phar and
+ maps its manifest inside archive.phar. The manifest entry inside
+ archive.phar would be named "internal.phar/file". Write access to internal
+ files inside an internal phar would be denied, as the entire archive must
+ be added or removed at the same time.
diff --git a/ext/phar/build_precommand.php b/ext/phar/build_precommand.php
new file mode 100755
index 0000000..c2fe9c8
--- /dev/null
+++ b/ext/phar/build_precommand.php
@@ -0,0 +1,55 @@
+#!/usr/bin/php
+<?php echo '<'.'?php';?>
+
+/** @file phar.php
+ * @ingroup Phar
+ * @brief class Phar Pre Command
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Phar Command
+ */
+foreach(array("SPL", "Reflection", "Phar") as $ext) {
+ if (!extension_loaded($ext)) {
+ echo "$argv[0] requires PHP extension $ext.\n";
+ exit(1);
+ }
+}
+
+<?php
+
+$classes = array(
+ 'DirectoryTreeIterator',
+ 'DirectoryGraphIterator',
+ 'InvertedRegexIterator',
+ 'CLICommand',
+ 'PharCommand',
+ );
+
+foreach($classes as $name) {
+ echo "if (!class_exists('$name', 0))\n{\n";
+ $f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
+ unset($f[0]);
+ $c = count($f);
+ while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
+ unset($f[$c--]);
+ }
+ if (substr($f[$c], -2) == "\r\n") {
+ $f[$c] = substr($f[$c], 0, -2);
+ }
+ if (substr($f[$c], -1) == "\n") {
+ $f[$c] = substr($f[$c], 0, -1);
+ }
+ if (substr($f[$c], -2) == '?>') {
+ $f[$c] = substr($f[$c], 0,-2);
+ }
+ while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
+ unset($f[$c--]);
+ }
+ echo join('', $f);
+ echo "\n}\n\n";
+}
+
+echo 'new PharCommand($argc, $argv);'."\n";
+
+?>
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
new file mode 100644
index 0000000..2ac7f3d
--- /dev/null
+++ b/ext/phar/config.m4
@@ -0,0 +1,30 @@
+dnl $Id$
+dnl config.m4 for extension phar
+
+PHP_ARG_ENABLE(phar, for phar archive support,
+[ --disable-phar Disable phar support], yes)
+
+if test "$PHP_PHAR" != "no"; then
+ PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared)
+ AC_MSG_CHECKING([for phar openssl support])
+ if test "$PHP_HASH_SHARED" != "yes"; then
+ if test "$PHP_HASH" != "no"; then
+ AC_DEFINE(PHAR_HASH_OK,1,[ ])
+ fi
+ else
+ AC_MSG_WARN([Phar: sha256/sha512 signature support disabled if ext/hash is built shared])
+ fi
+ if test "$PHP_OPENSSL_SHARED" = "yes"; then
+ AC_MSG_RESULT([no (shared openssl)])
+ else
+ if test "$PHP_OPENSSL" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(PHAR_HAVE_OPENSSL,1,[ ])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ PHP_ADD_EXTENSION_DEP(phar, hash, true)
+ PHP_ADD_EXTENSION_DEP(phar, spl, true)
+ PHP_ADD_MAKEFILE_FRAGMENT
+fi
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
new file mode 100644
index 0000000..93504f6
--- /dev/null
+++ b/ext/phar/config.w32
@@ -0,0 +1,46 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_ENABLE("phar", "disable phar support", "yes");
+ARG_ENABLE("phar-native-ssl", "enable phar with native OpenSSL support", "no");
+
+if (PHP_PHAR_NATIVE_SSL != "no") {
+ PHP_PHAR = PHP_PHAR_NATIVE_SSL;
+}
+
+if (PHP_PHAR != "no") {
+ EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c");
+ if (PHP_PHAR_SHARED || (PHP_PHAR_NATIVE_SSL_SHARED && PHP_SNAPSHOT_BUILD == "no")) {
+ ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR ");
+ }
+ if (PHP_PHAR_NATIVE_SSL != "no") {
+ if (CHECK_LIB("libeay32st.lib", "phar")) {
+ /* We don't really need GDI for this, but there's no
+ way to avoid linking it in the static openssl build */
+ ADD_FLAG("LIBS_PHAR", "libeay32st.lib gdi32.lib");
+ if (PHP_DEBUG == "no") {
+ /* Silence irrelevant-to-us warning in release builds */
+ ADD_FLAG("LDFLAGS_PHAR", "/IGNORE:4089 ");
+ }
+ AC_DEFINE('PHAR_HAVE_OPENSSL', 1);
+ STDOUT.WriteLine(' Native OpenSSL support in Phar enabled');
+ } else {
+ WARNING('Could not enable native OpenSSL support in Phar');
+ }
+ } else {
+ if (PHP_OPENSSL != "no" && !PHP_OPENSSL_SHARED && !PHP_PHAR_SHARED) {
+ AC_DEFINE('PHAR_HAVE_OPENSSL', 1);
+ STDOUT.WriteLine(' Native OpenSSL support in Phar enabled');
+ } else {
+ STDOUT.WriteLine(' Native OpenSSL support in Phar disabled');
+ }
+ }
+ if (PHP_HASH != "no") {
+ if (!PHP_HASH_SHARED) {
+ AC_DEFINE("PHAR_HASH_OK", 1);
+ } else {
+ WARNING('Phar: sha256/sha512 signature support disabled if ext/hash is built shared');
+ }
+ }
+ ADD_EXTENSION_DEP('phar', 'spl', true);
+}
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
new file mode 100644
index 0000000..277d058
--- /dev/null
+++ b/ext/phar/dirstream.c
@@ -0,0 +1,711 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar:// stream wrapper support |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#define PHAR_DIRSTREAM 1
+#include "phar_internal.h"
+#include "dirstream.h"
+
+BEGIN_EXTERN_C()
+void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_dir TSRMLS_DC);
+END_EXTERN_C()
+
+php_stream_ops phar_dir_ops = {
+ phar_dir_write, /* write */
+ phar_dir_read, /* read */
+ phar_dir_close, /* close */
+ phar_dir_flush, /* flush */
+ "phar dir",
+ phar_dir_seek, /* seek */
+ NULL, /* cast */
+ NULL, /* stat */
+ NULL, /* set option */
+};
+
+/**
+ * Used for closedir($fp) where $fp is an opendir('phar://...') directory handle
+ */
+static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
+{
+ HashTable *data = (HashTable *)stream->abstract;
+
+ if (data && data->arBuckets) {
+ zend_hash_destroy(data);
+ data->arBuckets = 0;
+ FREE_HASHTABLE(data);
+ stream->abstract = NULL;
+ }
+
+ return 0;
+}
+/* }}} */
+
+/**
+ * Used for seeking on a phar directory handle
+ */
+static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+{
+ HashTable *data = (HashTable *)stream->abstract;
+
+ if (!data) {
+ return -1;
+ }
+
+ if (whence == SEEK_END) {
+ whence = SEEK_SET;
+ offset = zend_hash_num_elements(data) + offset;
+ }
+
+ if (whence == SEEK_SET) {
+ zend_hash_internal_pointer_reset(data);
+ }
+
+ if (offset < 0) {
+ return -1;
+ } else {
+ *newoffset = 0;
+ while (*newoffset < offset && zend_hash_move_forward(data) == SUCCESS) {
+ ++(*newoffset);
+ }
+ return 0;
+ }
+}
+/* }}} */
+
+/**
+ * Used for readdir() on an opendir()ed phar directory handle
+ */
+static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
+{
+ size_t to_read;
+ HashTable *data = (HashTable *)stream->abstract;
+ phar_zstr key;
+ char *str_key;
+ uint keylen;
+ ulong unused;
+
+ if (FAILURE == zend_hash_has_more_elements(data)) {
+ return 0;
+ }
+
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) {
+ return 0;
+ }
+
+ PHAR_STR(key, str_key);
+ zend_hash_move_forward(data);
+ to_read = MIN(keylen, count);
+
+ if (to_read == 0 || count < keylen) {
+ PHAR_STR_FREE(str_key);
+ return 0;
+ }
+
+ memset(buf, 0, sizeof(php_stream_dirent));
+ memcpy(((php_stream_dirent *) buf)->d_name, str_key, to_read);
+ PHAR_STR_FREE(str_key);
+ ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
+
+ return sizeof(php_stream_dirent);
+}
+/* }}} */
+
+/**
+ * Dummy: Used for writing to a phar directory (i.e. not used)
+ */
+static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
+{
+ return 0;
+}
+/* }}} */
+
+/**
+ * Dummy: Used for flushing writes to a phar directory (i.e. not used)
+ */
+static int phar_dir_flush(php_stream *stream TSRMLS_DC) /* {{{ */
+{
+ return EOF;
+}
+/* }}} */
+
+/**
+ * add an empty element with a char * key to a hash table, avoiding duplicates
+ *
+ * This is used to get a unique listing of virtual directories within a phar,
+ * for iterating over opendir()ed phar directories.
+ */
+static int phar_add_empty(HashTable *ht, char *arKey, uint nKeyLength) /* {{{ */
+{
+ void *dummy = (char *) 1;
+
+ return zend_hash_update(ht, arKey, nKeyLength, (void *) &dummy, sizeof(void *), NULL);
+}
+/* }}} */
+
+/**
+ * Used for sorting directories alphabetically
+ */
+static int phar_compare_dir_name(const void *a, const void *b TSRMLS_DC) /* {{{ */
+{
+ Bucket *f;
+ Bucket *s;
+ int result;
+
+ f = *((Bucket **) a);
+ s = *((Bucket **) b);
+#if (PHP_MAJOR_VERSION < 6)
+ result = zend_binary_strcmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
+#else
+ result = zend_binary_strcmp(f->key.arKey.s, f->nKeyLength, s->key.arKey.s, s->nKeyLength);
+#endif
+
+ if (result < 0) {
+ return -1;
+ } else if (result > 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+/* }}} */
+
+/**
+ * Create a opendir() directory stream handle by iterating over each of the
+ * files in a phar and retrieving its relative path. From this, construct
+ * a list of files/directories that are "in" the directory represented by dir
+ */
+static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) /* {{{ */
+{
+ HashTable *data;
+ int dirlen = strlen(dir);
+ phar_zstr key;
+ char *entry, *found, *save, *str_key;
+ uint keylen;
+ ulong unused;
+
+ ALLOC_HASHTABLE(data);
+ zend_hash_init(data, 64, zend_get_hash_value, NULL, 0);
+
+ if ((*dir == '/' && dirlen == 1 && (manifest->nNumOfElements == 0)) || (dirlen >= sizeof(".phar")-1 && !memcmp(dir, ".phar", sizeof(".phar")-1))) {
+ /* make empty root directory for empty phar */
+ /* make empty directory for .phar magic directory */
+ efree(dir);
+ return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
+ }
+
+ zend_hash_internal_pointer_reset(manifest);
+
+ while (FAILURE != zend_hash_has_more_elements(manifest)) {
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
+ break;
+ }
+
+ PHAR_STR(key, str_key);
+
+ if (keylen <= (uint)dirlen) {
+ if (keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) {
+ PHAR_STR_FREE(str_key);
+ if (SUCCESS != zend_hash_move_forward(manifest)) {
+ break;
+ }
+ continue;
+ }
+ }
+
+ if (*dir == '/') {
+ /* root directory */
+ if (keylen >= sizeof(".phar")-1 && !memcmp(str_key, ".phar", sizeof(".phar")-1)) {
+ PHAR_STR_FREE(str_key);
+ /* do not add any magic entries to this directory */
+ if (SUCCESS != zend_hash_move_forward(manifest)) {
+ break;
+ }
+ continue;
+ }
+
+ if (NULL != (found = (char *) memchr(str_key, '/', keylen))) {
+ /* the entry has a path separator and is a subdirectory */
+ entry = (char *) safe_emalloc(found - str_key, 1, 1);
+ memcpy(entry, str_key, found - str_key);
+ keylen = found - str_key;
+ entry[keylen] = '\0';
+ } else {
+ entry = (char *) safe_emalloc(keylen, 1, 1);
+ memcpy(entry, str_key, keylen);
+ entry[keylen] = '\0';
+ }
+
+ PHAR_STR_FREE(str_key);
+ goto PHAR_ADD_ENTRY;
+ } else {
+ if (0 != memcmp(str_key, dir, dirlen)) {
+ /* entry in directory not found */
+ PHAR_STR_FREE(str_key);
+ if (SUCCESS != zend_hash_move_forward(manifest)) {
+ break;
+ }
+ continue;
+ } else {
+ if (str_key[dirlen] != '/') {
+ PHAR_STR_FREE(str_key);
+ if (SUCCESS != zend_hash_move_forward(manifest)) {
+ break;
+ }
+ continue;
+ }
+ }
+ }
+
+ save = str_key;
+ save += dirlen + 1; /* seek to just past the path separator */
+
+ if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) {
+ /* is subdirectory */
+ save -= dirlen + 1;
+ entry = (char *) safe_emalloc(found - save + dirlen, 1, 1);
+ memcpy(entry, save + dirlen + 1, found - save - dirlen - 1);
+ keylen = found - save - dirlen - 1;
+ entry[keylen] = '\0';
+ } else {
+ /* is file */
+ save -= dirlen + 1;
+ entry = (char *) safe_emalloc(keylen - dirlen, 1, 1);
+ memcpy(entry, save + dirlen + 1, keylen - dirlen - 1);
+ entry[keylen - dirlen - 1] = '\0';
+ keylen = keylen - dirlen - 1;
+ }
+ PHAR_STR_FREE(str_key);
+PHAR_ADD_ENTRY:
+ if (keylen) {
+ phar_add_empty(data, entry, keylen);
+ }
+
+ efree(entry);
+
+ if (SUCCESS != zend_hash_move_forward(manifest)) {
+ break;
+ }
+ }
+
+ if (FAILURE != zend_hash_has_more_elements(data)) {
+ efree(dir);
+ if (zend_hash_sort(data, zend_qsort, phar_compare_dir_name, 0 TSRMLS_CC) == FAILURE) {
+ FREE_HASHTABLE(data);
+ return NULL;
+ }
+ return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
+ } else {
+ efree(dir);
+ return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
+ }
+}
+/* }}}*/
+
+/**
+ * Open a directory handle within a phar archive
+ */
+php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
+{
+ php_url *resource = NULL;
+ php_stream *ret;
+ char *internal_file, *error, *str_key;
+ phar_zstr key;
+ uint keylen;
+ ulong unused;
+ phar_archive_data *phar;
+ phar_entry_info *entry = NULL;
+ uint host_len;
+
+ if ((resource = phar_parse_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar url \"%s\" is unknown", path);
+ return NULL;
+ }
+
+ /* we must have at the very least phar://alias.phar/ */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ if (resource->host && !resource->path) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", path, resource->host);
+ php_url_free(resource);
+ return NULL;
+ }
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\", must have at least phar://%s/", path, path);
+ return NULL;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar url \"%s\"", path);
+ return NULL;
+ }
+
+ host_len = strlen(resource->host);
+ phar_request_initialize(TSRMLS_C);
+ internal_file = resource->path + 1; /* strip leading "/" */
+
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ efree(error);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar file \"%s\" is unknown", resource->host);
+ }
+ php_url_free(resource);
+ return NULL;
+ }
+
+ if (error) {
+ efree(error);
+ }
+
+ if (*internal_file == '\0') {
+ /* root directory requested */
+ internal_file = estrndup(internal_file - 1, 1);
+ ret = phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ php_url_free(resource);
+ return ret;
+ }
+
+ if (!phar->manifest.arBuckets) {
+ php_url_free(resource);
+ return NULL;
+ }
+
+ if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, strlen(internal_file), (void**)&entry) && !entry->is_dir) {
+ php_url_free(resource);
+ return NULL;
+ } else if (entry && entry->is_dir) {
+ if (entry->is_mounted) {
+ php_url_free(resource);
+ return php_stream_opendir(entry->tmp, options, context);
+ }
+ internal_file = estrdup(internal_file);
+ php_url_free(resource);
+ return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ } else {
+ int i_len = strlen(internal_file);
+
+ /* search for directory */
+ zend_hash_internal_pointer_reset(&phar->manifest);
+ while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
+ if (HASH_KEY_NON_EXISTANT !=
+ zend_hash_get_current_key_ex(
+ &phar->manifest, &key, &keylen, &unused, 0, NULL)) {
+ PHAR_STR(key, str_key);
+ if (keylen > (uint)i_len && 0 == memcmp(str_key, internal_file, i_len)) {
+ PHAR_STR_FREE(str_key);
+ /* directory found */
+ internal_file = estrndup(internal_file,
+ i_len);
+ php_url_free(resource);
+ return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
+ }
+ PHAR_STR_FREE(str_key);
+ }
+
+ if (SUCCESS != zend_hash_move_forward(&phar->manifest)) {
+ break;
+ }
+ }
+ }
+
+ php_url_free(resource);
+ return NULL;
+}
+/* }}} */
+
+/**
+ * Make a new directory within a phar archive
+ */
+int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info entry, *e;
+ phar_archive_data *phar = NULL;
+ char *error, *arch, *entry2;
+ int arch_len, entry_len;
+ php_url *resource = NULL;
+ uint host_len;
+
+ /* pre-readonly check, we need to know if this is a data phar */
+ if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, &entry2, &entry_len, 2, 2 TSRMLS_CC)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\", no phar archive specified", url_from);
+ return 0;
+ }
+
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ phar = NULL;
+ }
+
+ efree(arch);
+ efree(entry2);
+
+ if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\", write operations disabled", url_from);
+ return 0;
+ }
+
+ if ((resource = phar_parse_url(wrapper, url_from, "w", options TSRMLS_CC)) == NULL) {
+ return 0;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url_from);
+ return 0;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url_from);
+ return 0;
+ }
+
+ host_len = strlen(resource->host);
+
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
+ efree(error);
+ php_url_free(resource);
+ return 0;
+ }
+
+ if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 2, &error, 1 TSRMLS_CC))) {
+ /* directory exists, or is a subdirectory of an existing file */
+ if (e->is_temp_dir) {
+ efree(e->filename);
+ efree(e);
+ }
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", resource->path+1, resource->host);
+ php_url_free(resource);
+ return 0;
+ }
+
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ efree(error);
+ php_url_free(resource);
+ return 0;
+ }
+
+ if (phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 0, &error, 1 TSRMLS_CC)) {
+ /* entry exists as a file */
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", resource->path+1, resource->host);
+ php_url_free(resource);
+ return 0;
+ }
+
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ efree(error);
+ php_url_free(resource);
+ return 0;
+ }
+
+ memset((void *) &entry, 0, sizeof(phar_entry_info));
+
+ /* strip leading "/" */
+ if (phar->is_zip) {
+ entry.is_zip = 1;
+ }
+
+ entry.filename = estrdup(resource->path + 1);
+
+ if (phar->is_tar) {
+ entry.is_tar = 1;
+ entry.tar_type = TAR_DIR;
+ }
+
+ entry.filename_len = strlen(resource->path + 1);
+ php_url_free(resource);
+ entry.is_dir = 1;
+ entry.phar = phar;
+ entry.is_modified = 1;
+ entry.is_crc_checked = 1;
+ entry.flags = PHAR_ENT_PERM_DEF_DIR;
+ entry.old_flags = PHAR_ENT_PERM_DEF_DIR;
+
+ if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", adding to manifest failed", entry.filename, phar->fname);
+ efree(error);
+ efree(entry.filename);
+ return 0;
+ }
+
+ phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", entry.filename, phar->fname, error);
+ zend_hash_del(&phar->manifest, entry.filename, entry.filename_len);
+ efree(error);
+ return 0;
+ }
+
+ phar_add_virtual_dirs(phar, entry.filename, entry.filename_len TSRMLS_CC);
+ return 1;
+}
+/* }}} */
+
+/**
+ * Remove a directory within a phar archive
+ */
+int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry;
+ phar_archive_data *phar = NULL;
+ char *error, *arch, *entry2;
+ int arch_len, entry_len;
+ php_url *resource = NULL;
+ uint host_len;
+ phar_zstr key;
+ char *str_key;
+ uint key_len;
+ ulong unused;
+ uint path_len;
+
+ /* pre-readonly check, we need to know if this is a data phar */
+ if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, &entry2, &entry_len, 2, 2 TSRMLS_CC)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\", no phar archive specified, or phar archive does not exist", url);
+ return 0;
+ }
+
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ phar = NULL;
+ }
+
+ efree(arch);
+ efree(entry2);
+
+ if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot rmdir directory \"%s\", write operations disabled", url);
+ return 0;
+ }
+
+ if ((resource = phar_parse_url(wrapper, url, "w", options TSRMLS_CC)) == NULL) {
+ return 0;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url);
+ return 0;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url);
+ return 0;
+ }
+
+ host_len = strlen(resource->host);
+
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", error retrieving phar information: %s", resource->path+1, resource->host, error);
+ efree(error);
+ php_url_free(resource);
+ return 0;
+ }
+
+ path_len = strlen(resource->path+1);
+
+ if (!(entry = phar_get_entry_info_dir(phar, resource->path + 1, path_len, 2, &error, 1 TSRMLS_CC))) {
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", resource->path+1, resource->host, error);
+ efree(error);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", directory does not exist", resource->path+1, resource->host);
+ }
+ php_url_free(resource);
+ return 0;
+ }
+
+ if (!entry->is_deleted) {
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL);
+ zend_hash_move_forward(&phar->manifest)) {
+
+ PHAR_STR(key, str_key);
+
+ if (key_len > path_len &&
+ memcmp(str_key, resource->path+1, path_len) == 0 &&
+ IS_SLASH(str_key[path_len])) {
+ PHAR_STR_FREE(str_key);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
+ if (entry->is_temp_dir) {
+ efree(entry->filename);
+ efree(entry);
+ }
+ php_url_free(resource);
+ return 0;
+ }
+ PHAR_STR_FREE(str_key);
+ }
+
+ for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
+ HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL);
+ zend_hash_move_forward(&phar->virtual_dirs)) {
+
+ PHAR_STR(key, str_key);
+
+ if (key_len > path_len &&
+ memcmp(str_key, resource->path+1, path_len) == 0 &&
+ IS_SLASH(str_key[path_len])) {
+ PHAR_STR_FREE(str_key);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
+ if (entry->is_temp_dir) {
+ efree(entry->filename);
+ efree(entry);
+ }
+ php_url_free(resource);
+ return 0;
+ }
+ PHAR_STR_FREE(str_key);
+ }
+ }
+
+ if (entry->is_temp_dir) {
+ zend_hash_del(&phar->virtual_dirs, resource->path+1, path_len);
+ efree(entry->filename);
+ efree(entry);
+ } else {
+ entry->is_deleted = 1;
+ entry->is_modified = 1;
+ phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", entry->filename, phar->fname, error);
+ php_url_free(resource);
+ efree(error);
+ return 0;
+ }
+ }
+
+ php_url_free(resource);
+ return 1;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h
new file mode 100644
index 0000000..9b07c9d
--- /dev/null
+++ b/ext/phar/dirstream.h
@@ -0,0 +1,47 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2006-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+BEGIN_EXTERN_C()
+int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
+int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC);
+
+#ifdef PHAR_DIRSTREAM
+php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC);
+
+/* directory handlers */
+static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
+static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
+static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
+static int phar_dir_flush(php_stream *stream TSRMLS_DC);
+static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+#else
+php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
+#endif
+END_EXTERN_C()
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c
new file mode 100644
index 0000000..6519372
--- /dev/null
+++ b/ext/phar/func_interceptors.c
@@ -0,0 +1,1216 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "phar_internal.h"
+
+#define PHAR_FUNC(name) \
+ static PHP_NAMED_FUNCTION(name)
+
+PHAR_FUNC(phar_opendir) /* {{{ */
+{
+ char *filename;
+ int filename_len;
+ zval *zcontext = NULL;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ goto skip_phar;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|z", &filename, &filename_len, &zcontext) == FAILURE) {
+ return;
+ }
+
+ if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ /* we are checking for existence of a file within the relative path. Chances are good that this is
+ retrieving something from within the phar archive */
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ php_stream_context *context = NULL;
+ php_stream *stream;
+ char *name;
+
+ efree(entry);
+ entry = estrndup(filename, filename_len);
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+ /* retrieving a file within the current directory, so use this if possible */
+ entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
+
+ if (entry[0] == '/') {
+ spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+ efree(entry);
+ efree(arch);
+ if (zcontext) {
+ context = php_stream_context_from_zval(zcontext, 0);
+ }
+ stream = php_stream_opendir(name, REPORT_ERRORS, context);
+ efree(name);
+ if (!stream) {
+ RETURN_FALSE;
+ }
+ php_stream_to_zval(stream, return_value);
+ return;
+ }
+ }
+skip_phar:
+ PHAR_G(orig_opendir)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+PHAR_FUNC(phar_file_get_contents) /* {{{ */
+{
+ char *filename;
+ int filename_len;
+ char *contents;
+ zend_bool use_include_path = 0;
+ php_stream *stream;
+ int len;
+ long offset = -1;
+ long maxlen = PHP_STREAM_COPY_ALL;
+ zval *zcontext = NULL;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ goto skip_phar;
+ }
+
+ /* Parse arguments */
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
+ goto skip_phar;
+ }
+
+ if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ php_stream_context *context = NULL;
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ char *name;
+ phar_archive_data *phar;
+
+ efree(entry);
+ entry = filename;
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+
+ if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
+ efree(arch);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero");
+ RETURN_FALSE;
+ }
+
+ /* retrieving a file defaults to within the current directory, so use this if possible */
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ goto skip_phar;
+ }
+ if (use_include_path) {
+ if ((entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
+ name = entry;
+ goto phar_it;
+ } else {
+ /* this file is not in the phar, use the original path */
+ efree(arch);
+ goto skip_phar;
+ }
+ } else {
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ /* this file is not in the phar, use the original path */
+notfound:
+ efree(arch);
+ efree(entry);
+ goto skip_phar;
+ }
+ } else {
+ if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ goto notfound;
+ }
+ }
+ /* auto-convert to phar:// */
+ if (entry[0] == '/') {
+ spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+ if (entry != filename) {
+ efree(entry);
+ }
+ }
+
+phar_it:
+ efree(arch);
+ if (zcontext) {
+ context = php_stream_context_from_zval(zcontext, 0);
+ }
+ stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context);
+ efree(name);
+
+ if (!stream) {
+ RETURN_FALSE;
+ }
+
+ if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_stream_close(stream);
+ RETURN_FALSE;
+ }
+
+ /* uses mmap if possible */
+ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
+#if PHP_API_VERSION < 20100412
+ if (PG(magic_quotes_runtime)) {
+ int newlen;
+ contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */
+ len = newlen;
+ }
+#endif
+ RETVAL_STRINGL(contents, len, 0);
+ } else if (len == 0) {
+ RETVAL_EMPTY_STRING();
+ } else {
+ RETVAL_FALSE;
+ }
+
+ php_stream_close(stream);
+ return;
+ }
+ }
+skip_phar:
+ PHAR_G(orig_file_get_contents)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+PHAR_FUNC(phar_readfile) /* {{{ */
+{
+ char *filename;
+ int filename_len;
+ int size = 0;
+ zend_bool use_include_path = 0;
+ zval *zcontext = NULL;
+ php_stream *stream;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ goto skip_phar;
+ }
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!", &filename, &filename_len, &use_include_path, &zcontext) == FAILURE) {
+ goto skip_phar;
+ }
+ if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ php_stream_context *context = NULL;
+ char *name;
+ phar_archive_data *phar;
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ goto skip_phar;
+ }
+
+ efree(entry);
+ entry = filename;
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+ /* retrieving a file defaults to within the current directory, so use this if possible */
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ goto skip_phar;
+ }
+ if (use_include_path) {
+ if (!(entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
+ /* this file is not in the phar, use the original path */
+ efree(arch);
+ goto skip_phar;
+ } else {
+ name = entry;
+ }
+ } else {
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ /* this file is not in the phar, use the original path */
+notfound:
+ efree(entry);
+ efree(arch);
+ goto skip_phar;
+ }
+ } else {
+ if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ goto notfound;
+ }
+ }
+ /* auto-convert to phar:// */
+ if (entry[0] == '/') {
+ spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+ efree(entry);
+ }
+
+ efree(arch);
+ context = php_stream_context_from_zval(zcontext, 0);
+ stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context);
+ efree(name);
+ if (stream == NULL) {
+ RETURN_FALSE;
+ }
+ size = php_stream_passthru(stream);
+ php_stream_close(stream);
+ RETURN_LONG(size);
+ }
+
+skip_phar:
+ PHAR_G(orig_readfile)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+
+}
+/* }}} */
+
+PHAR_FUNC(phar_fopen) /* {{{ */
+{
+ char *filename, *mode;
+ int filename_len, mode_len;
+ zend_bool use_include_path = 0;
+ zval *zcontext = NULL;
+ php_stream *stream;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ /* no need to check, include_path not even specified in fopen/ no active phars */
+ goto skip_phar;
+ }
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ps|br", &filename, &filename_len, &mode, &mode_len, &use_include_path, &zcontext) == FAILURE) {
+ goto skip_phar;
+ }
+ if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ php_stream_context *context = NULL;
+ char *name;
+ phar_archive_data *phar;
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ goto skip_phar;
+ }
+
+ efree(entry);
+ entry = filename;
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+ /* retrieving a file defaults to within the current directory, so use this if possible */
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ goto skip_phar;
+ }
+ if (use_include_path) {
+ if (!(entry = phar_find_in_include_path(entry, entry_len, NULL TSRMLS_CC))) {
+ /* this file is not in the phar, use the original path */
+ efree(arch);
+ goto skip_phar;
+ } else {
+ name = entry;
+ }
+ } else {
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (!zend_hash_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
+ /* this file is not in the phar, use the original path */
+notfound:
+ efree(entry);
+ efree(arch);
+ goto skip_phar;
+ }
+ } else {
+ if (!zend_hash_exists(&(phar->manifest), entry, entry_len)) {
+ /* this file is not in the phar, use the original path */
+ goto notfound;
+ }
+ }
+ /* auto-convert to phar:// */
+ if (entry[0] == '/') {
+ spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+ efree(entry);
+ }
+
+ efree(arch);
+ context = php_stream_context_from_zval(zcontext, 0);
+ stream = php_stream_open_wrapper_ex(name, mode, 0 | REPORT_ERRORS, NULL, context);
+ efree(name);
+ if (stream == NULL) {
+ RETURN_FALSE;
+ }
+ php_stream_to_zval(stream, return_value);
+ if (zcontext) {
+ zend_list_addref(Z_RESVAL_P(zcontext));
+ }
+ return;
+ }
+skip_phar:
+ PHAR_G(orig_fopen)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
+#endif
+#ifndef S_ISLNK
+#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
+#endif
+
+#define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH )
+
+#define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || (__t) == FS_LSTAT)
+#define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK)
+#define IS_ABLE_CHECK(__t) ((__t) == FS_IS_R || (__t) == FS_IS_W || (__t) == FS_IS_X)
+#define IS_ACCESS_CHECK(__t) (IS_ABLE_CHECK(type) || (__t) == FS_EXISTS)
+
+/* {{{ php_stat
+ */
+static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_DC)
+{
+ zval *stat_dev, *stat_ino, *stat_mode, *stat_nlink, *stat_uid, *stat_gid, *stat_rdev,
+ *stat_size, *stat_atime, *stat_mtime, *stat_ctime, *stat_blksize, *stat_blocks;
+ int rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */
+ char *stat_sb_names[13] = {
+ "dev", "ino", "mode", "nlink", "uid", "gid", "rdev",
+ "size", "atime", "mtime", "ctime", "blksize", "blocks"
+ };
+
+#ifndef NETWARE
+ if (type >= FS_IS_W && type <= FS_IS_X) {
+ if(stat_sb->st_uid==getuid()) {
+ rmask=S_IRUSR;
+ wmask=S_IWUSR;
+ xmask=S_IXUSR;
+ } else if(stat_sb->st_gid==getgid()) {
+ rmask=S_IRGRP;
+ wmask=S_IWGRP;
+ xmask=S_IXGRP;
+ } else {
+ int groups, n, i;
+ gid_t *gids;
+
+ groups = getgroups(0, NULL);
+ if(groups > 0) {
+ gids=(gid_t *)safe_emalloc(groups, sizeof(gid_t), 0);
+ n=getgroups(groups, gids);
+ for(i=0;i<n;++i){
+ if(stat_sb->st_gid==gids[i]) {
+ rmask=S_IRGRP;
+ wmask=S_IWGRP;
+ xmask=S_IXGRP;
+ break;
+ }
+ }
+ efree(gids);
+ }
+ }
+ }
+#endif
+
+ switch (type) {
+ case FS_PERMS:
+ RETURN_LONG((long)stat_sb->st_mode);
+ case FS_INODE:
+ RETURN_LONG((long)stat_sb->st_ino);
+ case FS_SIZE:
+ RETURN_LONG((long)stat_sb->st_size);
+ case FS_OWNER:
+ RETURN_LONG((long)stat_sb->st_uid);
+ case FS_GROUP:
+ RETURN_LONG((long)stat_sb->st_gid);
+ case FS_ATIME:
+#ifdef NETWARE
+ RETURN_LONG((long)stat_sb->st_atime.tv_sec);
+#else
+ RETURN_LONG((long)stat_sb->st_atime);
+#endif
+ case FS_MTIME:
+#ifdef NETWARE
+ RETURN_LONG((long)stat_sb->st_mtime.tv_sec);
+#else
+ RETURN_LONG((long)stat_sb->st_mtime);
+#endif
+ case FS_CTIME:
+#ifdef NETWARE
+ RETURN_LONG((long)stat_sb->st_ctime.tv_sec);
+#else
+ RETURN_LONG((long)stat_sb->st_ctime);
+#endif
+ case FS_TYPE:
+ if (S_ISLNK(stat_sb->st_mode)) {
+ RETURN_STRING("link", 1);
+ }
+ switch(stat_sb->st_mode & S_IFMT) {
+ case S_IFDIR: RETURN_STRING("dir", 1);
+ case S_IFREG: RETURN_STRING("file", 1);
+ }
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%u)", stat_sb->st_mode & S_IFMT);
+ RETURN_STRING("unknown", 1);
+ case FS_IS_W:
+ RETURN_BOOL((stat_sb->st_mode & wmask) != 0);
+ case FS_IS_R:
+ RETURN_BOOL((stat_sb->st_mode&rmask)!=0);
+ case FS_IS_X:
+ RETURN_BOOL((stat_sb->st_mode&xmask)!=0 && !S_ISDIR(stat_sb->st_mode));
+ case FS_IS_FILE:
+ RETURN_BOOL(S_ISREG(stat_sb->st_mode));
+ case FS_IS_DIR:
+ RETURN_BOOL(S_ISDIR(stat_sb->st_mode));
+ case FS_IS_LINK:
+ RETURN_BOOL(S_ISLNK(stat_sb->st_mode));
+ case FS_EXISTS:
+ RETURN_TRUE; /* the false case was done earlier */
+ case FS_LSTAT:
+ /* FALLTHROUGH */
+ case FS_STAT:
+ array_init(return_value);
+
+ MAKE_LONG_ZVAL_INCREF(stat_dev, stat_sb->st_dev);
+ MAKE_LONG_ZVAL_INCREF(stat_ino, stat_sb->st_ino);
+ MAKE_LONG_ZVAL_INCREF(stat_mode, stat_sb->st_mode);
+ MAKE_LONG_ZVAL_INCREF(stat_nlink, stat_sb->st_nlink);
+ MAKE_LONG_ZVAL_INCREF(stat_uid, stat_sb->st_uid);
+ MAKE_LONG_ZVAL_INCREF(stat_gid, stat_sb->st_gid);
+#ifdef HAVE_ST_RDEV
+ MAKE_LONG_ZVAL_INCREF(stat_rdev, stat_sb->st_rdev);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
+#endif
+ MAKE_LONG_ZVAL_INCREF(stat_size, stat_sb->st_size);
+#ifdef NETWARE
+ MAKE_LONG_ZVAL_INCREF(stat_atime, (stat_sb->st_atime).tv_sec);
+ MAKE_LONG_ZVAL_INCREF(stat_mtime, (stat_sb->st_mtime).tv_sec);
+ MAKE_LONG_ZVAL_INCREF(stat_ctime, (stat_sb->st_ctime).tv_sec);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_atime, stat_sb->st_atime);
+ MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_sb->st_mtime);
+ MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_sb->st_ctime);
+#endif
+#ifdef HAVE_ST_BLKSIZE
+ MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_sb->st_blksize);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_blksize,-1);
+#endif
+#ifdef HAVE_ST_BLOCKS
+ MAKE_LONG_ZVAL_INCREF(stat_blocks, stat_sb->st_blocks);
+#else
+ MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
+#endif
+ /* Store numeric indexes in propper order */
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_dev, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ino, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mode, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_nlink, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_uid, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_gid, sizeof(zval *), NULL);
+
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_rdev, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_size, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_atime, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mtime, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ctime, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blksize, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blocks, sizeof(zval *), NULL);
+
+ /* Store string indexes referencing the same zval*/
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0])+1, (void *) &stat_dev, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1])+1, (void *) &stat_ino, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2])+1, (void *) &stat_mode, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3])+1, (void *) &stat_nlink, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4])+1, (void *) &stat_uid, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5])+1, (void *) &stat_gid, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6])+1, (void *) &stat_rdev, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7])+1, (void *) &stat_size, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8])+1, (void *) &stat_atime, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9])+1, (void *) &stat_mtime, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10])+1, (void *) &stat_ctime, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11])+1, (void *) &stat_blksize, sizeof(zval *), NULL);
+ zend_hash_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12])+1, (void *) &stat_blocks, sizeof(zval *), NULL);
+
+ return;
+ }
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Didn't understand stat call");
+ RETURN_FALSE;
+}
+/* }}} */
+
+static void phar_file_stat(const char *filename, php_stat_len filename_length, int type, void (*orig_stat_func)(INTERNAL_FUNCTION_PARAMETERS), INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
+{
+ if (!filename_length) {
+ RETURN_FALSE;
+ }
+
+ if (!IS_ABSOLUTE_PATH(filename, filename_length) && !strstr(filename, "://")) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ struct stat sb = {0};
+ phar_entry_info *data = NULL;
+ phar_archive_data *phar;
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ /* we are checking for existence of a file within the relative path. Chances are good that this is
+ retrieving something from within the phar archive */
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (PHAR_G(last_phar) && fname_len - 7 >= PHAR_G(last_phar_name_len) && !memcmp(fname + 7, PHAR_G(last_phar_name), PHAR_G(last_phar_name_len))) {
+ arch = estrndup(PHAR_G(last_phar_name), PHAR_G(last_phar_name_len));
+ arch_len = PHAR_G(last_phar_name_len);
+ entry = estrndup(filename, filename_length);
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = (int) filename_length;
+ phar = PHAR_G(last_phar);
+ goto splitted;
+ }
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+
+ efree(entry);
+ entry = estrndup(filename, filename_length);
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = (int) filename_length;
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ efree(entry);
+ goto skip_phar;
+ }
+splitted:
+ entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &data)) {
+ efree(entry);
+ goto stat_entry;
+ }
+ goto notfound;
+ }
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &data)) {
+ efree(entry);
+ goto stat_entry;
+ }
+ if (zend_hash_exists(&(phar->virtual_dirs), entry, entry_len)) {
+ efree(entry);
+ efree(arch);
+ if (IS_EXISTS_CHECK(type)) {
+ RETURN_TRUE;
+ }
+ sb.st_size = 0;
+ sb.st_mode = 0777;
+ sb.st_mode |= S_IFDIR; /* regular directory */
+#ifdef NETWARE
+ sb.st_mtime.tv_sec = phar->max_timestamp;
+ sb.st_atime.tv_sec = phar->max_timestamp;
+ sb.st_ctime.tv_sec = phar->max_timestamp;
+#else
+ sb.st_mtime = phar->max_timestamp;
+ sb.st_atime = phar->max_timestamp;
+ sb.st_ctime = phar->max_timestamp;
+#endif
+ goto statme_baby;
+ } else {
+ char *save;
+ int save_len;
+
+notfound:
+ efree(entry);
+ save = PHAR_G(cwd);
+ save_len = PHAR_G(cwd_len);
+ /* this file is not in the current directory, use the original path */
+ entry = estrndup(filename, filename_length);
+ entry_len = filename_length;
+ PHAR_G(cwd) = "/";
+ PHAR_G(cwd_len) = 0;
+ /* clean path without cwd */
+ entry = phar_fix_filepath(entry, &entry_len, 1 TSRMLS_CC);
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &data)) {
+ PHAR_G(cwd) = save;
+ PHAR_G(cwd_len) = save_len;
+ efree(entry);
+ if (IS_EXISTS_CHECK(type)) {
+ efree(arch);
+ RETURN_TRUE;
+ }
+ goto stat_entry;
+ }
+ if (zend_hash_exists(&(phar->virtual_dirs), entry + 1, entry_len - 1)) {
+ PHAR_G(cwd) = save;
+ PHAR_G(cwd_len) = save_len;
+ efree(entry);
+ efree(arch);
+ if (IS_EXISTS_CHECK(type)) {
+ RETURN_TRUE;
+ }
+ sb.st_size = 0;
+ sb.st_mode = 0777;
+ sb.st_mode |= S_IFDIR; /* regular directory */
+#ifdef NETWARE
+ sb.st_mtime.tv_sec = phar->max_timestamp;
+ sb.st_atime.tv_sec = phar->max_timestamp;
+ sb.st_ctime.tv_sec = phar->max_timestamp;
+#else
+ sb.st_mtime = phar->max_timestamp;
+ sb.st_atime = phar->max_timestamp;
+ sb.st_ctime = phar->max_timestamp;
+#endif
+ goto statme_baby;
+ }
+ PHAR_G(cwd) = save;
+ PHAR_G(cwd_len) = save_len;
+ efree(entry);
+ efree(arch);
+ /* Error Occured */
+ if (!IS_EXISTS_CHECK(type)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%sstat failed for %s", IS_LINK_OPERATION(type) ? "L" : "", filename);
+ }
+ RETURN_FALSE;
+ }
+stat_entry:
+ efree(arch);
+ if (!data->is_dir) {
+ sb.st_size = data->uncompressed_filesize;
+ sb.st_mode = data->flags & PHAR_ENT_PERM_MASK;
+ if (data->link) {
+ sb.st_mode |= S_IFREG|S_IFLNK; /* regular file */
+ } else {
+ sb.st_mode |= S_IFREG; /* regular file */
+ }
+ /* timestamp is just the timestamp when this was added to the phar */
+#ifdef NETWARE
+ sb.st_mtime.tv_sec = data->timestamp;
+ sb.st_atime.tv_sec = data->timestamp;
+ sb.st_ctime.tv_sec = data->timestamp;
+#else
+ sb.st_mtime = data->timestamp;
+ sb.st_atime = data->timestamp;
+ sb.st_ctime = data->timestamp;
+#endif
+ } else {
+ sb.st_size = 0;
+ sb.st_mode = data->flags & PHAR_ENT_PERM_MASK;
+ sb.st_mode |= S_IFDIR; /* regular directory */
+ if (data->link) {
+ sb.st_mode |= S_IFLNK;
+ }
+ /* timestamp is just the timestamp when this was added to the phar */
+#ifdef NETWARE
+ sb.st_mtime.tv_sec = data->timestamp;
+ sb.st_atime.tv_sec = data->timestamp;
+ sb.st_ctime.tv_sec = data->timestamp;
+#else
+ sb.st_mtime = data->timestamp;
+ sb.st_atime = data->timestamp;
+ sb.st_ctime = data->timestamp;
+#endif
+ }
+
+statme_baby:
+ if (!phar->is_writeable) {
+ sb.st_mode = (sb.st_mode & 0555) | (sb.st_mode & ~0777);
+ }
+
+ sb.st_nlink = 1;
+ sb.st_rdev = -1;
+ /* this is only for APC, so use /dev/null device - no chance of conflict there! */
+ sb.st_dev = 0xc;
+ /* generate unique inode number for alias/filename, so no phars will conflict */
+ if (data) {
+ sb.st_ino = data->inode;
+ }
+#ifndef PHP_WIN32
+ sb.st_blksize = -1;
+ sb.st_blocks = -1;
+#endif
+ phar_fancy_stat(&sb, type, return_value TSRMLS_CC);
+ return;
+ }
+ }
+skip_phar:
+ orig_stat_func(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+#define PharFileFunction(fname, funcnum, orig) \
+void fname(INTERNAL_FUNCTION_PARAMETERS) { \
+ if (!PHAR_G(intercepted)) { \
+ PHAR_G(orig)(INTERNAL_FUNCTION_PARAM_PASSTHRU); \
+ } else { \
+ char *filename; \
+ int filename_len; \
+ \
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { \
+ return; \
+ } \
+ \
+ phar_file_stat(filename, (php_stat_len) filename_len, funcnum, PHAR_G(orig), INTERNAL_FUNCTION_PARAM_PASSTHRU); \
+ } \
+}
+/* }}} */
+
+/* {{{ proto int fileperms(string filename)
+ Get file permissions */
+PharFileFunction(phar_fileperms, FS_PERMS, orig_fileperms)
+/* }}} */
+
+/* {{{ proto int fileinode(string filename)
+ Get file inode */
+PharFileFunction(phar_fileinode, FS_INODE, orig_fileinode)
+/* }}} */
+
+/* {{{ proto int filesize(string filename)
+ Get file size */
+PharFileFunction(phar_filesize, FS_SIZE, orig_filesize)
+/* }}} */
+
+/* {{{ proto int fileowner(string filename)
+ Get file owner */
+PharFileFunction(phar_fileowner, FS_OWNER, orig_fileowner)
+/* }}} */
+
+/* {{{ proto int filegroup(string filename)
+ Get file group */
+PharFileFunction(phar_filegroup, FS_GROUP, orig_filegroup)
+/* }}} */
+
+/* {{{ proto int fileatime(string filename)
+ Get last access time of file */
+PharFileFunction(phar_fileatime, FS_ATIME, orig_fileatime)
+/* }}} */
+
+/* {{{ proto int filemtime(string filename)
+ Get last modification time of file */
+PharFileFunction(phar_filemtime, FS_MTIME, orig_filemtime)
+/* }}} */
+
+/* {{{ proto int filectime(string filename)
+ Get inode modification time of file */
+PharFileFunction(phar_filectime, FS_CTIME, orig_filectime)
+/* }}} */
+
+/* {{{ proto string filetype(string filename)
+ Get file type */
+PharFileFunction(phar_filetype, FS_TYPE, orig_filetype)
+/* }}} */
+
+/* {{{ proto bool is_writable(string filename)
+ Returns true if file can be written */
+PharFileFunction(phar_is_writable, FS_IS_W, orig_is_writable)
+/* }}} */
+
+/* {{{ proto bool is_readable(string filename)
+ Returns true if file can be read */
+PharFileFunction(phar_is_readable, FS_IS_R, orig_is_readable)
+/* }}} */
+
+/* {{{ proto bool is_executable(string filename)
+ Returns true if file is executable */
+PharFileFunction(phar_is_executable, FS_IS_X, orig_is_executable)
+/* }}} */
+
+/* {{{ proto bool file_exists(string filename)
+ Returns true if filename exists */
+PharFileFunction(phar_file_exists, FS_EXISTS, orig_file_exists)
+/* }}} */
+
+/* {{{ proto bool is_dir(string filename)
+ Returns true if file is directory */
+PharFileFunction(phar_is_dir, FS_IS_DIR, orig_is_dir)
+/* }}} */
+
+PHAR_FUNC(phar_is_file) /* {{{ */
+{
+ char *filename;
+ int filename_len;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ goto skip_phar;
+ }
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+ goto skip_phar;
+ }
+ if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ /* we are checking for existence of a file within the relative path. Chances are good that this is
+ retrieving something from within the phar archive */
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ phar_archive_data *phar;
+
+ efree(entry);
+ entry = filename;
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+ /* retrieving a file within the current directory, so use this if possible */
+ if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ phar_entry_info *etemp;
+
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &etemp)) {
+ /* this file is not in the current directory, use the original path */
+found_it:
+ efree(entry);
+ efree(arch);
+ RETURN_BOOL(!etemp->is_dir);
+ }
+ } else {
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &etemp)) {
+ goto found_it;
+ }
+ }
+ }
+ if (entry != filename) {
+ efree(entry);
+ }
+ efree(arch);
+ RETURN_FALSE;
+ }
+ }
+skip_phar:
+ PHAR_G(orig_is_file)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+PHAR_FUNC(phar_is_link) /* {{{ */
+{
+ char *filename;
+ int filename_len;
+
+ if (!PHAR_G(intercepted)) {
+ goto skip_phar;
+ }
+
+ if ((PHAR_GLOBALS->phar_fname_map.arBuckets && !zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)))
+ && !cached_phars.arBuckets) {
+ goto skip_phar;
+ }
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+ goto skip_phar;
+ }
+ if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
+ char *arch, *entry, *fname;
+ int arch_len, entry_len, fname_len;
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ /* we are checking for existence of a file within the relative path. Chances are good that this is
+ retrieving something from within the phar archive */
+
+ if (strncasecmp(fname, "phar://", 7)) {
+ goto skip_phar;
+ }
+ fname_len = strlen(fname);
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ phar_archive_data *phar;
+
+ efree(entry);
+ entry = filename;
+ /* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ entry_len = filename_len;
+ /* retrieving a file within the current directory, so use this if possible */
+ if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ phar_entry_info *etemp;
+
+ entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
+ if (entry[0] == '/') {
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry + 1, entry_len - 1, (void **) &etemp)) {
+ /* this file is not in the current directory, use the original path */
+found_it:
+ efree(entry);
+ efree(arch);
+ RETURN_BOOL(etemp->link);
+ }
+ } else {
+ if (SUCCESS == zend_hash_find(&(phar->manifest), entry, entry_len, (void **) &etemp)) {
+ goto found_it;
+ }
+ }
+ }
+ efree(entry);
+ efree(arch);
+ RETURN_FALSE;
+ }
+ }
+skip_phar:
+ PHAR_G(orig_is_link)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return;
+}
+/* }}} */
+
+/* {{{ proto array lstat(string filename)
+ Give information about a file or symbolic link */
+PharFileFunction(phar_lstat, FS_LSTAT, orig_lstat)
+/* }}} */
+
+/* {{{ proto array stat(string filename)
+ Give information about a file */
+PharFileFunction(phar_stat, FS_STAT, orig_stat)
+/* }}} */
+
+/* {{{ void phar_intercept_functions(TSRMLS_D) */
+void phar_intercept_functions(TSRMLS_D)
+{
+ if (!PHAR_G(request_init)) {
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+ }
+ PHAR_G(intercepted) = 1;
+}
+/* }}} */
+
+/* {{{ void phar_release_functions(TSRMLS_D) */
+void phar_release_functions(TSRMLS_D)
+{
+ PHAR_G(intercepted) = 0;
+}
+/* }}} */
+
+/* {{{ void phar_intercept_functions_init(TSRMLS_D) */
+#define PHAR_INTERCEPT(func) \
+ PHAR_G(orig_##func) = NULL; \
+ if (SUCCESS == zend_hash_find(CG(function_table), #func, sizeof(#func), (void **)&orig)) { \
+ PHAR_G(orig_##func) = orig->internal_function.handler; \
+ orig->internal_function.handler = phar_##func; \
+ }
+
+void phar_intercept_functions_init(TSRMLS_D)
+{
+ zend_function *orig;
+
+ PHAR_INTERCEPT(fopen);
+ PHAR_INTERCEPT(file_get_contents);
+ PHAR_INTERCEPT(is_file);
+ PHAR_INTERCEPT(is_link);
+ PHAR_INTERCEPT(is_dir);
+ PHAR_INTERCEPT(opendir);
+ PHAR_INTERCEPT(file_exists);
+ PHAR_INTERCEPT(fileperms);
+ PHAR_INTERCEPT(fileinode);
+ PHAR_INTERCEPT(filesize);
+ PHAR_INTERCEPT(fileowner);
+ PHAR_INTERCEPT(filegroup);
+ PHAR_INTERCEPT(fileatime);
+ PHAR_INTERCEPT(filemtime);
+ PHAR_INTERCEPT(filectime);
+ PHAR_INTERCEPT(filetype);
+ PHAR_INTERCEPT(is_writable);
+ PHAR_INTERCEPT(is_readable);
+ PHAR_INTERCEPT(is_executable);
+ PHAR_INTERCEPT(lstat);
+ PHAR_INTERCEPT(stat);
+ PHAR_INTERCEPT(readfile);
+ PHAR_G(intercepted) = 0;
+}
+/* }}} */
+
+/* {{{ void phar_intercept_functions_shutdown(TSRMLS_D) */
+#define PHAR_RELEASE(func) \
+ if (PHAR_G(orig_##func) && SUCCESS == zend_hash_find(CG(function_table), #func, sizeof(#func), (void **)&orig)) { \
+ orig->internal_function.handler = PHAR_G(orig_##func); \
+ } \
+ PHAR_G(orig_##func) = NULL;
+
+void phar_intercept_functions_shutdown(TSRMLS_D)
+{
+ zend_function *orig;
+
+ PHAR_RELEASE(fopen);
+ PHAR_RELEASE(file_get_contents);
+ PHAR_RELEASE(is_file);
+ PHAR_RELEASE(is_dir);
+ PHAR_RELEASE(opendir);
+ PHAR_RELEASE(file_exists);
+ PHAR_RELEASE(fileperms);
+ PHAR_RELEASE(fileinode);
+ PHAR_RELEASE(filesize);
+ PHAR_RELEASE(fileowner);
+ PHAR_RELEASE(filegroup);
+ PHAR_RELEASE(fileatime);
+ PHAR_RELEASE(filemtime);
+ PHAR_RELEASE(filectime);
+ PHAR_RELEASE(filetype);
+ PHAR_RELEASE(is_writable);
+ PHAR_RELEASE(is_readable);
+ PHAR_RELEASE(is_executable);
+ PHAR_RELEASE(lstat);
+ PHAR_RELEASE(stat);
+ PHAR_RELEASE(readfile);
+ PHAR_G(intercepted) = 0;
+}
+/* }}} */
+
+static struct _phar_orig_functions {
+ void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS);
+} phar_orig_functions = {NULL};
+
+void phar_save_orig_functions(TSRMLS_D) /* {{{ */
+{
+ phar_orig_functions.orig_fopen = PHAR_G(orig_fopen);
+ phar_orig_functions.orig_file_get_contents = PHAR_G(orig_file_get_contents);
+ phar_orig_functions.orig_is_file = PHAR_G(orig_is_file);
+ phar_orig_functions.orig_is_link = PHAR_G(orig_is_link);
+ phar_orig_functions.orig_is_dir = PHAR_G(orig_is_dir);
+ phar_orig_functions.orig_opendir = PHAR_G(orig_opendir);
+ phar_orig_functions.orig_file_exists = PHAR_G(orig_file_exists);
+ phar_orig_functions.orig_fileperms = PHAR_G(orig_fileperms);
+ phar_orig_functions.orig_fileinode = PHAR_G(orig_fileinode);
+ phar_orig_functions.orig_filesize = PHAR_G(orig_filesize);
+ phar_orig_functions.orig_fileowner = PHAR_G(orig_fileowner);
+ phar_orig_functions.orig_filegroup = PHAR_G(orig_filegroup);
+ phar_orig_functions.orig_fileatime = PHAR_G(orig_fileatime);
+ phar_orig_functions.orig_filemtime = PHAR_G(orig_filemtime);
+ phar_orig_functions.orig_filectime = PHAR_G(orig_filectime);
+ phar_orig_functions.orig_filetype = PHAR_G(orig_filetype);
+ phar_orig_functions.orig_is_writable = PHAR_G(orig_is_writable);
+ phar_orig_functions.orig_is_readable = PHAR_G(orig_is_readable);
+ phar_orig_functions.orig_is_executable = PHAR_G(orig_is_executable);
+ phar_orig_functions.orig_lstat = PHAR_G(orig_lstat);
+ phar_orig_functions.orig_readfile = PHAR_G(orig_readfile);
+ phar_orig_functions.orig_stat = PHAR_G(orig_stat);
+}
+/* }}} */
+
+void phar_restore_orig_functions(TSRMLS_D) /* {{{ */
+{
+ PHAR_G(orig_fopen) = phar_orig_functions.orig_fopen;
+ PHAR_G(orig_file_get_contents) = phar_orig_functions.orig_file_get_contents;
+ PHAR_G(orig_is_file) = phar_orig_functions.orig_is_file;
+ PHAR_G(orig_is_link) = phar_orig_functions.orig_is_link;
+ PHAR_G(orig_is_dir) = phar_orig_functions.orig_is_dir;
+ PHAR_G(orig_opendir) = phar_orig_functions.orig_opendir;
+ PHAR_G(orig_file_exists) = phar_orig_functions.orig_file_exists;
+ PHAR_G(orig_fileperms) = phar_orig_functions.orig_fileperms;
+ PHAR_G(orig_fileinode) = phar_orig_functions.orig_fileinode;
+ PHAR_G(orig_filesize) = phar_orig_functions.orig_filesize;
+ PHAR_G(orig_fileowner) = phar_orig_functions.orig_fileowner;
+ PHAR_G(orig_filegroup) = phar_orig_functions.orig_filegroup;
+ PHAR_G(orig_fileatime) = phar_orig_functions.orig_fileatime;
+ PHAR_G(orig_filemtime) = phar_orig_functions.orig_filemtime;
+ PHAR_G(orig_filectime) = phar_orig_functions.orig_filectime;
+ PHAR_G(orig_filetype) = phar_orig_functions.orig_filetype;
+ PHAR_G(orig_is_writable) = phar_orig_functions.orig_is_writable;
+ PHAR_G(orig_is_readable) = phar_orig_functions.orig_is_readable;
+ PHAR_G(orig_is_executable) = phar_orig_functions.orig_is_executable;
+ PHAR_G(orig_lstat) = phar_orig_functions.orig_lstat;
+ PHAR_G(orig_readfile) = phar_orig_functions.orig_readfile;
+ PHAR_G(orig_stat) = phar_orig_functions.orig_stat;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
+
diff --git a/ext/phar/func_interceptors.h b/ext/phar/func_interceptors.h
new file mode 100644
index 0000000..59d6bf6
--- /dev/null
+++ b/ext/phar/func_interceptors.h
@@ -0,0 +1,38 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2006-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+BEGIN_EXTERN_C()
+void phar_intercept_functions(TSRMLS_D);
+void phar_release_functions(TSRMLS_D);
+void phar_intercept_functions_init(TSRMLS_D);
+void phar_intercept_functions_shutdown(TSRMLS_D);
+void phar_save_orig_functions(TSRMLS_D);
+void phar_restore_orig_functions(TSRMLS_D);
+END_EXTERN_C()
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/gdbhelp b/ext/phar/gdbhelp
new file mode 100644
index 0000000..5411858
--- /dev/null
+++ b/ext/phar/gdbhelp
@@ -0,0 +1,122 @@
+define ___pharglobals
+ if basic_functions_module.zts
+ set $tsrm_ls = ts_resource_ex(0, 0)
+ set $pharglobals = ((zend_phar_globals) (*((void ***) $tsrm_ls))[phar_globals_id-1])
+ else
+ set $pharglobals = phar_globals
+ end
+end
+
+define ____print_pharht
+ set $ht = $arg0
+ set $p = $ht.pListHead
+
+ while $p != 0
+ set $i = $ind
+ while $i > 0
+ printf " "
+ set $i = $i - 1
+ end
+
+ set $temp = *(phar_archive_data*)$p->pDataPtr
+ ____print_str $temp.fname $temp.fname_len
+ printf " => "
+
+ if $arg1 == 0
+
+ printf "%i (alias ", $temp.refcount
+ ____print_str $temp.alias $temp.alias_len
+ printf ")\n"
+ end
+
+ set $p = $p->pListNext
+ end
+end
+
+define print_phar
+ set $ind = 1
+ ___pharglobals
+ printf "{"
+ ____print_pharht $pharglobals.phar_fname_map 0
+ printf "}\n"
+end
+
+document display_phar_globals
+ display phar globals
+end
+
+define display_phar_globals
+ ___pharglobals
+ graph display $phar_globals.$arg0
+end
+
+define print_pharfp
+ ___pharglobals
+ set $ht = $pharglobals.phar_fname_map
+ set $p = $ht.pListHead
+ set $fpcount = 0
+
+ while $p != 0
+ set $pharname = (*(phar_archive_data*)$p->pDataPtr).fname
+ set $pharrefcount = (*(phar_archive_data*)$p->pDataPtr).refcount
+ if (*(phar_archive_data*)$p->pDataPtr).fp != 0
+ set $fpcount = $fpcount + 1
+ printf "phar %s is open (%i)\n", $pharname, $pharrefcount
+ end
+ set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
+ set $m = $manifest.pListHead
+ while $m != 0
+ if (*(phar_entry_info *)$m->pData).fp
+ set $fpcount = $fpcount + 1
+ set $a = (*(phar_entry_info *)$m->pData).fp_refcount
+ printf "phar %s file %s is open (%i)\n", $pharname, (*(phar_entry_info *)$m->pData).filename, $a
+ end
+ set $m = $m->pListNext
+ end
+
+ set $p = $p->pListNext
+ end
+ printf "Open file pointers: %d\n", $fpcount
+end
+
+document print_pharfp
+ displays all open file pointers in phar, and the phars plus entries that are open with reference counts
+end
+
+define dump_entry
+ ___pharglobals
+ set $ht = $pharglobals.phar_fname_map
+ set $p = $ht.pListHead
+ set $done = 0
+ while $p != 0
+ set $t = (*(phar_archive_data*)$p->pDataPtr)
+ if $t.fname[0] == $arg0[0] || $t.alias[0] == $arg0[0]
+ set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
+ set $m = $manifest.pListHead
+ while $m != 0
+ if (*(phar_entry_info *)$m->pData).filename[0] == $arg1[0]
+ if $argc == 3
+ output *((phar_entry_info *)$m->pData)->fp
+ end
+ if $argc == 2
+ output *(phar_entry_info *)$m->pData
+ end
+ printf "\n"
+ set $done = 1
+ loop_break
+ end
+ set $m = $m->pListNext
+ end
+ end
+ if $done == 1
+ loop_break
+ end
+ set $p = $p->pListNext
+ end
+end
+
+document dump_entry
+ dump_entry "pharname"|"pharalias" "filename" [1]
+ display phar_entry_info for a file within a phar. If the optional third param
+ is passed in, displays the php_stream that is the file's fp
+end \ No newline at end of file
diff --git a/ext/phar/makestub.php b/ext/phar/makestub.php
new file mode 100644
index 0000000..2bb30e9
--- /dev/null
+++ b/ext/phar/makestub.php
@@ -0,0 +1,109 @@
+<?php
+$s = str_replace("\r", '', file_get_contents(dirname(__FILE__) . '/shortarc.php'));
+
+$s .= "\nExtract_Phar::go();\n__HALT_COMPILER();";
+$news = '';
+foreach (token_get_all($s) as $token) {
+ if (is_array($token)) {
+ if ($token[0] == T_COMMENT) {
+ $token[1] = '';
+ }
+ if ($token[0] == T_WHITESPACE) {
+ $n = str_repeat("\n", substr_count($token[1], "\n"));
+ $token[1] = strlen($n) ? $n : ' ';
+ }
+ $news .= $token[1];
+ } else {
+ $news .= $token;
+ }
+}
+$s = $news . ' ?>';
+$slen = strlen($s) - strlen('index.php') - strlen("000");
+$s = str_replace('\\', '\\\\', $s);
+$s = str_replace('"', '\\"', $s);
+$s = str_replace("\n", '\n', $s);
+// now we need to find the location of web index file
+$webs = substr($s, 0, strpos($s, "000"));
+$s = substr($s, strlen($webs) + strlen("000"));
+$s1 = substr($s, 0, strpos($s, 'index.php'));
+$s2 = substr($s, strlen($s1) + strlen('index.php'));
+$s2 = substr($s2, 0, strpos($s2, 'XXXX'));
+$s3 = substr($s, strlen($s2) + 4 + strlen($s1) + strlen('index.php'));
+
+$stub = '/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension generated stub |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-' . date('Y') . ' The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
+{
+';
+$s1split = str_split($s1, 2046);
+$s3split = str_split($s3, 2046);
+$took = false;
+foreach ($s1split as $i => $chunk) {
+ if ($took) {
+ $s1split[$i] = substr($chunk, 1);
+ $took = false;
+ }
+ if ($chunk[strlen($chunk) - 1] == '\\') {
+ $s1split[$i] .= $s1split[$i + 1][0];
+ $took = true;
+ }
+}
+foreach ($s3split as $i => $chunk) {
+ if ($took) {
+ $s3split[$i] = substr($chunk, 1);
+ $took = false;
+ }
+ if ($chunk[strlen($chunk) - 1] == '\\') {
+ $s3split[$i] .= $s3split[$i + 1][0];
+ $took = true;
+ }
+}
+$stub .= "\tstatic const char newstub0[] = \"" . $webs . '";
+';
+foreach ($s1split as $i => $chunk) {
+ $s1count = $i + 1;
+ $stub .= "\tstatic const char newstub1_" . $i . '[] = "' . $chunk . '";
+';
+}
+$stub .= "\tstatic const char newstub2[] = \"" . $s2 . "\";
+";
+foreach ($s3split as $i => $chunk) {
+ $s3count = $i + 1;
+ $stub .= "\tstatic const char newstub3_" . $i . '[] = "' . $chunk . '";
+';
+}
+$stub .= "\n\tstatic const int newstub_len = " . $slen . ";
+
+\t*len = spprintf(stub, name_len + web_len + newstub_len, \"%s%s" . str_repeat('%s', $s1count) . '%s%s%d'
+ . str_repeat('%s', $s3count) . '", newstub0, web';
+foreach ($s1split as $i => $unused) {
+ $stub .= ', newstub1_' . $i;
+}
+$stub .= ', index_php, newstub2';
+$stub .= ", name_len + web_len + newstub_len";
+foreach ($s3split as $i => $unused) {
+ $stub .= ', newstub3_' . $i;
+}
+$stub .= ");
+}";
+
+file_put_contents(dirname(__FILE__) . '/stub.h', $stub."\n");
+?>
diff --git a/ext/phar/package.xml b/ext/phar/package.xml
new file mode 100644
index 0000000..4a9798e
--- /dev/null
+++ b/ext/phar/package.xml
@@ -0,0 +1,1452 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.8.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>phar</name>
+ <channel>pecl.php.net</channel>
+ <summary>allows running of complete applications out of .phar files (like Java .jar files)</summary>
+ <description>This is the extension version of PEAR&apos;s PHP_Archive package. Support for
+zlib, bz2 and crc32 is achieved without any dependency other than the external
+zlib or bz2 extension.
+
+.phar files can be read using the phar stream, or with the Phar class. If the SPL extension
+is available, a Phar object can be used as an array to iterate over a phar&apos;s contents
+or to read files directly from the phar.
+
+Phar supports tar and zip file formats as well as the native phar file format, and can also be
+used to create data-only tar and zip archives with the PharData class, even if
+write access is disabled by the phar.readonly ini variable.
+
+Executable phar archives can be created using the streams API or with the Phar class, if
+the phar.readonly ini variable is set to false.
+
+Full support for MD5 and SHA1 signatures is possible. Signatures can be required
+if the ini variable phar.require_hash is set to true. When PECL extension hash is
+available then SHA-256 and SHA-512 signatures are supported as well.
+
+Phar is APC-compatible, the latest APC will cache files within a phar archive, resulting in
+a 6x speedup measured running phpMyAdmin as a phar archive.</description>
+ <lead>
+ <name>Greg Beaver</name>
+ <user>cellog</user>
+ <email>cellog@php.net</email>
+ <active>yes</active>
+ </lead>
+ <lead>
+ <name>Marcus Boerger</name>
+ <user>helly</user>
+ <email>helly@php.net</email>
+ <active>yes</active>
+ </lead>
+ <developer>
+ <name>Steph Fox</name>
+ <user>sfox</user>
+ <email>sfox@php.net</email>
+ <active>yes</active>
+ </developer>
+ <date>2009-07-26</date>
+ <time>15:41:33</time>
+ <version>
+ <release>2.0.0</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0RC2:
+ fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
+ getSignature() call
+ fixed PHP Bug #49020: phar misinterprets ustar long filename standard
+ fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
+ fixed PHP Bug #48791: open office files always reported as corrupted
+ fixed PHP Bug #48783: make install will fail saying phar file exists
+ fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
+ fixed PHP Bug #48681: openssl signature verification for tar archives broken
+ fixed PHP Bug #48377: error message unclear on converting phar with existing file
+ fixed isset() on sub-directories (isset(&quot;blah&quot;) if file &quot;blah/foo.php&quot; exists)
+
+ make phar work in PHP 6
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <dir name="phar">
+ <file name="clicommand.inc" role="src" />
+ <file name="directorygraphiterator.inc" role="src" />
+ <file name="directorytreeiterator.inc" role="src" />
+ <file name="invertedregexiterator.inc" role="src" />
+ <file name="phar.inc" role="src" />
+ <file name="phar.php" role="src" />
+ <file name="pharcommand.inc" role="src" />
+ </dir> <!-- /phar -->
+ <dir name="tests">
+ <dir name="cache_list">
+ <dir name="files">
+ <file name="blog.phar" role="test" />
+ <file name="blog.phar.inc" role="test" />
+ <file name="config.xml" role="test" />
+ <file name="extracted.inc" role="test" />
+ <file name="frontcontroller.phar" role="test" />
+ <file name="frontcontroller.phar.inc" role="test" />
+ <file name="frontcontroller2.phar" role="test" />
+ <file name="frontcontroller2.phar.inc" role="test" />
+ <file name="frontcontroller3.phar" role="test" />
+ <file name="frontcontroller3.phar.inc" role="test" />
+ <file name="frontcontroller4.phar" role="test" />
+ <file name="frontcontroller4.phar.inc" role="test" />
+ <file name="frontcontroller5.phar" role="test" />
+ <file name="frontcontroller5.phar.inc" role="test" />
+ <file name="frontcontroller6.phar" role="test" />
+ <file name="frontcontroller6.phar.inc" role="test" />
+ <file name="frontcontroller7.phar" role="test" />
+ <file name="frontcontroller7.phar.inc" role="test" />
+ <file name="frontcontroller8.phar" role="test" />
+ <file name="frontcontroller8.phar.inc" role="test" />
+ <file name="frontcontroller9.phar" role="test" />
+ <file name="frontcontroller9.phar.inc" role="test" />
+ <file name="frontcontroller10.phar" role="test" />
+ <file name="frontcontroller10.phar.inc" role="test" />
+ <file name="frontcontroller11.phar" role="test" />
+ <file name="frontcontroller11.phar.inc" role="test" />
+ <file name="frontcontroller12.phar" role="test" />
+ <file name="frontcontroller12.phar.inc" role="test" />
+ <file name="frontcontroller13.phar" role="test" />
+ <file name="frontcontroller13.phar.inc" role="test" />
+ <file name="frontcontroller14.phar" role="test" />
+ <file name="frontcontroller14.phar.inc" role="test" />
+ <file name="frontcontroller16.phar" role="test" />
+ <file name="frontcontroller16.phar.inc" role="test" />
+ <file name="frontcontroller17.phar" role="test" />
+ <file name="frontcontroller17.phar.inc" role="test" />
+ <file name="frontcontroller18.phar" role="test" />
+ <file name="frontcontroller18.phar.inc" role="test" />
+ <file name="frontcontroller19.phar" role="test" />
+ <file name="frontcontroller19.phar.inc" role="test" />
+ <file name="md5.phar" role="test" />
+ <file name="nophar.phar" role="test" />
+ <file name="nophar.phar.inc" role="test" />
+ <file name="openssl.phar" role="test" />
+ <file name="openssl.phar.pubkey" role="test" />
+ <file name="phar_oo_test.inc" role="test" />
+ <file name="phar_test.inc" role="test" />
+ <file name="private.pem" role="test" />
+ <file name="sha1.phar" role="test" />
+ <file name="sha256.phar" role="test" />
+ <file name="sha512.phar" role="test" />
+ <file name="write.phar" role="test" />
+ <file name="write.phar.inc" role="test" />
+ <file name="write2.phar" role="test" />
+ <file name="write2.phar.inc" role="test" />
+ <file name="write3.phar" role="test" />
+ <file name="write3.phar.inc" role="test" />
+ <file name="write4.phar" role="test" />
+ <file name="write4.phar.inc" role="test" />
+ <file name="write5.phar" role="test" />
+ <file name="write5.phar.inc" role="test" />
+ <file name="write6.phar" role="test" />
+ <file name="write6.phar.inc" role="test" />
+ <file name="write7.phar" role="test" />
+ <file name="write7.phar.inc" role="test" />
+ <file name="write8.phar" role="test" />
+ <file name="write8.phar.inc" role="test" />
+ <file name="write9.phar" role="test" />
+ <file name="write9.phar.inc" role="test" />
+ <file name="write10.phar" role="test" />
+ <file name="write10.phar.inc" role="test" />
+ <file name="write11.phar" role="test" />
+ <file name="write11.phar.inc" role="test" />
+ <file name="write12.phar" role="test" />
+ <file name="write12.phar.inc" role="test" />
+ <file name="write13.phar" role="test" />
+ <file name="write13.phar.inc" role="test" />
+ <file name="write14.phar" role="test" />
+ <file name="write14.phar.inc" role="test" />
+ <file name="write15.phar" role="test" />
+ <file name="write15.phar.inc" role="test" />
+ <file name="write16.phar" role="test" />
+ <file name="write16.phar.inc" role="test" />
+ <file name="write17.phar" role="test" />
+ <file name="write17.phar.inc" role="test" />
+ <file name="write18.phar" role="test" />
+ <file name="write18.phar.inc" role="test" />
+ <file name="write19.phar" role="test" />
+ <file name="write19.phar.inc" role="test" />
+ <file name="write20.phar" role="test" />
+ <file name="write20.phar.inc" role="test" />
+ <file name="write21.phar" role="test" />
+ <file name="write21.phar.inc" role="test" />
+ <file name="write22.phar" role="test" />
+ <file name="write22.phar.inc" role="test" />
+ <file name="write23.phar" role="test" />
+ <file name="write23.phar.inc" role="test" />
+ <file name="write24.phar" role="test" />
+ <file name="write24.phar.inc" role="test" />
+ <file name="write25.phar" role="test" />
+ <file name="write25.phar.inc" role="test" />
+ <file name="zfapp.tgz" role="test" />
+ </dir> <!-- /tests/cache_list/files -->
+ <file name="copyonwrite1.phar.phpt" role="test" />
+ <file name="copyonwrite2.phar.phpt" role="test" />
+ <file name="copyonwrite3.phar.phpt" role="test" />
+ <file name="copyonwrite4.phar.phpt" role="test" />
+ <file name="copyonwrite4a.phpt" role="test" />
+ <file name="copyonwrite5.phar.phpt" role="test" />
+ <file name="copyonwrite6.phar.phpt" role="test" />
+ <file name="copyonwrite7.phar.phpt" role="test" />
+ <file name="copyonwrite8.phar.phpt" role="test" />
+ <file name="copyonwrite9.phar.phpt" role="test" />
+ <file name="copyonwrite10.phar.phpt" role="test" />
+ <file name="copyonwrite11.phar.phpt" role="test" />
+ <file name="copyonwrite12.phar.phpt" role="test" />
+ <file name="copyonwrite13.phar.phpt" role="test" />
+ <file name="copyonwrite14.phar.phpt" role="test" />
+ <file name="copyonwrite15.phar.phpt" role="test" />
+ <file name="copyonwrite16.phar.phpt" role="test" />
+ <file name="copyonwrite17.phar.phpt" role="test" />
+ <file name="copyonwrite18.phar.phpt" role="test" />
+ <file name="copyonwrite19.phar.phpt" role="test" />
+ <file name="copyonwrite20.phar.phpt" role="test" />
+ <file name="copyonwrite21.phar.phpt" role="test" />
+ <file name="copyonwrite22.phar.phpt" role="test" />
+ <file name="copyonwrite23.phar.phpt" role="test" />
+ <file name="copyonwrite24.phar.phpt" role="test" />
+ <file name="copyonwrite25.phar.phpt" role="test" />
+ <file name="frontcontroller1.phpt" role="test" />
+ <file name="frontcontroller2.phpt" role="test" />
+ <file name="frontcontroller3.phpt" role="test" />
+ <file name="frontcontroller4.phpt" role="test" />
+ <file name="frontcontroller5.phpt" role="test" />
+ <file name="frontcontroller6.phpt" role="test" />
+ <file name="frontcontroller7.phpt" role="test" />
+ <file name="frontcontroller8.phpt" role="test" />
+ <file name="frontcontroller9.phpt" role="test" />
+ <file name="frontcontroller10.phpt" role="test" />
+ <file name="frontcontroller11.phpt" role="test" />
+ <file name="frontcontroller12.phpt" role="test" />
+ <file name="frontcontroller13.phpt" role="test" />
+ <file name="frontcontroller14.phpt" role="test" />
+ <file name="frontcontroller15.phpt" role="test" />
+ <file name="frontcontroller16.phpt" role="test" />
+ <file name="frontcontroller17.phpt" role="test" />
+ <file name="frontcontroller18.phpt" role="test" />
+ <file name="frontcontroller19.phpt" role="test" />
+ <file name="frontcontroller20.phpt" role="test" />
+ <file name="frontcontroller21.phpt" role="test" />
+ <file name="frontcontroller22.phpt" role="test" />
+ <file name="frontcontroller23.phpt" role="test" />
+ <file name="frontcontroller24.phpt" role="test" />
+ <file name="frontcontroller25.phpt" role="test" />
+ <file name="frontcontroller26.phpt" role="test" />
+ <file name="frontcontroller27.phpt" role="test" />
+ <file name="frontcontroller28.phpt" role="test" />
+ <file name="frontcontroller29.phpt" role="test" />
+ <file name="frontcontroller30.phpt" role="test" />
+ <file name="frontcontroller31.phpt" role="test" />
+ <file name="frontcontroller32.phpt" role="test" />
+ <file name="frontcontroller33.phpt" role="test" />
+ <file name="frontcontroller34.phpt" role="test" />
+ </dir> <!-- /tests/cache_list -->
+ <dir name="files">
+ <file name="blog.phar" role="test" />
+ <file name="blog.phar.inc" role="test" />
+ <file name="config.xml" role="test" />
+ <file name="extracted.inc" role="test" />
+ <file name="frontcontroller.phar" role="test" />
+ <file name="frontcontroller.phar.inc" role="test" />
+ <file name="frontcontroller2.phar" role="test" />
+ <file name="frontcontroller2.phar.inc" role="test" />
+ <file name="frontcontroller3.phar" role="test" />
+ <file name="frontcontroller3.phar.inc" role="test" />
+ <file name="frontcontroller4.phar" role="test" />
+ <file name="frontcontroller4.phar.inc" role="test" />
+ <file name="frontcontroller5.phar" role="test" />
+ <file name="frontcontroller5.phar.inc" role="test" />
+ <file name="frontcontroller6.phar" role="test" />
+ <file name="frontcontroller6.phar.inc" role="test" />
+ <file name="frontcontroller7.phar" role="test" />
+ <file name="frontcontroller7.phar.inc" role="test" />
+ <file name="frontcontroller8.phar" role="test" />
+ <file name="frontcontroller8.phar.inc" role="test" />
+ <file name="frontcontroller9.phar" role="test" />
+ <file name="frontcontroller9.phar.inc" role="test" />
+ <file name="frontcontroller10.phar" role="test" />
+ <file name="frontcontroller10.phar.inc" role="test" />
+ <file name="frontcontroller11.phar" role="test" />
+ <file name="frontcontroller11.phar.inc" role="test" />
+ <file name="frontcontroller12.phar" role="test" />
+ <file name="frontcontroller12.phar.inc" role="test" />
+ <file name="frontcontroller13.phar" role="test" />
+ <file name="frontcontroller13.phar.inc" role="test" />
+ <file name="frontcontroller14.phar" role="test" />
+ <file name="frontcontroller14.phar.inc" role="test" />
+ <file name="frontcontroller16.phar" role="test" />
+ <file name="frontcontroller16.phar.inc" role="test" />
+ <file name="frontcontroller17.phar" role="test" />
+ <file name="frontcontroller17.phar.inc" role="test" />
+ <file name="frontcontroller18.phar" role="test" />
+ <file name="frontcontroller18.phar.inc" role="test" />
+ <file name="frontcontroller19.phar" role="test" />
+ <file name="frontcontroller19.phar.inc" role="test" />
+ <file name="include_path.phar" role="test" />
+ <file name="include_path.phar.inc" role="test" />
+ <file name="include_path2.phar" role="test" />
+ <file name="md5.phar" role="test" />
+ <file name="nophar.phar" role="test" />
+ <file name="nophar.phar.inc" role="test" />
+ <file name="notbogus.zip" role="test" />
+ <file name="openssl.phar" role="test" />
+ <file name="openssl.phar.pubkey" role="test" />
+ <file name="phar_oo_test.inc" role="test" />
+ <file name="phar_test.inc" role="test" />
+ <file name="private.pem" role="test" />
+ <file name="sha1.phar" role="test" />
+ <file name="sha256.phar" role="test" />
+ <file name="sha512.phar" role="test" />
+ <file name="zfapp.tgz" role="test" />
+ </dir> <!-- /tests/files -->
+ <dir name="tar">
+ <dir name="files">
+ <file name="badalias1.phar.tar" role="test" />
+ <file name="badalias2.phar.tar" role="test" />
+ <file name="badalias3.phar.tar" role="test" />
+ <file name="badalias4.phar.tar" role="test" />
+ <file name="badalias5.phar.tar" role="test" />
+ <file name="biglink.tar" role="test" />
+ <file name="corrupt_tarmaker.php.inc" role="test" />
+ <file name="frontcontroller.phar.inc" role="test" />
+ <file name="frontcontroller.phar.tar" role="test" />
+ <file name="frontcontroller2.phar.inc" role="test" />
+ <file name="frontcontroller2.phar.tar" role="test" />
+ <file name="frontcontroller3.phar.inc" role="test" />
+ <file name="frontcontroller3.phar.tar" role="test" />
+ <file name="frontcontroller4.phar.inc" role="test" />
+ <file name="frontcontroller4.phar.tar" role="test" />
+ <file name="frontcontroller5.phar.inc" role="test" />
+ <file name="frontcontroller5.phar.tar" role="test" />
+ <file name="frontcontroller6.phar.inc" role="test" />
+ <file name="frontcontroller6.phar.tar" role="test" />
+ <file name="frontcontroller7.phar.inc" role="test" />
+ <file name="frontcontroller7.phar.tar" role="test" />
+ <file name="frontcontroller8.phar.inc" role="test" />
+ <file name="frontcontroller8.phar.tar" role="test" />
+ <file name="frontcontroller9.phar.inc" role="test" />
+ <file name="frontcontroller9.phar.tar" role="test" />
+ <file name="frontcontroller10.phar.inc" role="test" />
+ <file name="frontcontroller10.phar.tar" role="test" />
+ <file name="frontcontroller11.phar.inc" role="test" />
+ <file name="frontcontroller11.phar.tar" role="test" />
+ <file name="frontcontroller12.phar.inc" role="test" />
+ <file name="frontcontroller12.phar.tar" role="test" />
+ <file name="links.phar.tar" role="test" />
+ <file name="links.tar" role="test" />
+ <file name="make.dangerous.tar.php.inc" role="test" />
+ <file name="make_invalid_tar.php.inc" role="test" />
+ <file name="Net_URL-1.0.15.tgz" role="test" />
+ <file name="P1-1.0.0.tgz" role="test" />
+ <file name="P1-1.0.0.tgz.pubkey" role="test" />
+ <file name="subdirlink.tar" role="test" />
+ <file name="tarmaker.php.inc" role="test" />
+ <file name="tinylink.tar" role="test" />
+ <file name="trunc.tar" role="test" />
+ </dir> <!-- /tests/tar/files -->
+ <file name="033.phpt" role="test" />
+ <file name="033a.phpt" role="test" />
+ <file name="alias_acrobatics.phpt" role="test" />
+ <file name="all.phpt" role="test" />
+ <file name="allU.phpt" role="test" />
+ <file name="badalias.phpt" role="test" />
+ <file name="badchecksum.phpt" role="test" />
+ <file name="bignames.phpt" role="test" />
+ <file name="bignames_overflow.phpt" role="test" />
+ <file name="create_new_and_modify.phpt" role="test" />
+ <file name="create_new_phar_b.phpt" role="test" />
+ <file name="delete.phpt" role="test" />
+ <file name="delete_in_phar.phpt" role="test" />
+ <file name="delete_in_phar_b.phpt" role="test" />
+ <file name="delete_in_phar_confirm.phpt" role="test" />
+ <file name="dir.phpt" role="test" />
+ <file name="exists_as_phar.phpt" role="test" />
+ <file name="frontcontroller1.phar.phpt" role="test" />
+ <file name="frontcontroller2.phar.phpt" role="test" />
+ <file name="frontcontroller3.phar.phpt" role="test" />
+ <file name="frontcontroller4.phar.phpt" role="test" />
+ <file name="frontcontroller5.phar.phpt" role="test" />
+ <file name="frontcontroller6.phar.phpt" role="test" />
+ <file name="frontcontroller7.phar.phpt" role="test" />
+ <file name="frontcontroller8.phar.phpt" role="test" />
+ <file name="frontcontroller9.phar.phpt" role="test" />
+ <file name="frontcontroller10.phar.phpt" role="test" />
+ <file name="frontcontroller11.phar.phpt" role="test" />
+ <file name="frontcontroller12.phar.phpt" role="test" />
+ <file name="frontcontroller13.phar.phpt" role="test" />
+ <file name="frontcontroller14.phar.phpt" role="test" />
+ <file name="frontcontroller15.phar.phpt" role="test" />
+ <file name="frontcontroller16.phar.phpt" role="test" />
+ <file name="frontcontroller17.phar.phpt" role="test" />
+ <file name="frontcontroller18.phar.phpt" role="test" />
+ <file name="frontcontroller19.phar.phpt" role="test" />
+ <file name="frontcontroller20.phar.phpt" role="test" />
+ <file name="frontcontroller21.phar.phpt" role="test" />
+ <file name="links.phpt" role="test" />
+ <file name="links2.phpt" role="test" />
+ <file name="links3.phpt" role="test" />
+ <file name="links4.phpt" role="test" />
+ <file name="links5.phpt" role="test" />
+ <file name="links6.phpt" role="test" />
+ <file name="open_for_write_existing.phpt" role="test" />
+ <file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
+ <file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile.phpt" role="test" />
+ <file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
+ <file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
+ <file name="phar_buildfromiterator4.phpt" role="test" />
+ <file name="phar_buildfromiterator5.phpt" role="test" />
+ <file name="phar_buildfromiterator6.phpt" role="test" />
+ <file name="phar_buildfromiterator7.phpt" role="test" />
+ <file name="phar_buildfromiterator8.phpt" role="test" />
+ <file name="phar_buildfromiterator9.phpt" role="test" />
+ <file name="phar_commitwrite.phpt" role="test" />
+ <file name="phar_convert_phar.phpt" role="test" />
+ <file name="phar_convert_phar2.phpt" role="test" />
+ <file name="phar_convert_phar3.phpt" role="test" />
+ <file name="phar_convert_phar4.phpt" role="test" />
+ <file name="phar_copy.phpt" role="test" />
+ <file name="phar_magic.phpt" role="test" />
+ <file name="phar_setalias.phpt" role="test" />
+ <file name="phar_setalias2.phpt" role="test" />
+ <file name="phar_setdefaultstub.phpt" role="test" />
+ <file name="phar_setsignaturealgo2.phpt" role="test" />
+ <file name="phar_stub.phpt" role="test" />
+ <file name="phar_stub_error.phpt" role="test" />
+ <file name="refcount1.phpt" role="test" />
+ <file name="refcount1_5_2.phpt" role="test" />
+ <file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="require_hash.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
+ <file name="tar_001.phpt" role="test" />
+ <file name="tar_002.phpt" role="test" />
+ <file name="tar_003.phpt" role="test" />
+ <file name="tar_004.phpt" role="test" />
+ <file name="tar_004U.phpt" role="test" />
+ <file name="tar_bz2.phpt" role="test" />
+ <file name="tar_bz2U.phpt" role="test" />
+ <file name="tar_gzip.phpt" role="test" />
+ <file name="tar_gzipU.phpt" role="test" />
+ <file name="tar_makebz2.phpt" role="test" />
+ <file name="tar_makegz.phpt" role="test" />
+ <file name="tar_nohash.phpt" role="test" />
+ <file name="tar_nostub.phpt" role="test" />
+ <file name="tar_openssl_hash.phpt" role="test" />
+ <file name="truncated.phpt" role="test" />
+ </dir> <!-- /tests/tar -->
+ <dir name="zip">
+ <dir name="files">
+ <file name="badalias1.phar.zip" role="test" />
+ <file name="badalias2.phar.zip" role="test" />
+ <file name="badalias3.phar.zip" role="test" />
+ <file name="badalias4.phar.zip" role="test" />
+ <file name="badalias5.phar.zip" role="test" />
+ <file name="bz2_alias.phar.zip" role="test" />
+ <file name="bzip2.zip" role="test" />
+ <file name="cdir_offset.zip" role="test" />
+ <file name="compress_unsup1.zip" role="test" />
+ <file name="compress_unsup2.zip" role="test" />
+ <file name="compress_unsup3.zip" role="test" />
+ <file name="compress_unsup4.zip" role="test" />
+ <file name="compress_unsup5.zip" role="test" />
+ <file name="compress_unsup6.zip" role="test" />
+ <file name="compress_unsup7.zip" role="test" />
+ <file name="compress_unsup9.zip" role="test" />
+ <file name="compress_unsup10.zip" role="test" />
+ <file name="compress_unsup14.zip" role="test" />
+ <file name="compress_unsup18.zip" role="test" />
+ <file name="compress_unsup19.zip" role="test" />
+ <file name="compress_unsup97.zip" role="test" />
+ <file name="compress_unsup98.zip" role="test" />
+ <file name="compress_unsupunknown.zip" role="test" />
+ <file name="corrupt2.php.inc" role="test" />
+ <file name="corrupt3.php.inc" role="test" />
+ <file name="corrupt_count1.php.inc" role="test" />
+ <file name="corrupt_zipmaker.php.inc" role="test" />
+ <file name="count1.zip" role="test" />
+ <file name="count2.zip" role="test" />
+ <file name="disknumber.zip" role="test" />
+ <file name="encrypted.zip" role="test" />
+ <file name="extralen_toolong.zip" role="test" />
+ <file name="filecomment.zip" role="test" />
+ <file name="frontcontroller.phar.inc" role="test" />
+ <file name="frontcontroller.phar.zip" role="test" />
+ <file name="frontcontroller2.phar.inc" role="test" />
+ <file name="frontcontroller2.phar.zip" role="test" />
+ <file name="frontcontroller3.phar.inc" role="test" />
+ <file name="frontcontroller3.phar.zip" role="test" />
+ <file name="frontcontroller4.phar.inc" role="test" />
+ <file name="frontcontroller4.phar.zip" role="test" />
+ <file name="frontcontroller5.phar.inc" role="test" />
+ <file name="frontcontroller5.phar.zip" role="test" />
+ <file name="frontcontroller6.phar.inc" role="test" />
+ <file name="frontcontroller6.phar.zip" role="test" />
+ <file name="frontcontroller7.phar.inc" role="test" />
+ <file name="frontcontroller7.phar.zip" role="test" />
+ <file name="frontcontroller8.phar.inc" role="test" />
+ <file name="frontcontroller8.phar.zip" role="test" />
+ <file name="frontcontroller9.phar.inc" role="test" />
+ <file name="frontcontroller9.phar.zip" role="test" />
+ <file name="frontcontroller10.phar.inc" role="test" />
+ <file name="frontcontroller10.phar.zip" role="test" />
+ <file name="frontcontroller11.phar.inc" role="test" />
+ <file name="frontcontroller11.phar.zip" role="test" />
+ <file name="frontcontroller12.phar.inc" role="test" />
+ <file name="frontcontroller12.phar.zip" role="test" />
+ <file name="make_invalid_tar.php.inc" role="test" />
+ <file name="metadata.phar.inc" role="test" />
+ <file name="metadata.phar.zip" role="test" />
+ <file name="nozipend.zip" role="test" />
+ <file name="odt.odt" role="test" />
+ <file name="stdin.zip" role="test" />
+ <file name="test.odt" role="test" />
+ <file name="truncfilename.zip" role="test" />
+ <file name="zip.zip" role="test" />
+ <file name="zipmaker.php.inc" role="test" />
+ <file name="zlib_alias.phar.zip" role="test" />
+ </dir> <!-- /tests/zip/files -->
+ <file name="033.phpt" role="test" />
+ <file name="033a.phpt" role="test" />
+ <file name="alias_acrobatics.phpt" role="test" />
+ <file name="all.phpt" role="test" />
+ <file name="allU.phpt" role="test" />
+ <file name="badalias.phpt" role="test" />
+ <file name="bug48791.phpt" role="test" />
+ <file name="bzip2.phpt" role="test" />
+ <file name="corrupt_001.phpt" role="test" />
+ <file name="corrupt_002.phpt" role="test" />
+ <file name="corrupt_003.phpt" role="test" />
+ <file name="corrupt_004.phpt" role="test" />
+ <file name="corrupt_005.phpt" role="test" />
+ <file name="corrupt_006.phpt" role="test" />
+ <file name="corrupt_007.phpt" role="test" />
+ <file name="corrupt_008.phpt" role="test" />
+ <file name="corrupt_009.phpt" role="test" />
+ <file name="corrupt_010.phpt" role="test" />
+ <file name="create_new_and_modify.phpt" role="test" />
+ <file name="create_new_phar_b.phpt" role="test" />
+ <file name="delete.phpt" role="test" />
+ <file name="delete_in_phar.phpt" role="test" />
+ <file name="delete_in_phar_b.phpt" role="test" />
+ <file name="delete_in_phar_confirm.phpt" role="test" />
+ <file name="dir.phpt" role="test" />
+ <file name="exists_as_phar.phpt" role="test" />
+ <file name="frontcontroller1.phar.phpt" role="test" />
+ <file name="frontcontroller2.phar.phpt" role="test" />
+ <file name="frontcontroller3.phar.phpt" role="test" />
+ <file name="frontcontroller4.phar.phpt" role="test" />
+ <file name="frontcontroller5.phar.phpt" role="test" />
+ <file name="frontcontroller6.phar.phpt" role="test" />
+ <file name="frontcontroller7.phar.phpt" role="test" />
+ <file name="frontcontroller8.phar.phpt" role="test" />
+ <file name="frontcontroller9.phar.phpt" role="test" />
+ <file name="frontcontroller10.phar.phpt" role="test" />
+ <file name="frontcontroller11.phar.phpt" role="test" />
+ <file name="frontcontroller12.phar.phpt" role="test" />
+ <file name="frontcontroller13.phar.phpt" role="test" />
+ <file name="frontcontroller14.phar.phpt" role="test" />
+ <file name="frontcontroller15.phar.phpt" role="test" />
+ <file name="frontcontroller16.phar.phpt" role="test" />
+ <file name="frontcontroller17.phar.phpt" role="test" />
+ <file name="frontcontroller18.phar.phpt" role="test" />
+ <file name="frontcontroller19.phar.phpt" role="test" />
+ <file name="frontcontroller20.phar.phpt" role="test" />
+ <file name="frontcontroller21.phar.phpt" role="test" />
+ <file name="getalias.phpt" role="test" />
+ <file name="largezip.phpt" role="test" />
+ <file name="metadata_write_commit.phpt" role="test" />
+ <file name="metadata_write_commitU.phpt" role="test" />
+ <file name="notphar.phpt" role="test" />
+ <file name="odt.phpt" role="test" />
+ <file name="open_for_write_existing.phpt" role="test" />
+ <file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
+ <file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile.phpt" role="test" />
+ <file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
+ <file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
+ <file name="phar_buildfromiterator4.phpt" role="test" />
+ <file name="phar_buildfromiterator5.phpt" role="test" />
+ <file name="phar_buildfromiterator6.phpt" role="test" />
+ <file name="phar_buildfromiterator7.phpt" role="test" />
+ <file name="phar_buildfromiterator8.phpt" role="test" />
+ <file name="phar_buildfromiterator9.phpt" role="test" />
+ <file name="phar_commitwrite.phpt" role="test" />
+ <file name="phar_convert_phar.phpt" role="test" />
+ <file name="phar_copy.phpt" role="test" />
+ <file name="phar_magic.phpt" role="test" />
+ <file name="phar_magicU.phpt" role="test" />
+ <file name="phar_oo_compressallbz2.phpt" role="test" />
+ <file name="phar_oo_compressallgz.phpt" role="test" />
+ <file name="phar_setalias.phpt" role="test" />
+ <file name="phar_setalias2.phpt" role="test" />
+ <file name="phar_setdefaultstub.phpt" role="test" />
+ <file name="phar_setsignaturealgo2.phpt" role="test" />
+ <file name="phar_stub.phpt" role="test" />
+ <file name="phar_stub_error.phpt" role="test" />
+ <file name="refcount1.phpt" role="test" />
+ <file name="refcount1_5_2.phpt" role="test" />
+ <file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
+ <file name="unixzip.phpt" role="test" />
+ <file name="zlib.phpt" role="test" />
+ </dir> <!-- /tests/zip -->
+ <file name="001.phpt" role="test" />
+ <file name="002.phpt" role="test" />
+ <file name="003.phpt" role="test" />
+ <file name="003a.phpt" role="test" />
+ <file name="004.phpt" role="test" />
+ <file name="005.phpt" role="test" />
+ <file name="006.phpt" role="test" />
+ <file name="007.phpt" role="test" />
+ <file name="008.phpt" role="test" />
+ <file name="009.phpt" role="test" />
+ <file name="010.phpt" role="test" />
+ <file name="011.phpt" role="test" />
+ <file name="012.phpt" role="test" />
+ <file name="013.phpt" role="test" />
+ <file name="014.phpt" role="test" />
+ <file name="015.phpt" role="test" />
+ <file name="015b.phpt" role="test" />
+ <file name="016.phpt" role="test" />
+ <file name="016b.phpt" role="test" />
+ <file name="017.phpt" role="test" />
+ <file name="017U.phpt" role="test" />
+ <file name="018.phpt" role="test" />
+ <file name="018U.phpt" role="test" />
+ <file name="019.phpt" role="test" />
+ <file name="019b.phpt" role="test" />
+ <file name="019bU.phpt" role="test" />
+ <file name="019c.phpt" role="test" />
+ <file name="019cU.phpt" role="test" />
+ <file name="020.phpt" role="test" />
+ <file name="021.phpt" role="test" />
+ <file name="022.phpt" role="test" />
+ <file name="023.phpt" role="test" />
+ <file name="024.phpt" role="test" />
+ <file name="025.phpt" role="test" />
+ <file name="026.phpt" role="test" />
+ <file name="027.phpt" role="test" />
+ <file name="027U.phpt" role="test" />
+ <file name="028.phpt" role="test" />
+ <file name="029.phpt" role="test" />
+ <file name="030.phpt" role="test" />
+ <file name="031.phpt" role="test" />
+ <file name="032.phpt" role="test" />
+ <file name="033.phpt" role="test" />
+ <file name="033a.phpt" role="test" />
+ <file name="addfuncs.phpt" role="test" />
+ <file name="alias_acrobatics.phpt" role="test" />
+ <file name="badparameters.phpt" role="test" />
+ <file name="bug13727.phpt" role="test" />
+ <file name="bug13786.phpt" role="test" />
+ <file name="bug45218_SLOWTEST.phpt" role="test" />
+ <file name="bug45218_SLOWTESTU.phpt" role="test" />
+ <file name="bug46032.phpt" role="test" />
+ <file name="bug46060.phpt" role="test" />
+ <file name="bug46178.phpt" role="test" />
+ <file name="bug47085.phpt" role="test" />
+ <file name="bug48377.2.phpt" role="test" />
+ <file name="bug48377.phpt" role="test" />
+ <file name="cached_manifest_1.phpt" role="test" />
+ <file name="cached_manifest_1U.phpt" role="test" />
+ <file name="create_new_and_modify.phpt" role="test" />
+ <file name="create_new_phar.phpt" role="test" />
+ <file name="create_new_phar_b.phpt" role="test" />
+ <file name="create_new_phar_c.phpt" role="test" />
+ <file name="create_path_error.phpt" role="test" />
+ <file name="delete.phpt" role="test" />
+ <file name="delete_in_phar.phpt" role="test" />
+ <file name="delete_in_phar_b.phpt" role="test" />
+ <file name="delete_in_phar_confirm.phpt" role="test" />
+ <file name="dir.phpt" role="test" />
+ <file name="fgc_edgecases.phpt" role="test" />
+ <file name="file_get_contents.phpt" role="test" />
+ <file name="fopen.phpt" role="test" />
+ <file name="fopen5.2.phpt" role="test" />
+ <file name="fopen_edgecases.phpt" role="test" />
+ <file name="fopen_edgecases2.phpt" role="test" />
+ <file name="fopen_edgecases2U.phpt" role="test" />
+ <file name="front.phar.phpt" role="test" />
+ <file name="frontcontroller1.phpt" role="test" />
+ <file name="frontcontroller2.phpt" role="test" />
+ <file name="frontcontroller3.phpt" role="test" />
+ <file name="frontcontroller4.phpt" role="test" />
+ <file name="frontcontroller5.phpt" role="test" />
+ <file name="frontcontroller6.phpt" role="test" />
+ <file name="frontcontroller7.phpt" role="test" />
+ <file name="frontcontroller8.phpt" role="test" />
+ <file name="frontcontroller9.phpt" role="test" />
+ <file name="frontcontroller10.phpt" role="test" />
+ <file name="frontcontroller11.phpt" role="test" />
+ <file name="frontcontroller12.phpt" role="test" />
+ <file name="frontcontroller13.phpt" role="test" />
+ <file name="frontcontroller14.phpt" role="test" />
+ <file name="frontcontroller15.phpt" role="test" />
+ <file name="frontcontroller16.phpt" role="test" />
+ <file name="frontcontroller17.phpt" role="test" />
+ <file name="frontcontroller18.phpt" role="test" />
+ <file name="frontcontroller19.phpt" role="test" />
+ <file name="frontcontroller20.phpt" role="test" />
+ <file name="frontcontroller21.phpt" role="test" />
+ <file name="frontcontroller22.phpt" role="test" />
+ <file name="frontcontroller23.phpt" role="test" />
+ <file name="frontcontroller24.phpt" role="test" />
+ <file name="frontcontroller25.phpt" role="test" />
+ <file name="frontcontroller26.phpt" role="test" />
+ <file name="frontcontroller27.phpt" role="test" />
+ <file name="frontcontroller28.phpt" role="test" />
+ <file name="frontcontroller29.phpt" role="test" />
+ <file name="frontcontroller30.phpt" role="test" />
+ <file name="frontcontroller31.phpt" role="test" />
+ <file name="frontcontroller32.phpt" role="test" />
+ <file name="frontcontroller33.phpt" role="test" />
+ <file name="frontcontroller34.phpt" role="test" />
+ <file name="include_path.phpt" role="test" />
+ <file name="include_path_advanced.phpt" role="test" />
+ <file name="ini_set.phpt" role="test" />
+ <file name="ini_set_off.phpt" role="test" />
+ <file name="ini_set_offU.phpt" role="test" />
+ <file name="invalid_alias.phpt" role="test" />
+ <file name="invalid_setstubalias.phpt" role="test" />
+ <file name="metadata_read.phpt" role="test" />
+ <file name="metadata_readU.phpt" role="test" />
+ <file name="metadata_write.phpt" role="test" />
+ <file name="metadata_writeU.phpt" role="test" />
+ <file name="metadata_write_commit.phpt" role="test" />
+ <file name="metadata_write_commitU.phpt" role="test" />
+ <file name="mkdir.phpt" role="test" />
+ <file name="mounteddir.phpt" role="test" />
+ <file name="mounteddirU.phpt" role="test" />
+ <file name="nophar.phpt" role="test" />
+ <file name="nophar_web.phpt" role="test" />
+ <file name="opendir.phpt" role="test" />
+ <file name="opendir_edgecases.phpt" role="test" />
+ <file name="open_for_write_existing.phpt" role="test" />
+ <file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
+ <file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile.phpt" role="test" />
+ <file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
+ <file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
+ <file name="pharfileinfo_chmod.phpt" role="test" />
+ <file name="pharfileinfo_compression.phpt" role="test" />
+ <file name="pharfileinfo_construct.phpt" role="test" />
+ <file name="pharfileinfo_destruct.phpt" role="test" />
+ <file name="pharfileinfo_getcrc32.phpt" role="test" />
+ <file name="pharfileinfo_setmetadata.phpt" role="test" />
+ <file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
+ <file name="phar_buildfromdirectory1.phpt" role="test" />
+ <file name="phar_buildfromdirectory2.phpt" role="test" />
+ <file name="phar_buildfromdirectory3.phpt" role="test" />
+ <file name="phar_buildfromdirectory4.phpt" role="test" />
+ <file name="phar_buildfromdirectory5.phpt" role="test" />
+ <file name="phar_buildfromdirectory6.phpt" role="test" />
+ <file name="phar_buildfromiterator1.phpt" role="test" />
+ <file name="phar_buildfromiterator2.phpt" role="test" />
+ <file name="phar_buildfromiterator3.phpt" role="test" />
+ <file name="phar_buildfromiterator4.phpt" role="test" />
+ <file name="phar_buildfromiterator5.phpt" role="test" />
+ <file name="phar_buildfromiterator6.phpt" role="test" />
+ <file name="phar_buildfromiterator7.phpt" role="test" />
+ <file name="phar_buildfromiterator8.phpt" role="test" />
+ <file name="phar_buildfromiterator9.phpt" role="test" />
+ <file name="phar_buildfromiterator10.phpt" role="test" />
+ <file name="phar_bz2.phpt" role="test" />
+ <file name="phar_commitwrite.phpt" role="test" />
+ <file name="phar_construct_invalidurl.phpt" role="test" />
+ <file name="phar_convert_again.phpt" role="test" />
+ <file name="phar_convert_repeated.phpt" role="test" />
+ <file name="phar_convert_repeated_b.phpt" role="test" />
+ <file name="phar_convert_tar.phpt" role="test" />
+ <file name="phar_convert_tar2.phpt" role="test" />
+ <file name="phar_convert_tar3.phpt" role="test" />
+ <file name="phar_convert_zip.phpt" role="test" />
+ <file name="phar_copy.phpt" role="test" />
+ <file name="phar_createdefaultstub.phpt" role="test" />
+ <file name="phar_create_in_cwd.phpt" role="test" />
+ <file name="phar_ctx_001.phpt" role="test" />
+ <file name="phar_decompress.phpt" role="test" />
+ <file name="phar_dir_iterate.phpt" role="test" />
+ <file name="phar_dotted_path.phpt" role="test" />
+ <file name="phar_extract.phpt" role="test" />
+ <file name="phar_extract2.phpt" role="test" />
+ <file name="phar_extract3.phpt" role="test" />
+ <file name="phar_get_supportedcomp1.phpt" role="test" />
+ <file name="phar_get_supportedcomp2.phpt" role="test" />
+ <file name="phar_get_supportedcomp3.phpt" role="test" />
+ <file name="phar_get_supportedcomp4.phpt" role="test" />
+ <file name="phar_get_supported_signatures_001.phpt" role="test" />
+ <file name="phar_get_supported_signatures_001a.phpt" role="test" />
+ <file name="phar_get_supported_signatures_002.phpt" role="test" />
+ <file name="phar_get_supported_signatures_002a.phpt" role="test" />
+ <file name="phar_gobyebye.phpt" role="test" />
+ <file name="phar_gzip.phpt" role="test" />
+ <file name="phar_gzipU.phpt" role="test" />
+ <file name="phar_isvalidpharfilename.phpt" role="test" />
+ <file name="phar_magic.phpt" role="test" />
+ <file name="phar_metadata_read.phpt" role="test" />
+ <file name="phar_metadata_readU.phpt" role="test" />
+ <file name="phar_metadata_write.phpt" role="test" />
+ <file name="phar_metadata_writeU.phpt" role="test" />
+ <file name="phar_mount.phpt" role="test" />
+ <file name="phar_offset_check.phpt" role="test" />
+ <file name="phar_offset_get_error.phpt" role="test" />
+ <file name="phar_oo_001.phpt" role="test" />
+ <file name="phar_oo_001U.phpt" role="test" />
+ <file name="phar_oo_002.phpt" role="test" />
+ <file name="phar_oo_002U.phpt" role="test" />
+ <file name="phar_oo_003.phpt" role="test" />
+ <file name="phar_oo_004.phpt" role="test" />
+ <file name="phar_oo_004U.phpt" role="test" />
+ <file name="phar_oo_005.phpt" role="test" />
+ <file name="phar_oo_005U.phpt" role="test" />
+ <file name="phar_oo_005_5.2.phpt" role="test" />
+ <file name="phar_oo_006.phpt" role="test" />
+ <file name="phar_oo_007.phpt" role="test" />
+ <file name="phar_oo_008.phpt" role="test" />
+ <file name="phar_oo_009.phpt" role="test" />
+ <file name="phar_oo_010.phpt" role="test" />
+ <file name="phar_oo_011.phpt" role="test" />
+ <file name="phar_oo_011b.phpt" role="test" />
+ <file name="phar_oo_012.phpt" role="test" />
+ <file name="phar_oo_012b.phpt" role="test" />
+ <file name="phar_oo_012_confirm.phpt" role="test" />
+ <file name="phar_oo_compressallbz2.phpt" role="test" />
+ <file name="phar_oo_compressallgz.phpt" role="test" />
+ <file name="phar_oo_compressed_001.phpt" role="test" />
+ <file name="phar_oo_compressed_001b.phpt" role="test" />
+ <file name="phar_oo_compressed_002.phpt" role="test" />
+ <file name="phar_oo_compressed_002b.phpt" role="test" />
+ <file name="phar_oo_getcontents.phpt" role="test" />
+ <file name="phar_oo_getcontentsgz.phpt" role="test" />
+ <file name="phar_oo_getmodified.phpt" role="test" />
+ <file name="phar_oo_iswriteable.phpt" role="test" />
+ <file name="phar_oo_nosig.phpt" role="test" />
+ <file name="phar_oo_uncompressall.phpt" role="test" />
+ <file name="phar_running.phpt" role="test" />
+ <file name="phar_setalias.phpt" role="test" />
+ <file name="phar_setalias2.phpt" role="test" />
+ <file name="phar_setdefaultstub.phpt" role="test" />
+ <file name="phar_setsignaturealgo1.phpt" role="test" />
+ <file name="phar_setsignaturealgo2.phpt" role="test" />
+ <file name="phar_stub.phpt" role="test" />
+ <file name="phar_stub_error.phpt" role="test" />
+ <file name="phar_stub_write.phpt" role="test" />
+ <file name="phar_stub_write_file.phpt" role="test" />
+ <file name="phar_unlinkarchive.phpt" role="test" />
+ <file name="phpinfo_001.phpt" role="test" />
+ <file name="phpinfo_002.phpt" role="test" />
+ <file name="phpinfo_003.phpt" role="test" />
+ <file name="phpinfo_004.phpt" role="test" />
+ <file name="readfile.phpt" role="test" />
+ <file name="readfile_edgecases.phpt" role="test" />
+ <file name="readfile_edgecasesU.phpt" role="test" />
+ <file name="refcount1.phpt" role="test" />
+ <file name="refcount1_5_2.phpt" role="test" />
+ <file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="rename_dir_and_mount.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
+ <file name="security.phpt" role="test" />
+ <file name="stat.phpt" role="test" />
+ <file name="stat2.phpt" role="test" />
+ <file name="stat2_5.3.phpt" role="test" />
+ <file name="test_alias_unset.phpt" role="test" />
+ <file name="test_signaturealgos.phpt" role="test" />
+ <file name="test_unset.phpt" role="test" />
+ <file name="webphar_compilefail.phpt" role="test" />
+ <file name="withphar.phpt" role="test" />
+ <file name="withphar_web.phpt" role="test" />
+ <file name="zf_test.phpt" role="test" />
+ </dir> <!-- /tests -->
+ <file name="build_precommand.php" role="php" />
+ <file name="config.m4" role="src" />
+ <file name="config.w32" role="src" />
+ <file name="CREDITS" role="doc" />
+ <file name="dirstream.c" role="src" />
+ <file name="dirstream.h" role="src" />
+ <file name="func_interceptors.c" role="src" />
+ <file name="func_interceptors.h" role="src" />
+ <file name="gdbhelp" role="data" />
+ <file name="LICENSE" role="doc" />
+ <file name="Makefile.frag" role="src" />
+ <file name="makestub.php" role="php" />
+ <file name="phar.c" role="src" />
+ <file name="pharzip.h" role="src" />
+ <file name="phar_internal.h" role="src" />
+ <file name="phar_object.c" role="src" />
+ <file name="phar_path_check.c" role="src" />
+ <file name="phar_path_check.re" role="src" />
+ <file name="php_phar.h" role="src" />
+ <file name="shortarc.php" role="php" />
+ <file name="stream.c" role="src" />
+ <file name="stream.h" role="src" />
+ <file name="stub.h" role="src" />
+ <file name="tar.c" role="src" />
+ <file name="tar.h" role="src" />
+ <file name="TODO" role="doc" />
+ <file name="util.c" role="src" />
+ <file name="zip.c" role="src" />
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.1</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.3</min>
+ </pearinstaller>
+ </required>
+ <optional>
+ <package>
+ <name>bz2</name>
+ <channel>pecl.php.net</channel>
+ <providesextension>bz2</providesextension>
+ </package>
+ <package>
+ <name>hash</name>
+ <channel>pecl.php.net</channel>
+ <providesextension>hash</providesextension>
+ </package>
+ <extension>
+ <name>spl</name>
+ </extension>
+ <extension>
+ <name>zlib</name>
+ </extension>
+ </optional>
+ </dependencies>
+ <providesextension>phar</providesextension>
+ <extsrcrelease />
+ <changelog>
+ <release>
+ <version>
+ <release>2.0.0</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2009-07-26</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0RC2:
+ fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
+ getSignature() call
+ fixed PHP Bug #49020: phar misinterprets ustar long filename standard
+ fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
+ fixed PHP Bug #48791: open office files always reported as corrupted
+ fixed PHP Bug #48783: make install will fail saying phar file exists
+ fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
+ fixed PHP Bug #48681: openssl signature verification for tar archives broken
+ fixed PHP Bug #48377: error message unclear on converting phar with existing file
+ fixed isset() on sub-directories (isset(&quot;blah&quot;) if file &quot;blah/foo.php&quot; exists)
+
+ make phar work in PHP 6
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>2.0.0RC2</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2009-06-04</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>2.0.0RC1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2008-08-31</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>2.0.0b1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2008-05-12</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>2.0.0a2</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2008-03-27</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+Major feature functionality release
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add Phar::isTar(), Phar::isZip(), and Phar::isPhar() [Greg]
+ * add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() [Greg]
+ * add Phar::compress() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+
+Changes since 2.0.0a1: fix build in PHP 5.2
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>2.0.0a1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2008-03-26</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+Major feature functionality release
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add Phar::isTar(), Phar::isZip(), and Phar::isPhar() [Greg]
+ * add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() [Greg]
+ * add Phar::compress() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.2.1</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-08-24</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+* add Phar::setAlias() [Greg]
+* fix too many open file handles issue [Greg]
+* fix rename [Greg]
+* add Phar::getAlias() [Marcus]
+* Made -a optional in pack subcommand of phar.phar [Marcus]
+* Fix issue with apache module and extracted archives [Marcus]
+* Send all error messages to stderr in phar.phar [Marcus]
+* Added new subcommands add and delete to phar.phar [Marcus]
+* Made Phar::loadPhar() and Phar::mapPhar() ignore extracted archives [Marcus]
+* Fix issue with compressed entries and uncompressing entries [Marcus]
+* Verify stubs before writing [Marcus]
+* Always use longest stub end to avoid issues with length field [Marcus]
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.2.0</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-05-18</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+* add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
+* add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
+* fix Phar::CanWrite() [Marcus]
+* add preliminary phar command (phar.php) [Marcus]
+* add phar command (phar.phar) [Marcus]
+* list all available compression methods using Phar::getSupportedCompression() [Marcus]
+* remove RINIT [Marcus]
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.1.0</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-04-12</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+* implement ability connect a phar file &apos;phar://whatever&apos; to a directory. That way all
+ access to that phar archive are directed to the extracted directory. This
+ allows to have the installed files and the archive keep the same includes.
+ [Marcus]
+* implement SHA-2 (256, 512) support [Marcus]
+* implement setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512 Phar::PGP to
+ choose the kind of signature to use (PGP falls back to SHA1) [Greg]
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.0.1</release>
+ <api>1.0.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-03-28</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+* Fix return value of unlink() and rename() when used for phar archievs. [Marcus]
+ </notes>
+ </release>
+ <release>
+ <version>
+ <release>1.0.0</release>
+ <api>1.0.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-03-26</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+*BACKWARDS COMPATIBILITY BREAK*
+Rename Phar-&gt;begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering
+Note that isBuffering() returns the opposite value to isFlushingToPhar()
+ </notes>
+ </release>
+ </changelog>
+</package>
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
new file mode 100644
index 0000000..f9db05c
--- /dev/null
+++ b/ext/phar/phar.c
@@ -0,0 +1,3749 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: c5042cc34acebcc0926625b57dff03deebbe6472 $ */
+
+#define PHAR_MAIN 1
+#include "phar_internal.h"
+#include "SAPI.h"
+#include "func_interceptors.h"
+
+static void destroy_phar_data(void *pDest);
+
+ZEND_DECLARE_MODULE_GLOBALS(phar)
+#if PHP_VERSION_ID >= 50300
+char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
+#endif
+
+/**
+ * set's phar->is_writeable based on the current INI value
+ */
+static int phar_set_writeable_bit(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ zend_bool keep = *(zend_bool *)argument;
+ phar_archive_data *phar = *(phar_archive_data **)pDest;
+
+ if (!phar->is_data) {
+ phar->is_writeable = !keep;
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+/* if the original value is 0 (disabled), then allow setting/unsetting at will. Otherwise only allow 1 (enabled), and error on disabling */
+ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
+{
+ zend_bool old, ini;
+
+ if (entry->name_length == 14) {
+ old = PHAR_G(readonly_orig);
+ } else {
+ old = PHAR_G(require_hash_orig);
+ }
+
+ if (new_value_length == 2 && !strcasecmp("on", new_value)) {
+ ini = (zend_bool) 1;
+ }
+ else if (new_value_length == 3 && !strcasecmp("yes", new_value)) {
+ ini = (zend_bool) 1;
+ }
+ else if (new_value_length == 4 && !strcasecmp("true", new_value)) {
+ ini = (zend_bool) 1;
+ }
+ else {
+ ini = (zend_bool) atoi(new_value);
+ }
+
+ /* do not allow unsetting in runtime */
+ if (stage == ZEND_INI_STAGE_STARTUP) {
+ if (entry->name_length == 14) {
+ PHAR_G(readonly_orig) = ini;
+ } else {
+ PHAR_G(require_hash_orig) = ini;
+ }
+ } else if (old && !ini) {
+ return FAILURE;
+ }
+
+ if (entry->name_length == 14) {
+ PHAR_G(readonly) = ini;
+ if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets) {
+ zend_hash_apply_with_argument(&(PHAR_GLOBALS->phar_fname_map), phar_set_writeable_bit, (void *)&ini TSRMLS_CC);
+ }
+ } else {
+ PHAR_G(require_hash) = ini;
+ }
+
+ return SUCCESS;
+}
+/* }}}*/
+
+/* this global stores the global cached pre-parsed manifests */
+HashTable cached_phars;
+HashTable cached_alias;
+
+static void phar_split_cache_list(TSRMLS_D) /* {{{ */
+{
+ char *tmp;
+ char *key, *lasts, *end;
+ char ds[2];
+ phar_archive_data *phar;
+ uint i = 0;
+
+ if (!PHAR_GLOBALS->cache_list || !(PHAR_GLOBALS->cache_list[0])) {
+ return;
+ }
+
+ ds[0] = DEFAULT_DIR_SEPARATOR;
+ ds[1] = '\0';
+ tmp = estrdup(PHAR_GLOBALS->cache_list);
+
+ /* fake request startup */
+ PHAR_GLOBALS->request_init = 1;
+ if (zend_hash_init(&EG(regular_list), 0, NULL, NULL, 0) == SUCCESS) {
+ EG(regular_list).nNextFreeElement=1; /* we don't want resource id 0 */
+ }
+
+ PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
+ PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
+ /* these two are dummies and will be destroyed later */
+ zend_hash_init(&cached_phars, sizeof(phar_archive_data*), zend_get_hash_value, destroy_phar_data, 1);
+ zend_hash_init(&cached_alias, sizeof(phar_archive_data*), zend_get_hash_value, NULL, 1);
+ /* these two are real and will be copied over cached_phars/cached_alias later */
+ zend_hash_init(&(PHAR_GLOBALS->phar_fname_map), sizeof(phar_archive_data*), zend_get_hash_value, destroy_phar_data, 1);
+ zend_hash_init(&(PHAR_GLOBALS->phar_alias_map), sizeof(phar_archive_data*), zend_get_hash_value, NULL, 1);
+ PHAR_GLOBALS->manifest_cached = 1;
+ PHAR_GLOBALS->persist = 1;
+
+ for (key = php_strtok_r(tmp, ds, &lasts);
+ key;
+ key = php_strtok_r(NULL, ds, &lasts)) {
+ end = strchr(key, DEFAULT_DIR_SEPARATOR);
+
+ if (end) {
+ if (SUCCESS == phar_open_from_filename(key, end - key, NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+finish_up:
+ phar->phar_pos = i++;
+ php_stream_close(phar->fp);
+ phar->fp = NULL;
+ } else {
+finish_error:
+ PHAR_GLOBALS->persist = 0;
+ PHAR_GLOBALS->manifest_cached = 0;
+ efree(tmp);
+ zend_hash_destroy(&(PHAR_G(phar_fname_map)));
+ PHAR_GLOBALS->phar_fname_map.arBuckets = 0;
+ zend_hash_destroy(&(PHAR_G(phar_alias_map)));
+ PHAR_GLOBALS->phar_alias_map.arBuckets = 0;
+ zend_hash_destroy(&cached_phars);
+ zend_hash_destroy(&cached_alias);
+ zend_hash_graceful_reverse_destroy(&EG(regular_list));
+ memset(&EG(regular_list), 0, sizeof(HashTable));
+ /* free cached manifests */
+ PHAR_GLOBALS->request_init = 0;
+ return;
+ }
+ } else {
+ if (SUCCESS == phar_open_from_filename(key, strlen(key), NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+ goto finish_up;
+ } else {
+ goto finish_error;
+ }
+ }
+ }
+
+ PHAR_GLOBALS->persist = 0;
+ PHAR_GLOBALS->request_init = 0;
+ /* destroy dummy values from before */
+ zend_hash_destroy(&cached_phars);
+ zend_hash_destroy(&cached_alias);
+ cached_phars = PHAR_GLOBALS->phar_fname_map;
+ cached_alias = PHAR_GLOBALS->phar_alias_map;
+ PHAR_GLOBALS->phar_fname_map.arBuckets = 0;
+ PHAR_GLOBALS->phar_alias_map.arBuckets = 0;
+ zend_hash_graceful_reverse_destroy(&EG(regular_list));
+ memset(&EG(regular_list), 0, sizeof(HashTable));
+ efree(tmp);
+}
+/* }}} */
+
+ZEND_INI_MH(phar_ini_cache_list) /* {{{ */
+{
+ PHAR_G(cache_list) = new_value;
+
+ if (stage == ZEND_INI_STAGE_STARTUP) {
+ phar_split_cache_list(TSRMLS_C);
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+PHP_INI_BEGIN()
+ STD_PHP_INI_BOOLEAN( "phar.readonly", "1", PHP_INI_ALL, phar_ini_modify_handler, readonly, zend_phar_globals, phar_globals)
+ STD_PHP_INI_BOOLEAN( "phar.require_hash", "1", PHP_INI_ALL, phar_ini_modify_handler, require_hash, zend_phar_globals, phar_globals)
+ STD_PHP_INI_ENTRY("phar.cache_list", "", PHP_INI_SYSTEM, phar_ini_cache_list, cache_list, zend_phar_globals, phar_globals)
+PHP_INI_END()
+
+/**
+ * When all uses of a phar have been concluded, this frees the manifest
+ * and the phar slot
+ */
+void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+{
+ if (phar->alias && phar->alias != phar->fname) {
+ pefree(phar->alias, phar->is_persistent);
+ phar->alias = NULL;
+ }
+
+ if (phar->fname) {
+ pefree(phar->fname, phar->is_persistent);
+ phar->fname = NULL;
+ }
+
+ if (phar->signature) {
+ pefree(phar->signature, phar->is_persistent);
+ phar->signature = NULL;
+ }
+
+ if (phar->manifest.arBuckets) {
+ zend_hash_destroy(&phar->manifest);
+ phar->manifest.arBuckets = NULL;
+ }
+
+ if (phar->mounted_dirs.arBuckets) {
+ zend_hash_destroy(&phar->mounted_dirs);
+ phar->mounted_dirs.arBuckets = NULL;
+ }
+
+ if (phar->virtual_dirs.arBuckets) {
+ zend_hash_destroy(&phar->virtual_dirs);
+ phar->virtual_dirs.arBuckets = NULL;
+ }
+
+ if (phar->metadata) {
+ if (phar->is_persistent) {
+ if (phar->metadata_len) {
+ /* for zip comments that are strings */
+ free(phar->metadata);
+ } else {
+ zval_internal_ptr_dtor(&phar->metadata);
+ }
+ } else {
+ zval_ptr_dtor(&phar->metadata);
+ }
+ phar->metadata_len = 0;
+ phar->metadata = 0;
+ }
+
+ if (phar->fp) {
+ php_stream_close(phar->fp);
+ phar->fp = 0;
+ }
+
+ if (phar->ufp) {
+ php_stream_close(phar->ufp);
+ phar->ufp = 0;
+ }
+
+ pefree(phar, phar->is_persistent);
+}
+/* }}}*/
+
+/**
+ * Delete refcount and destruct if needed. On destruct return 1 else 0.
+ */
+int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+{
+ if (phar->is_persistent) {
+ return 0;
+ }
+
+ if (--phar->refcount < 0) {
+ if (PHAR_GLOBALS->request_done
+ || zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
+ phar_destroy_phar_data(phar TSRMLS_CC);
+ }
+ return 1;
+ } else if (!phar->refcount) {
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ if (phar->fp && !(phar->flags & PHAR_FILE_COMPRESSION_MASK)) {
+ /* close open file handle - allows removal or rename of
+ the file on windows, which has greedy locking
+ only close if the archive was not already compressed. If it
+ was compressed, then the fp does not refer to the original file */
+ php_stream_close(phar->fp);
+ phar->fp = NULL;
+ }
+
+ if (!zend_hash_num_elements(&phar->manifest)) {
+ /* this is a new phar that has perhaps had an alias/metadata set, but has never
+ been flushed */
+ if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
+ phar_destroy_phar_data(phar TSRMLS_CC);
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+/* }}}*/
+
+/**
+ * Destroy phar's in shutdown, here we don't care about aliases
+ */
+static void destroy_phar_data_only(void *pDest) /* {{{ */
+{
+ phar_archive_data *phar_data = *(phar_archive_data **) pDest;
+ TSRMLS_FETCH();
+
+ if (EG(exception) || --phar_data->refcount < 0) {
+ phar_destroy_phar_data(phar_data TSRMLS_CC);
+ }
+}
+/* }}}*/
+
+/**
+ * Delete aliases to phar's that got kicked out of the global table
+ */
+static int phar_unalias_apply(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ return *(void**)pDest == argument ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+/**
+ * Delete aliases to phar's that got kicked out of the global table
+ */
+static int phar_tmpclose_apply(void *pDest TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *) pDest;
+
+ if (entry->fp_type != PHAR_TMP) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (entry->fp && !entry->fp_refcount) {
+ php_stream_close(entry->fp);
+ entry->fp = NULL;
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+/**
+ * Filename map destructor
+ */
+static void destroy_phar_data(void *pDest) /* {{{ */
+{
+ phar_archive_data *phar_data = *(phar_archive_data **) pDest;
+ TSRMLS_FETCH();
+
+ if (PHAR_GLOBALS->request_ends) {
+ /* first, iterate over the manifest and close all PHAR_TMP entry fp handles,
+ this prevents unnecessary unfreed stream resources */
+ zend_hash_apply(&(phar_data->manifest), phar_tmpclose_apply TSRMLS_CC);
+ destroy_phar_data_only(pDest);
+ return;
+ }
+
+ zend_hash_apply_with_argument(&(PHAR_GLOBALS->phar_alias_map), phar_unalias_apply, phar_data TSRMLS_CC);
+
+ if (--phar_data->refcount < 0) {
+ phar_destroy_phar_data(phar_data TSRMLS_CC);
+ }
+}
+/* }}}*/
+
+/**
+ * destructor for the manifest hash, frees each file's entry
+ */
+void destroy_phar_manifest_entry(void *pDest) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)pDest;
+ TSRMLS_FETCH();
+
+ if (entry->cfp) {
+ php_stream_close(entry->cfp);
+ entry->cfp = 0;
+ }
+
+ if (entry->fp) {
+ php_stream_close(entry->fp);
+ entry->fp = 0;
+ }
+
+ if (entry->metadata) {
+ if (entry->is_persistent) {
+ if (entry->metadata_len) {
+ /* for zip comments that are strings */
+ free(entry->metadata);
+ } else {
+ zval_internal_ptr_dtor(&entry->metadata);
+ }
+ } else {
+ zval_ptr_dtor(&entry->metadata);
+ }
+ entry->metadata_len = 0;
+ entry->metadata = 0;
+ }
+
+ if (entry->metadata_str.c) {
+ smart_str_free(&entry->metadata_str);
+ entry->metadata_str.c = 0;
+ }
+
+ pefree(entry->filename, entry->is_persistent);
+
+ if (entry->link) {
+ pefree(entry->link, entry->is_persistent);
+ entry->link = 0;
+ }
+
+ if (entry->tmp) {
+ pefree(entry->tmp, entry->is_persistent);
+ entry->tmp = 0;
+ }
+}
+/* }}} */
+
+int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */
+{
+ int ret = 0;
+
+ if (idata->internal_file && !idata->internal_file->is_persistent) {
+ if (--idata->internal_file->fp_refcount < 0) {
+ idata->internal_file->fp_refcount = 0;
+ }
+
+ if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) {
+ php_stream_close(idata->fp);
+ }
+ /* if phar_get_or_create_entry_data returns a sub-directory, we have to free it */
+ if (idata->internal_file->is_temp_dir) {
+ destroy_phar_manifest_entry((void *)idata->internal_file);
+ efree(idata->internal_file);
+ }
+ }
+
+ phar_archive_delref(idata->phar TSRMLS_CC);
+ efree(idata);
+ return ret;
+}
+/* }}} */
+
+/**
+ * Removes an entry, either by actually removing it or by marking it.
+ */
+void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+
+ phar = idata->phar;
+
+ if (idata->internal_file->fp_refcount < 2) {
+ if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) {
+ php_stream_close(idata->fp);
+ }
+ zend_hash_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
+ idata->phar->refcount--;
+ efree(idata);
+ } else {
+ idata->internal_file->is_deleted = 1;
+ phar_entry_delref(idata TSRMLS_CC);
+ }
+
+ if (!phar->donotflush) {
+ phar_flush(phar, 0, 0, 0, error TSRMLS_CC);
+ }
+}
+/* }}} */
+
+#define MAPPHAR_ALLOC_FAIL(msg) \
+ if (fp) {\
+ php_stream_close(fp);\
+ }\
+ if (error) {\
+ spprintf(error, 0, msg, fname);\
+ }\
+ return FAILURE;
+
+#define MAPPHAR_FAIL(msg) \
+ efree(savebuf);\
+ if (mydata) {\
+ phar_destroy_phar_data(mydata TSRMLS_CC);\
+ }\
+ if (signature) {\
+ pefree(signature, PHAR_G(persist));\
+ }\
+ MAPPHAR_ALLOC_FAIL(msg)
+
+#ifdef WORDS_BIGENDIAN
+# define PHAR_GET_32(buffer, var) \
+ var = ((((unsigned char*)(buffer))[3]) << 24) \
+ | ((((unsigned char*)(buffer))[2]) << 16) \
+ | ((((unsigned char*)(buffer))[1]) << 8) \
+ | (((unsigned char*)(buffer))[0]); \
+ (buffer) += 4
+# define PHAR_GET_16(buffer, var) \
+ var = ((((unsigned char*)(buffer))[1]) << 8) \
+ | (((unsigned char*)(buffer))[0]); \
+ (buffer) += 2
+#else
+# define PHAR_GET_32(buffer, var) \
+ memcpy(&var, buffer, sizeof(var)); \
+ buffer += 4
+# define PHAR_GET_16(buffer, var) \
+ var = *(php_uint16*)(buffer); \
+ buffer += 2
+#endif
+#define PHAR_ZIP_16(var) ((php_uint16)((((php_uint16)var[0]) & 0xff) | \
+ (((php_uint16)var[1]) & 0xff) << 8))
+#define PHAR_ZIP_32(var) ((php_uint32)((((php_uint32)var[0]) & 0xff) | \
+ (((php_uint32)var[1]) & 0xff) << 8 | \
+ (((php_uint32)var[2]) & 0xff) << 16 | \
+ (((php_uint32)var[3]) & 0xff) << 24))
+
+/**
+ * Open an already loaded phar
+ */
+int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+#ifdef PHP_WIN32
+ char *unixfname;
+#endif
+
+ if (error) {
+ *error = NULL;
+ }
+#ifdef PHP_WIN32
+ unixfname = estrndup(fname, fname_len);
+ phar_unixify_path_separators(unixfname, fname_len);
+
+ if (SUCCESS == phar_get_archive(&phar, unixfname, fname_len, alias, alias_len, error TSRMLS_CC)
+ && ((alias && fname_len == phar->fname_len
+ && !strncmp(unixfname, phar->fname, fname_len)) || !alias)
+ ) {
+ phar_entry_info *stub;
+ efree(unixfname);
+#else
+ if (SUCCESS == phar_get_archive(&phar, fname, fname_len, alias, alias_len, error TSRMLS_CC)
+ && ((alias && fname_len == phar->fname_len
+ && !strncmp(fname, phar->fname, fname_len)) || !alias)
+ ) {
+ phar_entry_info *stub;
+#endif
+ /* logic above is as follows:
+ If an explicit alias was requested, ensure the filename passed in
+ matches the phar's filename.
+ If no alias was passed in, then it can match either and be valid
+ */
+
+ if (!is_data) {
+ /* prevent any ".phar" without a stub getting through */
+ if (!phar->halt_offset && !phar->is_brandnew && (phar->is_tar || phar->is_zip)) {
+ if (PHAR_G(readonly) && FAILURE == zend_hash_find(&(phar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
+ if (error) {
+ spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
+ }
+ return FAILURE;
+ }
+ }
+ }
+
+ if (pphar) {
+ *pphar = phar;
+ }
+
+ return SUCCESS;
+ } else {
+#ifdef PHP_WIN32
+ efree(unixfname);
+#endif
+ if (pphar) {
+ *pphar = NULL;
+ }
+
+ if (phar && error && !(options & REPORT_ERRORS)) {
+ efree(error);
+ }
+
+ return FAILURE;
+ }
+}
+/* }}}*/
+
+/**
+ * Parse out metadata from the manifest for a single file
+ *
+ * Meta-data is in this format:
+ * [len32][data...]
+ *
+ * data is the serialized zval
+ */
+int phar_parse_metadata(char **buffer, zval **metadata, int zip_metadata_len TSRMLS_DC) /* {{{ */
+{
+ const unsigned char *p;
+ php_uint32 buf_len;
+ php_unserialize_data_t var_hash;
+
+ if (!zip_metadata_len) {
+ PHAR_GET_32(*buffer, buf_len);
+ } else {
+ buf_len = zip_metadata_len;
+ }
+
+ if (buf_len) {
+ ALLOC_ZVAL(*metadata);
+ INIT_ZVAL(**metadata);
+ p = (const unsigned char*) *buffer;
+ PHP_VAR_UNSERIALIZE_INIT(var_hash);
+
+ if (!php_var_unserialize(metadata, &p, p + buf_len, &var_hash TSRMLS_CC)) {
+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
+ zval_ptr_dtor(metadata);
+ *metadata = NULL;
+ return FAILURE;
+ }
+
+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
+
+ if (PHAR_G(persist)) {
+ /* lazy init metadata */
+ zval_ptr_dtor(metadata);
+ *metadata = (zval *) pemalloc(buf_len, 1);
+ memcpy(*metadata, *buffer, buf_len);
+ *buffer += buf_len;
+ return SUCCESS;
+ }
+ } else {
+ *metadata = NULL;
+ }
+
+ if (!zip_metadata_len) {
+ *buffer += buf_len;
+ }
+
+ return SUCCESS;
+}
+/* }}}*/
+
+/**
+ * Does not check for a previously opened phar in the cache.
+ *
+ * Parse a new one and add it to the cache, returning either SUCCESS or
+ * FAILURE, and setting pphar to the pointer to the manifest entry
+ *
+ * This is used by phar_open_from_filename to process the manifest, but can be called
+ * directly.
+ */
+static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+{
+ char b32[4], *buffer, *endbuffer, *savebuf;
+ phar_archive_data *mydata = NULL;
+ phar_entry_info entry;
+ php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
+ php_uint16 manifest_ver;
+ long offset;
+ int sig_len, register_alias = 0, temp_alias = 0;
+ char *signature = NULL;
+
+ if (pphar) {
+ *pphar = NULL;
+ }
+
+ if (error) {
+ *error = NULL;
+ }
+
+ /* check for ?>\n and increment accordingly */
+ if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
+ MAPPHAR_ALLOC_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
+ }
+
+ buffer = b32;
+
+ if (3 != php_stream_read(fp, buffer, 3)) {
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest at stub end)")
+ }
+
+ if ((*buffer == ' ' || *buffer == '\n') && *(buffer + 1) == '?' && *(buffer + 2) == '>') {
+ int nextchar;
+ halt_offset += 3;
+ if (EOF == (nextchar = php_stream_getc(fp))) {
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest at stub end)")
+ }
+
+ if ((char) nextchar == '\r') {
+ /* if we have an \r we require an \n as well */
+ if (EOF == (nextchar = php_stream_getc(fp)) || (char)nextchar != '\n') {
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest at stub end)")
+ }
+ ++halt_offset;
+ }
+
+ if ((char) nextchar == '\n') {
+ ++halt_offset;
+ }
+ }
+
+ /* make sure we are at the right location to read the manifest */
+ if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
+ MAPPHAR_ALLOC_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
+ }
+
+ /* read in manifest */
+ buffer = b32;
+
+ if (4 != php_stream_read(fp, buffer, 4)) {
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest at manifest length)")
+ }
+
+ PHAR_GET_32(buffer, manifest_len);
+
+ if (manifest_len > 1048576 * 100) {
+ /* prevent serious memory issues by limiting manifest to at most 100 MB in length */
+ MAPPHAR_ALLOC_FAIL("manifest cannot be larger than 100 MB in phar \"%s\"")
+ }
+
+ buffer = (char *)emalloc(manifest_len);
+ savebuf = buffer;
+ endbuffer = buffer + manifest_len;
+
+ if (manifest_len < 10 || manifest_len != php_stream_read(fp, buffer, manifest_len)) {
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest header)")
+ }
+
+ /* extract the number of entries */
+ PHAR_GET_32(buffer, manifest_count);
+
+ if (manifest_count == 0) {
+ MAPPHAR_FAIL("in phar \"%s\", manifest claims to have zero entries. Phars must have at least 1 entry");
+ }
+
+ /* extract API version, lowest nibble currently unused */
+ manifest_ver = (((unsigned char)buffer[0]) << 8)
+ + ((unsigned char)buffer[1]);
+ buffer += 2;
+
+ if ((manifest_ver & PHAR_API_VER_MASK) < PHAR_API_MIN_READ) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "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_HDR_COMPRESSION_MASK;
+ manifest_flags &= ~PHAR_FILE_COMPRESSION_MASK;
+ /* remember whether this entire phar was compressed with gz/bzip2 */
+ manifest_flags |= compression;
+
+ /* The lowest nibble contains the phar wide flags. The compression flags can */
+ /* be ignored on reading because it is being generated anyways. */
+ if (manifest_flags & PHAR_HDR_SIGNATURE) {
+ char sig_buf[8], *sig_ptr = sig_buf;
+ off_t read_len;
+ size_t end_of_phar;
+
+ if (-1 == php_stream_seek(fp, -8, SEEK_END)
+ || (read_len = php_stream_tell(fp)) < 20
+ || 8 != php_stream_read(fp, sig_buf, 8)
+ || memcmp(sig_buf+4, "GBMB", 4)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
+ }
+ return FAILURE;
+ }
+
+ PHAR_GET_32(sig_ptr, sig_flags);
+
+ switch(sig_flags) {
+ case PHAR_SIG_OPENSSL: {
+ php_uint32 signature_len;
+ char *sig;
+ off_t whence;
+
+ /* we store the signature followed by the signature length */
+ if (-1 == php_stream_seek(fp, -12, SEEK_CUR)
+ || 4 != php_stream_read(fp, sig_buf, 4)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" openssl signature length could not be read", fname);
+ }
+ return FAILURE;
+ }
+
+ sig_ptr = sig_buf;
+ PHAR_GET_32(sig_ptr, signature_len);
+ sig = (char *) emalloc(signature_len);
+ whence = signature_len + 4;
+ whence = -whence;
+
+ if (-1 == php_stream_seek(fp, whence, SEEK_CUR)
+ || !(end_of_phar = php_stream_tell(fp))
+ || signature_len != php_stream_read(fp, sig, signature_len)) {
+ efree(savebuf);
+ efree(sig);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" openssl signature could not be read", fname);
+ }
+ return FAILURE;
+ }
+
+ if (FAILURE == phar_verify_signature(fp, end_of_phar, PHAR_SIG_OPENSSL, sig, signature_len, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ efree(savebuf);
+ efree(sig);
+ php_stream_close(fp);
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar \"%s\" openssl signature could not be verified: %s", fname, *error);
+ efree(save);
+ }
+ return FAILURE;
+ }
+ efree(sig);
+ }
+ break;
+#if PHAR_HASH_OK
+ case PHAR_SIG_SHA512: {
+ unsigned char digest[64];
+
+ php_stream_seek(fp, -(8 + 64), SEEK_END);
+ read_len = php_stream_tell(fp);
+
+ if (php_stream_read(fp, (char*)digest, sizeof(digest)) != sizeof(digest)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
+ }
+ return FAILURE;
+ }
+
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA512, (char *)digest, 64, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar \"%s\" SHA512 signature could not be verified: %s", fname, *error);
+ efree(save);
+ }
+ return FAILURE;
+ }
+ break;
+ }
+ case PHAR_SIG_SHA256: {
+ unsigned char digest[32];
+
+ php_stream_seek(fp, -(8 + 32), SEEK_END);
+ read_len = php_stream_tell(fp);
+
+ if (php_stream_read(fp, (char*)digest, sizeof(digest)) != sizeof(digest)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
+ }
+ return FAILURE;
+ }
+
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA256, (char *)digest, 32, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar \"%s\" SHA256 signature could not be verified: %s", fname, *error);
+ efree(save);
+ }
+ return FAILURE;
+ }
+ break;
+ }
+#else
+ case PHAR_SIG_SHA512:
+ case PHAR_SIG_SHA256:
+ efree(savebuf);
+ php_stream_close(fp);
+
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a unsupported signature", fname);
+ }
+ return FAILURE;
+#endif
+ case PHAR_SIG_SHA1: {
+ unsigned char digest[20];
+
+ php_stream_seek(fp, -(8 + 20), SEEK_END);
+ read_len = php_stream_tell(fp);
+
+ if (php_stream_read(fp, (char*)digest, sizeof(digest)) != sizeof(digest)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
+ }
+ return FAILURE;
+ }
+
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_SHA1, (char *)digest, 20, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar \"%s\" SHA1 signature could not be verified: %s", fname, *error);
+ efree(save);
+ }
+ return FAILURE;
+ }
+ break;
+ }
+ case PHAR_SIG_MD5: {
+ unsigned char digest[16];
+
+ php_stream_seek(fp, -(8 + 16), SEEK_END);
+ read_len = php_stream_tell(fp);
+
+ if (php_stream_read(fp, (char*)digest, sizeof(digest)) != sizeof(digest)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
+ }
+ return FAILURE;
+ }
+
+ if (FAILURE == phar_verify_signature(fp, read_len, PHAR_SIG_MD5, (char *)digest, 16, fname, &signature, &sig_len, error TSRMLS_CC)) {
+ efree(savebuf);
+ php_stream_close(fp);
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar \"%s\" MD5 signature could not be verified: %s", fname, *error);
+ efree(save);
+ }
+ return FAILURE;
+ }
+ break;
+ }
+ default:
+ efree(savebuf);
+ php_stream_close(fp);
+
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" has a broken or unsupported signature", fname);
+ }
+ return FAILURE;
+ }
+ } else if (PHAR_G(require_hash)) {
+ efree(savebuf);
+ php_stream_close(fp);
+
+ if (error) {
+ spprintf(error, 0, "phar \"%s\" does not have a signature", fname);
+ }
+ return FAILURE;
+ } else {
+ sig_flags = 0;
+ sig_len = 0;
+ }
+
+ /* extract alias */
+ PHAR_GET_32(buffer, tmp_len);
+
+ if (buffer + tmp_len > endbuffer) {
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (buffer overrun)");
+ }
+
+ if (manifest_len < 10 + tmp_len) {
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest header)")
+ }
+
+ /* tmp_len = 0 says alias length is 0, which means the alias is not stored in the phar */
+ if (tmp_len) {
+ /* if the alias is stored we enforce it (implicit overrides explicit) */
+ if (alias && alias_len && (alias_len != (int)tmp_len || strncmp(alias, buffer, tmp_len)))
+ {
+ buffer[tmp_len] = '\0';
+ php_stream_close(fp);
+
+ if (signature) {
+ efree(signature);
+ }
+
+ if (error) {
+ spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%s\" under different alias \"%s\"", fname, buffer, alias);
+ }
+
+ efree(savebuf);
+ return FAILURE;
+ }
+
+ alias_len = tmp_len;
+ alias = buffer;
+ buffer += tmp_len;
+ register_alias = 1;
+ } else if (!alias_len || !alias) {
+ /* if we neither have an explicit nor an implicit alias, we use the filename */
+ alias = NULL;
+ alias_len = 0;
+ register_alias = 0;
+ } else if (alias_len) {
+ register_alias = 1;
+ temp_alias = 1;
+ }
+
+ /* we have 5 32-bit items plus 1 byte at least */
+ if (manifest_count > ((manifest_len - 10 - tmp_len) / (5 * 4 + 1))) {
+ /* prevent serious memory issues */
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (too many manifest entries for size of manifest)")
+ }
+
+ mydata = pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist));
+ mydata->is_persistent = PHAR_G(persist);
+
+ /* check whether we have meta data, zero check works regardless of byte order */
+ if (mydata->is_persistent) {
+ PHAR_GET_32(buffer, mydata->metadata_len);
+ if (phar_parse_metadata(&buffer, &mydata->metadata, mydata->metadata_len TSRMLS_CC) == FAILURE) {
+ MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
+ }
+ } else {
+ if (phar_parse_metadata(&buffer, &mydata->metadata, 0 TSRMLS_CC) == FAILURE) {
+ MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
+ }
+ }
+
+ /* set up our manifest */
+ zend_hash_init(&mydata->manifest, manifest_count,
+ zend_get_hash_value, destroy_phar_manifest_entry, (zend_bool)mydata->is_persistent);
+ zend_hash_init(&mydata->mounted_dirs, 5,
+ zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);
+ zend_hash_init(&mydata->virtual_dirs, manifest_count * 2,
+ zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);
+ mydata->fname = pestrndup(fname, fname_len, mydata->is_persistent);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(mydata->fname, fname_len);
+#endif
+ mydata->fname_len = fname_len;
+ offset = halt_offset + manifest_len + 4;
+ memset(&entry, 0, sizeof(phar_entry_info));
+ entry.phar = mydata;
+ entry.fp_type = PHAR_FP;
+ entry.is_persistent = mydata->is_persistent;
+
+ for (manifest_index = 0; manifest_index < manifest_count; ++manifest_index) {
+ if (buffer + 4 > endbuffer) {
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)")
+ }
+
+ PHAR_GET_32(buffer, entry.filename_len);
+
+ if (entry.filename_len == 0) {
+ MAPPHAR_FAIL("zero-length filename encountered in phar \"%s\"");
+ }
+
+ if (entry.is_persistent) {
+ entry.manifest_pos = manifest_index;
+ }
+
+ if (buffer + entry.filename_len + 20 > endbuffer) {
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
+ }
+
+ if ((manifest_ver & PHAR_API_VER_MASK) >= PHAR_API_MIN_DIR && buffer[entry.filename_len - 1] == '/') {
+ entry.is_dir = 1;
+ } else {
+ entry.is_dir = 0;
+ }
+
+ phar_add_virtual_dirs(mydata, buffer, entry.filename_len TSRMLS_CC);
+ entry.filename = pestrndup(buffer, entry.filename_len, entry.is_persistent);
+ buffer += entry.filename_len;
+ PHAR_GET_32(buffer, entry.uncompressed_filesize);
+ PHAR_GET_32(buffer, entry.timestamp);
+
+ if (offset == halt_offset + (int)manifest_len + 4) {
+ mydata->min_timestamp = entry.timestamp;
+ mydata->max_timestamp = entry.timestamp;
+ } else {
+ if (mydata->min_timestamp > entry.timestamp) {
+ mydata->min_timestamp = entry.timestamp;
+ } else if (mydata->max_timestamp < entry.timestamp) {
+ mydata->max_timestamp = entry.timestamp;
+ }
+ }
+
+ PHAR_GET_32(buffer, entry.compressed_filesize);
+ PHAR_GET_32(buffer, entry.crc32);
+ PHAR_GET_32(buffer, entry.flags);
+
+ if (entry.is_dir) {
+ entry.filename_len--;
+ entry.flags |= PHAR_ENT_PERM_DEF_DIR;
+ }
+
+ if (entry.is_persistent) {
+ PHAR_GET_32(buffer, entry.metadata_len);
+ if (!entry.metadata_len) buffer -= 4;
+ if (phar_parse_metadata(&buffer, &entry.metadata, entry.metadata_len TSRMLS_CC) == FAILURE) {
+ pefree(entry.filename, entry.is_persistent);
+ MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
+ }
+ } else {
+ if (phar_parse_metadata(&buffer, &entry.metadata, 0 TSRMLS_CC) == FAILURE) {
+ pefree(entry.filename, entry.is_persistent);
+ MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
+ }
+ }
+
+ entry.offset = entry.offset_abs = offset;
+ offset += entry.compressed_filesize;
+
+ switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (!PHAR_G(has_zlib)) {
+ if (entry.metadata) {
+ if (entry.is_persistent) {
+ free(entry.metadata);
+ } else {
+ zval_ptr_dtor(&entry.metadata);
+ }
+ }
+ pefree(entry.filename, entry.is_persistent);
+ MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
+ }
+ break;
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (!PHAR_G(has_bz2)) {
+ if (entry.metadata) {
+ if (entry.is_persistent) {
+ free(entry.metadata);
+ } else {
+ zval_ptr_dtor(&entry.metadata);
+ }
+ }
+ pefree(entry.filename, entry.is_persistent);
+ MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
+ }
+ break;
+ default:
+ if (entry.uncompressed_filesize != entry.compressed_filesize) {
+ if (entry.metadata) {
+ if (entry.is_persistent) {
+ free(entry.metadata);
+ } else {
+ zval_ptr_dtor(&entry.metadata);
+ }
+ }
+ pefree(entry.filename, entry.is_persistent);
+ MAPPHAR_FAIL("internal corruption of phar \"%s\" (compressed and uncompressed size does not match for uncompressed entry)");
+ }
+ break;
+ }
+
+ manifest_flags |= (entry.flags & PHAR_ENT_COMPRESSION_MASK);
+ /* if signature matched, no need to check CRC32 for each file */
+ entry.is_crc_checked = (manifest_flags & PHAR_HDR_SIGNATURE ? 1 : 0);
+ phar_set_inode(&entry TSRMLS_CC);
+ 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_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->flags = manifest_flags;
+ endbuffer = strrchr(mydata->fname, '/');
+
+ if (endbuffer) {
+ mydata->ext = memchr(endbuffer, '.', (mydata->fname + fname_len) - endbuffer);
+ if (mydata->ext == endbuffer) {
+ mydata->ext = memchr(endbuffer + 1, '.', (mydata->fname + fname_len) - endbuffer - 1);
+ }
+ if (mydata->ext) {
+ mydata->ext_len = (mydata->fname + mydata->fname_len) - mydata->ext;
+ }
+ }
+
+ mydata->alias = alias ?
+ pestrndup(alias, alias_len, mydata->is_persistent) :
+ pestrndup(mydata->fname, fname_len, mydata->is_persistent);
+ mydata->alias_len = alias ? alias_len : fname_len;
+ mydata->sig_flags = sig_flags;
+ mydata->fp = fp;
+ mydata->sig_len = sig_len;
+ mydata->signature = signature;
+ phar_request_initialize(TSRMLS_C);
+
+ if (register_alias) {
+ phar_archive_data **fd_ptr;
+
+ mydata->is_temporary_alias = temp_alias;
+
+ if (!phar_validate_alias(mydata->alias, mydata->alias_len)) {
+ signature = NULL;
+ fp = NULL;
+ MAPPHAR_FAIL("Cannot open archive \"%s\", invalid alias");
+ }
+
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ signature = NULL;
+ fp = NULL;
+ MAPPHAR_FAIL("Cannot open archive \"%s\", alias is already in use by existing archive");
+ }
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ } else {
+ mydata->is_temporary_alias = 1;
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ efree(savebuf);
+
+ if (pphar) {
+ *pphar = mydata;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * Create or open a phar for writing
+ */
+int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ const char *ext_str, *z;
+ char *my_error;
+ int ext_len;
+ phar_archive_data **test, *unused = NULL;
+
+ test = &unused;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ /* first try to open an existing file */
+ if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1 TSRMLS_CC) == SUCCESS) {
+ goto check_file;
+ }
+
+ /* next try to create a new file */
+ if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1 TSRMLS_CC)) {
+ if (error) {
+ if (ext_len == -2) {
+ spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname);
+ } else {
+ spprintf(error, 0, "Cannot create phar '%s', file extension (or combination) not recognised or the directory does not exist", fname);
+ }
+ }
+ return FAILURE;
+ }
+check_file:
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error TSRMLS_CC) == SUCCESS) {
+ if (pphar) {
+ *pphar = *test;
+ }
+
+ if ((*test)->is_data && !(*test)->is_tar && !(*test)->is_zip) {
+ if (error) {
+ spprintf(error, 0, "Cannot open '%s' as a PharData object. Use Phar::__construct() for executable archives", fname);
+ }
+ return FAILURE;
+ }
+
+ if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) {
+ phar_entry_info *stub;
+ if (FAILURE == zend_hash_find(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
+ spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
+ return FAILURE;
+ }
+ }
+
+ if (!PHAR_G(readonly) || (*test)->is_data) {
+ (*test)->is_writeable = 1;
+ }
+ return SUCCESS;
+ } else if (my_error) {
+ if (error) {
+ *error = my_error;
+ } else {
+ efree(my_error);
+ }
+ return FAILURE;
+ }
+
+ if (ext_len > 3 && (z = memchr(ext_str, 'z', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ip", 2)) {
+ /* assume zip-based phar */
+ return phar_open_or_create_zip(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+ }
+
+ if (ext_len > 3 && (z = memchr(ext_str, 't', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ar", 2)) {
+ /* assume tar-based phar */
+ return phar_open_or_create_tar(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+ }
+
+ return phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC);
+}
+/* }}} */
+
+int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *mydata;
+ php_stream *fp;
+ char *actual = NULL, *p;
+
+ if (!pphar) {
+ pphar = &mydata;
+ }
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ return FAILURE;
+ }
+#endif
+ if (php_check_open_basedir(fname TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ /* first open readonly so it won't be created if not present */
+ fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual);
+
+ if (actual) {
+ fname = actual;
+ fname_len = strlen(actual);
+ }
+
+ if (fp) {
+ if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error TSRMLS_CC) == SUCCESS) {
+ if ((*pphar)->is_data || !PHAR_G(readonly)) {
+ (*pphar)->is_writeable = 1;
+ }
+ if (actual) {
+ efree(actual);
+ }
+ return SUCCESS;
+ } else {
+ /* file exists, but is either corrupt or not a phar archive */
+ if (actual) {
+ efree(actual);
+ }
+ return FAILURE;
+ }
+ }
+
+ if (actual) {
+ efree(actual);
+ }
+
+ if (PHAR_G(readonly) && !is_data) {
+ if (options & REPORT_ERRORS) {
+ if (error) {
+ spprintf(error, 0, "creating archive \"%s\" disabled by the php.ini setting phar.readonly", fname);
+ }
+ }
+ return FAILURE;
+ }
+
+ /* set up our manifest */
+ mydata = ecalloc(1, sizeof(phar_archive_data));
+ mydata->fname = expand_filepath(fname, NULL TSRMLS_CC);
+ fname_len = strlen(mydata->fname);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(mydata->fname, fname_len);
+#endif
+ p = strrchr(mydata->fname, '/');
+
+ if (p) {
+ mydata->ext = memchr(p, '.', (mydata->fname + fname_len) - p);
+ if (mydata->ext == p) {
+ mydata->ext = memchr(p + 1, '.', (mydata->fname + fname_len) - p - 1);
+ }
+ if (mydata->ext) {
+ mydata->ext_len = (mydata->fname + fname_len) - mydata->ext;
+ }
+ }
+
+ if (pphar) {
+ *pphar = mydata;
+ }
+
+ zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
+ zend_get_hash_value, destroy_phar_manifest_entry, 0);
+ zend_hash_init(&mydata->mounted_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, 0);
+ zend_hash_init(&mydata->virtual_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);
+ mydata->fname_len = fname_len;
+ snprintf(mydata->version, sizeof(mydata->version), "%s", PHP_PHAR_API_VERSION);
+ mydata->is_temporary_alias = alias ? 0 : 1;
+ mydata->internal_file_start = -1;
+ mydata->fp = NULL;
+ mydata->is_writeable = 1;
+ mydata->is_brandnew = 1;
+ phar_request_initialize(TSRMLS_C);
+ zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+
+ if (is_data) {
+ alias = NULL;
+ alias_len = 0;
+ mydata->is_data = 1;
+ /* assume tar format, PharData can specify other */
+ mydata->is_tar = 1;
+ } else {
+ phar_archive_data **fd_ptr;
+
+ if (alias && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias);
+ }
+
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+
+ if (pphar) {
+ *pphar = NULL;
+ }
+
+ return FAILURE;
+ }
+ }
+
+ mydata->alias = alias ? estrndup(alias, alias_len) : estrndup(mydata->fname, fname_len);
+ mydata->alias_len = alias ? alias_len : fname_len;
+ }
+
+ if (alias_len && alias) {
+ if (FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL)) {
+ if (options & REPORT_ERRORS) {
+ if (error) {
+ spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias);
+ }
+ }
+
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+
+ if (pphar) {
+ *pphar = NULL;
+ }
+
+ return FAILURE;
+ }
+ }
+
+ return SUCCESS;
+}
+/* }}}*/
+
+/**
+ * Return an already opened filename.
+ *
+ * Or scan a phar file for the required __HALT_COMPILER(); ?> token and verify
+ * that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
+ * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
+ */
+int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ php_stream *fp;
+ char *actual;
+ int ret, is_data = 0;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (!strstr(fname, ".phar")) {
+ is_data = 1;
+ }
+
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, pphar, error TSRMLS_CC) == SUCCESS) {
+ return SUCCESS;
+ } else if (error && *error) {
+ return FAILURE;
+ }
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ return FAILURE;
+ }
+#endif
+ if (php_check_open_basedir(fname TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual);
+
+ if (!fp) {
+ if (options & REPORT_ERRORS) {
+ if (error) {
+ spprintf(error, 0, "unable to open phar for reading \"%s\"", fname);
+ }
+ }
+ if (actual) {
+ efree(actual);
+ }
+ return FAILURE;
+ }
+
+ if (actual) {
+ fname = actual;
+ fname_len = strlen(actual);
+ }
+
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error TSRMLS_CC);
+
+ if (actual) {
+ efree(actual);
+ }
+
+ return ret;
+}
+/* }}}*/
+
+static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */
+{
+ const char *c;
+ int so_far = 0;
+
+ if (buf_len < search_len) {
+ return NULL;
+ }
+
+ c = buf - 1;
+
+ do {
+ if (!(c = memchr(c + 1, search[0], buf_len - search_len - so_far))) {
+ return (char *) NULL;
+ }
+
+ so_far = c - buf;
+
+ if (so_far >= (buf_len - search_len)) {
+ return (char *) NULL;
+ }
+
+ if (!memcmp(c, search, search_len)) {
+ return (char *) c;
+ }
+ } while (1);
+}
+/* }}} */
+
+/**
+ * Scan an open fp for the required __HALT_COMPILER(); ?> token and verify
+ * that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
+ * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
+ */
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC) /* {{{ */
+{
+ const char token[] = "__HALT_COMPILER();";
+ const char zip_magic[] = "PK\x03\x04";
+ const char gz_magic[] = "\x1f\x8b\x08";
+ const char bz_magic[] = "BZh";
+ char *pos, test = '\0';
+ const int window_size = 1024;
+ char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
+ const long readsize = sizeof(buffer) - sizeof(token);
+ const long tokenlen = sizeof(token) - 1;
+ long halt_offset;
+ size_t got;
+ php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (-1 == php_stream_rewind(fp)) {
+ MAPPHAR_ALLOC_FAIL("cannot rewind phar \"%s\"")
+ }
+
+ buffer[sizeof(buffer)-1] = '\0';
+ memset(buffer, 32, sizeof(token));
+ halt_offset = 0;
+
+ /* Maybe it's better to compile the file instead of just searching, */
+ /* but we only want the offset. So we want a .re scanner to find it. */
+ while(!php_stream_eof(fp)) {
+ if ((got = php_stream_read(fp, buffer+tokenlen, readsize)) < (size_t) tokenlen) {
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)")
+ }
+
+ if (!test) {
+ test = '\1';
+ pos = buffer+tokenlen;
+ if (!memcmp(pos, gz_magic, 3)) {
+ char err = 0;
+ php_stream_filter *filter;
+ php_stream *temp;
+ /* to properly decompress, we have to tell zlib to look for a zlib or gzip header */
+ zval filterparams;
+
+ if (!PHAR_G(has_zlib)) {
+ MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file, enable zlib extension in php.ini")
+ }
+ array_init(&filterparams);
+/* this is defined in zlib's zconf.h */
+#ifndef MAX_WBITS
+#define MAX_WBITS 15
+#endif
+ add_assoc_long(&filterparams, "window", MAX_WBITS + 32);
+
+ /* entire file is gzip-compressed, uncompress to temporary file */
+ if (!(temp = php_stream_fopen_tmpfile())) {
+ MAPPHAR_ALLOC_FAIL("unable to create temporary file for decompression of gzipped phar archive \"%s\"")
+ }
+
+ php_stream_rewind(fp);
+ filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp) TSRMLS_CC);
+
+ if (!filter) {
+ err = 1;
+ add_assoc_long(&filterparams, "window", MAX_WBITS);
+ filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp) TSRMLS_CC);
+ zval_dtor(&filterparams);
+
+ if (!filter) {
+ php_stream_close(temp);
+ MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6")
+ }
+ } else {
+ zval_dtor(&filterparams);
+ }
+
+ php_stream_filter_append(&temp->writefilters, filter);
+
+ if (SUCCESS != phar_stream_copy_to_stream(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
+ if (err) {
+ php_stream_close(temp);
+ MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6")
+ }
+ php_stream_close(temp);
+ MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file")
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(fp);
+ fp = temp;
+ php_stream_rewind(fp);
+ compression = PHAR_FILE_COMPRESSED_GZ;
+
+ /* now, start over */
+ test = '\0';
+ continue;
+ } else if (!memcmp(pos, bz_magic, 3)) {
+ php_stream_filter *filter;
+ php_stream *temp;
+
+ if (!PHAR_G(has_bz2)) {
+ MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, enable bz2 extension in php.ini")
+ }
+
+ /* entire file is bzip-compressed, uncompress to temporary file */
+ if (!(temp = php_stream_fopen_tmpfile())) {
+ MAPPHAR_ALLOC_FAIL("unable to create temporary file for decompression of bzipped phar archive \"%s\"")
+ }
+
+ php_stream_rewind(fp);
+ filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+
+ if (!filter) {
+ php_stream_close(temp);
+ MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\", filter creation failed")
+ }
+
+ php_stream_filter_append(&temp->writefilters, filter);
+
+ if (SUCCESS != phar_stream_copy_to_stream(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
+ php_stream_close(temp);
+ MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file")
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(fp);
+ fp = temp;
+ php_stream_rewind(fp);
+ compression = PHAR_FILE_COMPRESSED_BZ2;
+
+ /* now, start over */
+ test = '\0';
+ continue;
+ }
+
+ if (!memcmp(pos, zip_magic, 4)) {
+ php_stream_seek(fp, 0, SEEK_END);
+ return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, error TSRMLS_CC);
+ }
+
+ if (got > 512) {
+ if (phar_is_tar(pos, fname)) {
+ php_stream_rewind(fp);
+ return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, is_data, compression, error TSRMLS_CC);
+ }
+ }
+ }
+
+ if (got > 0 && (pos = phar_strnstr(buffer, got + sizeof(token), token, sizeof(token)-1)) != NULL) {
+ halt_offset += (pos - buffer); /* no -tokenlen+tokenlen here */
+ return phar_parse_pharfile(fp, fname, fname_len, alias, alias_len, halt_offset, pphar, compression, error TSRMLS_CC);
+ }
+
+ halt_offset += got;
+ memmove(buffer, buffer + window_size, tokenlen); /* move the memory buffer by the size of the window */
+ }
+
+ MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (__HALT_COMPILER(); not found)")
+}
+/* }}} */
+
+/*
+ * given the location of the file extension and the start of the file path,
+ * determine the end of the portion of the path (i.e. /path/to/file.ext/blah
+ * grabs "/path/to/file.ext" as does the straight /path/to/file.ext),
+ * stat it to determine if it exists.
+ * if so, check to see if it is a directory and fail if so
+ * if not, check to see if its dirname() exists (i.e. "/path/to") and is a directory
+ * succeed if we are creating the file, otherwise fail.
+ */
+static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create TSRMLS_DC) /* {{{ */
+{
+ php_stream_statbuf ssb;
+ char *realpath;
+ char *filename = estrndup(fname, (ext - fname) + ext_len);
+
+ if ((realpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(realpath, strlen(realpath));
+#endif
+ if (zend_hash_exists(&(PHAR_GLOBALS->phar_fname_map), realpath, strlen(realpath))) {
+ efree(realpath);
+ efree(filename);
+ return SUCCESS;
+ }
+
+ if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_phars, realpath, strlen(realpath))) {
+ efree(realpath);
+ efree(filename);
+ return SUCCESS;
+ }
+ efree(realpath);
+ }
+
+ if (SUCCESS == php_stream_stat_path((char *) filename, &ssb)) {
+
+ efree(filename);
+
+ if (ssb.sb.st_mode & S_IFDIR) {
+ return FAILURE;
+ }
+
+ if (for_create == 1) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+ } else {
+ char *slash;
+
+ if (!for_create) {
+ efree(filename);
+ return FAILURE;
+ }
+
+ slash = (char *) strrchr(filename, '/');
+
+ if (slash) {
+ *slash = '\0';
+ }
+
+ if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) {
+ if (!slash) {
+ if (!(realpath = expand_filepath(filename, NULL TSRMLS_CC))) {
+ efree(filename);
+ return FAILURE;
+ }
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(realpath, strlen(realpath));
+#endif
+ slash = strstr(realpath, filename) + ((ext - fname) + ext_len);
+ *slash = '\0';
+ slash = strrchr(realpath, '/');
+
+ if (slash) {
+ *slash = '\0';
+ } else {
+ efree(realpath);
+ efree(filename);
+ return FAILURE;
+ }
+
+ if (SUCCESS != php_stream_stat_path(realpath, &ssb)) {
+ efree(realpath);
+ efree(filename);
+ return FAILURE;
+ }
+
+ efree(realpath);
+
+ if (ssb.sb.st_mode & S_IFDIR) {
+ efree(filename);
+ return SUCCESS;
+ }
+ }
+
+ efree(filename);
+ return FAILURE;
+ }
+
+ efree(filename);
+
+ if (ssb.sb.st_mode & S_IFDIR) {
+ return SUCCESS;
+ }
+
+ return FAILURE;
+ }
+}
+/* }}} */
+
+/* check for ".phar" in extension */
+static int phar_check_str(const char *fname, const char *ext_str, int ext_len, int executable, int for_create TSRMLS_DC) /* {{{ */
+{
+ char test[51];
+ const char *pos;
+
+ if (ext_len >= 50) {
+ return FAILURE;
+ }
+
+ if (executable == 1) {
+ /* copy "." as well */
+ memcpy(test, ext_str - 1, ext_len + 1);
+ test[ext_len + 1] = '\0';
+ /* executable phars must contain ".phar" as a valid extension (phar://.pharmy/oops is invalid) */
+ /* (phar://hi/there/.phar/oops is also invalid) */
+ pos = strstr(test, ".phar");
+
+ if (pos && (*(pos - 1) != '/')
+ && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) {
+ return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ } else {
+ return FAILURE;
+ }
+ }
+
+ /* data phars need only contain a single non-"." to be valid */
+ if (!executable) {
+ pos = strstr(ext_str, ".phar");
+ if (!(pos && (*(pos - 1) != '/')
+ && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
+ return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ }
+ } else {
+ if (*(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
+ return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+ }
+ }
+
+ return FAILURE;
+}
+/* }}} */
+
+/*
+ * if executable is 1, only returns SUCCESS if the extension is one of the tar/zip .phar extensions
+ * if executable is 0, it returns SUCCESS only if the filename does *not* contain ".phar" anywhere, and treats
+ * the first extension as the filename extension
+ *
+ * if an extension is found, it sets ext_str to the location of the file extension in filename,
+ * and ext_len to the length of the extension.
+ * for urls like "phar://alias/oops" it instead sets ext_len to -1 and returns FAILURE, which tells
+ * the calling function to use "alias" as the phar alias
+ *
+ * the last parameter should be set to tell the thing to assume that filename is the full path, and only to check the
+ * extension rules, not to iterate.
+ */
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC) /* {{{ */
+{
+ const char *pos, *slash;
+
+ *ext_str = NULL;
+ *ext_len = 0;
+
+ if (!filename_len || filename_len == 1) {
+ return FAILURE;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+ /* first check for alias in first segment */
+ pos = memchr(filename, '/', filename_len);
+
+ if (pos && pos != filename) {
+ /* check for url like http:// or phar:// */
+ if (*(pos - 1) == ':' && (pos - filename) < filename_len - 1 && *(pos + 1) == '/') {
+ *ext_len = -2;
+ *ext_str = NULL;
+ return FAILURE;
+ }
+ if (zend_hash_exists(&(PHAR_GLOBALS->phar_alias_map), (char *) filename, pos - filename)) {
+ *ext_str = pos;
+ *ext_len = -1;
+ return FAILURE;
+ }
+
+ if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_alias, (char *) filename, pos - filename)) {
+ *ext_str = pos;
+ *ext_len = -1;
+ return FAILURE;
+ }
+ }
+
+ if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map)) || PHAR_G(manifest_cached)) {
+ phar_archive_data **pphar;
+
+ if (is_complete) {
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), (char *) filename, filename_len, (void **)&pphar)) {
+ *ext_str = filename + (filename_len - (*pphar)->ext_len);
+woohoo:
+ *ext_len = (*pphar)->ext_len;
+
+ if (executable == 2) {
+ return SUCCESS;
+ }
+
+ if (executable == 1 && !(*pphar)->is_data) {
+ return SUCCESS;
+ }
+
+ if (!executable && (*pphar)->is_data) {
+ return SUCCESS;
+ }
+
+ return FAILURE;
+ }
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, (char *) filename, filename_len, (void **)&pphar)) {
+ *ext_str = filename + (filename_len - (*pphar)->ext_len);
+ goto woohoo;
+ }
+ } else {
+ phar_zstr key;
+ char *str_key;
+ uint keylen;
+ ulong unused;
+
+ zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
+
+ while (FAILURE != zend_hash_has_more_elements(&(PHAR_GLOBALS->phar_fname_map))) {
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) {
+ break;
+ }
+
+ PHAR_STR(key, str_key);
+
+ if (keylen > (uint) filename_len) {
+ zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
+ PHAR_STR_FREE(str_key);
+ continue;
+ }
+
+ if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
+ || filename[keylen] == '/' || filename[keylen] == '\0')) {
+ PHAR_STR_FREE(str_key);
+ if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
+ break;
+ }
+ *ext_str = filename + (keylen - (*pphar)->ext_len);
+ goto woohoo;
+ }
+
+ PHAR_STR_FREE(str_key);
+ zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
+ }
+
+ if (PHAR_G(manifest_cached)) {
+ zend_hash_internal_pointer_reset(&cached_phars);
+
+ while (FAILURE != zend_hash_has_more_elements(&cached_phars)) {
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) {
+ break;
+ }
+
+ PHAR_STR(key, str_key);
+
+ if (keylen > (uint) filename_len) {
+ zend_hash_move_forward(&cached_phars);
+ PHAR_STR_FREE(str_key);
+ continue;
+ }
+
+ if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
+ || filename[keylen] == '/' || filename[keylen] == '\0')) {
+ PHAR_STR_FREE(str_key);
+ if (FAILURE == zend_hash_get_current_data(&cached_phars, (void **) &pphar)) {
+ break;
+ }
+ *ext_str = filename + (keylen - (*pphar)->ext_len);
+ goto woohoo;
+ }
+ PHAR_STR_FREE(str_key);
+ zend_hash_move_forward(&cached_phars);
+ }
+ }
+ }
+ }
+
+ pos = memchr(filename + 1, '.', filename_len);
+next_extension:
+ if (!pos) {
+ return FAILURE;
+ }
+
+ while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
+ pos = memchr(pos + 1, '.', filename_len - (pos - filename) + 1);
+ if (!pos) {
+ return FAILURE;
+ }
+ }
+
+ slash = memchr(pos, '/', filename_len - (pos - filename));
+
+ if (!slash) {
+ /* this is a url like "phar://blah.phar" with no directory */
+ *ext_str = pos;
+ *ext_len = strlen(pos);
+
+ /* file extension must contain "phar" */
+ switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create TSRMLS_CC)) {
+ case SUCCESS:
+ return SUCCESS;
+ case FAILURE:
+ /* we are at the end of the string, so we fail */
+ return FAILURE;
+ }
+ }
+
+ /* we've found an extension that ends at a directory separator */
+ *ext_str = pos;
+ *ext_len = slash - pos;
+
+ switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create TSRMLS_CC)) {
+ case SUCCESS:
+ return SUCCESS;
+ case FAILURE:
+ /* look for more extensions */
+ pos = strchr(pos + 1, '.');
+ if (pos) {
+ *ext_str = NULL;
+ *ext_len = 0;
+ }
+ goto next_extension;
+ }
+
+ return FAILURE;
+}
+/* }}} */
+
+static int php_check_dots(const char *element, int n) /* {{{ */
+{
+ for(n--; n >= 0; --n) {
+ if (element[n] != '.') {
+ return 1;
+ }
+ }
+ return 0;
+}
+/* }}} */
+
+#define IS_DIRECTORY_UP(element, len) \
+ (len >= 2 && !php_check_dots(element, len))
+
+#define IS_DIRECTORY_CURRENT(element, len) \
+ (len == 1 && element[0] == '.')
+
+#define IS_BACKSLASH(c) ((c) == '/')
+
+#ifdef COMPILE_DL_PHAR
+/* stupid-ass non-extern declaration in tsrm_strtok.h breaks dumbass MS compiler */
+static inline int in_character_class(char ch, const char *delim) /* {{{ */
+{
+ while (*delim) {
+ if (*delim == ch) {
+ return 1;
+ }
+ ++delim;
+ }
+ return 0;
+}
+/* }}} */
+
+char *tsrm_strtok_r(char *s, const char *delim, char **last) /* {{{ */
+{
+ char *token;
+
+ if (s == NULL) {
+ s = *last;
+ }
+
+ while (*s && in_character_class(*s, delim)) {
+ ++s;
+ }
+
+ if (!*s) {
+ return NULL;
+ }
+
+ token = s;
+
+ while (*s && !in_character_class(*s, delim)) {
+ ++s;
+ }
+
+ if (!*s) {
+ *last = s;
+ } else {
+ *s = '\0';
+ *last = s + 1;
+ }
+
+ return token;
+}
+/* }}} */
+#endif
+
+/**
+ * Remove .. and . references within a phar filename
+ */
+char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{ */
+{
+ char newpath[MAXPATHLEN];
+ int newpath_len;
+ char *ptr;
+ char *tok;
+ int ptr_length, path_length = *new_len;
+
+ if (PHAR_G(cwd_len) && use_cwd && path_length > 2 && path[0] == '.' && path[1] == '/') {
+ newpath_len = PHAR_G(cwd_len);
+ memcpy(newpath, PHAR_G(cwd), newpath_len);
+ } else {
+ newpath[0] = '/';
+ newpath_len = 1;
+ }
+
+ ptr = path;
+
+ if (*ptr == '/') {
+ ++ptr;
+ }
+
+ tok = ptr;
+
+ do {
+ ptr = memchr(ptr, '/', path_length - (ptr - path));
+ } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok);
+
+ if (!ptr && (path_length - (tok - path))) {
+ switch (path_length - (tok - path)) {
+ case 1:
+ if (*tok == '.') {
+ efree(path);
+ *new_len = 1;
+ return estrndup("/", 1);
+ }
+ break;
+ case 2:
+ if (tok[0] == '.' && tok[1] == '.') {
+ efree(path);
+ *new_len = 1;
+ return estrndup("/", 1);
+ }
+ }
+ return path;
+ }
+
+ while (ptr) {
+ ptr_length = ptr - tok;
+last_time:
+ if (IS_DIRECTORY_UP(tok, ptr_length)) {
+#define PREVIOUS newpath[newpath_len - 1]
+
+ while (newpath_len > 1 && !IS_BACKSLASH(PREVIOUS)) {
+ newpath_len--;
+ }
+
+ if (newpath[0] != '/') {
+ newpath[newpath_len] = '\0';
+ } else if (newpath_len > 1) {
+ --newpath_len;
+ }
+ } else if (!IS_DIRECTORY_CURRENT(tok, ptr_length)) {
+ if (newpath_len > 1) {
+ newpath[newpath_len++] = '/';
+ memcpy(newpath + newpath_len, tok, ptr_length+1);
+ } else {
+ memcpy(newpath + newpath_len, tok, ptr_length+1);
+ }
+
+ newpath_len += ptr_length;
+ }
+
+ if (ptr == path + path_length) {
+ break;
+ }
+
+ tok = ++ptr;
+
+ do {
+ ptr = memchr(ptr, '/', path_length - (ptr - path));
+ } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok);
+
+ if (!ptr && (path_length - (tok - path))) {
+ ptr_length = path_length - (tok - path);
+ ptr = path + path_length;
+ goto last_time;
+ }
+ }
+
+ efree(path);
+ *new_len = newpath_len;
+ return estrndup(newpath, newpath_len);
+}
+/* }}} */
+
+/**
+ * Process a phar stream name, ensuring we can handle any of:
+ *
+ * - whatever.phar
+ * - whatever.phar.gz
+ * - whatever.phar.bz2
+ * - whatever.phar.php
+ *
+ * Optionally the name might start with 'phar://'
+ *
+ * This is used by phar_parse_url()
+ */
+int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */
+{
+ const char *ext_str;
+#ifdef PHP_WIN32
+ char *save;
+#endif
+ int ext_len, free_filename = 0;
+
+ if (!strncasecmp(filename, "phar://", 7)) {
+ filename += 7;
+ filename_len -= 7;
+ }
+
+ ext_len = 0;
+#ifdef PHP_WIN32
+ free_filename = 1;
+ save = filename;
+ filename = estrndup(filename, filename_len);
+ phar_unixify_path_separators(filename, filename_len);
+#endif
+ if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str, &ext_len, executable, for_create, 0 TSRMLS_CC) == FAILURE) {
+ if (ext_len != -1) {
+ if (!ext_str) {
+ /* no / detected, restore arch for error message */
+#ifdef PHP_WIN32
+ *arch = save;
+#else
+ *arch = filename;
+#endif
+ }
+
+ if (free_filename) {
+ efree(filename);
+ }
+
+ return FAILURE;
+ }
+
+ ext_len = 0;
+ /* no extension detected - instead we are dealing with an alias */
+ }
+
+ *arch_len = ext_str - filename + ext_len;
+ *arch = estrndup(filename, *arch_len);
+
+ if (ext_str[ext_len]) {
+ *entry_len = filename_len - *arch_len;
+ *entry = estrndup(ext_str+ext_len, *entry_len);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(*entry, *entry_len);
+#endif
+ *entry = phar_fix_filepath(*entry, entry_len, 0 TSRMLS_CC);
+ } else {
+ *entry_len = 1;
+ *entry = estrndup("/", 1);
+ }
+
+ if (free_filename) {
+ efree(filename);
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * Invoked when a user calls Phar::mapPhar() from within an executing .phar
+ * to set up its manifest directly
+ */
+int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
+{
+ char *fname;
+ zval *halt_constant;
+ php_stream *fp;
+ int fname_len;
+ char *actual = NULL;
+ int ret;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+ if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, 0, REPORT_ERRORS, NULL, 0 TSRMLS_CC) == SUCCESS) {
+ return SUCCESS;
+ }
+
+ if (!strcmp(fname, "[no active file]")) {
+ if (error) {
+ spprintf(error, 0, "cannot initialize a phar outside of PHP execution");
+ }
+ return FAILURE;
+ }
+
+ MAKE_STD_ZVAL(halt_constant);
+
+ if (0 == zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC)) {
+ FREE_ZVAL(halt_constant);
+ if (error) {
+ spprintf(error, 0, "__HALT_COMPILER(); must be declared in a phar");
+ }
+ return FAILURE;
+ }
+
+ FREE_ZVAL(halt_constant);
+
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ return FAILURE;
+ }
+#endif
+
+ if (php_check_open_basedir(fname TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, &actual);
+
+ if (!fp) {
+ if (error) {
+ spprintf(error, 0, "unable to open phar for reading \"%s\"", fname);
+ }
+ if (actual) {
+ efree(actual);
+ }
+ return FAILURE;
+ }
+
+ if (actual) {
+ fname = actual;
+ fname_len = strlen(actual);
+ }
+
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error TSRMLS_CC);
+
+ if (actual) {
+ efree(actual);
+ }
+
+ return ret;
+}
+/* }}} */
+
+/**
+ * Validate the CRC32 of a file opened from within the phar
+ */
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC) /* {{{ */
+{
+ php_uint32 crc = ~0;
+ int len = idata->internal_file->uncompressed_filesize;
+ php_stream *fp = idata->fp;
+ phar_entry_info *entry = idata->internal_file;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (entry->is_zip && process_zip > 0) {
+ /* verify local file header */
+ phar_zip_file_header local;
+ phar_zip_data_desc desc;
+
+ if (SUCCESS != phar_open_archive_fp(idata->phar TSRMLS_CC)) {
+ spprintf(error, 0, "phar error: unable to open zip-based phar archive \"%s\" to verify local file header for file \"%s\"", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+ php_stream_seek(phar_get_entrypfp(idata->internal_file TSRMLS_CC), entry->header_offset, SEEK_SET);
+
+ if (sizeof(local) != php_stream_read(phar_get_entrypfp(idata->internal_file TSRMLS_CC), (char *) &local, sizeof(local))) {
+
+ spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local file header for file \"%s\")", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+
+ /* check for data descriptor */
+ if (((PHAR_ZIP_16(local.flags)) & 0x8) == 0x8) {
+ php_stream_seek(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ entry->header_offset + sizeof(local) +
+ PHAR_ZIP_16(local.filename_len) +
+ PHAR_ZIP_16(local.extra_len) +
+ entry->compressed_filesize, SEEK_SET);
+ if (sizeof(desc) != php_stream_read(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ (char *) &desc, sizeof(desc))) {
+ spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local data descriptor for file \"%s\")", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+ if (desc.signature[0] == 'P' && desc.signature[1] == 'K') {
+ memcpy(&(local.crc32), &(desc.crc32), 12);
+ } else {
+ /* old data descriptors have no signature */
+ memcpy(&(local.crc32), &desc, 12);
+ }
+ }
+ /* verify local header */
+ if (entry->filename_len != PHAR_ZIP_16(local.filename_len) || entry->crc32 != PHAR_ZIP_32(local.crc32) || entry->uncompressed_filesize != PHAR_ZIP_32(local.uncompsize) || entry->compressed_filesize != PHAR_ZIP_32(local.compsize)) {
+ spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (local header of file \"%s\" does not match central directory)", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+
+ /* construct actual offset to file start - local extra_len can be different from central extra_len */
+ entry->offset = entry->offset_abs =
+ sizeof(local) + entry->header_offset + PHAR_ZIP_16(local.filename_len) + PHAR_ZIP_16(local.extra_len);
+
+ if (idata->zero && idata->zero != entry->offset_abs) {
+ idata->zero = entry->offset_abs;
+ }
+ }
+
+ if (process_zip == 1) {
+ return SUCCESS;
+ }
+
+ php_stream_seek(fp, idata->zero, SEEK_SET);
+
+ while (len--) {
+ CRC32(crc, php_stream_getc(fp));
+ }
+
+ php_stream_seek(fp, idata->zero, SEEK_SET);
+
+ if (~crc == crc32) {
+ entry->is_crc_checked = 1;
+ return SUCCESS;
+ } else {
+ spprintf(error, 0, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+}
+/* }}} */
+
+static inline void phar_set_32(char *buffer, int var) /* {{{ */
+{
+#ifdef WORDS_BIGENDIAN
+ *((buffer) + 3) = (unsigned char) (((var) >> 24) & 0xFF);
+ *((buffer) + 2) = (unsigned char) (((var) >> 16) & 0xFF);
+ *((buffer) + 1) = (unsigned char) (((var) >> 8) & 0xFF);
+ *((buffer) + 0) = (unsigned char) ((var) & 0xFF);
+#else
+ memcpy(buffer, &var, sizeof(var));
+#endif
+} /* }}} */
+
+static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)data;
+
+ if (entry->fp_refcount <= 0 && entry->is_deleted) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+}
+/* }}} */
+
+#include "stub.h"
+
+char *phar_create_default_stub(const char *index_php, const char *web_index, size_t *len, char **error TSRMLS_DC) /* {{{ */
+{
+ char *stub = NULL;
+ int index_len, web_len;
+ size_t dummy;
+
+ if (!len) {
+ len = &dummy;
+ }
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (!index_php) {
+ index_php = "index.php";
+ }
+
+ if (!web_index) {
+ web_index = "index.php";
+ }
+
+ index_len = strlen(index_php);
+ web_len = strlen(web_index);
+
+ if (index_len > 400) {
+ /* ridiculous size not allowed for index.php startup filename */
+ if (error) {
+ spprintf(error, 0, "Illegal filename passed in for stub creation, was %d characters long, and only 400 or less is allowed", index_len);
+ return NULL;
+ }
+ }
+
+ if (web_len > 400) {
+ /* ridiculous size not allowed for index.php startup filename */
+ if (error) {
+ spprintf(error, 0, "Illegal web filename passed in for stub creation, was %d characters long, and only 400 or less is allowed", web_len);
+ return NULL;
+ }
+ }
+
+ phar_get_stub(index_php, web_index, len, &stub, index_len+1, web_len+1 TSRMLS_CC);
+ return stub;
+}
+/* }}} */
+
+/**
+ * Save phar contents to disk
+ *
+ * user_stub contains either a string, or a resource pointer, if len is a negative length.
+ * user_stub and len should be both 0 if the default or existing stub should be used
+ */
+int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
+{
+ char halt_stub[] = "__HALT_COMPILER();";
+ char *newstub, *tmp;
+ phar_entry_info *entry, *newentry;
+ int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
+ char *pos, has_dirs = 0;
+ char manifest[18], entry_buffer[24];
+ off_t manifest_ftell;
+ long offset;
+ size_t wrote;
+ php_uint32 manifest_len, mytime, loc, new_manifest_count;
+ php_uint32 newcrc32;
+ php_stream *file, *oldfile, *newfile, *stubfile;
+ php_stream_filter *filter;
+ php_serialize_data_t metadata_hash;
+ smart_str main_metadata_str = {0};
+ int free_user_stub, free_fp = 1, free_ufp = 1;
+
+ if (phar->is_persistent) {
+ if (error) {
+ spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (!zend_hash_num_elements(&phar->manifest) && !user_stub) {
+ return EOF;
+ }
+
+ zend_hash_clean(&phar->virtual_dirs);
+
+ if (phar->is_zip) {
+ return phar_zip_flush(phar, user_stub, len, convert, error TSRMLS_CC);
+ }
+
+ if (phar->is_tar) {
+ return phar_tar_flush(phar, user_stub, len, convert, error TSRMLS_CC);
+ }
+
+ if (PHAR_G(readonly)) {
+ return EOF;
+ }
+
+ if (phar->fp && !phar->is_brandnew) {
+ oldfile = phar->fp;
+ closeoldfile = 0;
+ php_stream_rewind(oldfile);
+ } else {
+ oldfile = php_stream_open_wrapper(phar->fname, "rb", 0, NULL);
+ closeoldfile = oldfile != NULL;
+ }
+ newfile = php_stream_fopen_tmpfile();
+ if (!newfile) {
+ if (error) {
+ spprintf(error, 0, "unable to create temporary file");
+ }
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+
+ if (user_stub) {
+ if (len < 0) {
+ /* resource passed in */
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to access resource to copy stub to new phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ if (len == -1) {
+ len = PHP_STREAM_COPY_ALL;
+ } else {
+ len = -len;
+ }
+ user_stub = 0;
+
+ if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to read resource to copy stub to new phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ free_user_stub = 1;
+ } else {
+ free_user_stub = 0;
+ }
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "illegal stub for phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ return EOF;
+ }
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
+ len = pos - user_stub + 18;
+ if ((size_t)len != php_stream_write(newfile, user_stub, len)
+ || 5 != php_stream_write(newfile, " ?>\r\n", 5)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ return EOF;
+ }
+ phar->halt_offset = len + 5;
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ } else {
+ size_t written;
+
+ if (!user_stub && phar->halt_offset && oldfile && !phar->is_brandnew) {
+ phar_stream_copy_to_stream(oldfile, newfile, phar->halt_offset, &written);
+ newstub = NULL;
+ } else {
+ /* this is either a brand new phar or a default stub overwrite */
+ newstub = phar_create_default_stub(NULL, NULL, &(phar->halt_offset), NULL TSRMLS_CC);
+ written = php_stream_write(newfile, newstub, phar->halt_offset);
+ }
+ if (phar->halt_offset != written) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ if (newstub) {
+ spprintf(error, 0, "unable to create stub in new phar \"%s\"", phar->fname);
+ } else {
+ spprintf(error, 0, "unable to copy stub of old phar to new phar \"%s\"", phar->fname);
+ }
+ }
+ if (newstub) {
+ efree(newstub);
+ }
+ return EOF;
+ }
+ if (newstub) {
+ efree(newstub);
+ }
+ }
+ manifest_ftell = php_stream_tell(newfile);
+ halt_offset = manifest_ftell;
+
+ /* Check whether we can get rid of some of the deleted entries which are
+ * unused. However some might still be in use so even after this clean-up
+ * we need to skip entries marked is_deleted. */
+ zend_hash_apply(&phar->manifest, phar_flush_clean_deleted_apply TSRMLS_CC);
+
+ /* compress as necessary, calculate crcs, serialize meta-data, manifest size, and file sizes */
+ main_metadata_str.c = 0;
+ if (phar->metadata) {
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ } else {
+ main_metadata_str.len = 0;
+ }
+ new_manifest_count = 0;
+ offset = 0;
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
+ zend_hash_move_forward(&phar->manifest)) {
+ if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ continue;
+ }
+ if (entry->cfp) {
+ /* did we forget to get rid of cfp last time? */
+ php_stream_close(entry->cfp);
+ entry->cfp = 0;
+ }
+ if (entry->is_deleted || entry->is_mounted) {
+ /* remove this from the new phar */
+ continue;
+ }
+ if (!entry->is_modified && entry->fp_refcount) {
+ /* open file pointers refer to this fp, do not free the stream */
+ switch (entry->fp_type) {
+ case PHAR_FP:
+ free_fp = 0;
+ break;
+ case PHAR_UFP:
+ free_ufp = 0;
+ default:
+ break;
+ }
+ }
+ /* after excluding deleted files, calculate manifest size in bytes and number of entries */
+ ++new_manifest_count;
+ phar_add_virtual_dirs(phar, entry->filename, entry->filename_len TSRMLS_CC);
+
+ if (entry->is_dir) {
+ /* we use this to calculate API version, 1.1.1 is used for phars with directories */
+ has_dirs = 1;
+ }
+ if (entry->metadata) {
+ if (entry->metadata_str.c) {
+ smart_str_free(&entry->metadata_str);
+ }
+ entry->metadata_str.c = 0;
+ entry->metadata_str.len = 0;
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ } else {
+ if (entry->metadata_str.c) {
+ smart_str_free(&entry->metadata_str);
+ }
+ entry->metadata_str.c = 0;
+ entry->metadata_str.len = 0;
+ }
+
+ /* 32 bits for filename length, length of filename, manifest + metadata, and add 1 for trailing / if a directory */
+ offset += 4 + entry->filename_len + sizeof(entry_buffer) + entry->metadata_str.len + (entry->is_dir ? 1 : 0);
+
+ /* compress and rehash as necessary */
+ if ((oldfile && !entry->is_modified) || entry->is_dir) {
+ if (entry->fp_type == PHAR_UFP) {
+ /* reset so we can copy the compressed data over */
+ entry->fp_type = PHAR_FP;
+ }
+ continue;
+ }
+ if (!phar_get_efp(entry, 0 TSRMLS_CC)) {
+ /* re-open internal file pointer just-in-time */
+ newentry = phar_open_jit(phar, entry, error TSRMLS_CC);
+ if (!newentry) {
+ /* major problem re-opening, so we ignore this file and the error */
+ efree(*error);
+ *error = NULL;
+ continue;
+ }
+ entry = newentry;
+ }
+ file = phar_get_efp(entry, 0 TSRMLS_CC);
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, phar->fname);
+ }
+ return EOF;
+ }
+ newcrc32 = ~0;
+ mytime = entry->uncompressed_filesize;
+ for (loc = 0;loc < mytime; ++loc) {
+ CRC32(newcrc32, php_stream_getc(file));
+ }
+ entry->crc32 = ~newcrc32;
+ entry->is_crc_checked = 1;
+ if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ /* not compressed */
+ entry->compressed_filesize = entry->uncompressed_filesize;
+ continue;
+ }
+ filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
+ if (!filter) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ if (error) {
+ spprintf(error, 0, "unable to gzip compress file \"%s\" to new phar \"%s\"", entry->filename, phar->fname);
+ }
+ } else {
+ if (error) {
+ spprintf(error, 0, "unable to bzip2 compress file \"%s\" to new phar \"%s\"", entry->filename, phar->fname);
+ }
+ }
+ return EOF;
+ }
+
+ /* create new file that holds the compressed version */
+ /* work around inability to specify freedom in write and strictness
+ in read count */
+ entry->cfp = php_stream_fopen_tmpfile();
+ if (!entry->cfp) {
+ if (error) {
+ spprintf(error, 0, "unable to create temporary file");
+ }
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ return EOF;
+ }
+ php_stream_flush(file);
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, phar->fname);
+ }
+ return EOF;
+ }
+ php_stream_filter_append((&entry->cfp->writefilters), filter);
+ if (SUCCESS != phar_stream_copy_to_stream(file, entry->cfp, entry->uncompressed_filesize, NULL)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", entry->filename, phar->fname);
+ }
+ return EOF;
+ }
+ php_stream_filter_flush(filter, 1);
+ php_stream_flush(entry->cfp);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_seek(entry->cfp, 0, SEEK_END);
+ entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp);
+ /* generate crc on compressed file */
+ php_stream_rewind(entry->cfp);
+ entry->old_flags = entry->flags;
+ entry->is_modified = 1;
+ 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: phar global flags
+ * 4: alias length
+ * ?: the alias itself
+ * 4: phar metadata length
+ * ?: phar metadata
+ */
+ restore_alias_len = phar->alias_len;
+ if (phar->is_temporary_alias) {
+ phar->alias_len = 0;
+ }
+
+ manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len;
+ phar_set_32(manifest, manifest_len);
+ phar_set_32(manifest+4, new_manifest_count);
+ if (has_dirs) {
+ *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF);
+ *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0));
+ } else {
+ *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION_NODIR) >> 8) & 0xFF);
+ *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION_NODIR) & 0xF0));
+ }
+ phar_set_32(manifest+10, global_flags);
+ phar_set_32(manifest+14, phar->alias_len);
+
+ /* write the manifest header */
+ if (sizeof(manifest) != php_stream_write(newfile, manifest, sizeof(manifest))
+ || (size_t)phar->alias_len != php_stream_write(newfile, phar->alias, phar->alias_len)) {
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ php_stream_close(newfile);
+ phar->alias_len = restore_alias_len;
+
+ if (error) {
+ spprintf(error, 0, "unable to write manifest header of new phar \"%s\"", phar->fname);
+ }
+
+ return EOF;
+ }
+
+ phar->alias_len = restore_alias_len;
+
+ phar_set_32(manifest, main_metadata_str.len);
+ if (4 != php_stream_write(newfile, manifest, 4) || (main_metadata_str.len
+ && main_metadata_str.len != php_stream_write(newfile, main_metadata_str.c, main_metadata_str.len))) {
+ smart_str_free(&main_metadata_str);
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ php_stream_close(newfile);
+ phar->alias_len = restore_alias_len;
+
+ if (error) {
+ spprintf(error, 0, "unable to write manifest meta-data of new phar \"%s\"", phar->fname);
+ }
+
+ return EOF;
+ }
+ smart_str_free(&main_metadata_str);
+
+ /* re-calculate the manifest location to simplify later code */
+ manifest_ftell = php_stream_tell(newfile);
+
+ /* now write the manifest */
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
+ zend_hash_move_forward(&phar->manifest)) {
+
+ if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ continue;
+ }
+
+ if (entry->is_deleted || entry->is_mounted) {
+ /* remove this from the new phar if deleted, ignore if mounted */
+ continue;
+ }
+
+ if (entry->is_dir) {
+ /* add 1 for trailing slash */
+ phar_set_32(entry_buffer, entry->filename_len + 1);
+ } else {
+ 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)
+ || (entry->is_dir && 1 != php_stream_write(newfile, "/", 1))) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ if (entry->is_dir) {
+ spprintf(error, 0, "unable to write filename of directory \"%s\" to manifest of new phar \"%s\"", entry->filename, phar->fname);
+ } else {
+ spprintf(error, 0, "unable to write filename of file \"%s\" to manifest of new phar \"%s\"", entry->filename, phar->fname);
+ }
+ }
+ return EOF;
+ }
+
+ /* set the manifest meta-data:
+ 4: uncompressed filesize
+ 4: creation timestamp
+ 4: compressed filesize
+ 4: crc32
+ 4: flags
+ 4: metadata-len
+ +: metadata
+ */
+ mytime = time(NULL);
+ phar_set_32(entry_buffer, entry->uncompressed_filesize);
+ phar_set_32(entry_buffer+4, mytime);
+ phar_set_32(entry_buffer+8, entry->compressed_filesize);
+ phar_set_32(entry_buffer+12, entry->crc32);
+ phar_set_32(entry_buffer+16, entry->flags);
+ phar_set_32(entry_buffer+20, entry->metadata_str.len);
+
+ if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer))
+ || entry->metadata_str.len != php_stream_write(newfile, entry->metadata_str.c, entry->metadata_str.len)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ php_stream_close(newfile);
+
+ if (error) {
+ spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", entry->filename, phar->fname);
+ }
+
+ return EOF;
+ }
+ }
+
+ /* now copy the actual file data to the new phar */
+ offset = php_stream_tell(newfile);
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
+ zend_hash_move_forward(&phar->manifest)) {
+
+ if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ continue;
+ }
+
+ if (entry->is_deleted || entry->is_dir || entry->is_mounted) {
+ continue;
+ }
+
+ if (entry->cfp) {
+ file = entry->cfp;
+ php_stream_rewind(file);
+ } else {
+ file = phar_get_efp(entry, 0 TSRMLS_CC);
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, phar->fname);
+ }
+ return EOF;
+ }
+ }
+
+ if (!file) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, phar->fname);
+ }
+ return EOF;
+ }
+
+ /* this will have changed for all files that have either changed compression or been modified */
+ entry->offset = entry->offset_abs = offset;
+ offset += entry->compressed_filesize;
+ if (phar_stream_copy_to_stream(file, newfile, entry->compressed_filesize, &wrote) == FAILURE) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ php_stream_close(newfile);
+
+ if (error) {
+ spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\"", entry->filename, phar->fname);
+ }
+
+ return EOF;
+ }
+
+ entry->is_modified = 0;
+
+ if (entry->cfp) {
+ php_stream_close(entry->cfp);
+ entry->cfp = NULL;
+ }
+
+ if (entry->fp_type == PHAR_MOD) {
+ /* this fp is in use by a phar_entry_data returned by phar_get_entry_data, it will be closed when the phar_entry_data is phar_entry_delref'ed */
+ if (entry->fp_refcount == 0 && entry->fp != phar->fp && entry->fp != phar->ufp) {
+ php_stream_close(entry->fp);
+ }
+
+ entry->fp = NULL;
+ entry->fp_type = PHAR_FP;
+ } else if (entry->fp_type == PHAR_UFP) {
+ entry->fp_type = PHAR_FP;
+ }
+ }
+
+ /* append signature */
+ if (global_flags & PHAR_HDR_SIGNATURE) {
+ char sig_buf[4];
+
+ php_stream_rewind(newfile);
+
+ if (phar->signature) {
+ efree(phar->signature);
+ phar->signature = NULL;
+ }
+
+ switch(phar->sig_flags) {
+#ifndef PHAR_HASH_OK
+ case PHAR_SIG_SHA512:
+ case PHAR_SIG_SHA256:
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\" with requested hash type", entry->filename, phar->fname);
+ }
+ return EOF;
+#endif
+ default: {
+ char *digest = NULL;
+ int digest_len;
+
+ if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, error TSRMLS_CC)) {
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar error: unable to write signature: %s", save);
+ efree(save);
+ }
+ if (digest) {
+ efree(digest);
+ }
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ return EOF;
+ }
+
+ php_stream_write(newfile, digest, digest_len);
+ efree(digest);
+ if (phar->sig_flags == PHAR_SIG_OPENSSL) {
+ phar_set_32(sig_buf, digest_len);
+ php_stream_write(newfile, sig_buf, 4);
+ }
+ break;
+ }
+ }
+ phar_set_32(sig_buf, phar->sig_flags);
+ php_stream_write(newfile, sig_buf, 4);
+ php_stream_write(newfile, "GBMB", 4);
+ }
+
+ /* finally, close the temp file, rename the original phar,
+ move the temp to the old phar, unlink the old phar, and reload it into memory
+ */
+ if (phar->fp && free_fp) {
+ php_stream_close(phar->fp);
+ }
+
+ if (phar->ufp) {
+ if (free_ufp) {
+ php_stream_close(phar->ufp);
+ }
+ phar->ufp = NULL;
+ }
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ phar->internal_file_start = halt_offset + manifest_len + 4;
+ phar->halt_offset = halt_offset;
+ phar->is_brandnew = 0;
+
+ php_stream_rewind(newfile);
+
+ if (phar->donotflush) {
+ /* deferred flush */
+ phar->fp = newfile;
+ } else {
+ phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
+ if (!phar->fp) {
+ phar->fp = newfile;
+ if (error) {
+ spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (phar->flags & PHAR_FILE_COMPRESSED_GZ) {
+ /* to properly compress, we have to tell zlib to add a zlib header */
+ zval filterparams;
+
+ array_init(&filterparams);
+ add_assoc_long(&filterparams, "window", MAX_WBITS+16);
+ filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ zval_dtor(&filterparams);
+
+ if (!filter) {
+ if (error) {
+ spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname);
+ }
+ return EOF;
+ }
+
+ php_stream_filter_append(&phar->fp->writefilters, filter);
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(phar->fp);
+ /* use the temp stream as our base */
+ phar->fp = newfile;
+ } else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
+ filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ php_stream_filter_append(&phar->fp->writefilters, filter);
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(phar->fp);
+ /* use the temp stream as our base */
+ phar->fp = newfile;
+ } else {
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ /* we could also reopen the file in "rb" mode but there is no need for that */
+ php_stream_close(newfile);
+ }
+ }
+
+ if (-1 == php_stream_seek(phar->fp, phar->halt_offset, SEEK_SET)) {
+ if (error) {
+ spprintf(error, 0, "unable to seek to __HALT_COMPILER(); in new phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ return EOF;
+}
+/* }}} */
+
+#ifdef COMPILE_DL_PHAR
+ZEND_GET_MODULE(phar)
+#endif
+
+/* {{{ phar_functions[]
+ *
+ * Every user visible function must have an entry in phar_functions[].
+ */
+zend_function_entry phar_functions[] = {
+ PHP_FE_END
+};
+/* }}}*/
+
+static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS_DC) /* {{{ */
+{
+ return php_stream_read(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC), buf, len);
+}
+/* }}} */
+
+#if PHP_VERSION_ID >= 50300
+static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
+{
+ return ((phar_archive_data*)handle)->halt_offset + 32;
+} /* }}} */
+
+#else /* PHP_VERSION_ID */
+
+static long phar_stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
+{
+ return (long)php_stream_tell(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC));
+}
+/* }}} */
+#endif
+
+zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
+#if PHP_VERSION_ID >= 50300
+#define phar_orig_zend_open zend_stream_open_function
+static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
+{
+ return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
+}
+#else
+int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
+#endif
+
+static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
+{
+ zend_op_array *res;
+ char *name = NULL;
+ int failed;
+ phar_archive_data *phar;
+
+ if (!file_handle || !file_handle->filename) {
+ return phar_orig_compile_file(file_handle, type TSRMLS_CC);
+ }
+ if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) {
+ if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) {
+ if (phar->is_zip || phar->is_tar) {
+ zend_file_handle f = *file_handle;
+
+ /* zip or tar-based phar */
+ spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php");
+ if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle TSRMLS_CC)) {
+ efree(name);
+ name = NULL;
+ file_handle->filename = f.filename;
+ if (file_handle->opened_path) {
+ efree(file_handle->opened_path);
+ }
+ file_handle->opened_path = f.opened_path;
+ file_handle->free_filename = f.free_filename;
+ } else {
+ *file_handle = f;
+ }
+ } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
+ /* compressed phar */
+#if PHP_VERSION_ID >= 50300
+ file_handle->type = ZEND_HANDLE_STREAM;
+ /* we do our own reading directly from the phar, don't change the next line */
+ file_handle->handle.stream.handle = phar;
+ file_handle->handle.stream.reader = phar_zend_stream_reader;
+ file_handle->handle.stream.closer = NULL;
+ file_handle->handle.stream.fsizer = phar_zend_stream_fsizer;
+ file_handle->handle.stream.isatty = 0;
+ phar->is_persistent ?
+ php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
+ php_stream_rewind(phar->fp);
+ memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
+#else /* PHP_VERSION_ID */
+ file_handle->type = ZEND_HANDLE_STREAM;
+ /* we do our own reading directly from the phar, don't change the next line */
+ file_handle->handle.stream.handle = phar;
+ file_handle->handle.stream.reader = phar_zend_stream_reader;
+ file_handle->handle.stream.closer = NULL; /* don't close - let phar handle this one */
+ file_handle->handle.stream.fteller = phar_stream_fteller_for_zend;
+ file_handle->handle.stream.interactive = 0;
+ phar->is_persistent ?
+ php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
+ php_stream_rewind(phar->fp);
+#endif
+ }
+ }
+ }
+
+ zend_try {
+ failed = 0;
+ res = phar_orig_compile_file(file_handle, type TSRMLS_CC);
+ } zend_catch {
+ failed = 1;
+ res = NULL;
+ } zend_end_try();
+
+ if (name) {
+ efree(name);
+ }
+
+ if (failed) {
+ zend_bailout();
+ }
+
+ return res;
+}
+/* }}} */
+
+#if PHP_VERSION_ID < 50300
+int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */
+{
+ char *arch, *entry;
+ int arch_len, entry_len;
+
+ /* this code is obsoleted in php 5.3 */
+ entry = (char *) filename;
+ if (!IS_ABSOLUTE_PATH(entry, strlen(entry)) && !strstr(entry, "://")) {
+ phar_archive_data **pphar = NULL;
+ char *fname;
+ int fname_len;
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+ if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) {
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
+ if (!pphar && PHAR_G(manifest_cached)) {
+ zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
+ }
+ efree(arch);
+ efree(entry);
+ }
+ }
+
+ /* retrieving an include within the current directory, so use this if possible */
+ if (!(entry = phar_find_in_include_path((char *) filename, strlen(filename), NULL TSRMLS_CC))) {
+ /* this file is not in the phar, use the original path */
+ goto skip_phar;
+ }
+
+ if (SUCCESS == phar_orig_zend_open(entry, handle TSRMLS_CC)) {
+ if (!handle->opened_path) {
+ handle->opened_path = entry;
+ }
+ if (entry != filename) {
+ handle->free_filename = 1;
+ }
+ return SUCCESS;
+ }
+
+ if (entry != filename) {
+ efree(entry);
+ }
+
+ return FAILURE;
+ }
+skip_phar:
+ return phar_orig_zend_open(filename, handle TSRMLS_CC);
+}
+/* }}} */
+#endif
+typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
+typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
+
+PHP_GINIT_FUNCTION(phar) /* {{{ */
+{
+ phar_mime_type mime;
+
+ memset(phar_globals, 0, sizeof(zend_phar_globals));
+ phar_globals->readonly = 1;
+
+ zend_hash_init(&phar_globals->mime_types, 0, NULL, NULL, 1);
+
+#define PHAR_SET_MIME(mimetype, ret, fileext) \
+ mime.mime = mimetype; \
+ mime.len = sizeof((mimetype))+1; \
+ mime.type = ret; \
+ zend_hash_add(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type), NULL); \
+
+ PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cc")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cpp")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c++")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "dtd")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "h")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "log")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "rng")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "txt")
+ PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "xsd")
+ PHAR_SET_MIME("", PHAR_MIME_PHP, "php")
+ PHAR_SET_MIME("", PHAR_MIME_PHP, "inc")
+ PHAR_SET_MIME("video/avi", PHAR_MIME_OTHER, "avi")
+ PHAR_SET_MIME("image/bmp", PHAR_MIME_OTHER, "bmp")
+ PHAR_SET_MIME("text/css", PHAR_MIME_OTHER, "css")
+ PHAR_SET_MIME("image/gif", PHAR_MIME_OTHER, "gif")
+ PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htm")
+ PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "html")
+ PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htmls")
+ PHAR_SET_MIME("image/x-ico", PHAR_MIME_OTHER, "ico")
+ PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpe")
+ PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpg")
+ PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpeg")
+ PHAR_SET_MIME("application/x-javascript", PHAR_MIME_OTHER, "js")
+ PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "midi")
+ PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "mid")
+ PHAR_SET_MIME("audio/mod", PHAR_MIME_OTHER, "mod")
+ PHAR_SET_MIME("movie/quicktime", PHAR_MIME_OTHER, "mov")
+ PHAR_SET_MIME("audio/mp3", PHAR_MIME_OTHER, "mp3")
+ PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpg")
+ PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpeg")
+ PHAR_SET_MIME("application/pdf", PHAR_MIME_OTHER, "pdf")
+ PHAR_SET_MIME("image/png", PHAR_MIME_OTHER, "png")
+ PHAR_SET_MIME("application/shockwave-flash", PHAR_MIME_OTHER, "swf")
+ PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tif")
+ PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tiff")
+ PHAR_SET_MIME("audio/wav", PHAR_MIME_OTHER, "wav")
+ PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm")
+ PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml")
+
+ phar_restore_orig_functions(TSRMLS_C);
+}
+/* }}} */
+
+PHP_GSHUTDOWN_FUNCTION(phar) /* {{{ */
+{
+ zend_hash_destroy(&phar_globals->mime_types);
+}
+/* }}} */
+
+PHP_MINIT_FUNCTION(phar) /* {{{ */
+{
+ REGISTER_INI_ENTRIES();
+
+ phar_orig_compile_file = zend_compile_file;
+ zend_compile_file = phar_compile_file;
+
+#if PHP_VERSION_ID >= 50300
+ phar_save_resolve_path = zend_resolve_path;
+ zend_resolve_path = phar_resolve_path;
+#else
+ phar_orig_zend_open = zend_stream_open_function;
+ zend_stream_open_function = phar_zend_open;
+#endif
+
+ phar_object_init(TSRMLS_C);
+
+ phar_intercept_functions_init(TSRMLS_C);
+ phar_save_orig_functions(TSRMLS_C);
+
+ return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper TSRMLS_CC);
+}
+/* }}} */
+
+PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
+{
+ php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
+
+ phar_intercept_functions_shutdown(TSRMLS_C);
+
+ if (zend_compile_file == phar_compile_file) {
+ zend_compile_file = phar_orig_compile_file;
+ }
+
+#if PHP_VERSION_ID < 50300
+ if (zend_stream_open_function == phar_zend_open) {
+ zend_stream_open_function = phar_orig_zend_open;
+ }
+#endif
+ if (PHAR_G(manifest_cached)) {
+ zend_hash_destroy(&(cached_phars));
+ zend_hash_destroy(&(cached_alias));
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+void phar_request_initialize(TSRMLS_D) /* {{{ */
+{
+ if (!PHAR_GLOBALS->request_init)
+ {
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+ PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
+ PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
+ PHAR_GLOBALS->request_init = 1;
+ PHAR_GLOBALS->request_ends = 0;
+ PHAR_GLOBALS->request_done = 0;
+ zend_hash_init(&(PHAR_GLOBALS->phar_fname_map), 5, zend_get_hash_value, destroy_phar_data, 0);
+ zend_hash_init(&(PHAR_GLOBALS->phar_persist_map), 5, zend_get_hash_value, NULL, 0);
+ zend_hash_init(&(PHAR_GLOBALS->phar_alias_map), 5, zend_get_hash_value, NULL, 0);
+
+ if (PHAR_G(manifest_cached)) {
+ phar_archive_data **pphar;
+ phar_entry_fp *stuff = (phar_entry_fp *) ecalloc(zend_hash_num_elements(&cached_phars), sizeof(phar_entry_fp));
+
+ for (zend_hash_internal_pointer_reset(&cached_phars);
+ zend_hash_get_current_data(&cached_phars, (void **)&pphar) == SUCCESS;
+ zend_hash_move_forward(&cached_phars)) {
+ stuff[pphar[0]->phar_pos].manifest = (phar_entry_fp_info *) ecalloc( zend_hash_num_elements(&(pphar[0]->manifest)), sizeof(phar_entry_fp_info));
+ }
+
+ PHAR_GLOBALS->cached_fp = stuff;
+ }
+
+ PHAR_GLOBALS->phar_SERVER_mung_list = 0;
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+ PHAR_G(cwd_init) = 0;
+ }
+}
+/* }}} */
+
+PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
+{
+ int i;
+
+ PHAR_GLOBALS->request_ends = 1;
+
+ if (PHAR_GLOBALS->request_init)
+ {
+ phar_release_functions(TSRMLS_C);
+ zend_hash_destroy(&(PHAR_GLOBALS->phar_alias_map));
+ PHAR_GLOBALS->phar_alias_map.arBuckets = NULL;
+ zend_hash_destroy(&(PHAR_GLOBALS->phar_fname_map));
+ PHAR_GLOBALS->phar_fname_map.arBuckets = NULL;
+ zend_hash_destroy(&(PHAR_GLOBALS->phar_persist_map));
+ PHAR_GLOBALS->phar_persist_map.arBuckets = NULL;
+ PHAR_GLOBALS->phar_SERVER_mung_list = 0;
+
+ if (PHAR_GLOBALS->cached_fp) {
+ for (i = 0; i < zend_hash_num_elements(&cached_phars); ++i) {
+ if (PHAR_GLOBALS->cached_fp[i].fp) {
+ php_stream_close(PHAR_GLOBALS->cached_fp[i].fp);
+ }
+ if (PHAR_GLOBALS->cached_fp[i].ufp) {
+ php_stream_close(PHAR_GLOBALS->cached_fp[i].ufp);
+ }
+ efree(PHAR_GLOBALS->cached_fp[i].manifest);
+ }
+ efree(PHAR_GLOBALS->cached_fp);
+ PHAR_GLOBALS->cached_fp = 0;
+ }
+
+ PHAR_GLOBALS->request_init = 0;
+
+ if (PHAR_G(cwd)) {
+ efree(PHAR_G(cwd));
+ }
+
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+ PHAR_G(cwd_init) = 0;
+ }
+
+ PHAR_GLOBALS->request_done = 1;
+ return SUCCESS;
+}
+/* }}} */
+
+PHP_MINFO_FUNCTION(phar) /* {{{ */
+{
+ phar_request_initialize(TSRMLS_C);
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
+ php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
+ php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
+ php_info_print_table_row(2, "SVN revision", "$Id: c5042cc34acebcc0926625b57dff03deebbe6472 $");
+ php_info_print_table_row(2, "Phar-based phar archives", "enabled");
+ php_info_print_table_row(2, "Tar-based phar archives", "enabled");
+ php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
+
+ if (PHAR_G(has_zlib)) {
+ php_info_print_table_row(2, "gzip compression", "enabled");
+ } else {
+ php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)");
+ }
+
+ if (PHAR_G(has_bz2)) {
+ php_info_print_table_row(2, "bzip2 compression", "enabled");
+ } else {
+ php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)");
+ }
+#ifdef PHAR_HAVE_OPENSSL
+ php_info_print_table_row(2, "Native OpenSSL support", "enabled");
+#else
+ if (zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
+ php_info_print_table_row(2, "OpenSSL support", "enabled");
+ } else {
+ php_info_print_table_row(2, "OpenSSL support", "disabled (install ext/openssl)");
+ }
+#endif
+ php_info_print_table_end();
+
+ php_info_print_box_start(0);
+ PUTS("Phar based on pear/PHP_Archive, original concept by Davey Shafik.");
+ PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
+ PUTS("Phar fully realized by Gregory Beaver and Marcus Boerger.");
+ PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
+ PUTS("Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.");
+ php_info_print_box_end();
+
+ DISPLAY_INI_ENTRIES();
+}
+/* }}} */
+
+/* {{{ phar_module_entry
+ */
+static const zend_module_dep phar_deps[] = {
+ ZEND_MOD_OPTIONAL("apc")
+ ZEND_MOD_OPTIONAL("bz2")
+ ZEND_MOD_OPTIONAL("openssl")
+ ZEND_MOD_OPTIONAL("zlib")
+ ZEND_MOD_OPTIONAL("standard")
+#if defined(HAVE_HASH) && !defined(COMPILE_DL_HASH)
+ ZEND_MOD_REQUIRED("hash")
+#endif
+#if HAVE_SPL
+ ZEND_MOD_REQUIRED("spl")
+#endif
+ ZEND_MOD_END
+};
+
+zend_module_entry phar_module_entry = {
+ STANDARD_MODULE_HEADER_EX, NULL,
+ phar_deps,
+ "Phar",
+ phar_functions,
+ PHP_MINIT(phar),
+ PHP_MSHUTDOWN(phar),
+ NULL,
+ PHP_RSHUTDOWN(phar),
+ PHP_MINFO(phar),
+ PHP_PHAR_VERSION,
+ PHP_MODULE_GLOBALS(phar), /* globals descriptor */
+ PHP_GINIT(phar), /* globals ctor */
+ PHP_GSHUTDOWN(phar), /* globals dtor */
+ NULL, /* post deactivate */
+ STANDARD_MODULE_PROPERTIES_EX
+};
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc
new file mode 100644
index 0000000..79bf5c8
--- /dev/null
+++ b/ext/phar/phar/clicommand.inc
@@ -0,0 +1,351 @@
+<?php
+
+/** @file clicommand.inc
+ * @ingroup Phar
+ * @brief class CLICommand
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Phar Command
+ */
+
+/** @ingroup Phar
+ * @brief Abstract base console command implementation
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+abstract class CLICommand
+{
+ protected $argc;
+ protected $argv;
+ protected $cmds = array();
+ protected $args = array();
+ protected $typs = array();
+
+ function __construct($argc, array $argv)
+ {
+ $this->argc = $argc;
+ $this->argv = $argv;
+ $this->cmds = self::getCommands($this);
+ $this->typs = self::getArgTyps($this);
+
+ if ($argc < 2) {
+ self::error("No command given, check ${argv[0]} help\n");
+ } elseif (!isset($this->cmds[$argv[1]]['run'])) {
+ self::error("Unknown command '${argv[1]}', check ${argv[0]} help\n");
+ } else {
+ $command = $argv[1];
+ }
+
+ if (isset($this->cmds[$command]['arg'])) {
+ $this->args = call_user_func(array($this, $this->cmds[$command]['arg']));
+ $i = 1;
+ $missing = false;
+ while (++$i < $argc) {
+ if ($argv[$i][0] == '-') {
+ if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) {
+ $arg = $argv[$i][1];
+ if (++$i >= $argc) {
+ self::error("Missing argument to parameter '$arg' of command '$command', check ${argv[0]} help\n");
+ } else {
+ $this->args[$arg]['val'] = $this->checkArgTyp($arg, $i, $argc, $argv);
+ }
+ } else {
+ self::error("Unknown parameter '${argv[$i]}' to command $command, check ${argv[0]} help\n");
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (isset($this->args[''])) {
+ if ($i >= $argc) {
+ if (isset($this->args['']['require']) && $this->args['']['require']) {
+ self::error("Missing default trailing arguments to command $command, check ${argv[0]} help\n");
+ }
+ } else {
+ $this->args['']['val'] = array();
+ while($i < $argc) {
+ $this->args['']['val'][] = $argv[$i++];
+ }
+ }
+ } else if ($i < $argc) {
+ self::error("Unexpected default arguments to command $command, check ${argv[0]} help\n");
+ }
+
+ foreach($this->args as $arg => $inf) {
+ if (strlen($arg) && !isset($inf['val']) && isset($inf['required']) && $inf['required']) {
+ $missing .= "Missing parameter '-$arg' to command $command, check ${argv[0]} help\n";
+ }
+ }
+
+ if (strlen($missing)) {
+ self::error($missing);
+ }
+ }
+
+ call_user_func(array($this, $this->cmds[$command]['run']), $this->args);
+ }
+
+ static function notice ($msg)
+ {
+ fprintf(STDERR, $msg);
+ }
+
+ static function error ($msg, $exit_code = 1)
+ {
+ self::notice($msg);
+ exit($exit_code);
+ }
+
+ function checkArgTyp($arg, $i, $argc, $argv)
+ {
+ $typ = $this->args[$arg]['typ'];
+
+ if (isset($this->typs[$typ]['typ'])) {
+ return call_user_func(array($this, $this->typs[$typ]['typ']), $argv[$i], $this->args[$arg], $arg);
+ } else {
+ return $argv[$i];
+ }
+ }
+
+ static function getSubFuncs(CLICommand $cmdclass, $prefix, array $subs)
+ {
+ $a = array();
+ $r = new ReflectionClass($cmdclass);
+ $l = strlen($prefix);
+
+ foreach($r->getMethods() as $m) {
+ if (substr($m->name, 0, $l) == $prefix) {
+ foreach($subs as $sub) {
+ $what = substr($m->name, $l+strlen($sub)+1);
+ $func = $prefix . $sub . '_' . $what;
+ $what = str_replace('_', '-', $what);
+ if ($r->hasMethod($func)) {
+ if (!isset($a[$what])) {
+ $a[$what] = array();
+ }
+ $a[$what][$sub] = /*$m->class . '::' .*/ $func;
+ }
+ }
+ }
+ }
+ return $a;
+ }
+
+ static function getCommands(CLICommand $cmdclass)
+ {
+ return self::getSubFuncs($cmdclass, 'cli_cmd_', array('arg','inf','run'));
+ }
+
+ static function getArgTyps(CLICommand $cmdclass)
+ {
+ return self::getSubFuncs($cmdclass, 'cli_arg_', array('typ'));
+ }
+
+ static function cli_arg_typ_bool($arg, $cfg, $key)
+ {
+ return (bool)$arg;
+ }
+
+ static function cli_arg_typ_int($arg, $cfg, $key)
+ {
+ if ((int)$arg != $arg) {
+ self::error("Argument to -$key must be an integer.\n");
+ }
+
+ return (int)$arg;
+ }
+
+ static function cli_arg_typ_regex($arg, $cfg, $key)
+ {
+ if (strlen($arg)) {
+ if (strlen($arg) > 1 && $arg[0] == $arg[strlen($arg)-1] && strpos('/,', $arg) !== false) {
+ return $arg;
+ } else {
+ return '/' . $arg . '/';
+ }
+ } else {
+ return NULL;
+ }
+ }
+
+ static function cli_arg_typ_select($arg, $cfg, $key)
+ {
+ if (!in_array($arg, array_keys($cfg['select']))) {
+ self::error("Parameter value '$arg' not one of '" . join("', '", array_keys($cfg['select'])) . "'.\n");
+ }
+ return $arg;
+ }
+
+ static function cli_arg_typ_dir($arg, $cfg, $key)
+ {
+ $f = realpath($arg);
+
+ if ($f===false || !file_exists($f) || !is_dir($f)) {
+ self::error("Requested path '$arg' does not exist.\n");
+ }
+ return $f;
+ }
+
+ static function cli_arg_typ_file($arg)
+ {
+ $f = new SplFileInfo($arg);
+ $f = $f->getRealPath();
+ if ($f===false || !file_exists($f)) {
+ echo "Requested file '$arg' does not exist.\n";
+ exit(1);
+ }
+ return $f;
+ }
+
+ static function cli_arg_typ_filenew($arg, $cfg, $key)
+ {
+ $d = dirname($arg);
+ $f = realpath($d);
+
+ if ($f === false) {
+ self::error("Path for file '$arg' does not exist.\n");
+ }
+ return $f . '/' . basename($arg);
+ }
+
+ static function cli_arg_typ_filecont($arg, $cfg, $key)
+ {
+ return file_get_contents(self::cli_arg_typ_file($arg, $cfg, $key));
+ }
+
+ function cli_get_SP2($l1, $arg_inf)
+ {
+ return str_repeat(' ', $l1 + 2 + 4 + 8);
+ }
+
+ function cli_get_SP3($l1, $l2, $arg_inf)
+ {
+ return str_repeat(' ', $l1 + 2 + 4 + 8 + 2 + $l2 + 2);
+ }
+
+ static function cli_cmd_inf_help()
+ {
+ return "This help or help for a selected command.";
+ }
+
+ private function cli_wordwrap($what, $l, $sp)
+ {
+ $p = max(79 - $l, 40); // minimum length for paragraph
+ $b = substr($what, 0, $l); // strip out initial $l
+ $r = substr($what, $l); // remainder
+ $r = str_replace("\n", "\n".$sp, $r); // in remainder replace \n's
+ return $b . wordwrap($r, $p, "\n".$sp);
+ }
+
+ private function cli_help_get_args($func, $l, $sp, $required)
+ {
+ $inf = "";
+ foreach(call_user_func($func, $l, $sp) as $arg => $conf) {
+ if ((isset($conf['required']) && $conf['required']) != $required) {
+ continue;
+ }
+
+ if (strlen($arg)) {
+ $arg = "-$arg ";
+ } else {
+ $arg = "... ";
+ }
+
+ $sp2 = $this->cli_get_SP2($l, $inf);
+ $l2 = strlen($sp2);
+ $inf .= $this->cli_wordwrap($sp . $arg . $conf['inf'], $l2, $sp2) . "\n";
+
+ if (isset($conf['select']) && count($conf['select'])) {
+ $ls = 0;
+ foreach($conf['select'] as $opt => $what) {
+ $ls = max($ls, strlen($opt));
+ }
+ $sp3 = $this->cli_get_SP3($l, $ls, $inf);
+ $l3 = strlen($sp3);
+ foreach($conf['select'] as $opt => $what) {
+ $inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-${ls}s ", $opt) . $what, $l3, $sp3) . "\n";
+ }
+ }
+ }
+ if (strlen($inf)) {
+ if ($required) {
+ return $sp . "Required arguments:\n\n" . $inf;
+ } else {
+ return $sp . "Optional arguments:\n\n". $inf;
+ }
+ }
+ }
+
+ function cli_cmd_arg_help()
+ {
+ return array('' => array('typ'=>'any','val'=>NULL,'inf'=>'Optional command to retrieve help for.'));
+ }
+
+ function cli_cmd_run_help()
+ {
+ $argv = $this->argv;
+ $which = $this->args['']['val'];
+ if (isset($which)) {
+ if (count($which) != 1) {
+ self::error("More than one command given.\n");
+ }
+
+ $which = $which[0];
+ if (!array_key_exists($which, $this->cmds)) {
+ if (strtolower($which) == 'commands') {
+ self::cli_cmd_run_help_list();
+ exit(0);
+ }
+ self::error("Unknown command, cannot retrieve help.\n");
+ }
+
+ $l = strlen($which);
+ $cmds = array($which => $this->cmds[$which]);
+ } else {
+ echo "\n$argv[0] <command> [options]\n\n";
+ $l = 0;
+ ksort($this->cmds);
+ foreach($this->cmds as $name => $funcs) {
+ $l = max($l, strlen($name));
+ }
+ $inf = "Commands:";
+ $lst = "";
+ $ind = strlen($inf) + 1;
+ foreach($this->cmds as $name => $funcs) {
+ $lst .= ' ' . $name;
+ }
+ echo $this->cli_wordwrap($inf.$lst, $ind, str_repeat(' ', $ind)) . "\n\n";
+ $cmds = $this->cmds;
+ }
+ $sp = str_repeat(' ', $l + 2);
+ foreach($cmds as $name => $funcs) {
+ $inf = $name . substr($sp, strlen($name));
+ if (isset($funcs['inf'])) {
+ $inf .= $this->cli_wordwrap(call_user_func(array($this, $funcs['inf'])), $l, $sp) . "\n";
+ if (isset($funcs['arg'])) {
+ $inf .= "\n";
+ $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, true);
+ $inf .= "\n";
+ $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, false);
+ }
+ }
+ echo "$inf\n\n";
+ }
+ exit(0);
+ }
+
+ static function cli_cmd_inf_help_list()
+ {
+ return "Lists available commands.";
+ }
+
+ function cli_cmd_run_help_list()
+ {
+ ksort($this->cmds);
+ echo join(' ', array_keys($this->cmds)) . "\n";
+ }
+}
+
+?>
diff --git a/ext/phar/phar/directorygraphiterator.inc b/ext/phar/phar/directorygraphiterator.inc
new file mode 100644
index 0000000..5a658dd
--- /dev/null
+++ b/ext/phar/phar/directorygraphiterator.inc
@@ -0,0 +1,34 @@
+<?php
+
+/** @file directorygraphiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryGraphIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2008
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A tree iterator that only shows directories.
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryGraphIterator extends DirectoryTreeIterator
+{
+ function __construct($path)
+ {
+ RecursiveIteratorIterator::__construct(
+ new RecursiveCachingIterator(
+ new ParentIterator(
+ new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
+ )
+ ),
+ CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
+ ),
+ parent::SELF_FIRST
+ );
+ }
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/phar/directorytreeiterator.inc b/ext/phar/phar/directorytreeiterator.inc
new file mode 100644
index 0000000..9ed2e1a
--- /dev/null
+++ b/ext/phar/phar/directorytreeiterator.inc
@@ -0,0 +1,54 @@
+<?php
+
+/** @file directorytreeiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryTreeIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2008
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief DirectoryIterator to generate ASCII graphic directory trees
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryTreeIterator extends RecursiveIteratorIterator
+{
+ /** Construct from a path.
+ * @param $path directory to iterate
+ */
+ function __construct($path)
+ {
+ parent::__construct(
+ new RecursiveCachingIterator(
+ new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
+ ),
+ CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
+ ),
+ parent::SELF_FIRST
+ );
+ }
+
+ /** @return the current element prefixed with ASCII graphics
+ */
+ function current()
+ {
+ $tree = '';
+ for ($l=0; $l < $this->getDepth(); $l++) {
+ $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
+ }
+ return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
+ . $this->getSubIterator($l)->__toString();
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getSubIterator(), $func), $params);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/phar/invertedregexiterator.inc b/ext/phar/phar/invertedregexiterator.inc
new file mode 100644
index 0000000..aec87e6
--- /dev/null
+++ b/ext/phar/phar/invertedregexiterator.inc
@@ -0,0 +1,27 @@
+<?php
+
+/** @file invertedregexiterator.inc
+ * @ingroup Phar
+ * @brief class InvertedRegexIterator
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Inverted RegexIterator
+ */
+
+/** @ingroup Phar
+ * @brief Inverted RegexIterator
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class InvertedRegexIterator extends RegexIterator
+{
+ /** @return !RegexIterator::accept()
+ */
+ function accept()
+ {
+ return !RegexIterator::accept();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/phar/phar.inc b/ext/phar/phar/phar.inc
new file mode 100644
index 0000000..7e7d618
--- /dev/null
+++ b/ext/phar/phar/phar.inc
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * @file phar.inc
+ * @ingroup Phar
+ * @brief class Phar
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Phar Command
+ */
+// {{{ class Phar extends PHP_Archive
+/**
+ * Phar class
+ *
+ * @ingroup Phar
+ * @brief Phar implementation
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class Phar extends PHP_Archive implements RecursiveIterator
+{
+ function getSignature()
+ {
+ return false;
+ }
+
+ function getAlias()
+ {
+ return false;
+ }
+
+ function rewind()
+ {
+ }
+
+ function valid()
+ {
+ return false;
+ }
+
+ function current()
+ {
+ }
+
+ function key()
+ {
+ }
+
+ function next()
+ {
+ }
+
+ function hasChildren()
+ {
+ return false;
+ }
+
+ function getChildren()
+ {
+ }
+
+ function hasMetadata()
+ {
+ }
+
+ function getMetadata()
+ {
+ }
+
+ function getStub()
+ {
+ }
+
+ function setStub()
+ {
+ }
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/phar/phar.php b/ext/phar/phar/phar.php
new file mode 100755
index 0000000..f6f26c2
--- /dev/null
+++ b/ext/phar/phar/phar.php
@@ -0,0 +1,56 @@
+#!/usr/local/bin/php
+<?php
+
+/** @file phar.php
+ * @ingroup Phar
+ * @brief class CLICommand
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Phar Command
+ */
+
+if (!extension_loaded('phar'))
+{
+ if (!class_exists('PHP_Archive', 0)) {
+ echo "Neither Extension Phar nor class PHP_Archive are available.\n";
+ exit(1);
+ }
+ if (!in_array('phar', stream_get_wrappers())) {
+ stream_wrapper_register('phar', 'PHP_Archive');
+ }
+ if (!class_exists('Phar',0)) {
+ require 'phar://'.__FILE__.'/phar.inc';
+ }
+}
+
+foreach(array("SPL", "Reflection") as $ext)
+{
+ if (!extension_loaded($ext)) {
+ echo "$argv[0] requires PHP extension $ext.\n";
+ exit(1);
+ }
+}
+
+function command_include($file)
+{
+ $file = 'phar://' . __FILE__ . '/' . $file;
+ if (file_exists($file)) {
+ include($file);
+ }
+}
+
+function command_autoload($classname)
+{
+ command_include(strtolower($classname) . '.inc');
+}
+
+Phar::mapPhar();
+
+spl_autoload_register('command_autoload');
+
+new PharCommand($argc, $argv);
+
+__HALT_COMPILER();
+
+?> \ No newline at end of file
diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc
new file mode 100644
index 0000000..c507ff9
--- /dev/null
+++ b/ext/phar/phar/pharcommand.inc
@@ -0,0 +1,1595 @@
+<?php
+
+/**
+ * @file pharcommand.inc
+ * @ingroup Phar
+ * @brief class CLICommand
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Phar Command
+ */
+// {{{ class PharCommand extends CLICommand
+/**
+ * PharCommand class
+ *
+ * This class handles the handling of the phar
+ * commands. It will be used from command line/console
+ * in order to retrieve and execute phar functions.
+ *
+ * @ingroup Phar
+ * @brief Phar console command implementation
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class PharCommand extends CLICommand
+{
+ // {{{ public function cli_get_SP2
+ public function cli_get_SP2($l1, $arg_inf)
+ {
+ return str_repeat(' ', $l1 + 2 + 4 + 9);
+ }
+ // }}}
+ // {{{ public function cli_get_SP3
+ /**
+ * Cli Get SP3
+ *
+ * @param string $l1 Eleven
+ * @param string $l2 Twelve
+ * @param string $arg_inf
+ * @return string The repeated string.
+ */
+ function cli_get_SP3($l1, $l2, $arg_inf)
+ {
+ return str_repeat(' ', $l1 + 2 + 4 + 9 + 2 + $l2 + 2);
+ }
+ // }}}
+ // {{{ static function phar_args
+ /**
+ * Phar arguments
+ *
+ * This function contains all the phar commands
+ *
+ * @param string $which Which argument is chosen.
+ * @param string $phartype The type of phar, specific file to work on
+ * @return unknown
+ */
+ static function phar_args($which, $phartype)
+ {
+ $phar_args = array(
+ 'a' => array(
+ 'typ' => 'alias',
+ 'val' => NULL,
+ 'inf' => '<alias> Provide an alias name for the phar file.'
+ ),
+ 'b' => array(
+ 'typ' => 'any',
+ 'val' => NULL,
+ 'inf' => '<bang> Hash-bang line to start the archive (e.g. #!/usr/bin/php). The hash '
+ .' mark itself \'#!\' and the newline character are optional.'
+ ),
+ 'c' => array(
+ 'typ' => 'compalg',
+ 'val' => NULL,
+ 'inf' => '<algo> Compression algorithm.',
+ 'select' => array(
+ '0' => 'No compression',
+ 'none' => 'No compression',
+ 'auto' => 'Automatically select compression algorithm'
+ )
+ ),
+ 'e' => array(
+ 'typ' => 'entry',
+ 'val' => NULL,
+ 'inf' => '<entry> Name of entry to work on (must include PHAR internal directory name if any).'
+ ),
+ 'f' => array(
+ 'typ' => $phartype,
+ 'val' => NULL,
+ 'inf' => '<file> Specifies the phar file to work on.'
+ ),
+ 'h' => array(
+ 'typ' => 'select',
+ 'val' => NULL,
+ 'inf' => '<method> Selects the hash algorithm.',
+ 'select' => array('md5' => 'MD5','sha1' => 'SHA1')
+ ),
+ 'i' => array(
+ 'typ' => 'regex',
+ 'val' => NULL,
+ 'inf' => '<regex> Specifies a regular expression for input files.'
+ ),
+ 'k' => array(
+ 'typ' => 'any',
+ 'val' => NULL,
+ 'inf' => '<index> Subscription index to work on.',
+ ),
+ 'l' => array(
+ 'typ' => 'int',
+ 'val' => 0,
+ 'inf' => '<level> Number of preceding subdirectories to strip from file entries',
+ ),
+ 'm' => array(
+ 'typ' => 'any',
+ 'val' => NULL,
+ 'inf' => '<meta> Meta data to store with entry (serialized php data).'
+ ),
+ 'p' => array(
+ 'typ' => 'loader',
+ 'val' => NULL,
+ 'inf' => '<loader> Location of PHP_Archive class file (pear list-files PHP_Archive).'
+ .'You can use \'0\' or \'1\' to locate it automatically using the mentioned '
+ .'pear command. When using \'0\' the command does not error out when the '
+ .'class file cannot be located. This switch also adds some code around the '
+ .'stub so that class PHP_Archive gets registered as phar:// stream wrapper '
+ .'if necessary. And finally this switch will add the file phar.inc from '
+ .'this package and load it to ensure class Phar is present.'
+ ,
+ ),
+ 's' => array(
+ 'typ' => 'file',
+ 'val' => NULL,
+ 'inf' => '<stub> Select the stub file.'
+ ),
+ 'x' => array(
+ 'typ' => 'regex',
+ 'val' => NULL,
+ 'inf' => '<regex> Regular expression for input files to exclude.'
+ ),
+ 'y' => array(
+ 'typ' => 'privkey',
+ 'val' => NULL,
+ 'inf' => '<key> Private key for OpenSSL signing.',
+ ),
+ );
+
+ if (extension_loaded('zlib')) {
+ $phar_args['c']['select']['gz'] = 'GZip compression';
+ $phar_args['c']['select']['gzip'] = 'GZip compression';
+ }
+
+ if (extension_loaded('bz2')) {
+ $phar_args['c']['select']['bz2'] = 'BZip2 compression';
+ $phar_args['c']['select']['bzip2'] = 'BZip2 compression';
+ }
+
+ $hash_avail = Phar::getSupportedSignatures();
+ $hash_optional = array('SHA-256' => 'SHA256',
+ 'SHA-512' => 'SHA512',
+ 'OpenSSL' => 'OpenSSL');
+ if (!in_array('OpenSSL', $hash_avail)) {
+ unset($phar_args['y']);
+ }
+
+ foreach($hash_optional as $key => $name) {
+ if (in_array($key, $hash_avail)) {
+ $phar_args['h']['select'][strtolower($name)] = $name;
+ }
+ }
+
+ $args = array();
+
+ foreach($phar_args as $lkey => $cfg) {
+ $ukey = strtoupper($lkey);
+ $required = strpos($which, $ukey) !== false;
+ $optional = strpos($which, $lkey) !== false;
+
+ if ($required || $optional) {
+ $args[$lkey] = $cfg;
+ $args[$lkey]['required'] = $required;
+ }
+ }
+ return $args;
+ }
+ // }}}
+ // {{{ static function strEndsWith
+ /**
+ * String Ends With
+ *
+ * Whether a string ends with another needle.
+ *
+ * @param string $haystack The haystack
+ * @param string $needle The needle.
+ * @return mixed false if doesn't end with anything, the string
+ * substr'ed if the string ends with the needle.
+ */
+ static function strEndsWith($haystack, $needle)
+ {
+ return substr($haystack, -strlen($needle)) == $needle;
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_loader
+ /**
+ * Argument type loader
+ *
+ * @param string $arg Either 'auto', 'optional' or an filename that
+ * contains class PHP_Archive
+ * @param string $cfg Configuration to pass to a new file
+ * @param string $key The key
+ * @return string $arg The argument.
+ */
+ static function cli_arg_typ_loader($arg, $cfg, $key)
+ {
+ if (($arg == '0' || $arg == '1') && !file_exists($arg) && substr(PHP_OS, 0, 3) != 'WIN') {
+ $found = NULL;
+ $apiver = false;
+ $path = explode(PATH_SEPARATOR, $_ENV['PATH']);
+ $pear = false;
+ foreach ($path as $component) {
+ if (file_exists($component . DIRECTORY_SEPARATOR . 'pear')
+ && is_executable($component . DIRECTORY_SEPARATOR . 'pear')) {
+ $pear = true;
+ break;
+ }
+ }
+ if ($pear) {
+ $apiver = `pear -q info PHP_Archive 2>/dev/null|grep 'API Version'`;
+ $apiver = trim(substr($apiver, strlen('API Version')));
+ }
+ if ($apiver) {
+ self::notice("PEAR package PHP_Archive: API Version: $apiver.\n");
+ $files = explode("\n", `pear list-files PHP_Archive`);
+ $phpdir = `pear config-get php_dir 2>/dev/null`;
+ $phpdir = trim($phpdir);
+ self::notice("PEAR package PHP_Archive: $phpdir.\n");
+ if (is_dir($phpdir)) {
+ foreach($files as $ent) {
+ $matches = NULL;
+ if (preg_match(",^php[ \t]+([^ \t].*[\\\\/]PHP[\\\\/]Archive\.php)$,", $ent, $matches)) {
+ $sub = $matches[1];
+ if (strpos($sub, $phpdir) !== 0) {
+ $found = NULL;
+ break;
+ }
+ $found = $sub;
+ break;
+ }
+ }
+ } else {
+ self::notice("PEAR package PHP_Archive: corrupt or inaccessible base dir: $php_dir.\n");
+ }
+ }
+ if (isset($found)) {
+ self::notice("PEAR package PHP_Archive: $found.\n");
+ } else {
+ $msg = "PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.\n";
+ if ($arg == '0') {
+ self::notice($msg);
+ } else {
+ self::error($msg);
+ }
+ }
+ $arg = $found;
+ }
+ return self::cli_arg_typ_file($arg);
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_pharnew
+ /**
+ * Argument type new phar
+ *
+ * @param string $arg The new phar component.
+ * @param string $cfg Configuration to pass to a new file
+ * @param string $key The key
+ * @return string $arg The new argument file.
+ */
+ static function cli_arg_typ_pharnew($arg, $cfg, $key)
+ {
+ $arg = self::cli_arg_typ_filenew($arg, $cfg, $key);
+ if (!Phar::isValidPharFilename($arg)) {
+ self::error("Phar files must have file extension '.phar', '.phar.php', '.phar.bz2' or '.phar.gz'.\n");
+ }
+ return $arg;
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_pharfile
+ /**
+ * Argument type existing Phar file
+ *
+ * Return filename of an existing Phar.
+ *
+ * @param string $arg The file in the phar to open.
+ * @param string $cfg The configuration information
+ * @param string $key The key information.
+ * @return string $pharfile The name of the loaded Phar file.
+ * @note The Phar will be loaded
+ */
+ static function cli_arg_typ_pharfile($arg, $cfg, $key)
+ {
+ try {
+ $pharfile = self::cli_arg_typ_file($arg, $cfg, $key);
+
+ if (!Phar::loadPhar($pharfile)) {
+ self::error("Unable to open phar '$arg'\n");
+ }
+
+ return $pharfile;
+ } catch(Exception $e) {
+ self::error("Exception while opening phar '$arg':\n" . $e->getMessage() . "\n");
+ }
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_pharurl
+ /**
+ * Argument type Phar url-like
+ *
+ * Check the argument as cli_arg_Typ_phar and return its name prefixed
+ * with phar://
+ *
+ * Ex:
+ * <code>
+ * $arg = 'pharchive.phar/file.php';
+ * cli_arg_typ_pharurl($arg)
+ * </code>
+ *
+ * @param string $arg The url-like phar archive to retrieve.
+ * @return string The phar file-archive.
+ */
+ static function cli_arg_typ_pharurl($arg, $cfg, $key)
+ {
+ return 'phar://' . self::cli_arg_typ_pharfile($arg, $cfg, $key);
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_phar
+ /**
+ * Cli argument type phar
+ *
+ * @param string $arg The phar archive to use.
+ * @return object new Phar of the passed argument.
+ */
+ static function cli_arg_typ_phar($arg, $cfg, $key)
+ {
+ try {
+ return new Phar(self::cli_arg_typ_pharfile($arg, $cfg, $key));
+ } catch(Exception $e) {
+ self::error("Exception while opening phar '$argv':\n" . $e->getMessage() . "\n");
+ }
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_entry
+ /**
+ * Argument type Entry name
+ *
+ * @param string $arg The argument (the entry)
+ * @return string $arg The entry itself.
+ */
+ static function cli_arg_typ_entry($arg, $cfg, $key)
+ {
+ // no further check atm, maybe check for no '/' at beginning
+ return $arg;
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_compalg
+ /**
+ * Argument type compression algorithm
+ *
+ * @param string $arg The phar selection
+ * @param string $cfg The config option.
+ * @param string $key The key information.
+ * @return string $arg The selected algorithm
+ */
+ static function cli_arg_typ_compalg($arg, $cfg, $key)
+ {
+ $arg = self::cli_arg_typ_select($arg, $cfg, $key);
+
+ switch($arg) {
+ case 'auto':
+ if (extension_loaded('zlib')) {
+ $arg = 'gz';
+ } elseif (extension_loaded('bz2')) {
+ $arg = 'bz2';
+ } else {
+ $arg = '0';
+ }
+ break;
+ }
+ return $arg;
+ }
+ // }}}
+ // {{{ static function cli_arg_typ_privkey
+ /**
+ * Argument type private key (for OpenSSL signing)
+ *
+ * @param string $arg The phar selection
+ * @param string $cfg The config option.
+ * @param string $key The key information.
+ * @return string $arg The private key.
+ */
+ static function cli_arg_typ_privkey($arg, $cfg, $key)
+ {
+ $arg = self::cli_arg_typ_string($arg, $cfg, $key);
+
+ $hash_avail = Phar::getSupportedSignatures();
+ if ($arg && !in_array('OpenSSL', $hash_avail))
+ {
+ self::error("Cannot specifiy private key without OpenSSL support.\n");
+ }
+ return $arg;
+ }
+ // }}}
+ // {{{ static function phar_check_hash
+ /**
+ * Check whether hash method is valid.
+ *
+ * @return Hash constant to be used.
+ */
+ function phar_check_hash($hash, $privkey)
+ {
+ switch($hash) {
+ case 'md5':
+ return Phar::MD5;
+ case 'sha1':
+ return Phar::SHA1;
+ case 'sha256':
+ return Phar::SHA256;
+ case 'sha512':
+ return Phar::SHA512;
+ case 'openssl':
+ if (!$privkey) {
+ self::error("Cannot use OpenSSL signing without key.\n");
+ }
+ return Phar::OPENSSL;
+ }
+ }
+ // }}}
+ // {{{ static function cli_cmd_inf_pack
+ /**
+ * Information pack
+ *
+ * @return string A description about packing files into a Phar archive.
+ */
+ static function cli_cmd_inf_pack()
+ {
+ return "Pack files into a PHAR archive.\n" .
+ "When using -s <stub>, then the stub file is being " .
+ "excluded from the list of input files/dirs." .
+ "To create an archive that contains PEAR class PHP_Archive " .
+ "then point -p argument to PHP/Archive.php.\n";
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_pack
+ /**
+ * Pack a new phar infos
+ *
+ * @return array $args The arguments for a new Phar archive.
+ */
+ static function cli_cmd_arg_pack()
+ {
+ $args = self::phar_args('abcFhilpsxy', 'pharnew');
+
+ $args[''] = array(
+ 'typ' => 'any',
+ 'val' => NULL,
+ 'required' => 1,
+ 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.',
+ );
+
+ return $args;
+ }
+ // }}}
+ // {{{ function phar_set_stub_begin
+ /**
+ * Set the stub
+ */
+ public function phar_set_stub_begin(Phar $phar, $stub, $loader = NULL, $hashbang = NULL)
+ {
+ if (isset($stub)) {
+ $c = file_get_contents($stub);
+
+ if (substr($c, 0, 2) == '#!') {
+ if (strpos($c, "\n") !== false) {
+ if (!isset($hashbang)) {
+ $hashbang = substr($c, 0, strpos($c, "\n") + 1);
+ }
+ $c = substr($c, strpos($c, "\n") + 1);
+ } else {
+ if (!isset($hashbang)) {
+ $hashbang = $c;
+ }
+ $c = NULL;
+ }
+ }
+
+ if (isset($hashbang)) {
+ if (substr($hashbang, 0, 2) != '#!') {
+ $hashbang = '#!' . $hashbang;
+ }
+ if (substr($hashbang, -1) != "\n") {
+ $hashbang .= "\n";
+ }
+ } else {
+ $hashbang = "";
+ }
+
+ if (isset($loader)) {
+ $s = "<?php if (!class_exists('PHP_Archive')) {\n?>";
+ if (is_file($loader)) {
+ $s .= file_get_contents($loader);
+ }
+ $s .= "<?php\n";
+ $s .= "}\n";
+ $s .= "if (!in_array('phar', stream_get_wrappers())) {\n";
+ $s .= "\tstream_wrapper_register('phar', 'PHP_Archive');\n";
+ $s .= "}\n";
+ $s .= "if (!class_exists('Phar',0)) {\n";
+ $s .= "\tinclude 'phar://'.__FILE__.'/phar.inc';\n";
+ $s .= "}\n";
+ $s .= '?>';
+ $s .= $c;
+
+ $phar->setStub($hashbang . $s);
+ } else {
+ $phar->setStub($hashbang . $c);
+ }
+ return new SplFileInfo($stub);
+ }
+ return NULL;
+ }
+ // }}}
+ // {{{ function phar_set_stub_end
+ /**
+ * Set stub end
+ */
+ public function phar_set_stub_end(Phar $phar, $stub, $loader = NULL)
+ {
+ if (isset($stub) && isset($loader)) {
+ if (substr(__FILE__, -15) == 'pharcommand.inc') {
+ self::phar_add_file($phar, 0, 'phar.inc', 'phar://'.__FILE__.'/phar.inc', NULL);
+ } else {
+ self::phar_add_file($phar, 0, 'phar.inc', dirname(__FILE__).'/phar/phar.inc', NULL);
+ }
+ }
+ }
+ // }}}
+ // {{{ function cli_cmd_run_pack
+ /**
+ * Pack a new Phar
+ *
+ * This function will try to pack a new Phar archive.
+ *
+ * @see Exit to make sure that we are done.
+ */
+ public function cli_cmd_run_pack()
+ {
+ if (ini_get('phar.readonly')) {
+ self::error("Creating phar files is disabled by ini setting 'phar.readonly'.\n");
+ }
+
+ if (!Phar::canWrite()) {
+ self::error("Creating phar files is disabled, Phar::canWrite() returned false.\n");
+ }
+
+ $alias = $this->args['a']['val'];
+ $hashbang = $this->args['b']['val'];
+ $archive = $this->args['f']['val'];
+ $hash = $this->args['h']['val'];
+ $privkey = $this->args['y']['val'];
+ $regex = $this->args['i']['val'];
+ $level = $this->args['l']['val'];
+ $loader = $this->args['p']['val'];
+ $stub = $this->args['s']['val'];
+ $invregex = $this->args['x']['val'];
+ $input = $this->args['']['val'];
+
+ $hash = self::phar_check_hash($hash, $privkey);
+
+ $phar = new Phar($archive, 0, $alias);
+
+ $phar->startBuffering();
+
+ $stub = $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang);
+
+ if (!is_array($input)) {
+ $this->phar_add($phar, $level, $input, $regex, $invregex, $stub, NULL, isset($loader));
+ } else {
+ foreach($input as $i) {
+ $this->phar_add($phar, $level, $i, $regex, $invregex, $stub, NULL, isset($loader));
+ }
+ }
+
+ $this->phar_set_stub_end($phar, $stub, $loader);
+
+ switch($this->args['c']['val']) {
+ case 'gz':
+ case 'gzip':
+ $phar->compressFiles(Phar::GZ);
+ break;
+ case 'bz2':
+ case 'bzip2':
+ $phar->compressFiles(Phar::BZ2);
+ break;
+ default:
+ $phar->decompressFiles();
+ break;
+ }
+
+ if ($hash) {
+ $phar->setSignatureAlgorithm($hash, $privkey);
+ }
+
+ $phar->stopBuffering();
+ exit(0);
+ }
+ // }}}
+ // {{{ static function phar_add
+ /**
+ * Add files to a phar archive.
+ *
+ * This function will take a directory and iterate through
+ * it and get the files to insert into the Phar archive.
+ *
+ * @param Phar $phar The phar object.
+ * @param string $input The input directory
+ * @param string $regex The regex used in RegexIterator.
+ * @param string $invregex The InvertedRegexIterator expression.
+ * @param SplFileInfo $stub Stub file object
+ * @param mixed $compress Compression algorithm or NULL
+ * @param boolean $noloader Whether to prevent adding the loader
+ */
+ static function phar_add(Phar $phar, $level, $input, $regex, $invregex, SplFileInfo $stub = NULL, $compress = NULL, $noloader = false)
+ {
+ if ($input && is_file($input) && !is_dir($input)) {
+ return self::phar_add_file($phar, $level, $input, $input, $compress);
+ }
+ $dir = new RecursiveDirectoryIterator($input);
+ $dir = new RecursiveIteratorIterator($dir);
+
+ if (isset($regex)) {
+ $dir = new RegexIterator($dir, $regex);
+ }
+
+ if (isset($invregex)) {
+ $dir = new InvertedRegexIterator($dir, $invregex);
+ }
+
+ try {
+ foreach($dir as $file) {
+ if ((empty($stub) || $file->getRealPath() != $stub->getRealPath()) && !is_dir($file)) {
+ self::phar_add_file($phar, $level, $dir->getSubPathName(), $file, $compress, $noloader);
+ }
+ }
+ } catch(Excpetion $e) {
+ self::error("Unable to complete operation on file '$file'\n" . $e->getMessage() . "\n");
+ }
+ }
+ // }}}
+ // {{{ static function phar_add_file
+ /**
+ * Add a phar file
+ *
+ * This function adds a file to a phar archive.
+ *
+ * @param Phar $phar The phar object
+ * @param string $level The level of the file.
+ * @param string $entry The entry point
+ * @param string $file The file to add to the archive
+ * @param string $compress The compression scheme for the file.
+ * @param boolean $noloader Whether to prevent adding the loader
+ */
+ static function phar_add_file(Phar $phar, $level, $entry, $file, $compress, $noloader = false)
+ {
+ $entry = str_replace('//', '/', $entry);
+ while($level-- > 0 && ($p = strpos($entry, '/')) !== false) {
+ $entry = substr($entry, $p+1);
+ }
+
+ if ($noloader && $entry == 'phar.inc') {
+ return;
+ }
+
+ echo "$entry\n";
+
+ $phar[$entry] = file_get_contents($file);
+ switch($compress) {
+ case 'gz':
+ case 'gzip':
+ $phar[$entry]->compress(Phar::GZ);
+ break;
+ case 'bz2':
+ case 'bzip2':
+ $phar[$entry]->compress(Phar::BZ2);
+ break;
+ case '0':
+ $phar[$entry]->decompress();
+ break;
+ default:
+ break;
+ }
+ }
+ // }}}
+ // {{{ public function phar_dir_echo
+ /**
+ * Echo directory
+ *
+ * @param string $pn
+ * @param unknown_type $f
+ */
+ public function phar_dir_echo($pn, $f)
+ {
+ echo "$f\n";
+ }
+ // }}}
+ // {{{ public function phar_dir_operation
+ /**
+ * Directory operations
+ *
+ * Phar directory operations.
+ *
+ * @param RecursiveIteratorIterator $dir The recursiveIteratorIterator object.
+ * @param string $func Function to call on the iterations
+ * @param array $args Function arguments.
+ */
+ public function phar_dir_operation(RecursiveIteratorIterator $dir, $func, array $args = array())
+ {
+ $regex = $this->args['i']['val'];
+ $invregex= $this->args['x']['val'];
+
+ if (isset($regex)) {
+ $dir = new RegexIterator($dir, $regex);
+ }
+
+ if (isset($invregex)) {
+ $dir = new InvertedRegexIterator($dir, $invregex);
+ }
+
+ $any = false;
+ foreach($dir as $pn => $f) {
+ $any = true;
+ call_user_func($func, $pn, $f, $args);
+ }
+ return $any;
+ }
+ // {{{ static function cli_cmd_inf_list
+ /**
+ * Cli Command Info List
+ *
+ * @return string What inf does
+ */
+ static function cli_cmd_inf_list()
+ {
+ return "List contents of a PHAR archive.";
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_list
+ /**
+ * Cli Command Argument List
+ *
+ * @return arguments list
+ */
+ static function cli_cmd_arg_list()
+ {
+ return self::phar_args('Fix', 'pharurl');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_list
+ /**
+ * Cli Command Run List
+ *
+ * @see $this->phar_dir_operation
+ */
+ public function cli_cmd_run_list()
+ {
+ $this->phar_dir_operation(
+ new DirectoryTreeIterator(
+ $this->args['f']['val']),
+ array($this, 'phar_dir_echo')
+ );
+ }
+ // }}}
+ // {{{ static function cli_command_inf_tree
+ /**
+ * Cli Command Inf Tree
+ *
+ * @return string The description of a directory tree for a Phar archive.
+ */
+ static function cli_cmd_inf_tree()
+ {
+ return "Get a directory tree for a PHAR archive.";
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_tree
+ /**
+ * Cli Command Argument Tree
+ *
+ * @return string Arguments in URL format.
+ */
+ static function cli_cmd_arg_tree()
+ {
+ return self::phar_args('Fix', 'pharurl');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_tree
+ /**
+ * Cli Command Run Tree
+ *
+ * Set the phar_dir_operation with a directorygraphiterator.
+ *
+ * @see DirectoryGraphIterator
+ * @see $this->phar_dir_operation
+ *
+ */
+ public function cli_cmd_run_tree()
+ {
+ $a = $this->phar_dir_operation(
+ new DirectoryGraphIterator(
+ $this->args['f']['val']),
+ array($this, 'phar_dir_echo')
+ );
+ if (!$a) {
+ echo "|-<root directory>\n";
+ }
+ }
+ // }}}
+ // {{{ cli_cmd_inf_extract
+ /**
+ * Cli Command Inf Extract
+ *
+ * @return string The description of the command extra to a directory.
+ */
+ static function cli_cmd_inf_extract()
+ {
+ return "Extract a PHAR package to a directory.";
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_extract
+ /**
+ * Cli Command Arguments Extract
+ *
+ * The arguments for the extract function.
+ *
+ * @return array The arguments for the extraction.
+ */
+ static function cli_cmd_arg_extract()
+ {
+ $args = self::phar_args('Fix', 'phar');
+
+ $args[''] = array(
+ 'type' => 'dir',
+ 'val' => '.',
+ 'inf' => ' Directory to extract to (defaults to \'.\').',
+ );
+
+ return $args;
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_extract
+ /**
+ * Run Extract
+ *
+ * Run the extraction of a phar Archive.
+ *
+ * @see $this->phar_dir_operation
+ */
+ public function cli_cmd_run_extract()
+ {
+ $dir = $this->args['']['val'];
+
+ if (is_array($dir)) {
+ if (count($dir) != 1) {
+ self::error("Only one target directory allowed.\n");
+ } else {
+ $dir = $dir[0];
+ }
+ }
+
+ $phar = $this->args['f']['val'];
+ $base = $phar->getPathname();
+ $bend = strpos($base, '.phar');
+ $bend = strpos($base, '/', $bend);
+ $base = substr($base, 0, $bend + 1);
+ $blen = strlen($base);
+
+ $this->phar_dir_operation(
+ new RecursiveIteratorIterator($phar),
+ array($this, 'phar_dir_extract'),
+ array($blen, $dir)
+ );
+ }
+ // }}}
+ // {{{ public function phar_dir_extract
+ /**
+ * Extract to a directory
+ *
+ * This function will extract the content of a Phar
+ * to a directory and create new files and directories
+ * depending on the permissions on that folder.
+ *
+ * @param string $pn
+ * @param string $f The file name
+ * @param array $args The directory and Blen informations
+ */
+ public function phar_dir_extract($pn, $f, $args)
+ {
+ $blen = $args[0];
+ $dir = $args[1];
+ $sub = substr($pn, $blen);
+ $target = $dir . '/' . $sub;
+
+ if (!file_exists(dirname($target))) {
+ @mkdir(dirname($target), 0777, true);
+ }
+ if (!file_exists(dirname($target))) {
+ self::error("Operation could not be completed\n");
+ }
+
+ echo "$sub";
+
+ if (!@copy($f, $target)) {
+ echo " ...error\n";
+ } else {
+ echo " ...ok\n";
+ }
+ }
+ // }}}
+ // {{{ static function cli_cmd_inf_delete
+ /**
+ * Delete an entry from a phar information.
+ *
+ * @return string The information
+ */
+ static function cli_cmd_inf_delete()
+ {
+ return 'Delete entry from a PHAR archive';
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_delete
+ /**
+ * The cli command argument for deleting.
+ *
+ * @return array informations about the arguments to use.
+ */
+ static function cli_cmd_arg_delete()
+ {
+ return self::phar_args('FE', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_delete
+ /**
+ * Deleting execution
+ *
+ * Execute the deleting of the file from the phar archive.
+ */
+ public function cli_cmd_run_delete()
+ {
+ $phar = $this->args['f']['val'];
+ $entry = $this->args['e']['val'];
+
+ $phar->startBuffering();
+ unset($phar[$entry]);
+ $phar->stopBuffering();
+ }
+ // }}}
+ // {{{ static function cli_cmd_inf_add
+ /**
+ * Client comment add file information
+ *
+ * @return string The description of the feature
+ */
+ static function cli_cmd_inf_add()
+ {
+ return "Add entries to a PHAR package.";
+ }
+ // }}}
+ // {{{ static function cli_cmd_arg_add
+ /**
+ * Add a file arguments
+ */
+ static function cli_cmd_arg_add()
+ {
+ $args = self::phar_args('acFilx', 'phar');
+ $args[''] = array(
+ 'type' => 'any',
+ 'val' => NULL,
+ 'required' => 1,
+ 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.',
+ );
+ return $args;
+ }
+ // }}}
+ // {{{ public functio cli_cmd_run_add
+ /**
+ * Add a file
+ *
+ * Run the action of adding a file to
+ * a phar archive.
+ */
+ public function cli_cmd_run_add()
+ {
+ $compress= $this->args['c']['val'];
+ $phar = $this->args['f']['val'];
+ $regex = $this->args['i']['val'];
+ $level = $this->args['l']['val'];
+ $invregex= $this->args['x']['val'];
+ $input = $this->args['']['val'];
+
+ $phar->startBuffering();
+
+ if (!is_array($input)) {
+ $this->phar_add($phar, $level, $input, $regex, $invregex, NULL, $compress);
+ } else {
+ foreach($input as $i) {
+ $this->phar_add($phar, $level, $i, $regex, $invregex, NULL, $compress);
+ }
+ }
+ $phar->stopBuffering();
+ exit(0);
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_stub_set
+ /**
+ * Set the stup of a phar file.
+ *
+ * @return string The stub set description.
+ */
+ public function cli_cmd_inf_stub_set()
+ {
+ return "Set the stub of a PHAR file. " .
+ "If no input file is specified as stub then stdin is being used.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_stub_set
+ /**
+ * Set the argument stub
+ *
+ * @return string arguments for a stub
+ */
+ public function cli_cmd_arg_stub_set()
+ {
+ $args = self::phar_args('bFps', 'phar');
+ $args['s']['val'] = 'php://stdin';
+ return $args;
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_stub_set
+ /**
+ * Cli Command run stub set
+ *
+ * @see $phar->setStub()
+ */
+ public function cli_cmd_run_stub_set()
+ {
+ $hashbang = $this->args['b']['val'];
+ $phar = $this->args['f']['val'];
+ $stub = $this->args['s']['val'];
+ $loader = $this->args['p']['val'];
+
+ $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang);
+ $this->phar_set_stub_end($phar, $stub, $loader);
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_stub_get
+ /**
+ * Get the command stub infos.
+ *
+ * @return string a description of the stub of a Phar file.
+ */
+ public function cli_cmd_inf_stub_get()
+ {
+ return "Get the stub of a PHAR file. " .
+ "If no output file is specified as stub then stdout is being used.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_stub_get
+ /**
+ * Get the argument stub
+ *
+ * @return array $args The arguments passed to the stub.
+ */
+ public function cli_cmd_arg_stub_get()
+ {
+ $args = self::phar_args('Fs', 'phar');
+ $args['s']['val'] = 'php://stdin';
+ return $args;
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_stub_get
+ /**
+ * Cli Command Run Stub
+ *
+ * Get arguments and store them into a stub.
+ *
+ * @param arguments $args
+ * @see $this->args
+ */
+ public function cli_cmd_run_stub_get($args)
+ {
+ $phar = $this->args['f']['val'];
+ $stub = $this->args['s']['val'];
+
+ file_put_contents($stub, $phar->getStub());
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_compress
+ /**
+ * Cli Command Inf Compress
+ *
+ * Cli Command compress informations
+ *
+ * @return string A description of the command.
+ */
+ public function cli_cmd_inf_compress()
+ {
+ return "Compress or uncompress all files or a selected entry.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_cmpress
+ /**
+ * Cli Command Arg Compress
+ *
+ * @return array The arguments for compress
+ */
+ public function cli_cmd_arg_compress()
+ {
+ return self::phar_args('FCe', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_compress
+ /**
+ * Cli Command Run Compress
+ *
+ * @see $this->args
+ */
+ public function cli_cmd_run_compress()
+ {
+ $phar = $this->args['f']['val'];
+ $entry = $this->args['e']['val'];
+
+ switch($this->args['c']['val']) {
+ case 'gz':
+ case 'gzip':
+ if (isset($entry)) {
+ $phar[$entry]->compress(Phar::GZ);
+ } else {
+ $phar->compressFiles(Phar::GZ);
+ }
+ break;
+ case 'bz2':
+ case 'bzip2':
+ if (isset($entry)) {
+ $phar[$entry]->compress(Phar::BZ2);
+ } else {
+ $phar->compressFiles(Phar::BZ2);
+ }
+ break;
+ default:
+ if (isset($entry)) {
+ $phar[$entry]->decompress();
+ } else {
+ $phar->decompressFiles();
+ }
+ break;
+ }
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_sign
+ /**
+ * Cli Command Info Signature
+ *
+ * @return string A description of the signature arguments.
+ */
+ public function cli_cmd_inf_sign()
+ {
+ return "Set signature hash algorithm.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_sign
+ /**
+ * Cli Command Argument Sign
+ *
+ * @return array Arguments for Signature
+ */
+ public function cli_cmd_arg_sign()
+ {
+ return self::phar_args('FHy', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_sign
+ /**
+ * Cli Command Run Signature
+ *
+ * @see $phar->setSignaturealgorithm
+ */
+ public function cli_cmd_run_sign()
+ {
+ $phar = $this->args['f']['val'];
+ $hash = $this->args['h']['val'];
+ $privkey = $this->args['y']['val'];
+
+ $hash = self::phar_check_hash($hash, $privkey);
+
+ $phar->setSignatureAlgorithm($hash, $privkey);
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_meta_set
+ /**
+ * Cli Command Inf Meta Set
+ *
+ * @return string A description
+ */
+ public function cli_cmd_inf_meta_set()
+ {
+ return "Set meta data of a PHAR entry or a PHAR package using serialized input. " .
+ "If no input file is specified for meta data then stdin is being used." .
+ "You can also specify a particular index using -k. In that case the metadata is " .
+ "expected to be an array and the value of the given index is being set. If " .
+ "the metadata is not present or empty a new array will be created. If the " .
+ "metadata is present and a flat value then the return value is 1. Also using -k " .
+ "the input is been taken directly rather then being serialized.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_meta_set
+ /**
+ * Cli Command Argument Meta Set
+ *
+ * @return array The arguments for meta set
+ */
+ public function cli_cmd_arg_meta_set()
+ {
+ return self::phar_args('FekM', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_met_set
+ /**
+ * Cli Command Run Metaset
+ *
+ * @see $phar->startBuffering
+ * @see $phar->setMetadata
+ * @see $phar->stopBuffering
+ */
+ public function cli_cmd_run_meta_set()
+ {
+ $phar = $this->args['f']['val'];
+ $entry = $this->args['e']['val'];
+ $index = $this->args['k']['val'];
+ $meta = $this->args['m']['val'];
+
+ $phar->startBuffering();
+
+ if (isset($index)) {
+ if (isset($entry)) {
+ if ($phar[$entry]->hasMetadata()) {
+ $old = $phar[$entry]->getMetadata();
+ } else {
+ $old = array();
+ }
+ } else {
+ if ($phar->hasMetadata()) {
+ $old = $phar->getMetadata();
+ } else {
+ $old = array();
+ }
+ }
+
+ if (!is_array($old)) {
+ self::error('Metadata is a flat value while an index operation was issued.');
+ }
+
+ $old[$index] = $meta;
+ $meta = $old;
+ } else {
+ $meta = unserialize($meta);
+ }
+
+ if (isset($entry)) {
+ $phar[$entry]->setMetadata($meta);
+ } else {
+ $phar->setMetadata($meta);
+ }
+ $phar->stopBuffering();
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_met_get
+ /**
+ * Cli Command Inf Metaget
+ *
+ * @return string A description of the metaget arguments
+ */
+ public function cli_cmd_inf_meta_get()
+ {
+ return "Get meta information of a PHAR entry or a PHAR package in serialized from. " .
+ "If no output file is specified for meta data then stdout is being used.\n" .
+ "You can also specify a particular index using -k. In that case the metadata is " .
+ "expected to be an array and the value of the given index is returned using echo " .
+ "rather than using serialize. If that index does not exist or no meta data is " .
+ "present then the return value is 1.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_meta_get
+ /**
+ * Cli Command arg metaget
+ *
+ * @return array The arguments for meta get.
+ */
+ public function cli_cmd_arg_meta_get()
+ {
+ return self::phar_args('Fek', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_meta_get
+ /**
+ * Cli Command Run Metaget
+ *
+ * @see $this->args
+ * @see $phar[$x]->hasMetadata()
+ * @see $phar->getMetadata()
+ */
+ public function cli_cmd_run_meta_get()
+ {
+ $phar = $this->args['f']['val'];
+ $entry = $this->args['e']['val'];
+ $index = $this->args['k']['val'];
+
+ if (isset($entry)) {
+ if (!$phar[$entry]->hasMetadata()) {
+ echo "No Metadata\n";
+ exit(1);
+ }
+ echo serialize($phar[$entry]->getMetadata());
+ } else {
+ if (!$phar->hasMetadata()) {
+ echo "No Metadata\n";
+ exit(1);
+ }
+ $meta = $phar->getMetadata();
+ }
+
+ if (isset($index)) {
+ if (isset($index)) {
+ if (isset($meta[$index])) {
+ echo $meta[$index];
+ exit(0);
+ } else {
+ echo "No Metadata\n";
+ exit(1);
+ }
+ } else {
+ echo serialize($meta);
+ }
+ }
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_meta_del
+ /**
+ * Cli Command Inf Metadel
+ *
+ * @return string A description of the metadel function
+ */
+ public function cli_cmd_inf_meta_del()
+ {
+ return "Delete meta information of a PHAR entry or a PHAR package.\n" .
+ "If -k is given then the metadata is expected to be an array " .
+ "and the given index is being deleted.\n" .
+ "If something was deleted the return value is 0 otherwise it is 1.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_meta_del
+ /**
+ * CliC ommand Arg Metadelete
+ *
+ * @return array The arguments for metadel
+ */
+ public function cli_cmd_arg_meta_del()
+ {
+ return self::phar_args('Fek', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_meta_del
+ /**
+ * Cli Command Run MetaDel
+ *
+ * @see $phar[$x]->delMetadata()
+ * @see $phar->delMetadata()
+ */
+ public function cli_cmd_run_meta_del()
+ {
+ $phar = $this->args['f']['val'];
+ $entry = $this->args['e']['val'];
+ $index = $this->args['k']['val'];
+
+ if (isset($entry)) {
+ if (isset($index)) {
+ if (!$phar[$entry]->hasMetadata()) {
+ exit(1);
+ }
+ $meta = $phar[$entry]->getMetadata();
+
+ // @todo add error message here.
+ if (!is_array($meta)) {
+ exit(1);
+ }
+
+ unset($meta[$index]);
+ $phar[$entry]->setMetadata($meta);
+ } else {
+ exit($phar[$entry]->delMetadata() ? 0 : 1);
+ }
+ } else {
+ if (isset($index)) {
+ if (!$phar->hasMetadata()) {
+ exit(1);
+ }
+
+ $meta = $phar->getMetadata();
+
+ // @todo Add error message
+ if (!is_array($meta)) {
+ exit(1);
+ }
+
+ unset($meta[$index]);
+ $phar->setMetadata($meta);
+ } else {
+ exit($phar->delMetadata() ? 0 : 1);
+ }
+ }
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_info
+ /**
+ * CLi Command Inf Info
+ *
+ * @return string A description about the info commands.
+ */
+ public function cli_cmd_inf_info()
+ {
+ return "Get information about a PHAR package.\n" .
+ "By using -k it is possible to return a single value.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_info
+ /**
+ * Cli Command Arg Infos
+ *
+ * @return array The arguments for info command.
+ */
+ public function cli_cmd_arg_info()
+ {
+ return self::phar_args('Fk', 'phar');
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_info
+ /**
+ * Cli Command Run Info
+ *
+ * @param args $args
+ */
+ public function cli_cmd_run_info()
+ {
+ $phar = $this->args['f']['val'];
+ $index = $this->args['k']['val'];
+
+ $hash = $phar->getSignature();
+ $infos = array();
+
+ if ($phar->getAlias()) {
+ $infos['Alias'] = $phar->getAlias();
+ }
+
+ if (!$hash) {
+ $infos['Hash-type'] = 'NONE';
+ } else {
+ $infos['Hash-type'] = $hash['hash_type'];
+ $infos['Hash'] = $hash['hash'];
+ }
+
+ $csize = 0;
+ $usize = 0;
+ $count = 0;
+ $ccount = 0;
+ $ucount = 0;
+ $mcount = 0;
+ $compalg = array('GZ'=>0, 'BZ2'=>0);
+
+ foreach(new RecursiveIteratorIterator($phar) as $ent) {
+ $count++;
+ if ($ent->isCompressed()) {
+ $ccount++;
+ $csize += $ent->getCompressedSize();
+ if ($ent->isCompressed(Phar::GZ)) {
+ $compalg['GZ']++;
+ } elseif ($ent->isCompressed(Phar::BZ2)) {
+ $compalg['BZ2']++;
+ }
+ } else {
+ $ucount++;
+ $csize += $ent->getSize();
+ }
+
+ $usize += $ent->getSize();
+
+ if ($ent->hasMetadata()) {
+ $mcount++;
+ }
+ }
+
+ $infos['Entries'] = $count;
+ $infos['Uncompressed-files'] = $ucount;
+ $infos['Compressed-files'] = $ccount;
+ $infos['Compressed-gz'] = $compalg['GZ'];
+ $infos['Compressed-bz2'] = $compalg['BZ2'];
+ $infos['Uncompressed-size'] = $usize;
+ $infos['Compressed-size'] = $csize;
+ $infos['Compression-ratio'] = sprintf('%.3g%%', $usize ? ($csize * 100) / $usize : 100);
+ $infos['Metadata-global'] = $phar->hasMetadata() * 1;
+ $infos['Metadata-files'] = $mcount;
+ $infos['Stub-size'] = strlen($phar->getStub());
+
+ if (isset($index)) {
+ if (!isset($infos[$index])) {
+ self::error("Requested value does not exist.\n");
+ }
+
+ echo $infos[$index];
+ exit(0);
+ }
+
+ $l = 0;
+ foreach($infos as $which => $val) {
+ $l = max(strlen($which), $l);
+ }
+
+ foreach($infos as $which => $val) {
+ echo $which . ':' . str_repeat(' ', $l + 1 - strlen($which)) . $val . "\n";
+ }
+ }
+ // }}}
+ // {{{ public function cli_cmd_inf_version
+ /**
+ * CLi Command Inf Version
+ *
+ * @return string A description about the info commands.
+ */
+ public function cli_cmd_inf_version()
+ {
+ return "Get information about the PHAR environment and the tool version.";
+ }
+ // }}}
+ // {{{ public function cli_cmd_arg_version
+ /**
+ * Cli Command Arg Version
+ *
+ * @return array The arguments for version command.
+ */
+ public function cli_cmd_arg_version()
+ {
+ return self::phar_args('', NULL);
+ }
+ // }}}
+ // {{{ public function cli_cmd_run_info
+ /**
+ * Cli Command Run Info
+ *
+ * @param args $args
+ */
+ public function cli_cmd_run_version()
+ {
+ $use_ext = extension_loaded('phar');
+ $version = array(
+ 'PHP Version' => phpversion(),
+ 'phar.phar version' => '$Id: cb343675b557b02dd09d0f1902d0ec50f5f482ee $',
+ 'Phar EXT version' => $use_ext ? phpversion('phar') : 'Not available',
+ 'Phar API version' => Phar::apiVersion(),
+ 'Phar-based phar archives' => true,
+ 'Tar-based phar archives' => $use_ext,
+ 'ZIP-based phar archives' => $use_ext,
+ 'gzip compression' => extension_loaded('zlib'),
+ 'bzip2 compression' => extension_loaded('bz2'),
+ 'supported signatures' => $use_ext ? join(', ', Phar::getSupportedSignatures()) : '',
+ );
+ $klen = 0;
+ foreach($version as $k => $v)
+ {
+ $klen = max($klen, strlen($k));
+ }
+ ++$klen;
+ foreach($version as $k => $v) {
+ if (is_bool($v)) {
+ $v = $v ? 'enabled' : 'disabled';
+ }
+ printf("%-${klen}s %s\n", $k.':', $v);
+ }
+ }
+ // }}}
+}
+// }}}
+?>
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
new file mode 100644
index 0000000..daa85f1
--- /dev/null
+++ b/ext/phar/phar_internal.h
@@ -0,0 +1,722 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2006-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <time.h>
+#include "php.h"
+#include "tar.h"
+#include "php_ini.h"
+#include "zend_constants.h"
+#include "zend_execute.h"
+#include "zend_exceptions.h"
+#include "zend_hash.h"
+#include "zend_interfaces.h"
+#include "zend_operators.h"
+#include "zend_qsort.h"
+#include "zend_vm.h"
+#include "main/php_streams.h"
+#include "main/streams/php_stream_plain_wrapper.h"
+#include "main/SAPI.h"
+#include "main/php_main.h"
+#include "main/php_open_temporary_file.h"
+#include "ext/standard/info.h"
+#include "ext/standard/basic_functions.h"
+#include "ext/standard/file.h"
+#include "ext/standard/php_string.h"
+#include "ext/standard/url.h"
+#include "ext/standard/crc32.h"
+#include "ext/standard/md5.h"
+#include "ext/standard/sha1.h"
+#include "ext/standard/php_var.h"
+#include "ext/standard/php_smart_str.h"
+#include "ext/standard/php_versioning.h"
+#ifndef PHP_WIN32
+#include "TSRM/tsrm_strtok_r.h"
+#endif
+#include "TSRM/tsrm_virtual_cwd.h"
+#if HAVE_SPL
+#include "ext/spl/spl_array.h"
+#include "ext/spl/spl_directory.h"
+#include "ext/spl/spl_engine.h"
+#include "ext/spl/spl_exceptions.h"
+#include "ext/spl/spl_iterators.h"
+#endif
+#include "php_phar.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef PHAR_HASH_OK
+#include "ext/hash/php_hash.h"
+#include "ext/hash/php_hash_sha.h"
+#endif
+
+#ifndef E_RECOVERABLE_ERROR
+# define E_RECOVERABLE_ERROR E_ERROR
+#endif
+
+#ifndef pestrndup
+# define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
+#endif
+
+#ifndef ALLOC_PERMANENT_ZVAL
+# define ALLOC_PERMANENT_ZVAL(z) \
+ (z) = (zval*)malloc(sizeof(zval))
+#endif
+
+/* PHP_ because this is public information via MINFO */
+#define PHP_PHAR_API_VERSION "1.1.1"
+/* x.y.z maps to 0xyz0 */
+#define PHAR_API_VERSION 0x1110
+/* if we bump PHAR_API_VERSION, change this from 0x1100 to PHAR_API_VERSION */
+#define PHAR_API_VERSION_NODIR 0x1100
+#define PHAR_API_MIN_DIR 0x1110
+#define PHAR_API_MIN_READ 0x1000
+#define PHAR_API_MAJORVERSION 0x1000
+#define PHAR_API_MAJORVER_MASK 0xF000
+#define PHAR_API_VER_MASK 0xFFF0
+
+#define PHAR_HDR_COMPRESSION_MASK 0x0000F000
+#define PHAR_HDR_COMPRESSED_NONE 0x00000000
+#define PHAR_HDR_COMPRESSED_GZ 0x00001000
+#define PHAR_HDR_COMPRESSED_BZ2 0x00002000
+#define PHAR_HDR_SIGNATURE 0x00010000
+
+/* flags for defining that the entire file should be compressed */
+#define PHAR_FILE_COMPRESSION_MASK 0x00F00000
+#define PHAR_FILE_COMPRESSED_NONE 0x00000000
+#define PHAR_FILE_COMPRESSED_GZ 0x00100000
+#define PHAR_FILE_COMPRESSED_BZ2 0x00200000
+
+#define PHAR_SIG_MD5 0x0001
+#define PHAR_SIG_SHA1 0x0002
+#define PHAR_SIG_SHA256 0x0003
+#define PHAR_SIG_SHA512 0x0004
+#define PHAR_SIG_OPENSSL 0x0010
+
+/* flags byte for each file adheres to these bitmasks.
+ All unused values are reserved */
+#define PHAR_ENT_COMPRESSION_MASK 0x0000F000
+#define PHAR_ENT_COMPRESSED_NONE 0x00000000
+#define PHAR_ENT_COMPRESSED_GZ 0x00001000
+#define PHAR_ENT_COMPRESSED_BZ2 0x00002000
+
+#define PHAR_ENT_PERM_MASK 0x000001FF
+#define PHAR_ENT_PERM_MASK_USR 0x000001C0
+#define PHAR_ENT_PERM_SHIFT_USR 6
+#define PHAR_ENT_PERM_MASK_GRP 0x00000038
+#define PHAR_ENT_PERM_SHIFT_GRP 3
+#define PHAR_ENT_PERM_MASK_OTH 0x00000007
+#define PHAR_ENT_PERM_DEF_FILE 0x000001B6
+#define PHAR_ENT_PERM_DEF_DIR 0x000001FF
+
+#define PHAR_FORMAT_SAME 0
+#define PHAR_FORMAT_PHAR 1
+#define PHAR_FORMAT_TAR 2
+#define PHAR_FORMAT_ZIP 3
+
+#define TAR_FILE '0'
+#define TAR_LINK '1'
+#define TAR_SYMLINK '2'
+#define TAR_DIR '5'
+#define TAR_NEW '8'
+
+#define PHAR_MUNG_PHP_SELF (1<<0)
+#define PHAR_MUNG_REQUEST_URI (1<<1)
+#define PHAR_MUNG_SCRIPT_NAME (1<<2)
+#define PHAR_MUNG_SCRIPT_FILENAME (1<<3)
+
+typedef struct _phar_entry_fp phar_entry_fp;
+typedef struct _phar_archive_data phar_archive_data;
+
+ZEND_BEGIN_MODULE_GLOBALS(phar)
+ /* a list of phar_archive_data objects that reference a cached phar, so
+ that if copy-on-write is performed, we can swap them out for the new value */
+ HashTable phar_persist_map;
+ HashTable phar_fname_map;
+ /* for cached phars, this is a per-process store of fp/ufp */
+ phar_entry_fp *cached_fp;
+ HashTable phar_alias_map;
+ int phar_SERVER_mung_list;
+ int readonly;
+ char* cache_list;
+ int manifest_cached;
+ int persist;
+ int has_zlib;
+ int has_bz2;
+ zend_bool readonly_orig;
+ zend_bool require_hash_orig;
+ zend_bool intercepted;
+ int request_init;
+ int require_hash;
+ int request_done;
+ int request_ends;
+ void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS);
+ /* used for includes with . in them inside front controller */
+ char* cwd;
+ int cwd_len;
+ int cwd_init;
+ char *openssl_privatekey;
+ int openssl_privatekey_len;
+ /* phar_get_archive cache */
+ char* last_phar_name;
+ int last_phar_name_len;
+ char* last_alias;
+ int last_alias_len;
+ phar_archive_data* last_phar;
+ HashTable mime_types;
+ZEND_END_MODULE_GLOBALS(phar)
+
+ZEND_EXTERN_MODULE_GLOBALS(phar)
+
+#ifdef ZTS
+# include "TSRM.h"
+# define PHAR_G(v) TSRMG(phar_globals_id, zend_phar_globals *, v)
+# define PHAR_GLOBALS ((zend_phar_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phar_globals_id)])
+#else
+# define PHAR_G(v) (phar_globals.v)
+# define PHAR_GLOBALS (&phar_globals)
+#endif
+
+#ifndef php_uint16
+# if SIZEOF_SHORT == 2
+# define php_uint16 unsigned short
+# else
+# define php_uint16 uint16_t
+# endif
+#endif
+#include "pharzip.h"
+
+#if HAVE_SPL
+typedef union _phar_archive_object phar_archive_object;
+typedef union _phar_entry_object phar_entry_object;
+#endif
+
+/*
+ * used in phar_entry_info->fp_type to
+ */
+enum phar_fp_type {
+ /* regular file pointer phar_archive_data->fp */
+ PHAR_FP,
+ /* uncompressed file pointer phar_archive_data->uncompressed_fp */
+ PHAR_UFP,
+ /* modified file pointer phar_entry_info->fp */
+ PHAR_MOD,
+ /* temporary manifest entry (file outside of the phar mapped to a location inside the phar)
+ this entry stores the stream to open in link (normally used for tars, but we steal it here) */
+ PHAR_TMP
+};
+
+/* entry for one file in a phar file */
+typedef struct _phar_entry_info {
+ /* first bytes are exactly as in file */
+ php_uint32 uncompressed_filesize;
+ php_uint32 timestamp;
+ php_uint32 compressed_filesize;
+ php_uint32 crc32;
+ php_uint32 flags;
+ /* remainder */
+ /* when changing compression, save old flags in case fp is NULL */
+ php_uint32 old_flags;
+ zval *metadata;
+ int metadata_len; /* only used for cached manifests */
+ php_uint32 filename_len;
+ char *filename;
+ enum phar_fp_type fp_type;
+ /* offset within original phar file of the file contents */
+ long offset_abs;
+ /* offset within fp of the file contents */
+ long offset;
+ /* offset within original phar file of the file header (for zip-based/tar-based) */
+ long header_offset;
+ php_stream *fp;
+ php_stream *cfp;
+ int fp_refcount;
+ char *tmp;
+ phar_archive_data *phar;
+ smart_str metadata_str;
+ char *link; /* symbolic link to another file */
+ char tar_type;
+ /* position in the manifest */
+ uint manifest_pos;
+ /* for stat */
+ unsigned short inode;
+
+ unsigned int is_crc_checked:1;
+ unsigned int is_modified:1;
+ unsigned int is_deleted:1;
+ unsigned int is_dir:1;
+ /* this flag is used for mounted entries (external files mapped to location
+ inside a phar */
+ unsigned int is_mounted:1;
+ /* used when iterating */
+ unsigned int is_temp_dir:1;
+ /* tar-based phar file stuff */
+ unsigned int is_tar:1;
+ /* zip-based phar file stuff */
+ unsigned int is_zip:1;
+ /* for cached phar entries */
+ unsigned int is_persistent:1;
+} phar_entry_info;
+
+/* information about a phar file (the archive itself) */
+struct _phar_archive_data {
+ char *fname;
+ int fname_len;
+ /* for phar_detect_fname_ext, this stores the location of the file extension within fname */
+ char *ext;
+ int ext_len;
+ char *alias;
+ int alias_len;
+ char version[12];
+ size_t internal_file_start;
+ size_t halt_offset;
+ HashTable manifest;
+ /* hash of virtual directories, as in path/to/file.txt has path/to and path as virtual directories */
+ HashTable virtual_dirs;
+ /* hash of mounted directory paths */
+ HashTable mounted_dirs;
+ php_uint32 flags;
+ php_uint32 min_timestamp;
+ php_uint32 max_timestamp;
+ php_stream *fp;
+ /* decompressed file contents are stored here */
+ php_stream *ufp;
+ int refcount;
+ php_uint32 sig_flags;
+ int sig_len;
+ char *signature;
+ zval *metadata;
+ int metadata_len; /* only used for cached manifests */
+ uint phar_pos;
+ /* if 1, then this alias was manually specified by the user and is not a permanent alias */
+ unsigned int is_temporary_alias:1;
+ unsigned int is_modified:1;
+ unsigned int is_writeable:1;
+ unsigned int is_brandnew:1;
+ /* defer phar creation */
+ unsigned int donotflush:1;
+ /* zip-based phar variables */
+ unsigned int is_zip:1;
+ /* tar-based phar variables */
+ unsigned int is_tar:1;
+ /* PharData variables */
+ unsigned int is_data:1;
+ /* for cached phar manifests */
+ unsigned int is_persistent:1;
+};
+
+typedef struct _phar_entry_fp_info {
+ enum phar_fp_type fp_type;
+ /* offset within fp of the file contents */
+ long offset;
+} phar_entry_fp_info;
+
+struct _phar_entry_fp {
+ php_stream *fp;
+ php_stream *ufp;
+ phar_entry_fp_info *manifest;
+};
+
+static inline php_stream *phar_get_entrypfp(phar_entry_info *entry TSRMLS_DC)
+{
+ if (!entry->is_persistent) {
+ return entry->phar->fp;
+ }
+ return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].fp;
+}
+
+static inline php_stream *phar_get_entrypufp(phar_entry_info *entry TSRMLS_DC)
+{
+ if (!entry->is_persistent) {
+ return entry->phar->ufp;
+ }
+ return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].ufp;
+}
+
+static inline void phar_set_entrypfp(phar_entry_info *entry, php_stream *fp TSRMLS_DC)
+{
+ if (!entry->phar->is_persistent) {
+ entry->phar->fp = fp;
+ return;
+ }
+
+ PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].fp = fp;
+}
+
+static inline void phar_set_entrypufp(phar_entry_info *entry, php_stream *fp TSRMLS_DC)
+{
+ if (!entry->phar->is_persistent) {
+ entry->phar->ufp = fp;
+ return;
+ }
+
+ PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].ufp = fp;
+}
+
+static inline php_stream *phar_get_pharfp(phar_archive_data *phar TSRMLS_DC)
+{
+ if (!phar->is_persistent) {
+ return phar->fp;
+ }
+ return PHAR_GLOBALS->cached_fp[phar->phar_pos].fp;
+}
+
+static inline php_stream *phar_get_pharufp(phar_archive_data *phar TSRMLS_DC)
+{
+ if (!phar->is_persistent) {
+ return phar->ufp;
+ }
+ return PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp;
+}
+
+static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp TSRMLS_DC)
+{
+ if (!phar->is_persistent) {
+ phar->fp = fp;
+ return;
+ }
+
+ PHAR_GLOBALS->cached_fp[phar->phar_pos].fp = fp;
+}
+
+static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp TSRMLS_DC)
+{
+ if (!phar->is_persistent) {
+ phar->ufp = fp;
+ return;
+ }
+
+ PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp = fp;
+}
+
+static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)
+{
+ phar_entry_fp_info *data;
+
+ if (!entry->is_persistent) {
+ entry->fp_type = type;
+ entry->offset = offset;
+ return;
+ }
+ data = &(PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos]);
+ data->fp_type = type;
+ data->offset = offset;
+}
+
+static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry TSRMLS_DC)
+{
+ if (!entry->is_persistent) {
+ return entry->fp_type;
+ }
+ return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
+}
+
+static inline off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
+{
+ if (!entry->is_persistent) {
+ return entry->offset;
+ }
+ if (PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type == PHAR_FP) {
+ if (!PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset) {
+ PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset = entry->offset;
+ }
+ }
+ return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].offset;
+}
+
+#define PHAR_MIME_PHP '\0'
+#define PHAR_MIME_PHPS '\1'
+#define PHAR_MIME_OTHER '\2'
+
+typedef struct _phar_mime_type {
+ char *mime;
+ int len;
+ /* one of PHAR_MIME_* */
+ char type;
+} phar_mime_type;
+
+/* stream access data for one file entry in a phar file */
+typedef struct _phar_entry_data {
+ phar_archive_data *phar;
+ php_stream *fp;
+ /* stream position proxy, allows multiple open streams referring to the same fp */
+ off_t position;
+ /* for copies of the phar fp, defines where 0 is */
+ off_t zero;
+ unsigned int for_write:1;
+ unsigned int is_zip:1;
+ unsigned int is_tar:1;
+ phar_entry_info *internal_file;
+} phar_entry_data;
+
+#if HAVE_SPL
+/* archive php object */
+union _phar_archive_object {
+ zend_object std;
+ spl_filesystem_object spl;
+ struct {
+ zend_object std;
+ phar_archive_data *archive;
+ } arc;
+};
+#endif
+
+#if HAVE_SPL
+/* entry php object */
+union _phar_entry_object {
+ zend_object std;
+ spl_filesystem_object spl;
+ struct {
+ zend_object std;
+ phar_entry_info *entry;
+ } ent;
+};
+#endif
+
+#ifndef PHAR_MAIN
+# if PHP_VERSION_ID >= 50300
+extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
+# endif
+#endif
+
+#if PHP_VERSION_ID < 50209
+static inline size_t phar_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
+{
+ size_t ret = php_stream_copy_to_stream(src, dest, maxlen);
+ if (len) {
+ *len = ret;
+ }
+ if (ret) {
+ return SUCCESS;
+ }
+ return FAILURE;
+}
+#else
+# define phar_stream_copy_to_stream(src, dest, maxlen, len) _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC)
+
+#endif
+
+#if PHP_VERSION_ID >= 60000
+typedef zstr phar_zstr;
+#define PHAR_STR(a, b) \
+ spprintf(&b, 0, "%s", a.s);
+#define PHAR_ZSTR(a, b) \
+ b = ZSTR(a);
+#define PHAR_STR_FREE(a) \
+ efree(a);
+static inline int phar_make_unicode(zstr *c_var, char *arKey, uint nKeyLength TSRMLS_DC)
+{
+ int c_var_len;
+ UConverter *conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv));
+
+ c_var->u = NULL;
+ if (zend_string_to_unicode(conv, &c_var->u, &c_var_len, arKey, nKeyLength TSRMLS_CC) == FAILURE) {
+
+ if (c_var->u) {
+ efree(c_var->u);
+ }
+ return 0;
+
+ }
+ return c_var_len;
+}
+static inline int phar_find_key(HashTable *_SERVER, char *key, int len, void **stuff TSRMLS_DC)
+{
+ if (SUCCESS == zend_hash_find(_SERVER, key, len, stuff)) {
+ return 1;
+ } else {
+ int s = len;
+ zstr var;
+ s = phar_make_unicode(&var, key, len TSRMLS_CC);
+ if (SUCCESS == zend_u_hash_find(_SERVER, IS_UNICODE, var, s, stuff)) {
+ efree(var.u);
+ return 1;
+ }
+ efree(var.u);
+ return 0;
+ }
+}
+#else
+typedef char *phar_zstr;
+#define PHAR_STR(a, b) \
+ b = a;
+#define PHAR_ZSTR(a, b) \
+ b = a;
+#define PHAR_STR_FREE(a)
+#endif
+
+BEGIN_EXTERN_C()
+
+#ifdef PHP_WIN32
+char *tsrm_strtok_r(char *s, const char *delim, char **last);
+
+static inline void phar_unixify_path_separators(char *path, int path_len)
+{
+ char *s;
+
+ /* unixify win paths */
+ for (s = path; s - path < path_len; ++s) {
+ if (*s == '\\') {
+ *s = '/';
+ }
+ }
+}
+#endif
+/**
+ * validate an alias, returns 1 for success, 0 for failure
+ */
+static inline int phar_validate_alias(const char *alias, int alias_len) /* {{{ */
+{
+ return !(memchr(alias, '/', alias_len) || memchr(alias, '\\', alias_len) || memchr(alias, ':', alias_len) ||
+ memchr(alias, ';', alias_len) || memchr(alias, '\n', alias_len) || memchr(alias, '\r', alias_len));
+}
+/* }}} */
+
+static inline void phar_set_inode(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+{
+ char tmp[MAXPATHLEN];
+ int tmp_len;
+
+ tmp_len = entry->filename_len + entry->phar->fname_len;
+ memcpy(tmp, entry->phar->fname, entry->phar->fname_len);
+ memcpy(tmp + entry->phar->fname_len, entry->filename, entry->filename_len);
+ entry->inode = (unsigned short)zend_get_hash_value(tmp, tmp_len);
+}
+/* }}} */
+
+void phar_request_initialize(TSRMLS_D);
+
+void phar_object_init(TSRMLS_D);
+void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC);
+
+int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC);
+int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_DC);
+int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_DC);
+int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error TSRMLS_DC);
+int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC);
+int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error TSRMLS_DC);
+
+/* utility functions */
+char *phar_create_default_stub(const char *index_php, const char *web_index, size_t *len, char **error TSRMLS_DC);
+char *phar_decompress_filter(phar_entry_info * entry, int return_unknown);
+char *phar_compress_filter(phar_entry_info * entry, int return_unknown);
+
+void phar_remove_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC);
+void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC);
+int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC);
+char *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar TSRMLS_DC);
+char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC);
+phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
+int phar_parse_metadata(char **buffer, zval **metadata, int zip_metadata_len TSRMLS_DC);
+void destroy_phar_manifest_entry(void *pDest);
+int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC);
+php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC);
+int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC);
+int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC);
+phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC);
+int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
+int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC);
+int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC);
+int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC);
+
+/* tar functions in tar.c */
+int phar_is_tar(char *buf, char *fname);
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC);
+int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+
+/* zip functions in zip.c */
+int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
+int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+
+#ifdef PHAR_MAIN
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC);
+extern php_stream_wrapper php_stream_phar_wrapper;
+#else
+extern HashTable cached_phars;
+extern HashTable cached_alias;
+#endif
+
+int phar_archive_delref(phar_archive_data *phar TSRMLS_DC);
+int phar_entry_delref(phar_entry_data *idata TSRMLS_DC);
+
+phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC);
+phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
+phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC);
+int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC);
+int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
+int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);
+
+typedef enum {
+ pcr_use_query,
+ pcr_is_ok,
+ pcr_err_double_slash,
+ pcr_err_up_dir,
+ pcr_err_curr_dir,
+ pcr_err_back_slash,
+ pcr_err_star,
+ pcr_err_illegal_char,
+ pcr_err_empty_entry
+} phar_path_check_result;
+
+phar_path_check_result phar_path_check(char **p, int *len, const char **error);
+
+END_EXTERN_C()
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
new file mode 100644
index 0000000..a6dd2c8
--- /dev/null
+++ b/ext/phar/phar_object.c
@@ -0,0 +1,5487 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "phar_internal.h"
+#include "func_interceptors.h"
+
+static zend_class_entry *phar_ce_archive;
+static zend_class_entry *phar_ce_data;
+static zend_class_entry *phar_ce_PharException;
+
+#if HAVE_SPL
+static zend_class_entry *phar_ce_entry;
+#endif
+
+#if PHP_MAJOR_VERSION > 5 || ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3))
+# define PHAR_ARG_INFO
+#else
+# define PHAR_ARG_INFO static
+#endif
+
+static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_DC) /* {{{ */
+{
+ char *ext;
+ phar_mime_type *mime;
+ ext = strrchr(file, '.');
+ if (!ext) {
+ *mime_type = "text/plain";
+ /* no file extension = assume text/plain */
+ return PHAR_MIME_OTHER;
+ }
+ ++ext;
+ if (SUCCESS != zend_hash_find(mimes, ext, strlen(ext), (void **) &mime)) {
+ *mime_type = "application/octet-stream";
+ return PHAR_MIME_OTHER;
+ }
+ *mime_type = mime->mime;
+ return mime->type;
+}
+/* }}} */
+
+static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */
+{
+ HashTable *_SERVER;
+ zval **stuff;
+ char *path_info;
+ int basename_len = strlen(basename);
+ int code;
+ zval *temp;
+
+ /* "tweak" $_SERVER variables requested in earlier call to Phar::mungServer() */
+ if (!PG(http_globals)[TRACK_VARS_SERVER]) {
+ return;
+ }
+
+ _SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
+
+ /* PATH_INFO and PATH_TRANSLATED should always be munged */
+ if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+
+ if (Z_STRLEN_PP(stuff) > entry_len && !memcmp(Z_STRVAL_PP(stuff), entry, entry_len)) {
+ ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + entry_len, request_uri_len, 1);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL);
+ }
+ }
+
+ if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+ Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL);
+ }
+
+ if (!PHAR_GLOBALS->phar_SERVER_mung_list) {
+ return;
+ }
+
+ if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {
+ if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+
+ if (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {
+ ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL);
+ }
+ }
+ }
+
+ if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {
+ if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+
+ if (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {
+ ZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL);
+ }
+ }
+ }
+
+ if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {
+ if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+ ZVAL_STRINGL(*stuff, entry, entry_len, 1);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL);
+ }
+ }
+
+ if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {
+ if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) {
+ path_info = Z_STRVAL_PP(stuff);
+ code = Z_STRLEN_PP(stuff);
+ Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
+
+ MAKE_STD_ZVAL(temp);
+ ZVAL_STRINGL(temp, path_info, code, 0);
+
+ zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL);
+ }
+ }
+}
+/* }}} */
+
+static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, int entry_len, char *arch, char *basename, char *ru, int ru_len TSRMLS_DC) /* {{{ */
+{
+ char *name = NULL, buf[8192];
+ const char *cwd;
+ zend_syntax_highlighter_ini syntax_highlighter_ini;
+ sapi_header_line ctr = {0};
+ size_t got;
+ int dummy = 1, name_len;
+ zend_file_handle file_handle;
+ zend_op_array *new_op_array;
+ zval *result = NULL;
+ php_stream *fp;
+ off_t position;
+
+ switch (code) {
+ case PHAR_MIME_PHPS:
+ efree(basename);
+ /* highlight source */
+ if (entry[0] == '/') {
+ name_len = spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ name_len = spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+ php_get_highlight_struct(&syntax_highlighter_ini);
+
+ highlight_file(name, &syntax_highlighter_ini TSRMLS_CC);
+
+ efree(name);
+#ifdef PHP_WIN32
+ efree(arch);
+#endif
+ zend_bailout();
+ case PHAR_MIME_OTHER:
+ /* send headers, output file contents */
+ efree(basename);
+ ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ efree(ctr.line);
+ ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ efree(ctr.line);
+
+ if (FAILURE == sapi_send_headers(TSRMLS_C)) {
+ zend_bailout();
+ }
+
+ /* prepare to output */
+ fp = phar_get_efp(info, 1 TSRMLS_CC);
+
+ if (!fp) {
+ char *error;
+ if (!phar_open_jit(phar, info, &error TSRMLS_CC)) {
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ return -1;
+ }
+ fp = phar_get_efp(info, 1 TSRMLS_CC);
+ }
+ position = 0;
+ phar_seek_efp(info, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+
+ do {
+ got = php_stream_read(fp, buf, MIN(8192, info->uncompressed_filesize - position));
+ if (got > 0) {
+ PHPWRITE(buf, got);
+ position += got;
+ if (position == (off_t) info->uncompressed_filesize) {
+ break;
+ }
+ }
+ } while (1);
+
+ zend_bailout();
+ case PHAR_MIME_PHP:
+ if (basename) {
+ phar_mung_server_vars(arch, entry, entry_len, basename, ru_len TSRMLS_CC);
+ efree(basename);
+ }
+
+ if (entry[0] == '/') {
+ name_len = spprintf(&name, 4096, "phar://%s%s", arch, entry);
+ } else {
+ name_len = spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ }
+
+ file_handle.type = ZEND_HANDLE_FILENAME;
+ file_handle.handle.fd = 0;
+ file_handle.filename = name;
+ file_handle.opened_path = NULL;
+ file_handle.free_filename = 0;
+
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+
+ if (zend_hash_add(&EG(included_files), name, name_len+1, (void *)&dummy, sizeof(int), NULL) == SUCCESS) {
+ if ((cwd = zend_memrchr(entry, '/', entry_len))) {
+ PHAR_G(cwd_init) = 1;
+ if (entry == cwd) {
+ /* root directory */
+ PHAR_G(cwd_len) = 0;
+ PHAR_G(cwd) = NULL;
+ } else if (entry[0] == '/') {
+ PHAR_G(cwd_len) = cwd - (entry + 1);
+ PHAR_G(cwd) = estrndup(entry + 1, PHAR_G(cwd_len));
+ } else {
+ PHAR_G(cwd_len) = cwd - entry;
+ PHAR_G(cwd) = estrndup(entry, PHAR_G(cwd_len));
+ }
+ }
+
+ new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
+
+ if (!new_op_array) {
+ zend_hash_del(&EG(included_files), name, name_len+1);
+ }
+
+ zend_destroy_file_handle(&file_handle TSRMLS_CC);
+
+ } else {
+ efree(name);
+ new_op_array = NULL;
+ }
+#ifdef PHP_WIN32
+ efree(arch);
+#endif
+ if (new_op_array) {
+ EG(return_value_ptr_ptr) = &result;
+ EG(active_op_array) = new_op_array;
+
+ zend_try {
+ zend_execute(new_op_array TSRMLS_CC);
+ if (PHAR_G(cwd)) {
+ efree(PHAR_G(cwd));
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+ }
+
+ PHAR_G(cwd_init) = 0;
+ efree(name);
+ destroy_op_array(new_op_array TSRMLS_CC);
+ efree(new_op_array);
+
+
+ if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {
+ zval_ptr_dtor(EG(return_value_ptr_ptr));
+ }
+ } zend_catch {
+ if (PHAR_G(cwd)) {
+ efree(PHAR_G(cwd));
+ PHAR_G(cwd) = NULL;
+ PHAR_G(cwd_len) = 0;
+ }
+
+ PHAR_G(cwd_init) = 0;
+ efree(name);
+ } zend_end_try();
+
+ zend_bailout();
+ }
+
+ return PHAR_MIME_PHP;
+ }
+ return -1;
+}
+/* }}} */
+
+static void phar_do_403(char *entry, int entry_len TSRMLS_DC) /* {{{ */
+{
+ sapi_header_line ctr = {0};
+
+ ctr.response_code = 403;
+ ctr.line_len = sizeof("HTTP/1.0 403 Access Denied")-1;
+ ctr.line = "HTTP/1.0 403 Access Denied";
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_send_headers(TSRMLS_C);
+ PHPWRITE("<html>\n <head>\n <title>Access Denied</title>\n </head>\n <body>\n <h1>403 - File ", sizeof("<html>\n <head>\n <title>Access Denied</title>\n </head>\n <body>\n <h1>403 - File ") - 1);
+ PHPWRITE(entry, entry_len);
+ PHPWRITE(" Access Denied</h1>\n </body>\n</html>", sizeof(" Access Denied</h1>\n </body>\n</html>") - 1);
+}
+/* }}} */
+
+static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, char *f404, int f404_len, char *entry, int entry_len TSRMLS_DC) /* {{{ */
+{
+ sapi_header_line ctr = {0};
+ phar_entry_info *info;
+
+ if (phar && f404_len) {
+ info = phar_get_entry_info(phar, f404, f404_len, NULL, 1 TSRMLS_CC);
+
+ if (info) {
+ phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0 TSRMLS_CC);
+ return;
+ }
+ }
+
+ ctr.response_code = 404;
+ ctr.line_len = sizeof("HTTP/1.0 404 Not Found")-1;
+ ctr.line = "HTTP/1.0 404 Not Found";
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_send_headers(TSRMLS_C);
+ PHPWRITE("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ", sizeof("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ") - 1);
+ PHPWRITE(entry, entry_len);
+ PHPWRITE(" Not Found</h1>\n </body>\n</html>", sizeof(" Not Found</h1>\n </body>\n</html>") - 1);
+}
+/* }}} */
+
+/* post-process REQUEST_URI and retrieve the actual request URI. This is for
+ cases like http://localhost/blah.phar/path/to/file.php/extra/stuff
+ which calls "blah.phar" file "path/to/file.php" with PATH_INFO "/extra/stuff" */
+static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len TSRMLS_DC) /* {{{ */
+{
+ char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
+ int e_len = *entry_len - 1, u_len = 0;
+ phar_archive_data **pphar = NULL;
+
+ /* we already know we can retrieve the phar if we reach here */
+ zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **) &pphar);
+
+ if (!pphar && PHAR_G(manifest_cached)) {
+ zend_hash_find(&cached_phars, fname, fname_len, (void **) &pphar);
+ }
+
+ do {
+ if (zend_hash_exists(&((*pphar)->manifest), e, e_len)) {
+ if (u) {
+ u[0] = '/';
+ *ru = estrndup(u, u_len+1);
+ ++u_len;
+ u[0] = '\0';
+ } else {
+ *ru = NULL;
+ }
+ *ru_len = u_len;
+ *entry_len = e_len + 1;
+ return;
+ }
+
+ if (u) {
+ u1 = strrchr(e, '/');
+ u[0] = '/';
+ saveu = u;
+ e_len += u_len + 1;
+ u = u1;
+ if (!u) {
+ return;
+ }
+ } else {
+ u = strrchr(e, '/');
+ if (!u) {
+ if (saveu) {
+ saveu[0] = '/';
+ }
+ return;
+ }
+ }
+
+ u[0] = '\0';
+ u_len = strlen(u + 1);
+ e_len -= u_len + 1;
+
+ if (e_len < 0) {
+ if (saveu) {
+ saveu[0] = '/';
+ }
+ return;
+ }
+ } while (1);
+}
+/* }}} */
+
+/* {{{ proto void Phar::running([bool retphar = true])
+ * return the name of the currently running phar archive. If the optional parameter
+ * is set to true, return the phar:// URL to the currently running phar
+ */
+PHP_METHOD(Phar, running)
+{
+ char *fname, *arch, *entry;
+ int fname_len, arch_len, entry_len;
+ zend_bool retphar = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &retphar) == FAILURE) {
+ return;
+ }
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+ if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ efree(entry);
+ if (retphar) {
+ RETVAL_STRINGL(fname, arch_len + 7, 1);
+ efree(arch);
+ return;
+ } else {
+ RETURN_STRINGL(arch, arch_len, 0);
+ }
+ }
+
+ RETURN_STRINGL("", 0, 1);
+}
+/* }}} */
+
+/* {{{ proto void Phar::mount(string pharpath, string externalfile)
+ * mount an external file or path to a location within the phar. This maps
+ * an external file or directory to a location within the phar archive, allowing
+ * reference to an external location as if it were within the phar archive. This
+ * is useful for writable temp files like databases
+ */
+PHP_METHOD(Phar, mount)
+{
+ char *fname, *arch = NULL, *entry = NULL, *path, *actual;
+ int fname_len, arch_len, entry_len, path_len, actual_len;
+ phar_archive_data **pphar;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ return;
+ }
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(fname, fname_len);
+#endif
+
+ if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ efree(entry);
+ entry = NULL;
+
+ if (path_len > 7 && !memcmp(path, "phar://", 7)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Can only mount internal paths within a phar archive, use a relative path instead of \"%s\"", path);
+ efree(arch);
+ return;
+ }
+carry_on2:
+ if (SUCCESS != zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, arch, arch_len, (void **)&pphar)) {
+ if (SUCCESS == phar_copy_on_write(pphar TSRMLS_CC)) {
+ goto carry_on;
+ }
+ }
+
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s is not a phar archive, cannot mount", arch);
+
+ if (arch) {
+ efree(arch);
+ }
+ return;
+ }
+carry_on:
+ if (SUCCESS != phar_mount_entry(*pphar, actual, actual_len, path, path_len TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s within phar %s failed", path, actual, arch);
+ if (path && path == entry) {
+ efree(entry);
+ }
+
+ if (arch) {
+ efree(arch);
+ }
+
+ return;
+ }
+
+ if (entry && path && path == entry) {
+ efree(entry);
+ }
+
+ if (arch) {
+ efree(arch);
+ }
+
+ return;
+ } else if (PHAR_GLOBALS->phar_fname_map.arBuckets && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void **)&pphar)) {
+ goto carry_on;
+ } else if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, fname, fname_len, (void **)&pphar)) {
+ if (SUCCESS == phar_copy_on_write(pphar TSRMLS_CC)) {
+ goto carry_on;
+ }
+
+ goto carry_on;
+ } else if (SUCCESS == phar_split_fname(path, path_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ path = entry;
+ path_len = entry_len;
+ goto carry_on2;
+ }
+
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s failed", path, actual);
+}
+/* }}} */
+
+/* {{{ proto void Phar::webPhar([string alias, [string index, [string f404, [array mimetypes, [callback rewrites]]]]])
+ * mapPhar for web-based phars. Reads the currently executed file (a phar)
+ * and registers its manifest. When executed in the CLI or CGI command-line sapi,
+ * this works exactly like mapPhar(). When executed by a web-based sapi, this
+ * reads $_SERVER['REQUEST_URI'] (the actual original value) and parses out the
+ * intended internal file.
+ */
+PHP_METHOD(Phar, webPhar)
+{
+ zval *mimeoverride = NULL, *rewrite = NULL;
+ char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL;
+ int alias_len = 0, ret, f404_len = 0, free_pathinfo = 0, ru_len = 0;
+ char *fname, *path_info, *mime_type = NULL, *entry, *pt;
+ const char *basename;
+ int fname_len, entry_len, code, index_php_len = 0, not_cgi;
+ phar_archive_data *phar = NULL;
+ phar_entry_info *info = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) {
+ return;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+ if (phar_open_executed_filename(alias, alias_len, &error TSRMLS_CC) != SUCCESS) {
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ return;
+ }
+
+ /* retrieve requested file within phar */
+ if (!(SG(request_info).request_method && SG(request_info).request_uri && (!strcmp(SG(request_info).request_method, "GET") || !strcmp(SG(request_info).request_method, "POST")))) {
+ return;
+ }
+
+#ifdef PHP_WIN32
+ fname = estrndup(fname, fname_len);
+ phar_unixify_path_separators(fname, fname_len);
+#endif
+ basename = zend_memrchr(fname, '/', fname_len);
+
+ if (!basename) {
+ basename = fname;
+ } else {
+ ++basename;
+ }
+
+ if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1))
+ || (strlen(sapi_module.name) == sizeof("cgi")-1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi")-1))) {
+
+ if (PG(http_globals)[TRACK_VARS_SERVER]) {
+ HashTable *_server = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
+ zval **z_script_name, **z_path_info;
+
+ if (SUCCESS != zend_hash_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void**)&z_script_name) ||
+ IS_STRING != Z_TYPE_PP(z_script_name) ||
+ !strstr(Z_STRVAL_PP(z_script_name), basename)) {
+ return;
+ }
+
+ if (SUCCESS == zend_hash_find(_server, "PATH_INFO", sizeof("PATH_INFO"), (void**)&z_path_info) &&
+ IS_STRING == Z_TYPE_PP(z_path_info)) {
+ entry_len = Z_STRLEN_PP(z_path_info);
+ entry = estrndup(Z_STRVAL_PP(z_path_info), entry_len);
+ path_info = emalloc(Z_STRLEN_PP(z_script_name) + entry_len + 1);
+ memcpy(path_info, Z_STRVAL_PP(z_script_name), Z_STRLEN_PP(z_script_name));
+ memcpy(path_info + Z_STRLEN_PP(z_script_name), entry, entry_len + 1);
+ free_pathinfo = 1;
+ } else {
+ entry_len = 0;
+ entry = estrndup("", 0);
+ path_info = Z_STRVAL_PP(z_script_name);
+ }
+
+ pt = estrndup(Z_STRVAL_PP(z_script_name), Z_STRLEN_PP(z_script_name));
+
+ } else {
+ char *testit;
+
+ testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1 TSRMLS_CC);
+ if (!(pt = strstr(testit, basename))) {
+ efree(testit);
+ return;
+ }
+
+ path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1 TSRMLS_CC);
+
+ if (path_info) {
+ entry = path_info;
+ entry_len = strlen(entry);
+ spprintf(&path_info, 0, "%s%s", testit, path_info);
+ free_pathinfo = 1;
+ } else {
+ path_info = testit;
+ free_pathinfo = 1;
+ entry = estrndup("", 0);
+ entry_len = 0;
+ }
+
+ pt = estrndup(testit, (pt - testit) + (fname_len - (basename - fname)));
+ }
+ not_cgi = 0;
+ } else {
+ path_info = SG(request_info).request_uri;
+
+ if (!(pt = strstr(path_info, basename))) {
+ /* this can happen with rewrite rules - and we have no idea what to do then, so return */
+ return;
+ }
+
+ entry_len = strlen(path_info);
+ entry_len -= (pt - path_info) + (fname_len - (basename - fname));
+ entry = estrndup(pt + (fname_len - (basename - fname)), entry_len);
+
+ pt = estrndup(path_info, (pt - path_info) + (fname_len - (basename - fname)));
+ not_cgi = 1;
+ }
+
+ if (rewrite) {
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
+ zval *params, *retval_ptr, **zp[1];
+
+ MAKE_STD_ZVAL(params);
+ ZVAL_STRINGL(params, entry, entry_len, 1);
+ zp[0] = &params;
+
+#if PHP_VERSION_ID < 50300
+ if (FAILURE == zend_fcall_info_init(rewrite, &fci, &fcc TSRMLS_CC)) {
+#else
+ if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
+#endif
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: invalid rewrite callback");
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ return;
+ }
+
+ fci.param_count = 1;
+ fci.params = zp;
+#if PHP_VERSION_ID < 50300
+ ++(params->refcount);
+#else
+ Z_ADDREF_P(params);
+#endif
+ fci.retval_ptr_ptr = &retval_ptr;
+
+ if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
+ if (!EG(exception)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: failed to call rewrite callback");
+ }
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ return;
+ }
+
+ if (!fci.retval_ptr_ptr || !retval_ptr) {
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: rewrite callback must return a string or false");
+ return;
+ }
+
+ switch (Z_TYPE_P(retval_ptr)) {
+#if PHP_VERSION_ID >= 60000
+ case IS_UNICODE:
+ zval_unicode_to_string(retval_ptr TSRMLS_CC);
+ /* break intentionally omitted */
+#endif
+ case IS_STRING:
+ efree(entry);
+
+ if (fci.retval_ptr_ptr != &retval_ptr) {
+ entry = estrndup(Z_STRVAL_PP(fci.retval_ptr_ptr), Z_STRLEN_PP(fci.retval_ptr_ptr));
+ entry_len = Z_STRLEN_PP(fci.retval_ptr_ptr);
+ } else {
+ entry = Z_STRVAL_P(retval_ptr);
+ entry_len = Z_STRLEN_P(retval_ptr);
+ }
+
+ break;
+ case IS_BOOL:
+ phar_do_403(entry, entry_len TSRMLS_CC);
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ zend_bailout();
+ return;
+ default:
+ efree(retval_ptr);
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: rewrite callback must return a string or false");
+ return;
+ }
+ }
+
+ if (entry_len) {
+ phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len TSRMLS_CC);
+ }
+
+ if (!entry_len || (entry_len == 1 && entry[0] == '/')) {
+ efree(entry);
+ /* direct request */
+ if (index_php_len) {
+ entry = index_php;
+ entry_len = index_php_len;
+ if (entry[0] != '/') {
+ spprintf(&entry, 0, "/%s", index_php);
+ ++entry_len;
+ }
+ } else {
+ /* assume "index.php" is starting point */
+ entry = estrndup("/index.php", sizeof("/index.php"));
+ entry_len = sizeof("/index.php")-1;
+ }
+
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL TSRMLS_CC) ||
+ (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0 TSRMLS_CC)) == NULL) {
+ phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len TSRMLS_CC);
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ zend_bailout();
+ } else {
+ char *tmp = NULL, sa = '\0';
+ sapi_header_line ctr = {0};
+ ctr.response_code = 301;
+ ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")-1;
+ ctr.line = "HTTP/1.1 301 Moved Permanently";
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+
+ if (not_cgi) {
+ tmp = strstr(path_info, basename) + fname_len;
+ sa = *tmp;
+ *tmp = '\0';
+ }
+
+ ctr.response_code = 0;
+
+ if (path_info[strlen(path_info)-1] == '/') {
+ ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1);
+ } else {
+ ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry);
+ }
+
+ if (not_cgi) {
+ *tmp = sa;
+ }
+
+ if (free_pathinfo) {
+ efree(path_info);
+ }
+
+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
+ sapi_send_headers(TSRMLS_C);
+ efree(ctr.line);
+ zend_bailout();
+ }
+ }
+
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL TSRMLS_CC) ||
+ (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0 TSRMLS_CC)) == NULL) {
+ phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len TSRMLS_CC);
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
+ zend_bailout();
+ }
+
+ if (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {
+ const char *ext = zend_memrchr(entry, '.', entry_len);
+ zval **val;
+
+ if (ext) {
+ ++ext;
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) {
+ switch (Z_TYPE_PP(val)) {
+ case IS_LONG:
+ if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) {
+ mime_type = "";
+ code = Z_LVAL_PP(val);
+ } else {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
+ RETURN_FALSE;
+ }
+ break;
+ case IS_STRING:
+ mime_type = Z_STRVAL_PP(val);
+ code = PHAR_MIME_OTHER;
+ break;
+ default:
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
+ RETURN_FALSE;
+ }
+ }
+ }
+ }
+
+ if (!mime_type) {
+ code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type TSRMLS_CC);
+ }
+ ret = phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto void Phar::mungServer(array munglist)
+ * Defines a list of up to 4 $_SERVER variables that should be modified for execution
+ * to mask the presence of the phar archive. This should be used in conjunction with
+ * Phar::webPhar(), and has no effect otherwise
+ * SCRIPT_NAME, PHP_SELF, REQUEST_URI and SCRIPT_FILENAME
+ */
+PHP_METHOD(Phar, mungServer)
+{
+ zval *mungvalues;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &mungvalues) == FAILURE) {
+ return;
+ }
+
+ if (!zend_hash_num_elements(Z_ARRVAL_P(mungvalues))) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
+ return;
+ }
+
+ if (zend_hash_num_elements(Z_ARRVAL_P(mungvalues)) > 4) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
+ return;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+
+ for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) {
+ zval **data = NULL;
+
+ if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()");
+ return;
+ }
+
+ if (Z_TYPE_PP(data) != IS_STRING) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
+ return;
+ }
+
+ if (Z_STRLEN_PP(data) == sizeof("PHP_SELF")-1 && !strncmp(Z_STRVAL_PP(data), "PHP_SELF", sizeof("PHP_SELF")-1)) {
+ PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_PHP_SELF;
+ }
+
+ if (Z_STRLEN_PP(data) == sizeof("REQUEST_URI")-1) {
+ if (!strncmp(Z_STRVAL_PP(data), "REQUEST_URI", sizeof("REQUEST_URI")-1)) {
+ PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_REQUEST_URI;
+ }
+ if (!strncmp(Z_STRVAL_PP(data), "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) {
+ PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_NAME;
+ }
+ }
+
+ if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
+ PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto void Phar::interceptFileFuncs()
+ * instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions
+ * and return stat on files within the phar for relative paths
+ *
+ * Once called, this cannot be reversed, and continue until the end of the request.
+ *
+ * This allows legacy scripts to be pharred unmodified
+ */
+PHP_METHOD(Phar, interceptFileFuncs)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ phar_intercept_functions(TSRMLS_C);
+}
+/* }}} */
+
+/* {{{ proto array Phar::createDefaultStub([string indexfile[, string webindexfile]])
+ * Return a stub that can be used to run a phar-based archive without the phar extension
+ * indexfile is the CLI startup filename, which defaults to "index.php", webindexfile
+ * is the web startup filename, and also defaults to "index.php"
+ */
+PHP_METHOD(Phar, createDefaultStub)
+{
+ char *index = NULL, *webindex = NULL, *stub, *error;
+ int index_len = 0, webindex_len = 0;
+ size_t stub_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ return;
+ }
+
+ stub = phar_create_default_stub(index, webindex, &stub_len, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ return;
+ }
+ RETURN_STRINGL(stub, stub_len, 0);
+}
+/* }}} */
+
+/* {{{ proto mixed Phar::mapPhar([string alias, [int dataoffset]])
+ * Reads the currently executed file (a phar) and registers its manifest */
+PHP_METHOD(Phar, mapPhar)
+{
+ char *alias = NULL, *error;
+ int alias_len = 0;
+ long dataoffset = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
+ return;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+
+ RETVAL_BOOL(phar_open_executed_filename(alias, alias_len, &error TSRMLS_CC) == SUCCESS);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+} /* }}} */
+
+/* {{{ proto mixed Phar::loadPhar(string filename [, string alias])
+ * Loads any phar archive with an alias */
+PHP_METHOD(Phar, loadPhar)
+{
+ char *fname, *alias = NULL, *error;
+ int fname_len, alias_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ return;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+
+ RETVAL_BOOL(phar_open_from_filename(fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, &error TSRMLS_CC) == SUCCESS);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+} /* }}} */
+
+/* {{{ proto string Phar::apiVersion()
+ * Returns the api version */
+PHP_METHOD(Phar, apiVersion)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1, 1);
+}
+/* }}}*/
+
+/* {{{ proto bool Phar::canCompress([int method])
+ * Returns whether phar extension supports compression using zlib/bzip2 */
+PHP_METHOD(Phar, canCompress)
+{
+ long method = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ return;
+ }
+
+ phar_request_initialize(TSRMLS_C);
+ switch (method) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (PHAR_G(has_zlib)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (PHAR_G(has_bz2)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+ default:
+ if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto bool Phar::canWrite()
+ * Returns whether phar extension supports writing and creating phars */
+PHP_METHOD(Phar, canWrite)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ RETURN_BOOL(!PHAR_G(readonly));
+}
+/* }}} */
+
+/* {{{ proto bool Phar::isValidPharFilename(string filename[, bool executable = true])
+ * Returns whether the given filename is a valid phar filename */
+PHP_METHOD(Phar, isValidPharFilename)
+{
+ char *fname;
+ const char *ext_str;
+ int fname_len, ext_len, is_executable;
+ zend_bool executable = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ return;
+ }
+
+ is_executable = executable;
+ RETVAL_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, is_executable, 2, 1 TSRMLS_CC) == SUCCESS);
+}
+/* }}} */
+
+#if HAVE_SPL
+/**
+ * from spl_directory
+ */
+static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar = (phar_archive_data *) object->oth;
+
+ if (!phar->is_persistent) {
+ phar_archive_delref(phar TSRMLS_CC);
+ }
+
+ object->oth = NULL;
+}
+/* }}} */
+
+/**
+ * from spl_directory
+ */
+static void phar_spl_foreign_clone(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar_data = (phar_archive_data *) dst->oth;
+
+ if (!phar_data->is_persistent) {
+ ++(phar_data->refcount);
+ }
+}
+/* }}} */
+
+static spl_other_handler phar_spl_foreign_handler = {
+ phar_spl_foreign_dtor,
+ phar_spl_foreign_clone
+};
+#endif /* HAVE_SPL */
+
+/* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]])
+ * Construct a Phar archive object
+ *
+ * proto void PharData::__construct(string fname [[, int flags [, string alias]], int file format = Phar::TAR])
+ * Construct a PharData archive object
+ *
+ * This function is used as the constructor for both the Phar and PharData
+ * classes, hence the two prototypes above.
+ */
+PHP_METHOD(Phar, __construct)
+{
+#if !HAVE_SPL
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Cannot instantiate Phar object without SPL extension");
+#else
+ char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
+ int fname_len, alias_len = 0, arch_len, entry_len, is_data;
+#if PHP_VERSION_ID < 50300
+ long flags = 0;
+#else
+ long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
+#endif
+ long format = 0;
+ phar_archive_object *phar_obj;
+ phar_archive_data *phar_data;
+ zval *zobj = getThis(), arg1, arg2;
+
+ phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data TSRMLS_CC);
+
+ if (is_data) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ return;
+ }
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ return;
+ }
+ }
+
+ if (phar_obj->arc.archive) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
+ return;
+ }
+
+ save_fname = fname;
+ if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, !is_data, 2 TSRMLS_CC)) {
+ /* use arch (the basename for the archive) for fname instead of fname */
+ /* this allows support for RecursiveDirectoryIterator of subdirectories */
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(arch, arch_len);
+#endif
+ fname = arch;
+ fname_len = arch_len;
+#ifdef PHP_WIN32
+ } else {
+ arch = estrndup(fname, fname_len);
+ arch_len = fname_len;
+ fname = arch;
+ phar_unixify_path_separators(arch, arch_len);
+#endif
+ }
+
+ if (phar_open_or_create_filename(fname, fname_len, alias, alias_len, is_data, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
+
+ if (fname == arch && fname != save_fname) {
+ efree(arch);
+ fname = save_fname;
+ }
+
+ if (entry) {
+ efree(entry);
+ }
+
+ if (error) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "%s", error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Phar creation or opening failed");
+ }
+
+ return;
+ }
+
+ if (is_data && phar_data->is_tar && phar_data->is_brandnew && format == PHAR_FORMAT_ZIP) {
+ phar_data->is_zip = 1;
+ phar_data->is_tar = 0;
+ }
+
+ if (fname == arch) {
+ efree(arch);
+ fname = save_fname;
+ }
+
+ if ((is_data && !phar_data->is_data) || (!is_data && phar_data->is_data)) {
+ if (is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "PharData class can only be used for non-executable tar and zip archives");
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Phar class can only be used for executable tar and zip archives");
+ }
+ efree(entry);
+ return;
+ }
+
+ is_data = phar_data->is_data;
+
+ if (!phar_data->is_persistent) {
+ ++(phar_data->refcount);
+ }
+
+ phar_obj->arc.archive = phar_data;
+ phar_obj->spl.oth_handler = &phar_spl_foreign_handler;
+
+ if (entry) {
+ fname_len = spprintf(&fname, 0, "phar://%s%s", phar_data->fname, entry);
+ efree(entry);
+ } else {
+ fname_len = spprintf(&fname, 0, "phar://%s", phar_data->fname);
+ }
+
+ INIT_PZVAL(&arg1);
+ ZVAL_STRINGL(&arg1, fname, fname_len, 0);
+ INIT_PZVAL(&arg2);
+ ZVAL_LONG(&arg2, flags);
+
+ zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj),
+ &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2);
+
+ if (!phar_data->is_persistent) {
+ phar_obj->arc.archive->is_data = is_data;
+ } else if (!EG(exception)) {
+ /* register this guy so we can modify if necessary */
+ zend_hash_add(&PHAR_GLOBALS->phar_persist_map, (const char *) phar_obj->arc.archive, sizeof(phar_obj->arc.archive), (void *) &phar_obj, sizeof(phar_archive_object **), NULL);
+ }
+
+ phar_obj->spl.info_class = phar_ce_entry;
+ efree(fname);
+#endif /* HAVE_SPL */
+}
+/* }}} */
+
+/* {{{ proto array Phar::getSupportedSignatures()
+ * Return array of supported signature types
+ */
+PHP_METHOD(Phar, getSupportedSignatures)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+
+ add_next_index_stringl(return_value, "MD5", 3, 1);
+ add_next_index_stringl(return_value, "SHA-1", 5, 1);
+#ifdef PHAR_HASH_OK
+ add_next_index_stringl(return_value, "SHA-256", 7, 1);
+ add_next_index_stringl(return_value, "SHA-512", 7, 1);
+#endif
+#if PHAR_HAVE_OPENSSL
+ add_next_index_stringl(return_value, "OpenSSL", 7, 1);
+#else
+ if (zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
+ add_next_index_stringl(return_value, "OpenSSL", 7, 1);
+ }
+#endif
+}
+/* }}} */
+
+/* {{{ proto array Phar::getSupportedCompression()
+ * Return array of supported comparession algorithms
+ */
+PHP_METHOD(Phar, getSupportedCompression)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+ phar_request_initialize(TSRMLS_C);
+
+ if (PHAR_G(has_zlib)) {
+ add_next_index_stringl(return_value, "GZ", 2, 1);
+ }
+
+ if (PHAR_G(has_bz2)) {
+ add_next_index_stringl(return_value, "BZIP2", 5, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto array Phar::unlinkArchive(string archive)
+ * Completely remove a phar archive from memory and disk
+ */
+PHP_METHOD(Phar, unlinkArchive)
+{
+ char *fname, *error, *zname, *arch, *entry;
+ int fname_len, zname_len, arch_len, entry_len;
+ phar_archive_data *phar;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (!fname_len) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"\"");
+ return;
+ }
+
+ if (FAILURE == phar_open_from_filename(fname, fname_len, NULL, 0, REPORT_ERRORS, &phar, &error TSRMLS_CC)) {
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"%s\": %s", fname, error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown phar archive \"%s\"", fname);
+ }
+ return;
+ }
+
+ zname = (char*)zend_get_executed_filename(TSRMLS_C);
+ zname_len = strlen(zname);
+
+ if (zname_len > 7 && !memcmp(zname, "phar://", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
+ if (arch_len == fname_len && !memcmp(arch, fname, arch_len)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" cannot be unlinked from within itself", fname);
+ efree(arch);
+ efree(entry);
+ return;
+ }
+ efree(arch);
+ efree(entry);
+ }
+
+ if (phar->is_persistent) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" is in phar.cache_list, cannot unlinkArchive()", fname);
+ return;
+ }
+
+ if (phar->refcount) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar archive \"%s\" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()", fname);
+ return;
+ }
+
+ fname = estrndup(phar->fname, phar->fname_len);
+
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ phar_archive_delref(phar TSRMLS_CC);
+ unlink(fname);
+ efree(fname);
+ RETURN_TRUE;
+}
+/* }}} */
+
+#if HAVE_SPL
+
+#define PHAR_ARCHIVE_OBJECT() \
+ phar_archive_object *phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
+ if (!phar_obj->arc.archive) { \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Cannot call method on an uninitialized Phar object"); \
+ return; \
+ }
+
+/* {{{ proto void Phar::__destruct()
+ * if persistent, remove from the cache
+ */
+PHP_METHOD(Phar, __destruct)
+{
+ phar_archive_object *phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (phar_obj->arc.archive && phar_obj->arc.archive->is_persistent) {
+ zend_hash_del(&PHAR_GLOBALS->phar_persist_map, (const char *) phar_obj->arc.archive, sizeof(phar_obj->arc.archive));
+ }
+}
+/* }}} */
+
+struct _phar_t {
+ phar_archive_object *p;
+ zend_class_entry *c;
+ char *b;
+ uint l;
+ zval *ret;
+ int count;
+ php_stream *fp;
+};
+
+static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
+{
+ zval **value;
+ zend_uchar key_type;
+ zend_bool close_fp = 1;
+ ulong int_key;
+ struct _phar_t *p_obj = (struct _phar_t*) puser;
+ uint str_key_len, base_len = p_obj->l, fname_len;
+ phar_entry_data *data;
+ php_stream *fp;
+ size_t contents_len;
+ char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL;
+ phar_zstr key;
+ char *str_key;
+ zend_class_entry *ce = p_obj->c;
+ phar_archive_object *phar_obj = p_obj->p;
+ char *str = "[stream]";
+
+ iter->funcs->get_current_data(iter, &value TSRMLS_CC);
+
+ if (EG(exception)) {
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (!value) {
+ /* failure in get_current_data */
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned no value", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ switch (Z_TYPE_PP(value)) {
+#if PHP_VERSION_ID >= 60000
+ case IS_UNICODE:
+ zval_unicode_to_string(*(value) TSRMLS_CC);
+ /* break intentionally omitted */
+#endif
+ case IS_STRING:
+ break;
+ case IS_RESOURCE:
+ php_stream_from_zval_no_verify(fp, value);
+
+ if (!fp) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returned an invalid stream handle", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (iter->funcs->get_current_key) {
+ key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC);
+
+ if (EG(exception)) {
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (key_type == HASH_KEY_IS_LONG) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (key_type > 9) { /* IS_UNICODE == 10 */
+#if PHP_VERSION_ID < 60000
+/* this can never happen, but fixes a compile warning */
+ spprintf(&str_key, 0, "%s", key);
+#else
+ spprintf(&str_key, 0, "%v", key);
+ ezfree(key);
+#endif
+ } else {
+ PHAR_STR(key, str_key);
+ }
+
+ save = str_key;
+
+ if (str_key[str_key_len - 1] == '\0') {
+ str_key_len--;
+ }
+
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ close_fp = 0;
+ opened = (char *) estrndup(str, sizeof("[stream]") + 1);
+ goto after_open_fp;
+ case IS_OBJECT:
+ if (instanceof_function(Z_OBJCE_PP(value), spl_ce_SplFileInfo TSRMLS_CC)) {
+ char *test = NULL;
+ zval dummy;
+ spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(*value TSRMLS_CC);
+
+ if (!base_len) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ switch (intern->type) {
+ case SPL_FS_DIR:
+#if PHP_VERSION_ID >= 60000
+ test = spl_filesystem_object_get_path(intern, NULL, NULL TSRMLS_CC).s;
+#elif PHP_VERSION_ID >= 50300
+ test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC);
+#else
+ test = intern->path;
+#endif
+ fname_len = spprintf(&fname, 0, "%s%c%s", test, DEFAULT_SLASH, intern->u.dir.entry.d_name);
+ php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC);
+
+ if (Z_BVAL(dummy)) {
+ /* ignore directories */
+ efree(fname);
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ test = expand_filepath(fname, NULL TSRMLS_CC);
+ efree(fname);
+
+ if (test) {
+ fname = test;
+ fname_len = strlen(fname);
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ save = fname;
+ goto phar_spl_fileinfo;
+ case SPL_FS_INFO:
+ case SPL_FS_FILE:
+#if PHP_VERSION_ID >= 60000
+ if (intern->file_name_type == IS_UNICODE) {
+ zval zv;
+
+ INIT_ZVAL(zv);
+ Z_UNIVAL(zv) = intern->file_name;
+ Z_UNILEN(zv) = intern->file_name_len;
+ Z_TYPE(zv) = IS_UNICODE;
+
+ zval_copy_ctor(&zv);
+ zval_unicode_to_string(&zv TSRMLS_CC);
+ fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC);
+ ezfree(Z_UNIVAL(zv));
+ } else {
+ fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC);
+ }
+#else
+ fname = expand_filepath(intern->file_name, NULL TSRMLS_CC);
+#endif
+ if (!fname) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ fname_len = strlen(fname);
+ save = fname;
+ goto phar_spl_fileinfo;
+ }
+ }
+ /* fall-through */
+ default:
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid value (must return a string)", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ fname = Z_STRVAL_PP(value);
+ fname_len = Z_STRLEN_PP(value);
+
+phar_spl_fileinfo:
+ if (base_len) {
+ temp = expand_filepath(base, NULL TSRMLS_CC);
+ if (!temp) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
+ if (save) {
+ efree(save);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ base = temp;
+ base_len = strlen(base);
+
+ if (strstr(fname, base)) {
+ str_key_len = fname_len - base_len;
+
+ if (str_key_len <= 0) {
+ if (save) {
+ efree(save);
+ efree(temp);
+ }
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ str_key = fname + base_len;
+
+ if (*str_key == '/' || *str_key == '\\') {
+ str_key++;
+ str_key_len--;
+ }
+
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that is not in the base directory \"%s\"", ce->name, fname, base);
+
+ if (save) {
+ efree(save);
+ efree(temp);
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+ }
+ } else {
+ if (iter->funcs->get_current_key) {
+ key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC);
+
+ if (EG(exception)) {
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (key_type == HASH_KEY_IS_LONG) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (key_type > 9) { /* IS_UNICODE == 10 */
+#if PHP_VERSION_ID < 60000
+/* this can never happen, but fixes a compile warning */
+ spprintf(&str_key, 0, "%s", key);
+#else
+ spprintf(&str_key, 0, "%v", key);
+ ezfree(key);
+#endif
+ } else {
+ PHAR_STR(key, str_key);
+ }
+
+ save = str_key;
+
+ if (str_key[str_key_len - 1] == '\0') str_key_len--;
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ }
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ce->name, fname);
+
+ if (save) {
+ efree(save);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+ }
+#endif
+
+ if (php_check_open_basedir(fname TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ce->name, fname);
+
+ if (save) {
+ efree(save);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ /* try to open source file, then create internal phar file and copy contents */
+ fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened);
+
+ if (!fp) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned a file that could not be opened \"%s\"", ce->name, fname);
+
+ if (save) {
+ efree(save);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+ }
+after_open_fp:
+ if (str_key_len >= sizeof(".phar")-1 && !memcmp(str_key, ".phar", sizeof(".phar")-1)) {
+ /* silently skip any files that would be added to the magic .phar directory */
+ if (save) {
+ efree(save);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ if (opened) {
+ efree(opened);
+ }
+
+ if (close_fp) {
+ php_stream_close(fp);
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key, str_key_len, "w+b", 0, &error, 1 TSRMLS_CC))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s cannot be created: %s", str_key, error);
+ efree(error);
+
+ if (save) {
+ efree(save);
+ }
+
+ if (opened) {
+ efree(opened);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ if (close_fp) {
+ php_stream_close(fp);
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+
+ } else {
+ if (error) {
+ efree(error);
+ }
+ /* convert to PHAR_UFP */
+ if (data->internal_file->fp_type == PHAR_MOD) {
+ php_stream_close(data->internal_file->fp);
+ }
+
+ data->internal_file->fp = NULL;
+ data->internal_file->fp_type = PHAR_UFP;
+ data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp);
+ data->fp = NULL;
+ phar_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len);
+ data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize =
+ php_stream_tell(p_obj->fp) - data->internal_file->offset;
+ }
+
+ if (close_fp) {
+ php_stream_close(fp);
+ }
+
+ add_assoc_string(p_obj->ret, str_key, opened, 0);
+
+ if (save) {
+ efree(save);
+ }
+
+ if (temp) {
+ efree(temp);
+ }
+
+ data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
+ phar_entry_delref(data TSRMLS_CC);
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+/* {{{ proto array Phar::buildFromDirectory(string base_dir[, string regex])
+ * Construct a phar archive from an existing directory, recursively.
+ * Optional second parameter is a regular expression for filtering directory contents.
+ *
+ * Return value is an array mapping phar index to actual files added.
+ */
+PHP_METHOD(Phar, buildFromDirectory)
+{
+ char *dir, *error, *regex = NULL;
+ int dir_len, regex_len = 0;
+ zend_bool apply_reg = 0;
+ zval arg, arg2, *iter, *iteriter, *regexiter = NULL;
+ struct _phar_t pass;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write to archive - write operations restricted by INI setting");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ MAKE_STD_ZVAL(iter);
+
+ if (SUCCESS != object_init_ex(iter, spl_ce_RecursiveDirectoryIterator)) {
+ zval_ptr_dtor(&iter);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate directory iterator for %s", phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ INIT_PZVAL(&arg);
+ ZVAL_STRINGL(&arg, dir, dir_len, 0);
+ INIT_PZVAL(&arg2);
+#if PHP_VERSION_ID < 50300
+ ZVAL_LONG(&arg2, 0);
+#else
+ ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS);
+#endif
+
+ zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator,
+ &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2);
+
+ if (EG(exception)) {
+ zval_ptr_dtor(&iter);
+ RETURN_FALSE;
+ }
+
+ MAKE_STD_ZVAL(iteriter);
+
+ if (SUCCESS != object_init_ex(iteriter, spl_ce_RecursiveIteratorIterator)) {
+ zval_ptr_dtor(&iter);
+ zval_ptr_dtor(&iteriter);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate directory iterator for %s", phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ zend_call_method_with_1_params(&iteriter, spl_ce_RecursiveIteratorIterator,
+ &spl_ce_RecursiveIteratorIterator->constructor, "__construct", NULL, iter);
+
+ if (EG(exception)) {
+ zval_ptr_dtor(&iter);
+ zval_ptr_dtor(&iteriter);
+ RETURN_FALSE;
+ }
+
+ zval_ptr_dtor(&iter);
+
+ if (regex_len > 0) {
+ apply_reg = 1;
+ MAKE_STD_ZVAL(regexiter);
+
+ if (SUCCESS != object_init_ex(regexiter, spl_ce_RegexIterator)) {
+ zval_ptr_dtor(&iteriter);
+ zval_dtor(regexiter);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate regex iterator for %s", phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ INIT_PZVAL(&arg2);
+ ZVAL_STRINGL(&arg2, regex, regex_len, 0);
+
+ zend_call_method_with_2_params(&regexiter, spl_ce_RegexIterator,
+ &spl_ce_RegexIterator->constructor, "__construct", NULL, iteriter, &arg2);
+ }
+
+ array_init(return_value);
+
+ pass.c = apply_reg ? Z_OBJCE_P(regexiter) : Z_OBJCE_P(iteriter);
+ pass.p = phar_obj;
+ pass.b = dir;
+ pass.l = dir_len;
+ pass.count = 0;
+ pass.ret = return_value;
+ pass.fp = php_stream_fopen_tmpfile();
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zval_ptr_dtor(&iteriter);
+ if (apply_reg) {
+ zval_ptr_dtor(&regexiter);
+ }
+ php_stream_close(pass.fp);
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (SUCCESS == spl_iterator_apply((apply_reg ? regexiter : iteriter), (spl_iterator_apply_func_t) phar_build, (void *) &pass TSRMLS_CC)) {
+ zval_ptr_dtor(&iteriter);
+
+ if (apply_reg) {
+ zval_ptr_dtor(&regexiter);
+ }
+
+ phar_obj->arc.archive->ufp = pass.fp;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ } else {
+ zval_ptr_dtor(&iteriter);
+ if (apply_reg) {
+ zval_ptr_dtor(&regexiter);
+ }
+ php_stream_close(pass.fp);
+ }
+}
+/* }}} */
+
+/* {{{ proto array Phar::buildFromIterator(Iterator iter[, string base_directory])
+ * Construct a phar archive from an iterator. The iterator must return a series of strings
+ * that are full paths to files that should be added to the phar. The iterator key should
+ * be the path that the file will have within the phar archive.
+ *
+ * If base directory is specified, then the key will be ignored, and instead the portion of
+ * the current value minus the base directory will be used
+ *
+ * Returned is an array mapping phar index to actual file added
+ */
+PHP_METHOD(Phar, buildFromIterator)
+{
+ zval *obj;
+ char *error;
+ uint base_len = 0;
+ char *base = NULL;
+ struct _phar_t pass;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out phar archive, phar is read-only");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ array_init(return_value);
+
+ pass.c = Z_OBJCE_P(obj);
+ pass.p = phar_obj;
+ pass.b = base;
+ pass.l = base_len;
+ pass.ret = return_value;
+ pass.count = 0;
+ pass.fp = php_stream_fopen_tmpfile();
+
+ if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass TSRMLS_CC)) {
+ phar_obj->arc.archive->ufp = pass.fp;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ } else {
+ php_stream_close(pass.fp);
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::count()
+ * Returns the number of entries in the Phar archive
+ */
+PHP_METHOD(Phar, count)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_LONG(zend_hash_num_elements(&phar_obj->arc.archive->manifest));
+}
+/* }}} */
+
+/* {{{ proto bool Phar::isFileFormat(int format)
+ * Returns true if the phar archive is based on the tar/zip/phar file format depending
+ * on whether Phar::TAR, Phar::ZIP or Phar::PHAR was passed in
+ */
+PHP_METHOD(Phar, isFileFormat)
+{
+ long type;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ switch (type) {
+ case PHAR_FORMAT_TAR:
+ RETURN_BOOL(phar_obj->arc.archive->is_tar);
+ case PHAR_FORMAT_ZIP:
+ RETURN_BOOL(phar_obj->arc.archive->is_zip);
+ case PHAR_FORMAT_PHAR:
+ RETURN_BOOL(!phar_obj->arc.archive->is_tar && !phar_obj->arc.archive->is_zip);
+ default:
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Unknown file format specified");
+ }
+}
+/* }}} */
+
+static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
+{
+ char *error;
+ off_t offset;
+ phar_entry_info *link;
+
+ if (FAILURE == phar_open_entry_fp(entry, &error, 1 TSRMLS_CC)) {
+ if (error) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", entry->phar->fname, entry->filename, error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents", entry->phar->fname, entry->filename);
+ }
+ return FAILURE;
+ }
+
+ /* copy old contents in entirety */
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+ offset = php_stream_tell(fp);
+ link = phar_get_link_source(entry TSRMLS_CC);
+
+ if (!link) {
+ link = entry;
+ }
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, entry->filename);
+ return FAILURE;
+ }
+
+ if (entry->fp_type == PHAR_MOD) {
+ /* save for potential restore on error */
+ entry->cfp = entry->fp;
+ entry->fp = NULL;
+ }
+
+ /* set new location of file contents */
+ entry->fp_type = PHAR_FP;
+ entry->offset = offset;
+ return SUCCESS;
+}
+/* }}} */
+
+static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */
+{
+ const char *oldname = NULL;
+ char *oldpath = NULL;
+ char *basename = NULL, *basepath = NULL;
+ char *newname = NULL, *newpath = NULL;
+ zval *ret, arg1;
+ zend_class_entry *ce;
+ char *error;
+ const char *pcr_error;
+ int ext_len = ext ? strlen(ext) : 0;
+ int oldname_len;
+ phar_archive_data **pphar = NULL;
+ php_stream_statbuf ssb;
+
+ if (!ext) {
+ if (phar->is_zip) {
+
+ if (phar->is_data) {
+ ext = "zip";
+ } else {
+ ext = "phar.zip";
+ }
+
+ } else if (phar->is_tar) {
+
+ switch (phar->flags) {
+ case PHAR_FILE_COMPRESSED_GZ:
+ if (phar->is_data) {
+ ext = "tar.gz";
+ } else {
+ ext = "phar.tar.gz";
+ }
+ break;
+ case PHAR_FILE_COMPRESSED_BZ2:
+ if (phar->is_data) {
+ ext = "tar.bz2";
+ } else {
+ ext = "phar.tar.bz2";
+ }
+ break;
+ default:
+ if (phar->is_data) {
+ ext = "tar";
+ } else {
+ ext = "phar.tar";
+ }
+ }
+ } else {
+
+ switch (phar->flags) {
+ case PHAR_FILE_COMPRESSED_GZ:
+ ext = "phar.gz";
+ break;
+ case PHAR_FILE_COMPRESSED_BZ2:
+ ext = "phar.bz2";
+ break;
+ default:
+ ext = "phar";
+ }
+ }
+ } else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) {
+
+ if (phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
+ }
+ return NULL;
+ }
+
+ if (ext[0] == '.') {
+ ++ext;
+ }
+
+ oldpath = estrndup(phar->fname, phar->fname_len);
+ oldname = zend_memrchr(phar->fname, '/', phar->fname_len);
+ ++oldname;
+ oldname_len = strlen(oldname);
+
+ basename = estrndup(oldname, oldname_len);
+ spprintf(&newname, 0, "%s.%s", strtok(basename, "."), ext);
+ efree(basename);
+
+
+
+ basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len));
+ phar->fname_len = spprintf(&newpath, 0, "%s%s", basepath, newname);
+ phar->fname = newpath;
+ phar->ext = newpath + phar->fname_len - strlen(ext) - 1;
+ efree(basepath);
+ efree(newname);
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_find(&cached_phars, newpath, phar->fname_len, (void **) &pphar)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname);
+ return NULL;
+ }
+
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void **) &pphar)) {
+ if ((*pphar)->fname_len == phar->fname_len && !memcmp((*pphar)->fname, phar->fname, phar->fname_len)) {
+ if (!zend_hash_num_elements(&phar->manifest)) {
+ (*pphar)->is_tar = phar->is_tar;
+ (*pphar)->is_zip = phar->is_zip;
+ (*pphar)->is_data = phar->is_data;
+ (*pphar)->flags = phar->flags;
+ (*pphar)->fp = phar->fp;
+ phar->fp = NULL;
+ phar_destroy_phar_data(phar TSRMLS_CC);
+ phar = *pphar;
+ phar->refcount++;
+ newpath = oldpath;
+ goto its_ok;
+ }
+ }
+
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", phar->fname);
+ return NULL;
+ }
+its_ok:
+ if (SUCCESS == php_stream_stat_path(newpath, &ssb)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
+ return NULL;
+ }
+ if (!phar->is_data) {
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1 TSRMLS_CC)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar \"%s\" has invalid extension %s", phar->fname, ext);
+ return NULL;
+ }
+
+ if (phar->alias) {
+ if (phar->is_temporary_alias) {
+ phar->alias = NULL;
+ phar->alias_len = 0;
+ } else {
+ phar->alias = estrndup(newpath, strlen(newpath));
+ phar->alias_len = strlen(newpath);
+ phar->is_temporary_alias = 1;
+ zend_hash_update(&(PHAR_GLOBALS->phar_alias_map), newpath, phar->fname_len, (void*)&phar, sizeof(phar_archive_data*), NULL);
+ }
+ }
+
+ } else {
+
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 0, 1, 1 TSRMLS_CC)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
+ return NULL;
+ }
+
+ phar->alias = NULL;
+ phar->alias_len = 0;
+ }
+
+ if ((!pphar || phar == *pphar) && SUCCESS != zend_hash_update(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void*)&phar, sizeof(phar_archive_data*), NULL)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars", phar->fname);
+ return NULL;
+ }
+
+ phar_flush(phar, 0, 0, 1, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ efree(oldpath);
+ return NULL;
+ }
+
+ efree(oldpath);
+
+ if (phar->is_data) {
+ ce = phar_ce_data;
+ } else {
+ ce = phar_ce_archive;
+ }
+
+ MAKE_STD_ZVAL(ret);
+
+ if (SUCCESS != object_init_ex(ret, ce)) {
+ zval_dtor(ret);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
+ return NULL;
+ }
+
+ INIT_PZVAL(&arg1);
+ ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len, 0);
+
+ zend_call_method_with_1_params(&ret, ce, &ce->constructor, "__construct", NULL, &arg1);
+ return ret;
+}
+/* }}} */
+
+static zval *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ phar_entry_info *entry, newentry;
+ zval *ret;
+
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ phar = (phar_archive_data *) ecalloc(1, sizeof(phar_archive_data));
+ /* set whole-archive compression and type from parameter */
+ phar->flags = flags;
+ phar->is_data = source->is_data;
+
+ switch (convert) {
+ case PHAR_FORMAT_TAR:
+ phar->is_tar = 1;
+ break;
+ case PHAR_FORMAT_ZIP:
+ phar->is_zip = 1;
+ break;
+ default:
+ phar->is_data = 0;
+ break;
+ }
+
+ zend_hash_init(&(phar->manifest), sizeof(phar_entry_info),
+ zend_get_hash_value, destroy_phar_manifest_entry, 0);
+ zend_hash_init(&phar->mounted_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, 0);
+ zend_hash_init(&phar->virtual_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, 0);
+
+ phar->fp = php_stream_fopen_tmpfile();
+ phar->fname = source->fname;
+ phar->fname_len = source->fname_len;
+ phar->is_temporary_alias = source->is_temporary_alias;
+ phar->alias = source->alias;
+
+ if (source->metadata) {
+ zval *t;
+
+ t = source->metadata;
+ ALLOC_ZVAL(phar->metadata);
+ *phar->metadata = *t;
+ zval_copy_ctor(phar->metadata);
+#if PHP_VERSION_ID < 50300
+ phar->metadata->refcount = 1;
+#else
+ Z_SET_REFCOUNT_P(phar->metadata, 1);
+#endif
+
+ phar->metadata_len = 0;
+ }
+
+ /* first copy each file's uncompressed contents to a temporary file and set per-file flags */
+ for (zend_hash_internal_pointer_reset(&source->manifest); SUCCESS == zend_hash_has_more_elements(&source->manifest); zend_hash_move_forward(&source->manifest)) {
+
+ if (FAILURE == zend_hash_get_current_data(&source->manifest, (void **) &entry)) {
+ zend_hash_destroy(&(phar->manifest));
+ php_stream_close(phar->fp);
+ efree(phar);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot convert phar archive \"%s\"", source->fname);
+ return NULL;
+ }
+
+ newentry = *entry;
+
+ if (newentry.link) {
+ newentry.link = estrdup(newentry.link);
+ goto no_copy;
+ }
+
+ if (newentry.tmp) {
+ newentry.tmp = estrdup(newentry.tmp);
+ goto no_copy;
+ }
+
+ newentry.metadata_str.c = 0;
+
+ if (FAILURE == phar_copy_file_contents(&newentry, phar->fp TSRMLS_CC)) {
+ zend_hash_destroy(&(phar->manifest));
+ php_stream_close(phar->fp);
+ efree(phar);
+ /* exception already thrown */
+ return NULL;
+ }
+no_copy:
+ newentry.filename = estrndup(newentry.filename, newentry.filename_len);
+
+ if (newentry.metadata) {
+ zval *t;
+
+ t = newentry.metadata;
+ ALLOC_ZVAL(newentry.metadata);
+ *newentry.metadata = *t;
+ zval_copy_ctor(newentry.metadata);
+#if PHP_VERSION_ID < 50300
+ newentry.metadata->refcount = 1;
+#else
+ Z_SET_REFCOUNT_P(newentry.metadata, 1);
+#endif
+
+ newentry.metadata_str.c = NULL;
+ newentry.metadata_str.len = 0;
+ }
+
+ newentry.is_zip = phar->is_zip;
+ newentry.is_tar = phar->is_tar;
+
+ if (newentry.is_tar) {
+ newentry.tar_type = (entry->is_dir ? TAR_DIR : TAR_FILE);
+ }
+
+ newentry.is_modified = 1;
+ newentry.phar = phar;
+ newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */
+ phar_set_inode(&newentry TSRMLS_CC);
+ zend_hash_add(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info), NULL);
+ phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC);
+ }
+
+ if ((ret = phar_rename_archive(phar, ext, 0 TSRMLS_CC))) {
+ return ret;
+ } else {
+ zend_hash_destroy(&(phar->manifest));
+ zend_hash_destroy(&(phar->mounted_dirs));
+ zend_hash_destroy(&(phar->virtual_dirs));
+ php_stream_close(phar->fp);
+ efree(phar->fname);
+ efree(phar);
+ return NULL;
+ }
+}
+/* }}} */
+
+/* {{{ proto object Phar::convertToExecutable([int format[, int compression [, string file_ext]]])
+ * Convert a phar.tar or phar.zip archive to the phar file format. The
+ * optional parameter allows the user to determine the new
+ * filename extension (default is phar).
+ */
+PHP_METHOD(Phar, convertToExecutable)
+{
+ char *ext = NULL;
+ int is_data, ext_len = 0;
+ php_uint32 flags;
+ zval *ret;
+ /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
+ long format = 9021976, method = 9021976;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out executable phar archive, phar is read-only");
+ return;
+ }
+
+ switch (format) {
+ case 9021976:
+ case PHAR_FORMAT_SAME: /* null is converted to 0 */
+ /* by default, use the existing format */
+ if (phar_obj->arc.archive->is_tar) {
+ format = PHAR_FORMAT_TAR;
+ } else if (phar_obj->arc.archive->is_zip) {
+ format = PHAR_FORMAT_ZIP;
+ } else {
+ format = PHAR_FORMAT_PHAR;
+ }
+ break;
+ case PHAR_FORMAT_PHAR:
+ case PHAR_FORMAT_TAR:
+ case PHAR_FORMAT_ZIP:
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP");
+ return;
+ }
+
+ switch (method) {
+ case 9021976:
+ flags = phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSION_MASK;
+ break;
+ case 0:
+ flags = PHAR_FILE_COMPRESSED_NONE;
+ break;
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (format == PHAR_FORMAT_ZIP) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
+ return;
+ }
+
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
+ return;
+ }
+
+ flags = PHAR_FILE_COMPRESSED_GZ;
+ break;
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (format == PHAR_FORMAT_ZIP) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
+ return;
+ }
+
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
+ return;
+ }
+
+ flags = PHAR_FILE_COMPRESSED_BZ2;
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
+ return;
+ }
+
+ is_data = phar_obj->arc.archive->is_data;
+ phar_obj->arc.archive->is_data = 0;
+ ret = phar_convert_to_other(phar_obj->arc.archive, format, ext, flags TSRMLS_CC);
+ phar_obj->arc.archive->is_data = is_data;
+
+ if (ret) {
+ RETURN_ZVAL(ret, 1, 1);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto object Phar::convertToData([int format[, int compression [, string file_ext]]])
+ * Convert an archive to a non-executable .tar or .zip.
+ * The optional parameter allows the user to determine the new
+ * filename extension (default is .zip or .tar).
+ */
+PHP_METHOD(Phar, convertToData)
+{
+ char *ext = NULL;
+ int is_data, ext_len = 0;
+ php_uint32 flags;
+ zval *ret;
+ /* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
+ long format = 9021976, method = 9021976;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ return;
+ }
+
+ switch (format) {
+ case 9021976:
+ case PHAR_FORMAT_SAME: /* null is converted to 0 */
+ /* by default, use the existing format */
+ if (phar_obj->arc.archive->is_tar) {
+ format = PHAR_FORMAT_TAR;
+ } else if (phar_obj->arc.archive->is_zip) {
+ format = PHAR_FORMAT_ZIP;
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out data phar archive, use Phar::TAR or Phar::ZIP");
+ return;
+ }
+ break;
+ case PHAR_FORMAT_PHAR:
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out data phar archive, use Phar::TAR or Phar::ZIP");
+ return;
+ case PHAR_FORMAT_TAR:
+ case PHAR_FORMAT_ZIP:
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP");
+ return;
+ }
+
+ switch (method) {
+ case 9021976:
+ flags = phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSION_MASK;
+ break;
+ case 0:
+ flags = PHAR_FILE_COMPRESSED_NONE;
+ break;
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (format == PHAR_FORMAT_ZIP) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
+ return;
+ }
+
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
+ return;
+ }
+
+ flags = PHAR_FILE_COMPRESSED_GZ;
+ break;
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (format == PHAR_FORMAT_ZIP) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
+ return;
+ }
+
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
+ return;
+ }
+
+ flags = PHAR_FILE_COMPRESSED_BZ2;
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
+ return;
+ }
+
+ is_data = phar_obj->arc.archive->is_data;
+ phar_obj->arc.archive->is_data = 1;
+ ret = phar_convert_to_other(phar_obj->arc.archive, format, ext, flags TSRMLS_CC);
+ phar_obj->arc.archive->is_data = is_data;
+
+ if (ret) {
+ RETURN_ZVAL(ret, 1, 1);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto int|false Phar::isCompressed()
+ * Returns Phar::GZ or PHAR::BZ2 if the entire archive is compressed
+ * (.tar.gz/tar.bz2 and so on), or FALSE otherwise.
+ */
+PHP_METHOD(Phar, isCompressed)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_GZ) {
+ RETURN_LONG(PHAR_ENT_COMPRESSED_GZ);
+ }
+
+ if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
+ RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2);
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto bool Phar::isWritable()
+ * Returns true if phar.readonly=0 or phar is a PharData AND the actual file is writable.
+ */
+PHP_METHOD(Phar, isWritable)
+{
+ php_stream_statbuf ssb;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (!phar_obj->arc.archive->is_writeable) {
+ RETURN_FALSE;
+ }
+
+ if (SUCCESS != php_stream_stat_path(phar_obj->arc.archive->fname, &ssb)) {
+ if (phar_obj->arc.archive->is_brandnew) {
+ /* assume it works if the file doesn't exist yet */
+ RETURN_TRUE;
+ }
+ RETURN_FALSE;
+ }
+
+ RETURN_BOOL((ssb.sb.st_mode & (S_IWOTH | S_IWGRP | S_IWUSR)) != 0);
+}
+/* }}} */
+
+/* {{{ proto bool Phar::delete(string entry)
+ * Deletes a named file within the archive.
+ */
+PHP_METHOD(Phar, delete)
+{
+ char *fname;
+ int fname_len;
+ char *error;
+ phar_entry_info *entry;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out phar archive, phar is read-only");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
+ if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (entry->is_deleted) {
+ /* entry is deleted, but has not been flushed to disk yet */
+ RETURN_TRUE;
+ } else {
+ entry->is_deleted = 1;
+ entry->is_modified = 1;
+ phar_obj->arc.archive->is_modified = 1;
+ }
+ }
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be deleted", fname);
+ RETURN_FALSE;
+ }
+
+ phar_flush(phar_obj->arc.archive, NULL, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int Phar::getAlias()
+ * Returns the alias for the Phar or NULL.
+ */
+PHP_METHOD(Phar, getAlias)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->alias && phar_obj->arc.archive->alias != phar_obj->arc.archive->fname) {
+ RETURN_STRINGL(phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::getPath()
+ * Returns the real path to the phar archive on disk
+ */
+PHP_METHOD(Phar, getPath)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_STRINGL(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, 1);
+}
+/* }}} */
+
+/* {{{ proto bool Phar::setAlias(string alias)
+ * Sets the alias for a Phar archive. The default value is the full path
+ * to the archive.
+ */
+PHP_METHOD(Phar, setAlias)
+{
+ char *alias, *error, *oldalias;
+ phar_archive_data **fd_ptr;
+ int alias_len, oldalias_len, old_temp, readd = 0;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out phar archive, phar is read-only");
+ RETURN_FALSE;
+ }
+
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ if (phar_obj->arc.archive->is_data) {
+ if (phar_obj->arc.archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar alias cannot be set in a plain tar archive");
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar alias cannot be set in a plain zip archive");
+ }
+ RETURN_FALSE;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &alias, &alias_len) == SUCCESS) {
+ if (alias_len == phar_obj->arc.archive->alias_len && memcmp(phar_obj->arc.archive->alias, alias, alias_len) == 0) {
+ RETURN_TRUE;
+ }
+ if (alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void**)&fd_ptr)) {
+ spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, (*fd_ptr)->fname);
+ if (SUCCESS == phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ efree(error);
+ goto valid_alias;
+ }
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ RETURN_FALSE;
+ }
+ if (!phar_validate_alias(alias, alias_len)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+valid_alias:
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ if (phar_obj->arc.archive->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, (void**)&fd_ptr)) {
+ zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len);
+ readd = 1;
+ }
+
+ oldalias = phar_obj->arc.archive->alias;
+ oldalias_len = phar_obj->arc.archive->alias_len;
+ old_temp = phar_obj->arc.archive->is_temporary_alias;
+
+ if (alias_len) {
+ phar_obj->arc.archive->alias = estrndup(alias, alias_len);
+ } else {
+ phar_obj->arc.archive->alias = NULL;
+ }
+
+ phar_obj->arc.archive->alias_len = alias_len;
+ phar_obj->arc.archive->is_temporary_alias = 0;
+ phar_flush(phar_obj->arc.archive, NULL, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ phar_obj->arc.archive->alias = oldalias;
+ phar_obj->arc.archive->alias_len = oldalias_len;
+ phar_obj->arc.archive->is_temporary_alias = old_temp;
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ if (readd) {
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), oldalias, oldalias_len, (void*)&(phar_obj->arc.archive), sizeof(phar_archive_data*), NULL);
+ }
+ efree(error);
+ RETURN_FALSE;
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&(phar_obj->arc.archive), sizeof(phar_archive_data*), NULL);
+
+ if (oldalias) {
+ efree(oldalias);
+ }
+
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto string Phar::getVersion()
+ * Return version info of Phar archive
+ */
+PHP_METHOD(Phar, getVersion)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_STRING(phar_obj->arc.archive->version, 1);
+}
+/* }}} */
+
+/* {{{ proto void Phar::startBuffering()
+ * Do not flush a writeable phar (save its contents) until explicitly requested
+ */
+PHP_METHOD(Phar, startBuffering)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ phar_obj->arc.archive->donotflush = 1;
+}
+/* }}} */
+
+/* {{{ proto bool Phar::isBuffering()
+ * Returns whether write operations are flushing to disk immediately.
+ */
+PHP_METHOD(Phar, isBuffering)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_BOOL(phar_obj->arc.archive->donotflush);
+}
+/* }}} */
+
+/* {{{ proto bool Phar::stopBuffering()
+ * Saves the contents of a modified archive to disk.
+ */
+PHP_METHOD(Phar, stopBuffering)
+{
+ char *error;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot write out phar archive, phar is read-only");
+ return;
+ }
+
+ phar_obj->arc.archive->donotflush = 0;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool Phar::setStub(string|stream stub [, int len])
+ * Change the stub in a phar, phar.tar or phar.zip archive to something other
+ * than the default. The stub *must* end with a call to __HALT_COMPILER().
+ */
+PHP_METHOD(Phar, setStub)
+{
+ zval *zstub;
+ char *stub, *error;
+ int stub_len;
+ long len = -1;
+ php_stream *stream;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot change stub, phar is read-only");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_data) {
+ if (phar_obj->arc.archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar stub cannot be set in a plain tar archive");
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar stub cannot be set in a plain zip archive");
+ }
+ return;
+ }
+
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zstub, &len) == SUCCESS) {
+ if ((php_stream_from_zval_no_verify(stream, &zstub)) != NULL) {
+ if (len > 0) {
+ len = -len;
+ } else {
+ len = -1;
+ }
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ phar_flush(phar_obj->arc.archive, (char *) &zstub, len, 0, &error TSRMLS_CC);
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ RETURN_TRUE;
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot change stub, unable to read from input stream");
+ }
+ } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &stub, &stub_len) == SUCCESS) {
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ phar_flush(phar_obj->arc.archive, stub, stub_len, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto bool Phar::setDefaultStub([string index[, string webindex]])
+ * In a pure phar archive, sets a stub that can be used to run the archive
+ * regardless of whether the phar extension is available. The first parameter
+ * is the CLI startup filename, which defaults to "index.php". The second
+ * parameter is the web startup filename and also defaults to "index.php"
+ * (falling back to CLI behaviour).
+ * Both parameters are optional.
+ * In a phar.zip or phar.tar archive, the default stub is used only to
+ * identify the archive to the extension as a Phar object. This allows the
+ * extension to treat phar.zip and phar.tar types as honorary phars. Since
+ * files cannot be loaded via this kind of stub, no parameters are accepted
+ * when the Phar object is zip- or tar-based.
+ */
+PHP_METHOD(Phar, setDefaultStub)
+{
+ char *index = NULL, *webindex = NULL, *error = NULL, *stub = NULL;
+ int index_len = 0, webindex_len = 0, created_stub = 0;
+ size_t stub_len = 0;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (phar_obj->arc.archive->is_data) {
+ if (phar_obj->arc.archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar stub cannot be set in a plain tar archive");
+ } else {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "A Phar stub cannot be set in a plain zip archive");
+ }
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (ZEND_NUM_ARGS() > 0 && (phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS());
+ RETURN_FALSE;
+ }
+
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot change stub: phar.readonly=1");
+ RETURN_FALSE;
+ }
+
+ if (!phar_obj->arc.archive->is_tar && !phar_obj->arc.archive->is_zip) {
+ stub = phar_create_default_stub(index, webindex, &stub_len, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ if (stub) {
+ efree(stub);
+ }
+ RETURN_FALSE;
+ }
+
+ created_stub = 1;
+ }
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ phar_flush(phar_obj->arc.archive, stub, stub_len, 1, &error TSRMLS_CC);
+
+ if (created_stub) {
+ efree(stub);
+ }
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array Phar::setSignatureAlgorithm(int sigtype[, string privatekey])
+ * Sets the signature algorithm for a phar and applies it. The signature
+ * algorithm must be one of Phar::MD5, Phar::SHA1, Phar::SHA256,
+ * Phar::SHA512, or Phar::OPENSSL. Note that zip- based phar archives
+ * cannot support signatures.
+ */
+PHP_METHOD(Phar, setSignatureAlgorithm)
+{
+ long algo;
+ char *error, *key = NULL;
+ int key_len = 0;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot set signature algorithm, phar is read-only");
+ return;
+ }
+
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &algo, &key, &key_len) != SUCCESS) {
+ return;
+ }
+
+ switch (algo) {
+ case PHAR_SIG_SHA256:
+ case PHAR_SIG_SHA512:
+#ifndef PHAR_HASH_OK
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled and built non-shared");
+ return;
+#endif
+ case PHAR_SIG_MD5:
+ case PHAR_SIG_SHA1:
+ case PHAR_SIG_OPENSSL:
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ phar_obj->arc.archive->sig_flags = algo;
+ phar_obj->arc.archive->is_modified = 1;
+ PHAR_G(openssl_privatekey) = key;
+ PHAR_G(openssl_privatekey_len) = key_len;
+
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Unknown signature algorithm specified");
+ }
+}
+/* }}} */
+
+/* {{{ proto array|false Phar::getSignature()
+ * Returns a hash signature, or FALSE if the archive is unsigned.
+ */
+PHP_METHOD(Phar, getSignature)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->signature) {
+ char *unknown;
+ int unknown_len;
+
+ array_init(return_value);
+ add_assoc_stringl(return_value, "hash", phar_obj->arc.archive->signature, phar_obj->arc.archive->sig_len, 1);
+ switch(phar_obj->arc.archive->sig_flags) {
+ case PHAR_SIG_MD5:
+ add_assoc_stringl(return_value, "hash_type", "MD5", 3, 1);
+ break;
+ case PHAR_SIG_SHA1:
+ add_assoc_stringl(return_value, "hash_type", "SHA-1", 5, 1);
+ break;
+ case PHAR_SIG_SHA256:
+ add_assoc_stringl(return_value, "hash_type", "SHA-256", 7, 1);
+ break;
+ case PHAR_SIG_SHA512:
+ add_assoc_stringl(return_value, "hash_type", "SHA-512", 7, 1);
+ break;
+ case PHAR_SIG_OPENSSL:
+ add_assoc_stringl(return_value, "hash_type", "OpenSSL", 7, 1);
+ break;
+ default:
+ unknown_len = spprintf(&unknown, 0, "Unknown (%u)", phar_obj->arc.archive->sig_flags);
+ add_assoc_stringl(return_value, "hash_type", unknown, unknown_len, 0);
+ break;
+ }
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto bool Phar::getModified()
+ * Return whether phar was modified
+ */
+PHP_METHOD(Phar, getModified)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_BOOL(phar_obj->arc.archive->is_modified);
+}
+/* }}} */
+
+static int phar_set_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)pDest;
+ php_uint32 compress = *(php_uint32 *)argument;
+
+ if (entry->is_deleted) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ entry->old_flags = entry->flags;
+ entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry->flags |= compress;
+ entry->is_modified = 1;
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+static int phar_test_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)pDest;
+
+ if (entry->is_deleted) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (!PHAR_G(has_bz2)) {
+ if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
+ *(int *) argument = 0;
+ }
+ }
+
+ if (!PHAR_G(has_zlib)) {
+ if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ *(int *) argument = 0;
+ }
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+static void pharobj_set_compression(HashTable *manifest, php_uint32 compress TSRMLS_DC) /* {{{ */
+{
+ zend_hash_apply_with_argument(manifest, phar_set_compression, &compress TSRMLS_CC);
+}
+/* }}} */
+
+static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
+{
+ int test;
+
+ test = 1;
+ zend_hash_apply_with_argument(manifest, phar_test_compression, &test TSRMLS_CC);
+ return test;
+}
+/* }}} */
+
+/* {{{ proto object Phar::compress(int method[, string extension])
+ * Compress a .tar, or .phar.tar with whole-file compression
+ * The parameter can be one of Phar::GZ or Phar::BZ2 to specify
+ * the kind of compression desired
+ */
+PHP_METHOD(Phar, compress)
+{
+ long method;
+ char *ext = NULL;
+ int ext_len = 0;
+ php_uint32 flags;
+ zval *ret;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &method, &ext, &ext_len) == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot compress phar archive, phar is read-only");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_zip) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot compress zip-based archives with whole-archive compression");
+ return;
+ }
+
+ switch (method) {
+ case 0:
+ flags = PHAR_FILE_COMPRESSED_NONE;
+ break;
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
+ return;
+ }
+ flags = PHAR_FILE_COMPRESSED_GZ;
+ break;
+
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
+ return;
+ }
+ flags = PHAR_FILE_COMPRESSED_BZ2;
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_tar) {
+ ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_TAR, ext, flags TSRMLS_CC);
+ } else {
+ ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_PHAR, ext, flags TSRMLS_CC);
+ }
+
+ if (ret) {
+ RETURN_ZVAL(ret, 1, 1);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto object Phar::decompress([string extension])
+ * Decompress a .tar, or .phar.tar with whole-file compression
+ */
+PHP_METHOD(Phar, decompress)
+{
+ char *ext = NULL;
+ int ext_len = 0;
+ zval *ret;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext, &ext_len) == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot decompress phar archive, phar is read-only");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_zip) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot decompress zip-based archives with whole-archive compression");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_tar) {
+ ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_TAR, ext, PHAR_FILE_COMPRESSED_NONE TSRMLS_CC);
+ } else {
+ ret = phar_convert_to_other(phar_obj->arc.archive, PHAR_FORMAT_PHAR, ext, PHAR_FILE_COMPRESSED_NONE TSRMLS_CC);
+ }
+
+ if (ret) {
+ RETURN_ZVAL(ret, 1, 1);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto object Phar::compressFiles(int method)
+ * Compress all files within a phar or zip archive using the specified compression
+ * The parameter can be one of Phar::GZ or Phar::BZ2 to specify
+ * the kind of compression desired
+ */
+PHP_METHOD(Phar, compressFiles)
+{
+ char *error;
+ php_uint32 flags;
+ long method;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar is readonly, cannot change compression");
+ return;
+ }
+
+ switch (method) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
+ return;
+ }
+ flags = PHAR_ENT_COMPRESSED_GZ;
+ break;
+
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
+ return;
+ }
+ flags = PHAR_ENT_COMPRESSED_BZ2;
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_tar) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with Gzip compression, tar archives cannot compress individual files, use compress() to compress the whole archive");
+ return;
+ }
+
+ if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
+ if (flags == PHAR_FILE_COMPRESSED_GZ) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be decompressed");
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress all files as Bzip2, some are compressed as gzip and cannot be decompressed");
+ }
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ pharobj_set_compression(&phar_obj->arc.archive->manifest, flags TSRMLS_CC);
+ phar_obj->arc.archive->is_modified = 1;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool Phar::decompressFiles()
+ * decompress every file
+ */
+PHP_METHOD(Phar, decompressFiles)
+{
+ char *error;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar is readonly, cannot change compression");
+ return;
+ }
+
+ if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot decompress all files, some are compressed as bzip2 or gzip and cannot be decompressed");
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_tar) {
+ RETURN_TRUE;
+ } else {
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC);
+ }
+
+ phar_obj->arc.archive->is_modified = 1;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool Phar::copy(string oldfile, string newfile)
+ * copy a file internal to the phar archive to another new file within the phar
+ */
+PHP_METHOD(Phar, copy)
+{
+ char *oldfile, *newfile, *error;
+ const char *pcr_error;
+ int oldfile_len, newfile_len;
+ phar_entry_info *oldentry, newentry = {0}, *temp;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "Cannot copy \"%s\" to \"%s\", phar is read-only", oldfile, newfile);
+ RETURN_FALSE;
+ }
+
+ if (oldfile_len >= sizeof(".phar")-1 && !memcmp(oldfile, ".phar", sizeof(".phar")-1)) {
+ /* can't copy a meta file */
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "file \"%s\" cannot be copied to file \"%s\", cannot copy Phar meta-file in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ if (newfile_len >= sizeof(".phar")-1 && !memcmp(newfile, ".phar", sizeof(".phar")-1)) {
+ /* can't copy a meta file */
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "file \"%s\" cannot be copied to file \"%s\", cannot copy to Phar meta-file in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ if (!zend_hash_exists(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len) || SUCCESS != zend_hash_find(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len, (void**)&oldentry) || oldentry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "file \"%s\" cannot be copied to file \"%s\", file does not exist in %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ if (zend_hash_exists(&phar_obj->arc.archive->manifest, newfile, (uint) newfile_len)) {
+ if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, newfile, (uint) newfile_len, (void**)&temp) || !temp->is_deleted) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "file \"%s\" cannot be copied to file \"%s\", file must not already exist in phar %s", oldfile, newfile, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+ }
+
+ if (phar_path_check(&newfile, &newfile_len, &pcr_error) > pcr_is_ok) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
+ "file \"%s\" contains invalid characters %s, cannot be copied from \"%s\" in phar %s", newfile, pcr_error, oldfile, phar_obj->arc.archive->fname);
+ RETURN_FALSE;
+ }
+
+ if (phar_obj->arc.archive->is_persistent) {
+ if (FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ /* re-populate with copied-on-write entry */
+ zend_hash_find(&phar_obj->arc.archive->manifest, oldfile, (uint) oldfile_len, (void**)&oldentry);
+ }
+
+ memcpy((void *) &newentry, oldentry, sizeof(phar_entry_info));
+
+ if (newentry.metadata) {
+ zval *t;
+
+ t = newentry.metadata;
+ ALLOC_ZVAL(newentry.metadata);
+ *newentry.metadata = *t;
+ zval_copy_ctor(newentry.metadata);
+#if PHP_VERSION_ID < 50300
+ newentry.metadata->refcount = 1;
+#else
+ Z_SET_REFCOUNT_P(newentry.metadata, 1);
+#endif
+
+ newentry.metadata_str.c = NULL;
+ newentry.metadata_str.len = 0;
+ }
+
+ newentry.filename = estrndup(newfile, newfile_len);
+ newentry.filename_len = newfile_len;
+ newentry.fp_refcount = 0;
+
+ if (oldentry->fp_type != PHAR_FP) {
+ if (FAILURE == phar_copy_entry_fp(oldentry, &newentry, &error TSRMLS_CC)) {
+ efree(newentry.filename);
+ php_stream_close(newentry.fp);
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ return;
+ }
+ }
+
+ zend_hash_add(&oldentry->phar->manifest, newfile, newfile_len, (void*)&newentry, sizeof(phar_entry_info), NULL);
+ phar_obj->arc.archive->is_modified = 1;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int Phar::offsetExists(string entry)
+ * determines whether a file exists in the phar
+ */
+PHP_METHOD(Phar, offsetExists)
+{
+ char *fname;
+ int fname_len;
+ phar_entry_info *entry;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ return;
+ }
+
+ if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
+ if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (entry->is_deleted) {
+ /* entry is deleted, but has not been flushed to disk yet */
+ RETURN_FALSE;
+ }
+ }
+
+ if (fname_len >= sizeof(".phar")-1 && !memcmp(fname, ".phar", sizeof(".phar")-1)) {
+ /* none of these are real files, so they don't exist */
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ } else {
+ if (zend_hash_exists(&phar_obj->arc.archive->virtual_dirs, fname, (uint) fname_len)) {
+ RETURN_TRUE;
+ }
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::offsetGet(string entry)
+ * get a PharFileInfo object for a specific file
+ */
+PHP_METHOD(Phar, offsetGet)
+{
+ char *fname, *error;
+ int fname_len;
+ zval *zfname;
+ phar_entry_info *entry;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ return;
+ }
+
+ /* security is 0 here so that we can get a better error message than "entry doesn't exist" */
+ if (!(entry = phar_get_entry_info_dir(phar_obj->arc.archive, fname, fname_len, 1, &error, 0 TSRMLS_CC))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:"");
+ } else {
+ if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot get stub \".phar/stub.php\" directly in phar \"%s\", use getStub", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot get alias \".phar/alias.txt\" directly in phar \"%s\", use getAlias", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (fname_len >= sizeof(".phar")-1 && !memcmp(fname, ".phar", sizeof(".phar")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot directly get any files or directories in magic \".phar\" directory", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (entry->is_temp_dir) {
+ efree(entry->filename);
+ efree(entry);
+ }
+
+ fname_len = spprintf(&fname, 0, "phar://%s/%s", phar_obj->arc.archive->fname, fname);
+ MAKE_STD_ZVAL(zfname);
+ ZVAL_STRINGL(zfname, fname, fname_len, 0);
+ spl_instantiate_arg_ex1(phar_obj->spl.info_class, &return_value, 0, zfname TSRMLS_CC);
+ zval_ptr_dtor(&zfname);
+ }
+}
+/* }}} */
+
+/* {{{ add a file within the phar archive from a string or resource
+ */
+static void phar_add_file(phar_archive_data **pphar, char *filename, int filename_len, char *cont_str, int cont_len, zval *zresource TSRMLS_DC)
+{
+ char *error;
+ size_t contents_len;
+ phar_entry_data *data;
+ php_stream *contents_file;
+
+ if (filename_len >= sizeof(".phar")-1 && !memcmp(filename, ".phar", sizeof(".phar")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname);
+ return;
+ }
+
+ if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1 TSRMLS_CC))) {
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created: %s", filename, error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created", filename);
+ }
+ return;
+ } else {
+ if (error) {
+ efree(error);
+ }
+
+ if (!data->internal_file->is_dir) {
+ if (cont_str) {
+ contents_len = php_stream_write(data->fp, cont_str, cont_len);
+ if (contents_len != cont_len) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", filename);
+ return;
+ }
+ } else {
+ if (!(php_stream_from_zval_no_verify(contents_file, &zresource))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", filename);
+ return;
+ }
+ phar_stream_copy_to_stream(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len);
+ }
+
+ data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
+ }
+
+ /* check for copy-on-write */
+ if (pphar[0] != data->phar) {
+ *pphar = data->phar;
+ }
+ phar_entry_delref(data TSRMLS_CC);
+ phar_flush(*pphar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ create a directory within the phar archive
+ */
+static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len TSRMLS_DC)
+{
+ char *error;
+ phar_entry_data *data;
+
+ if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, dirname, dirname_len, "w+b", 2, &error, 1 TSRMLS_CC))) {
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Directory %s does not exist and cannot be created: %s", dirname, error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Directory %s does not exist and cannot be created", dirname);
+ }
+
+ return;
+ } else {
+ if (error) {
+ efree(error);
+ }
+
+ /* check for copy on write */
+ if (data->phar != *pphar) {
+ *pphar = data->phar;
+ }
+ phar_entry_delref(data TSRMLS_CC);
+ phar_flush(*pphar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::offsetSet(string entry, string value)
+ * set the contents of an internal file to those of an external file
+ */
+PHP_METHOD(Phar, offsetSet)
+{
+ char *fname, *cont_str = NULL;
+ int fname_len, cont_len;
+ zval *zresource;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ return;
+ }
+
+ if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use setAlias", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (fname_len >= sizeof(".phar")-1 && !memcmp(fname, ".phar", sizeof(".phar")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set any files or directories in magic \".phar\" directory", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ phar_add_file(&(phar_obj->arc.archive), fname, fname_len, cont_str, cont_len, zresource TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto int Phar::offsetUnset(string entry)
+ * remove a file from a phar
+ */
+PHP_METHOD(Phar, offsetUnset)
+{
+ char *fname, *error;
+ int fname_len;
+ phar_entry_info *entry;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ return;
+ }
+
+ if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
+ if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
+ if (entry->is_deleted) {
+ /* entry is deleted, but has not been flushed to disk yet */
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_persistent) {
+ if (FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ /* re-populate entry after copy on write */
+ zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void **)&entry);
+ }
+ entry->is_modified = 0;
+ entry->is_deleted = 1;
+ /* we need to "flush" the stream to save the newly deleted file on disk */
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+ }
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto string Phar::addEmptyDir(string dirname)
+ * Adds an empty directory to the phar archive
+ */
+PHP_METHOD(Phar, addEmptyDir)
+{
+ char *dirname;
+ int dirname_len;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dirname, &dirname_len) == FAILURE) {
+ return;
+ }
+
+ if (dirname_len >= sizeof(".phar")-1 && !memcmp(dirname, ".phar", sizeof(".phar")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot create a directory in magic \".phar\" directory");
+ return;
+ }
+
+ phar_mkdir(&phar_obj->arc.archive, dirname, dirname_len TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto string Phar::addFile(string filename[, string localname])
+ * Adds a file to the archive using the filename, or the second parameter as the name within the archive
+ */
+PHP_METHOD(Phar, addFile)
+{
+ char *fname, *localname = NULL;
+ int fname_len, localname_len = 0;
+ php_stream *resource;
+ zval *zresource;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ return;
+ }
+
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive, safe_mode restrictions prevent this", fname);
+ return;
+ }
+#endif
+
+ if (!strstr(fname, "://") && php_check_open_basedir(fname TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname);
+ return;
+ }
+
+ if (!(resource = php_stream_open_wrapper(fname, "rb", 0, NULL))) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "phar error: unable to open file \"%s\" to add to phar archive", fname);
+ return;
+ }
+
+ if (localname) {
+ fname = localname;
+ fname_len = localname_len;
+ }
+
+ MAKE_STD_ZVAL(zresource);
+ php_stream_to_zval(resource, zresource);
+ phar_add_file(&(phar_obj->arc.archive), fname, fname_len, NULL, 0, zresource TSRMLS_CC);
+ efree(zresource);
+ php_stream_close(resource);
+}
+/* }}} */
+
+/* {{{ proto string Phar::addFromString(string localname, string contents)
+ * Adds a file to the archive using its contents as a string
+ */
+PHP_METHOD(Phar, addFromString)
+{
+ char *localname, *cont_str;
+ int localname_len, cont_len;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ return;
+ }
+
+ phar_add_file(&(phar_obj->arc.archive), localname, localname_len, cont_str, cont_len, NULL TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto string Phar::getStub()
+ * Returns the stub at the head of a phar archive as a string.
+ */
+PHP_METHOD(Phar, getStub)
+{
+ size_t len;
+ char *buf;
+ php_stream *fp;
+ php_stream_filter *filter = NULL;
+ phar_entry_info *stub;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) {
+
+ if (SUCCESS == zend_hash_find(&(phar_obj->arc.archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1, (void **)&stub)) {
+ if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ fp = phar_obj->arc.archive->fp;
+ } else {
+ if (!(fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to open phar \"%s\"", phar_obj->arc.archive->fname);
+ return;
+ }
+ if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
+ char *filter_name;
+
+ if ((filter_name = phar_decompress_filter(stub, 0)) != NULL) {
+ filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+ } else {
+ filter = NULL;
+ }
+ if (!filter) {
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->arc.archive->fname, phar_decompress_filter(stub, 1));
+ return;
+ }
+ php_stream_filter_append(&fp->readfilters, filter);
+ }
+ }
+
+ if (!fp) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Unable to read stub");
+ return;
+ }
+
+ php_stream_seek(fp, stub->offset_abs, SEEK_SET);
+ len = stub->uncompressed_filesize;
+ goto carry_on;
+ } else {
+ RETURN_STRINGL("", 0, 1);
+ }
+ }
+ len = phar_obj->arc.archive->halt_offset;
+
+ if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew) {
+ fp = phar_obj->arc.archive->fp;
+ } else {
+ fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
+ }
+
+ if (!fp) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Unable to read stub");
+ return;
+ }
+
+ php_stream_rewind(fp);
+carry_on:
+ buf = safe_emalloc(len, 1, 1);
+
+ if (len != php_stream_read(fp, buf, len)) {
+ if (fp != phar_obj->arc.archive->fp) {
+ php_stream_close(fp);
+ }
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Unable to read stub");
+ efree(buf);
+ return;
+ }
+
+ if (filter) {
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ }
+
+ if (fp != phar_obj->arc.archive->fp) {
+ php_stream_close(fp);
+ }
+
+ buf[len] = '\0';
+ RETURN_STRINGL(buf, len, 0);
+}
+/* }}}*/
+
+/* {{{ proto int Phar::hasMetaData()
+ * Returns TRUE if the phar has global metadata, FALSE otherwise.
+ */
+PHP_METHOD(Phar, hasMetadata)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ RETURN_BOOL(phar_obj->arc.archive->metadata != NULL);
+}
+/* }}} */
+
+/* {{{ proto int Phar::getMetaData()
+ * Returns the global metadata of the phar
+ */
+PHP_METHOD(Phar, getMetadata)
+{
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->metadata) {
+ if (phar_obj->arc.archive->is_persistent) {
+ zval *ret;
+ char *buf = estrndup((char *) phar_obj->arc.archive->metadata, phar_obj->arc.archive->metadata_len);
+ /* assume success, we would have failed before */
+ phar_parse_metadata(&buf, &ret, phar_obj->arc.archive->metadata_len TSRMLS_CC);
+ efree(buf);
+ RETURN_ZVAL(ret, 0, 1);
+ }
+ RETURN_ZVAL(phar_obj->arc.archive->metadata, 1, 0);
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::setMetaData(mixed $metadata)
+ * Sets the global metadata of the phar
+ */
+PHP_METHOD(Phar, setMetadata)
+{
+ char *error;
+ zval *metadata;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
+ return;
+ }
+
+ if (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar_obj->arc.archive->fname);
+ return;
+ }
+ if (phar_obj->arc.archive->metadata) {
+ zval_ptr_dtor(&phar_obj->arc.archive->metadata);
+ phar_obj->arc.archive->metadata = NULL;
+ }
+
+ MAKE_STD_ZVAL(phar_obj->arc.archive->metadata);
+ ZVAL_ZVAL(phar_obj->arc.archive->metadata, metadata, 1, 0);
+ phar_obj->arc.archive->is_modified = 1;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+}
+/* }}} */
+
+/* {{{ proto int Phar::delMetadata()
+ * Deletes the global metadata of the phar
+ */
+PHP_METHOD(Phar, delMetadata)
+{
+ char *error;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (phar_obj->arc.archive->metadata) {
+ zval_ptr_dtor(&phar_obj->arc.archive->metadata);
+ phar_obj->arc.archive->metadata = NULL;
+ phar_obj->arc.archive->is_modified = 1;
+ phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ RETURN_FALSE;
+ } else {
+ RETURN_TRUE;
+ }
+
+ } else {
+ RETURN_TRUE;
+ }
+}
+/* }}} */
+#if PHP_API_VERSION < 20100412
+#define PHAR_OPENBASEDIR_CHECKPATH(filename) \
+ (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)
+#else
+#define PHAR_OPENBASEDIR_CHECKPATH(filename) \
+ php_check_open_basedir(filename TSRMLS_CC)
+#endif
+
+static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error TSRMLS_DC) /* {{{ */
+{
+ php_stream_statbuf ssb;
+ int len;
+ php_stream *fp;
+ char *fullpath;
+ const char *slash;
+ mode_t mode;
+
+ if (entry->is_mounted) {
+ /* silently ignore mounted entries */
+ return SUCCESS;
+ }
+
+ if (entry->filename_len >= sizeof(".phar")-1 && !memcmp(entry->filename, ".phar", sizeof(".phar")-1)) {
+ return SUCCESS;
+ }
+
+ len = spprintf(&fullpath, 0, "%s/%s", dest, entry->filename);
+
+ if (len >= MAXPATHLEN) {
+ char *tmp;
+ /* truncate for error message */
+ fullpath[50] = '\0';
+ if (entry->filename_len > 50) {
+ tmp = estrndup(entry->filename, 50);
+ spprintf(error, 4096, "Cannot extract \"%s...\" to \"%s...\", extracted filename is too long for filesystem", tmp, fullpath);
+ efree(tmp);
+ } else {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s...\", extracted filename is too long for filesystem", entry->filename, fullpath);
+ }
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ if (!len) {
+ spprintf(error, 4096, "Cannot extract \"%s\", internal error", entry->filename);
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ if (PHAR_OPENBASEDIR_CHECKPATH(fullpath)) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", openbasedir/safe mode restrictions in effect", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ /* let see if the path already exists */
+ if (!overwrite && SUCCESS == php_stream_stat_path(fullpath, &ssb)) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", path already exists", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ /* perform dirname */
+ slash = zend_memrchr(entry->filename, '/', entry->filename_len);
+
+ if (slash) {
+ fullpath[dest_len + (slash - entry->filename) + 1] = '\0';
+ } else {
+ fullpath[dest_len] = '\0';
+ }
+
+ if (FAILURE == php_stream_stat_path(fullpath, &ssb)) {
+ if (entry->is_dir) {
+ if (!php_stream_mkdir(fullpath, entry->flags & PHAR_ENT_PERM_MASK, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
+ spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+ } else {
+ if (!php_stream_mkdir(fullpath, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
+ spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+ }
+ }
+
+ if (slash) {
+ fullpath[dest_len + (slash - entry->filename) + 1] = '/';
+ } else {
+ fullpath[dest_len] = '/';
+ }
+
+ /* it is a standalone directory, job done */
+ if (entry->is_dir) {
+ efree(fullpath);
+ return SUCCESS;
+ }
+
+#if PHP_API_VERSION < 20100412
+ fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
+#else
+ fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
+#endif
+
+ if (!fp) {
+ spprintf(error, 4096, "Cannot extract \"%s\", could not open for writing \"%s\"", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ if (!phar_get_efp(entry, 0 TSRMLS_CC)) {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", entry->filename, fullpath, *error);
+ } else {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer", entry->filename, fullpath);
+ }
+ efree(fullpath);
+ php_stream_close(fp);
+ return FAILURE;
+ }
+ }
+
+ if (FAILURE == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to seek internal file pointer", entry->filename, fullpath);
+ efree(fullpath);
+ php_stream_close(fp);
+ return FAILURE;
+ }
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", entry->filename, fullpath);
+ efree(fullpath);
+ php_stream_close(fp);
+ return FAILURE;
+ }
+
+ php_stream_close(fp);
+ mode = (mode_t) entry->flags & PHAR_ENT_PERM_MASK;
+
+ if (FAILURE == VCWD_CHMOD(fullpath, mode)) {
+ spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", setting file permissions failed", entry->filename, fullpath);
+ efree(fullpath);
+ return FAILURE;
+ }
+
+ efree(fullpath);
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ proto bool Phar::extractTo(string pathto[[, mixed files], bool overwrite])
+ * Extract one or more file from a phar archive, optionally overwriting existing files
+ */
+PHP_METHOD(Phar, extractTo)
+{
+ char *error = NULL;
+ php_stream *fp;
+ php_stream_statbuf ssb;
+ phar_entry_info *entry;
+ char *pathto, *filename, *actual;
+ int pathto_len, filename_len;
+ int ret, i;
+ int nelems;
+ zval *zval_files = NULL;
+ zend_bool overwrite = 0;
+
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ return;
+ }
+
+ fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual);
+
+ if (!fp) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ "Invalid argument, %s cannot be found", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ efree(actual);
+ php_stream_close(fp);
+
+ if (pathto_len < 1) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ "Invalid argument, extraction path must be non-zero length");
+ return;
+ }
+
+ if (pathto_len >= MAXPATHLEN) {
+ char *tmp = estrndup(pathto, 50);
+ /* truncate for error message */
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp);
+ efree(tmp);
+ return;
+ }
+
+ if (php_stream_stat_path(pathto, &ssb) < 0) {
+ ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);
+ if (!ret) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Unable to create path \"%s\" for extraction", pathto);
+ return;
+ }
+ } else if (!(ssb.sb.st_mode & S_IFDIR)) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Unable to use path \"%s\" for extraction, it is a file, must be a directory", pathto);
+ return;
+ }
+
+ if (zval_files) {
+ switch (Z_TYPE_P(zval_files)) {
+ case IS_NULL:
+ goto all_files;
+#if PHP_VERSION_ID >= 60000
+ case IS_UNICODE:
+ zval_unicode_to_string(zval_files TSRMLS_CC);
+ /* break intentionally omitted */
+#endif
+ case IS_STRING:
+ filename = Z_STRVAL_P(zval_files);
+ filename_len = Z_STRLEN_P(zval_files);
+ break;
+ case IS_ARRAY:
+ nelems = zend_hash_num_elements(Z_ARRVAL_P(zval_files));
+ if (nelems == 0 ) {
+ RETURN_FALSE;
+ }
+ for (i = 0; i < nelems; i++) {
+ zval **zval_file;
+ if (zend_hash_index_find(Z_ARRVAL_P(zval_files), i, (void **) &zval_file) == SUCCESS) {
+ switch (Z_TYPE_PP(zval_file)) {
+#if PHP_VERSION_ID >= 60000
+ case IS_UNICODE:
+ zval_unicode_to_string(*(zval_file) TSRMLS_CC);
+ /* break intentionally omitted */
+#endif
+ case IS_STRING:
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ "Invalid argument, array of filenames to extract contains non-string value");
+ return;
+ }
+ if (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), (void **)&entry)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", Z_STRVAL_PP(zval_file), phar_obj->arc.archive->fname);
+ }
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ "Extraction from phar \"%s\" failed: %s", phar_obj->arc.archive->fname, error);
+ efree(error);
+ return;
+ }
+ }
+ }
+ RETURN_TRUE;
+ default:
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+ "Invalid argument, expected a filename (string) or array of filenames");
+ return;
+ }
+
+ if (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, filename, filename_len, (void **)&entry)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ "Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", filename, phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ "Extraction from phar \"%s\" failed: %s", phar_obj->arc.archive->fname, error);
+ efree(error);
+ return;
+ }
+ } else {
+ phar_archive_data *phar;
+all_files:
+ phar = phar_obj->arc.archive;
+ /* Extract all files */
+ if (!zend_hash_num_elements(&(phar->manifest))) {
+ RETURN_TRUE;
+ }
+
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
+ zend_hash_move_forward(&phar->manifest)) {
+
+ if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
+ continue;
+ }
+
+ if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
+ "Extraction from phar \"%s\" failed: %s", phar->fname, error);
+ efree(error);
+ return;
+ }
+ }
+ }
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto void PharFileInfo::__construct(string entry)
+ * Construct a Phar entry object
+ */
+PHP_METHOD(PharFileInfo, __construct)
+{
+ char *fname, *arch, *entry, *error;
+ int fname_len, arch_len, entry_len;
+ phar_entry_object *entry_obj;
+ phar_entry_info *entry_info;
+ phar_archive_data *phar_data;
+ zval *zobj = getThis(), arg1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
+ return;
+ }
+
+ entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (entry_obj->ent.entry) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
+ return;
+ }
+
+ if (fname_len < 7 || memcmp(fname, "phar://", 7) || phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "'%s' is not a valid phar archive URL (must have at least phar://filename.phar)", fname);
+ return;
+ }
+
+ if (phar_open_from_filename(arch, arch_len, NULL, 0, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
+ efree(arch);
+ efree(entry);
+ if (error) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Cannot open phar file '%s': %s", fname, error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Cannot open phar file '%s'", fname);
+ }
+ return;
+ }
+
+ if ((entry_info = phar_get_entry_info_dir(phar_data, entry, entry_len, 1, &error, 1 TSRMLS_CC)) == NULL) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
+ "Cannot access phar file entry '%s' in archive '%s'%s%s", entry, arch, error ? ", " : "", error ? error : "");
+ efree(arch);
+ efree(entry);
+ return;
+ }
+
+ efree(arch);
+ efree(entry);
+
+ entry_obj->ent.entry = entry_info;
+
+ INIT_PZVAL(&arg1);
+ ZVAL_STRINGL(&arg1, fname, fname_len, 0);
+
+ zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj),
+ &spl_ce_SplFileInfo->constructor, "__construct", NULL, &arg1);
+}
+/* }}} */
+
+#define PHAR_ENTRY_OBJECT() \
+ phar_entry_object *entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
+ if (!entry_obj->ent.entry) { \
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Cannot call method on an uninitialized PharFileInfo object"); \
+ return; \
+ }
+
+/* {{{ proto void PharFileInfo::__destruct()
+ * clean up directory-based entry objects
+ */
+PHP_METHOD(PharFileInfo, __destruct)
+{
+ phar_entry_object *entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
+
+ if (entry_obj->ent.entry && entry_obj->ent.entry->is_temp_dir) {
+ if (entry_obj->ent.entry->filename) {
+ efree(entry_obj->ent.entry->filename);
+ entry_obj->ent.entry->filename = NULL;
+ }
+
+ efree(entry_obj->ent.entry);
+ entry_obj->ent.entry = NULL;
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::getCompressedSize()
+ * Returns the compressed size
+ */
+PHP_METHOD(PharFileInfo, getCompressedSize)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_LONG(entry_obj->ent.entry->compressed_filesize);
+}
+/* }}} */
+
+/* {{{ proto bool PharFileInfo::isCompressed([int compression_type])
+ * Returns whether the entry is compressed, and whether it is compressed with Phar::GZ or Phar::BZ2 if specified
+ */
+PHP_METHOD(PharFileInfo, isCompressed)
+{
+ /* a number that is not Phar::GZ or Phar::BZ2 */
+ long method = 9021976;
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ return;
+ }
+
+ switch (method) {
+ case 9021976:
+ RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK);
+ case PHAR_ENT_COMPRESSED_GZ:
+ RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ);
+ case PHAR_ENT_COMPRESSED_BZ2:
+ RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2);
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Unknown compression type specified"); \
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::getCRC32()
+ * Returns CRC32 code or throws an exception if not CRC checked
+ */
+PHP_METHOD(PharFileInfo, getCRC32)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry is a directory, does not have a CRC"); \
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_crc_checked) {
+ RETURN_LONG(entry_obj->ent.entry->crc32);
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry was not CRC checked"); \
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::isCRCChecked()
+ * Returns whether file entry is CRC checked
+ */
+PHP_METHOD(PharFileInfo, isCRCChecked)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_BOOL(entry_obj->ent.entry->is_crc_checked);
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::getPharFlags()
+ * Returns the Phar file entry flags
+ */
+PHP_METHOD(PharFileInfo, getPharFlags)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_LONG(entry_obj->ent.entry->flags & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK));
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::chmod()
+ * set the file permissions for the Phar. This only allows setting execution bit, read/write
+ */
+PHP_METHOD(PharFileInfo, chmod)
+{
+ char *error;
+ long perms;
+ PHAR_ENTRY_OBJECT();
+
+ if (entry_obj->ent.entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->ent.entry->filename); \
+ return;
+ }
+
+ if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->ent.entry->phar;
+
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ return;
+ }
+ /* re-populate after copy-on-write */
+ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ }
+ /* clear permissions */
+ entry_obj->ent.entry->flags &= ~PHAR_ENT_PERM_MASK;
+ perms &= 0777;
+ entry_obj->ent.entry->flags |= perms;
+ entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
+ entry_obj->ent.entry->phar->is_modified = 1;
+ entry_obj->ent.entry->is_modified = 1;
+
+ /* hackish cache in php_stat needs to be cleared */
+ /* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */
+ if (BG(CurrentLStatFile)) {
+ efree(BG(CurrentLStatFile));
+ }
+
+ if (BG(CurrentStatFile)) {
+ efree(BG(CurrentStatFile));
+ }
+
+ BG(CurrentLStatFile) = NULL;
+ BG(CurrentStatFile) = NULL;
+ phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::hasMetaData()
+ * Returns the metadata of the entry
+ */
+PHP_METHOD(PharFileInfo, hasMetadata)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_BOOL(entry_obj->ent.entry->metadata != NULL);
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::getMetaData()
+ * Returns the metadata of the entry
+ */
+PHP_METHOD(PharFileInfo, getMetadata)
+{
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->metadata) {
+ if (entry_obj->ent.entry->is_persistent) {
+ zval *ret;
+ char *buf = estrndup((char *) entry_obj->ent.entry->metadata, entry_obj->ent.entry->metadata_len);
+ /* assume success, we would have failed before */
+ phar_parse_metadata(&buf, &ret, entry_obj->ent.entry->metadata_len TSRMLS_CC);
+ efree(buf);
+ RETURN_ZVAL(ret, 0, 1);
+ }
+ RETURN_ZVAL(entry_obj->ent.entry->metadata, 1, 0);
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::setMetaData(mixed $metadata)
+ * Sets the metadata of the entry
+ */
+PHP_METHOD(PharFileInfo, setMetadata)
+{
+ char *error;
+ zval *metadata;
+
+ PHAR_ENTRY_OBJECT();
+
+ if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry is a temporary directory (not an actual entry in the archive), cannot set metadata"); \
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->ent.entry->phar;
+
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ return;
+ }
+ /* re-populate after copy-on-write */
+ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ }
+ if (entry_obj->ent.entry->metadata) {
+ zval_ptr_dtor(&entry_obj->ent.entry->metadata);
+ entry_obj->ent.entry->metadata = NULL;
+ }
+
+ MAKE_STD_ZVAL(entry_obj->ent.entry->metadata);
+ ZVAL_ZVAL(entry_obj->ent.entry->metadata, metadata, 1, 0);
+
+ entry_obj->ent.entry->is_modified = 1;
+ entry_obj->ent.entry->phar->is_modified = 1;
+ phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool PharFileInfo::delMetaData()
+ * Deletes the metadata of the entry
+ */
+PHP_METHOD(PharFileInfo, delMetadata)
+{
+ char *error;
+
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by the php.ini setting phar.readonly");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_temp_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry is a temporary directory (not an actual entry in the archive), cannot delete metadata"); \
+ return;
+ }
+
+ if (entry_obj->ent.entry->metadata) {
+ if (entry_obj->ent.entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->ent.entry->phar;
+
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ return;
+ }
+ /* re-populate after copy-on-write */
+ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ }
+ zval_ptr_dtor(&entry_obj->ent.entry->metadata);
+ entry_obj->ent.entry->metadata = NULL;
+ entry_obj->ent.entry->is_modified = 1;
+ entry_obj->ent.entry->phar->is_modified = 1;
+
+ phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ RETURN_FALSE;
+ } else {
+ RETURN_TRUE;
+ }
+
+ } else {
+ RETURN_TRUE;
+ }
+}
+/* }}} */
+
+/* {{{ proto string PharFileInfo::getContent()
+ * return the complete file contents of the entry (like file_get_contents)
+ */
+PHP_METHOD(PharFileInfo, getContent)
+{
+ char *error;
+ php_stream *fp;
+ phar_entry_info *link;
+
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ return;
+ }
+
+ link = phar_get_link_source(entry_obj->ent.entry TSRMLS_CC);
+
+ if (!link) {
+ link = entry_obj->ent.entry;
+ }
+
+ if (SUCCESS != phar_open_entry_fp(link, &error, 0 TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ efree(error);
+ return;
+ }
+
+ if (!(fp = phar_get_efp(link, 0 TSRMLS_CC))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ return;
+ }
+
+ phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC);
+ Z_TYPE_P(return_value) = IS_STRING;
+ Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
+
+ if (!Z_STRVAL_P(return_value)) {
+ Z_STRVAL_P(return_value) = estrndup("", 0);
+ }
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::compress(int compression_type)
+ * Instructs the Phar class to compress the current file using zlib or bzip2 compression
+ */
+PHP_METHOD(PharFileInfo, compress)
+{
+ long method;
+ char *error;
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_tar) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with Gzip compression, not possible with tar-based phar archives");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry is a directory, cannot set compression"); \
+ return;
+ }
+
+ if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar is readonly, cannot change compression");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress deleted file");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->ent.entry->phar;
+
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ return;
+ }
+ /* re-populate after copy-on-write */
+ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ }
+ switch (method) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ RETURN_TRUE;
+ }
+
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
+ return;
+ }
+
+ /* decompress this file indirectly */
+ if (SUCCESS != phar_open_entry_fp(entry_obj->ent.entry, &error, 1 TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ efree(error);
+ return;
+ }
+ }
+
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with gzip compression, zlib extension is not enabled");
+ return;
+ }
+
+ entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
+ entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_GZ;
+ break;
+ case PHAR_ENT_COMPRESSED_BZ2:
+ if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
+ RETURN_TRUE;
+ }
+
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
+ if (!PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
+ return;
+ }
+
+ /* decompress this file indirectly */
+ if (SUCCESS != phar_open_entry_fp(entry_obj->ent.entry, &error, 1 TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
+ efree(error);
+ return;
+ }
+ }
+
+ if (!PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with bzip2 compression, bz2 extension is not enabled");
+ return;
+ }
+ entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
+ entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Unknown compression type specified"); \
+ }
+
+ entry_obj->ent.entry->phar->is_modified = 1;
+ entry_obj->ent.entry->is_modified = 1;
+ phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int PharFileInfo::decompress()
+ * Instructs the Phar class to decompress the current file
+ */
+PHP_METHOD(PharFileInfo, decompress)
+{
+ char *error;
+ PHAR_ENTRY_OBJECT();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_dir) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
+ "Phar entry is a directory, cannot set compression"); \
+ return;
+ }
+
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
+ RETURN_TRUE;
+ }
+
+ if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Phar is readonly, cannot decompress");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_deleted) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress deleted file");
+ return;
+ }
+
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot decompress Gzip-compressed file, zlib extension is not enabled");
+ return;
+ }
+
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot decompress Bzip2-compressed file, bz2 extension is not enabled");
+ return;
+ }
+
+ if (entry_obj->ent.entry->is_persistent) {
+ phar_archive_data *phar = entry_obj->ent.entry->phar;
+
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
+ return;
+ }
+ /* re-populate after copy-on-write */
+ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry);
+ }
+ if (!entry_obj->ent.entry->fp) {
+ if (FAILURE == phar_open_archive_fp(entry_obj->ent.entry->phar TSRMLS_CC)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
+ return;
+ }
+ entry_obj->ent.entry->fp_type = PHAR_FP;
+ }
+
+ entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags;
+ entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ entry_obj->ent.entry->phar->is_modified = 1;
+ entry_obj->ent.entry->is_modified = 1;
+ phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC);
+
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ RETURN_TRUE;
+}
+/* }}} */
+
+#endif /* HAVE_SPL */
+
+/* {{{ phar methods */
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(0, alias)
+ ZEND_ARG_INFO(0, fileformat)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_createDS, 0, 0, 0)
+ ZEND_ARG_INFO(0, index)
+ ZEND_ARG_INFO(0, webindex)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_cancompress, 0, 0, 0)
+ ZEND_ARG_INFO(0, method)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isvalidpharfilename, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, executable)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_loadPhar, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, alias)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mapPhar, 0, 0, 0)
+ ZEND_ARG_INFO(0, alias)
+ ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mount, 0, 0, 2)
+ ZEND_ARG_INFO(0, inphar)
+ ZEND_ARG_INFO(0, externalfile)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mungServer, 0, 0, 1)
+ ZEND_ARG_INFO(0, munglist)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0)
+ ZEND_ARG_INFO(0, alias)
+ ZEND_ARG_INFO(0, index)
+ ZEND_ARG_INFO(0, f404)
+ ZEND_ARG_INFO(0, mimetypes)
+ ZEND_ARG_INFO(0, rewrites)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1)
+ ZEND_ARG_INFO(0, retphar)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_ua, 0, 0, 1)
+ ZEND_ARG_INFO(0, archive)
+ZEND_END_ARG_INFO()
+
+#if HAVE_SPL
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_build, 0, 0, 1)
+ ZEND_ARG_INFO(0, iterator)
+ ZEND_ARG_INFO(0, base_directory)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_conv, 0, 0, 0)
+ ZEND_ARG_INFO(0, format)
+ ZEND_ARG_INFO(0, compression_type)
+ ZEND_ARG_INFO(0, file_ext)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comps, 0, 0, 1)
+ ZEND_ARG_INFO(0, compression_type)
+ ZEND_ARG_INFO(0, file_ext)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_decomp, 0, 0, 0)
+ ZEND_ARG_INFO(0, file_ext)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comp, 0, 0, 1)
+ ZEND_ARG_INFO(0, compression_type)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_compo, 0, 0, 0)
+ ZEND_ARG_INFO(0, compression_type)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_copy, 0, 0, 2)
+ ZEND_ARG_INFO(0, newfile)
+ ZEND_ARG_INFO(0, oldfile)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_delete, 0, 0, 1)
+ ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromdir, 0, 0, 1)
+ ZEND_ARG_INFO(0, base_dir)
+ ZEND_ARG_INFO(0, regex)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetExists, 0, 0, 1)
+ ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetSet, 0, 0, 2)
+ ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setAlias, 0, 0, 1)
+ ZEND_ARG_INFO(0, alias)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setMetadata, 0, 0, 1)
+ ZEND_ARG_INFO(0, metadata)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setSigAlgo, 0, 0, 1)
+ ZEND_ARG_INFO(0, algorithm)
+ ZEND_ARG_INFO(0, privatekey)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setStub, 0, 0, 1)
+ ZEND_ARG_INFO(0, newstub)
+ ZEND_ARG_INFO(0, maxlen)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_emptydir, 0, 0, 0)
+ ZEND_ARG_INFO(0, dirname)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_extract, 0, 0, 1)
+ ZEND_ARG_INFO(0, pathto)
+ ZEND_ARG_INFO(0, files)
+ ZEND_ARG_INFO(0, overwrite)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_addfile, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, localname)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromstring, 0, 0, 1)
+ ZEND_ARG_INFO(0, localname)
+ ZEND_ARG_INFO(0, contents)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isff, 0, 0, 1)
+ ZEND_ARG_INFO(0, fileformat)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO(arginfo_phar__void, 0)
+ZEND_END_ARG_INFO()
+
+
+#endif /* HAVE_SPL */
+
+zend_function_entry php_archive_methods[] = {
+#if !HAVE_SPL
+ PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PRIVATE)
+#else
+ PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addFile, arginfo_phar_addfile, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addFromString, arginfo_phar_fromstring, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, buildFromDirectory, arginfo_phar_fromdir, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, buildFromIterator, arginfo_phar_build, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, compressFiles, arginfo_phar_comp, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, decompressFiles, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, compress, arginfo_phar_comps, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, decompress, arginfo_phar_decomp, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, convertToExecutable, arginfo_phar_conv, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, convertToData, arginfo_phar_conv, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, copy, arginfo_phar_copy, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, count, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, delete, arginfo_phar_delete, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, extractTo, arginfo_phar_extract, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getAlias, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getPath, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getModified, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getSignature, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getStub, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, getVersion, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, isBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, isCompressed, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, isFileFormat, arginfo_phar_isff, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, isWritable, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, offsetUnset, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, setAlias, arginfo_phar_setAlias, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, setDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, setSignatureAlgorithm, arginfo_phar_setSigAlgo, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, startBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, stopBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
+#endif
+ /* static member functions */
+ PHP_ME(Phar, apiVersion, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, canCompress, arginfo_phar_cancompress, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, canWrite, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, createDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, getSupportedCompression,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, getSupportedSignatures,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, interceptFileFuncs, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, isValidPharFilename, arginfo_phar_isvalidpharfilename, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, mount, arginfo_phar_mount, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, unlinkArchive, arginfo_phar_ua, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_FE_END
+};
+
+#if HAVE_SPL
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ZEND_END_ARG_INFO()
+
+PHAR_ARG_INFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_entry_chmod, 0, 0, 1)
+ ZEND_ARG_INFO(0, perms)
+ZEND_END_ARG_INFO()
+
+zend_function_entry php_entry_methods[] = {
+ PHP_ME(PharFileInfo, __construct, arginfo_entry___construct, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, chmod, arginfo_entry_chmod, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, compress, arginfo_phar_comp, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, decompress, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, getCompressedSize, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, getCRC32, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, getContent, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, getPharFlags, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, isCompressed, arginfo_phar_compo, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, isCRCChecked, arginfo_phar__void, ZEND_ACC_PUBLIC)
+ PHP_ME(PharFileInfo, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
+#endif /* HAVE_SPL */
+
+zend_function_entry phar_exception_methods[] = {
+ PHP_FE_END
+};
+/* }}} */
+
+#define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \
+ zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+
+#if PHP_VERSION_ID < 50200
+# define phar_exception_get_default() zend_exception_get_default()
+#else
+# define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
+#endif
+
+void phar_object_init(TSRMLS_D) /* {{{ */
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
+ phar_ce_PharException = zend_register_internal_class_ex(&ce, phar_exception_get_default(), NULL TSRMLS_CC);
+
+#if HAVE_SPL
+ INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
+ phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator, NULL TSRMLS_CC);
+
+ zend_class_implements(phar_ce_archive TSRMLS_CC, 2, spl_ce_Countable, zend_ce_arrayaccess);
+
+ INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
+ phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator, NULL TSRMLS_CC);
+
+ zend_class_implements(phar_ce_data TSRMLS_CC, 2, spl_ce_Countable, zend_ce_arrayaccess);
+
+ INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
+ phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo, NULL TSRMLS_CC);
+#else
+ INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
+ phar_ce_archive = zend_register_internal_class(&ce TSRMLS_CC);
+ phar_ce_archive->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+ INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
+ phar_ce_data = zend_register_internal_class(&ce TSRMLS_CC);
+ phar_ce_data->ce_flags |= ZEND_ACC_FINAL_CLASS;
+#endif
+
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "NONE", PHAR_ENT_COMPRESSED_NONE)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHAR", PHAR_FORMAT_PHAR)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "TAR", PHAR_FORMAT_TAR)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "ZIP", PHAR_FORMAT_ZIP)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "COMPRESSED", PHAR_ENT_COMPRESSION_MASK)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHP", PHAR_MIME_PHP)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHPS", PHAR_MIME_PHPS)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "MD5", PHAR_SIG_MD5)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "OPENSSL", PHAR_SIG_OPENSSL)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA1", PHAR_SIG_SHA1)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA256", PHAR_SIG_SHA256)
+ REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA512", PHAR_SIG_SHA512)
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c
new file mode 100644
index 0000000..8275c9c
--- /dev/null
+++ b/ext/phar/phar_path_check.c
@@ -0,0 +1,185 @@
+/* Generated by re2c 0.13.5 on Fri Feb 25 04:35:39 2011 */
+#line 1 "ext/phar/phar_path_check.re"
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2007-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "phar_internal.h"
+
+phar_path_check_result phar_path_check(char **s, int *len, const char **error)
+{
+ const unsigned char *p = (const unsigned char*)*s;
+ const unsigned char *m;
+
+ if (*len == 1 && *p == '.') {
+ *error = "current directory reference";
+ return pcr_err_curr_dir;
+ } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
+ *error = "upper directory reference";
+ return pcr_err_up_dir;
+ }
+
+#define YYCTYPE unsigned char
+#define YYCURSOR p
+#define YYLIMIT p+*len
+#define YYMARKER m
+#define YYFILL(n)
+
+loop:
+
+#line 47 "ext/phar/phar_path_check.c"
+{
+ YYCTYPE yych;
+
+ if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+ yych = *YYCURSOR;
+ if (yych <= '.') {
+ if (yych <= '\n') {
+ if (yych <= 0x00) goto yy13;
+ if (yych <= '\t') goto yy10;
+ goto yy12;
+ } else {
+ if (yych <= 0x19) goto yy10;
+ if (yych == '*') goto yy6;
+ goto yy15;
+ }
+ } else {
+ if (yych <= '?') {
+ if (yych <= '/') goto yy2;
+ if (yych <= '>') goto yy15;
+ goto yy8;
+ } else {
+ if (yych == '\\') goto yy4;
+ if (yych <= 0x7F) goto yy15;
+ goto yy10;
+ }
+ }
+yy2:
+ yych = *(YYMARKER = ++YYCURSOR);
+ if (yych <= '-') goto yy3;
+ if (yych <= '.') goto yy16;
+ if (yych <= '/') goto yy18;
+yy3:
+#line 93 "ext/phar/phar_path_check.re"
+ {
+ goto loop;
+ }
+#line 84 "ext/phar/phar_path_check.c"
+yy4:
+ ++YYCURSOR;
+#line 60 "ext/phar/phar_path_check.re"
+ {
+ *error = "back-slash";
+ return pcr_err_back_slash;
+ }
+#line 92 "ext/phar/phar_path_check.c"
+yy6:
+ ++YYCURSOR;
+#line 64 "ext/phar/phar_path_check.re"
+ {
+ *error = "star";
+ return pcr_err_star;
+ }
+#line 100 "ext/phar/phar_path_check.c"
+yy8:
+ ++YYCURSOR;
+#line 68 "ext/phar/phar_path_check.re"
+ {
+ if (**s == '/') {
+ (*s)++;
+ }
+ *len = (p - (const unsigned char*)*s) -1;
+ *error = NULL;
+ return pcr_use_query;
+ }
+#line 112 "ext/phar/phar_path_check.c"
+yy10:
+ ++YYCURSOR;
+yy11:
+#line 76 "ext/phar/phar_path_check.re"
+ {
+ *error ="illegal character";
+ return pcr_err_illegal_char;
+ }
+#line 121 "ext/phar/phar_path_check.c"
+yy12:
+ yych = *++YYCURSOR;
+ goto yy11;
+yy13:
+ ++YYCURSOR;
+#line 80 "ext/phar/phar_path_check.re"
+ {
+ if (**s == '/') {
+ (*s)++;
+ (*len)--;
+ }
+ if ((p - (const unsigned char*)*s) - 1 != *len)
+ {
+ *error ="illegal character";
+ return pcr_err_illegal_char;
+ }
+ *error = NULL;
+ return pcr_is_ok;
+ }
+#line 141 "ext/phar/phar_path_check.c"
+yy15:
+ yych = *++YYCURSOR;
+ goto yy3;
+yy16:
+ yych = *++YYCURSOR;
+ if (yych <= 0x00) goto yy21;
+ if (yych <= '-') goto yy17;
+ if (yych <= '.') goto yy20;
+ if (yych <= '/') goto yy21;
+yy17:
+ YYCURSOR = YYMARKER;
+ goto yy3;
+yy18:
+ ++YYCURSOR;
+#line 48 "ext/phar/phar_path_check.re"
+ {
+ *error = "double slash";
+ return pcr_err_double_slash;
+ }
+#line 161 "ext/phar/phar_path_check.c"
+yy20:
+ yych = *++YYCURSOR;
+ if (yych <= 0x00) goto yy23;
+ if (yych == '/') goto yy23;
+ goto yy17;
+yy21:
+ ++YYCURSOR;
+#line 56 "ext/phar/phar_path_check.re"
+ {
+ *error = "current directory reference";
+ return pcr_err_curr_dir;
+ }
+#line 174 "ext/phar/phar_path_check.c"
+yy23:
+ ++YYCURSOR;
+#line 52 "ext/phar/phar_path_check.re"
+ {
+ *error = "upper directory reference";
+ return pcr_err_up_dir;
+ }
+#line 182 "ext/phar/phar_path_check.c"
+}
+#line 96 "ext/phar/phar_path_check.re"
+
+}
diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re
new file mode 100644
index 0000000..e43b3f8
--- /dev/null
+++ b/ext/phar/phar_path_check.re
@@ -0,0 +1,97 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2007-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "phar_internal.h"
+
+phar_path_check_result phar_path_check(char **s, int *len, const char **error)
+{
+ const unsigned char *p = (const unsigned char*)*s;
+ const unsigned char *m;
+
+ if (*len == 1 && *p == '.') {
+ *error = "current directory reference";
+ return pcr_err_curr_dir;
+ } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
+ *error = "upper directory reference";
+ return pcr_err_up_dir;
+ }
+
+#define YYCTYPE unsigned char
+#define YYCURSOR p
+#define YYLIMIT p+*len
+#define YYMARKER m
+#define YYFILL(n)
+
+loop:
+/*!re2c
+END = "\x00";
+ILL = [\x01-\x19\x80-\xFF];
+EOS = "/" | END;
+ANY = .;
+"//" {
+ *error = "double slash";
+ return pcr_err_double_slash;
+ }
+"/.." EOS {
+ *error = "upper directory reference";
+ return pcr_err_up_dir;
+ }
+"/." EOS {
+ *error = "current directory reference";
+ return pcr_err_curr_dir;
+ }
+"\\" {
+ *error = "back-slash";
+ return pcr_err_back_slash;
+ }
+"*" {
+ *error = "star";
+ return pcr_err_star;
+ }
+"?" {
+ if (**s == '/') {
+ (*s)++;
+ }
+ *len = (p - (const unsigned char*)*s) -1;
+ *error = NULL;
+ return pcr_use_query;
+ }
+ILL {
+ *error ="illegal character";
+ return pcr_err_illegal_char;
+ }
+END {
+ if (**s == '/') {
+ (*s)++;
+ (*len)--;
+ }
+ if ((p - (const unsigned char*)*s) - 1 != *len)
+ {
+ *error ="illegal character";
+ return pcr_err_illegal_char;
+ }
+ *error = NULL;
+ return pcr_is_ok;
+ }
+ANY {
+ goto loop;
+ }
+*/
+}
diff --git a/ext/phar/pharzip.h b/ext/phar/pharzip.h
new file mode 100644
index 0000000..9c088d3
--- /dev/null
+++ b/ext/phar/pharzip.h
@@ -0,0 +1,243 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2006-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+typedef struct _phar_zip_file_header {
+ char signature[4]; /* local file header signature 4 bytes (0x04034b50) */
+ char zipversion[2]; /* version needed to extract 2 bytes */
+ char flags[2]; /* general purpose bit flag 2 bytes */
+ char compressed[2]; /* compression method 2 bytes */
+ char timestamp[2]; /* last mod file time 2 bytes */
+ char datestamp[2]; /* last mod file date 2 bytes */
+ char crc32[4]; /* crc-32 4 bytes */
+ char compsize[4]; /* compressed size 4 bytes */
+ char uncompsize[4]; /* uncompressed size 4 bytes */
+ char filename_len[2]; /* file name length 2 bytes */
+ char extra_len[2]; /* extra field length 2 bytes */
+/* file name (variable size) */
+/* extra field (variable size) */
+} phar_zip_file_header;
+
+/* unused in this release */
+typedef struct _phar_zip_file_datadesc {
+ char signature[4]; /* signature (optional) 4 bytes */
+ char crc32[4]; /* crc-32 4 bytes */
+ char compsize[4]; /* compressed size 4 bytes */
+ char uncompsize[4]; /* uncompressed size 4 bytes */
+} phar_zip_data_desc;
+
+/* unused in this release */
+typedef struct _phar_zip_file_datadesc_zip64 {
+ char crc32[4]; /* crc-32 4 bytes */
+ char compsize[4]; /* compressed size 8 bytes */
+ char compsize2[4];
+ char uncompsize[4]; /* uncompressed size 8 bytes */
+ char uncompsize2[4];
+} phar_zip_data_desc_zip64;
+
+typedef struct _phar_zip_archive_extra_data_record {
+ char signature[4]; /* archive extra data signature 4 bytes (0x08064b50) */
+ char len[4]; /* extra field length 4 bytes */
+/* extra field data (variable size) */
+} phar_zip_archive_extra_data_record;
+
+/* madeby/extractneeded value if bzip2 compression is used */
+#define PHAR_ZIP_BZIP2 "46"
+/* madeby/extractneeded value for other cases */
+#define PHAR_ZIP_NORM "20"
+
+#define PHAR_ZIP_FLAG_ENCRYPTED 0x0001
+/* data descriptor present for this file */
+#define PHAR_ZIP_FLAG_DATADESC 0x0008
+#define PHAR_ZIP_FLAG_UTF8 0x0400
+
+/*
+0 - The file is stored (no compression)
+1 - The file is Shrunk
+2 - The file is Reduced with compression factor 1
+3 - The file is Reduced with compression factor 2
+4 - The file is Reduced with compression factor 3
+5 - The file is Reduced with compression factor 4
+6 - The file is Imploded
+7 - Reserved for Tokenizing compression algorithm
+8 - The file is Deflated
+9 - Enhanced Deflating using Deflate64(tm)
+10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
+11 - Reserved by PKWARE
+12 - File is compressed using BZIP2 algorithm
+13 - Reserved by PKWARE
+14 - LZMA (EFS)
+15 - Reserved by PKWARE
+16 - Reserved by PKWARE
+17 - Reserved by PKWARE
+18 - File is compressed using IBM TERSE (new)
+19 - IBM LZ77 z Architecture (PFS)
+97 - WavPack compressed data
+98 - PPMd version I, Rev 1
+*/
+#define PHAR_ZIP_COMP_NONE 0
+#define PHAR_ZIP_COMP_DEFLATE 8
+#define PHAR_ZIP_COMP_BZIP2 12
+
+/*
+ -ASi Unix Extra Field:
+ ====================
+
+ The following is the layout of the ASi extra block for Unix. The
+ local-header and central-header versions are identical.
+ (Last Revision 19960916)
+
+ Value Size Description
+ ----- ---- -----------
+ (Unix3) 0x756e Short tag for this extra block type ("nu")
+ TSize Short total data size for this block
+ CRC Long CRC-32 of the remaining data
+ Mode Short file permissions
+ SizDev Long symlink'd size OR major/minor dev num
+ UID Short user ID
+ GID Short group ID
+ (var.) variable symbolic link filename
+
+ Mode is the standard Unix st_mode field from struct stat, containing
+ user/group/other permissions, setuid/setgid and symlink info, etc.
+
+ If Mode indicates that this file is a symbolic link, SizDev is the
+ size of the file to which the link points. Otherwise, if the file
+ is a device, SizDev contains the standard Unix st_rdev field from
+ struct stat (includes the major and minor numbers of the device).
+ SizDev is undefined in other cases.
+
+ If Mode indicates that the file is a symbolic link, the final field
+ will be the name of the file to which the link points. The file-
+ name length can be inferred from TSize.
+
+ [Note that TSize may incorrectly refer to the data size not counting
+ the CRC; i.e., it may be four bytes too small.]
+*/
+
+typedef struct _phar_zip_extra_field_header {
+ char tag[2];
+ char size[2];
+} phar_zip_extra_field_header;
+
+typedef struct _phar_zip_unix3 {
+ char tag[2]; /* 0x756e Short tag for this extra block type ("nu") */
+ char size[2]; /* TSize Short total data size for this block */
+ char crc32[4]; /* CRC Long CRC-32 of the remaining data */
+ char perms[2]; /* Mode Short file permissions */
+ char symlinksize[4]; /* SizDev Long symlink'd size OR major/minor dev num */
+ char uid[2]; /* UID Short user ID */
+ char gid[2]; /* GID Short group ID */
+/* (var.) variable symbolic link filename */
+} phar_zip_unix3;
+
+typedef struct _phar_zip_central_dir_file {
+ char signature[4]; /* central file header signature 4 bytes (0x02014b50) */
+ char madeby[2]; /* version made by 2 bytes */
+ char zipversion[2]; /* version needed to extract 2 bytes */
+ char flags[2]; /* general purpose bit flag 2 bytes */
+ char compressed[2]; /* compression method 2 bytes */
+ char timestamp[2]; /* last mod file time 2 bytes */
+ char datestamp[2]; /* last mod file date 2 bytes */
+ char crc32[4]; /* crc-32 4 bytes */
+ char compsize[4]; /* compressed size 4 bytes */
+ char uncompsize[4]; /* uncompressed size 4 bytes */
+ char filename_len[2]; /* file name length 2 bytes */
+ char extra_len[2]; /* extra field length 2 bytes */
+ char comment_len[2]; /* file comment length 2 bytes */
+ char disknumber[2]; /* disk number start 2 bytes */
+ char internal_atts[2]; /* internal file attributes 2 bytes */
+ char external_atts[4]; /* external file attributes 4 bytes */
+ char offset[4]; /* relative offset of local header 4 bytes */
+
+/* file name (variable size) */
+/* extra field (variable size) */
+/* file comment (variable size) */
+} phar_zip_central_dir_file;
+
+typedef struct _phar_zip_dir_signature {
+ char signature[4]; /* header signature 4 bytes (0x05054b50) */
+ char size[2]; /* size of data 2 bytes */
+} phar_zip_dir_signature;
+
+/* unused in this release */
+typedef struct _phar_zip64_dir_end {
+ char signature[4]; /* zip64 end of central dir
+ signature 4 bytes (0x06064b50) */
+ char size1[4]; /* size of zip64 end of central
+ directory record 8 bytes */
+ char size2[4];
+ char madeby[2]; /* version made by 2 bytes */
+ char extractneeded[2]; /* version needed to extract 2 bytes */
+ char disknum[4]; /* number of this disk 4 bytes */
+ char cdir_num[4]; /* number of the disk with the
+ start of the central directory 4 bytes */
+ char entries1[4]; /* total number of entries in the
+ central directory on this disk 8 bytes */
+ char entries2[4];
+ char entriestotal1[4]; /* total number of entries in the
+ central directory 8 bytes */
+ char entriestotal2[4];
+ char cdirsize1[4]; /* size of the central directory 8 bytes */
+ char cdirsize2[4];
+ char offset1[4]; /* offset of start of central
+ directory with respect to
+ the starting disk number 8 bytes */
+ char offset2[4];
+/* zip64 extensible data sector (variable size) */
+} phar_zip64_dir_end;
+
+/* unused in this release */
+typedef struct _phar_zip64_dir_locator {
+ char signature[4]; /* zip64 end of central dir locator
+ signature 4 bytes (0x07064b50) */
+ char disknum[4]; /* number of the disk with the
+ start of the zip64 end of
+ central directory 4 bytes */
+ char diroffset1[4]; /* relative offset of the zip64
+ end of central directory record 8 bytes */
+ char diroffset2[4];
+ char totaldisks[4]; /* total number of disks 4 bytes */
+} phar_zip64_dir_locator;
+
+typedef struct _phar_zip_dir_end {
+ char signature[4]; /* end of central dir signature 4 bytes (0x06054b50) */
+ char disknumber[2]; /* number of this disk 2 bytes */
+ char centraldisk[2]; /* number of the disk with the
+ start of the central directory 2 bytes */
+ char counthere[2]; /* total number of entries in the
+ central directory on this disk 2 bytes */
+ char count[2]; /* total number of entries in
+ the central directory 2 bytes */
+ char cdir_size[4]; /* size of the central directory 4 bytes */
+ char cdir_offset[4]; /* offset of start of central
+ directory with respect to
+ the starting disk number 4 bytes */
+ char comment_len[2]; /* .ZIP file comment length 2 bytes */
+/* .ZIP file comment (variable size) */
+} phar_zip_dir_end;
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
new file mode 100644
index 0000000..a6d7bff
--- /dev/null
+++ b/ext/phar/php_phar.h
@@ -0,0 +1,47 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_PHAR_H
+#define PHP_PHAR_H
+
+#define PHP_PHAR_VERSION "2.0.1"
+
+#include "ext/standard/basic_functions.h"
+extern zend_module_entry phar_module_entry;
+#define phpext_phar_ptr &phar_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_PHAR_API __declspec(dllexport)
+#else
+#define PHP_PHAR_API
+#endif
+
+#endif /* PHP_PHAR_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/shortarc.php b/ext/phar/shortarc.php
new file mode 100644
index 0000000..1bf3baa
--- /dev/null
+++ b/ext/phar/shortarc.php
@@ -0,0 +1,295 @@
+<?php
+
+$web = '000';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+ Phar::interceptFileFuncs();
+ set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+ Phar::webPhar(null, $web);
+ include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+ return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+ Extract_Phar::go(true);
+ $mimes = array(
+ 'phps' => 2,
+ 'c' => 'text/plain',
+ 'cc' => 'text/plain',
+ 'cpp' => 'text/plain',
+ 'c++' => 'text/plain',
+ 'dtd' => 'text/plain',
+ 'h' => 'text/plain',
+ 'log' => 'text/plain',
+ 'rng' => 'text/plain',
+ 'txt' => 'text/plain',
+ 'xsd' => 'text/plain',
+ 'php' => 1,
+ 'inc' => 1,
+ 'avi' => 'video/avi',
+ 'bmp' => 'image/bmp',
+ 'css' => 'text/css',
+ 'gif' => 'image/gif',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'htmls' => 'text/html',
+ 'ico' => 'image/x-ico',
+ 'jpe' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'js' => 'application/x-javascript',
+ 'midi' => 'audio/midi',
+ 'mid' => 'audio/midi',
+ 'mod' => 'audio/mod',
+ 'mov' => 'movie/quicktime',
+ 'mp3' => 'audio/mp3',
+ 'mpg' => 'video/mpeg',
+ 'mpeg' => 'video/mpeg',
+ 'pdf' => 'application/pdf',
+ 'png' => 'image/png',
+ 'swf' => 'application/shockwave-flash',
+ 'tif' => 'image/tiff',
+ 'tiff' => 'image/tiff',
+ 'wav' => 'audio/wav',
+ 'xbm' => 'image/xbm',
+ 'xml' => 'text/xml',
+ );
+
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Pragma: no-cache");
+
+ $basename = basename(__FILE__);
+ if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+ chdir(Extract_Phar::$temp);
+ include $web;
+ return;
+ }
+ $pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+ if (!$pt || $pt == '/') {
+ $pt = $web;
+ header('HTTP/1.1 301 Moved Permanently');
+ header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+ exit;
+ }
+ $a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+ if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+ header('HTTP/1.0 404 Not Found');
+ echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+ exit;
+ }
+ $b = pathinfo($a);
+ if (!isset($b['extension'])) {
+ header('Content-Type: text/plain');
+ header('Content-Length: ' . filesize($a));
+ readfile($a);
+ exit;
+ }
+ if (isset($mimes[$b['extension']])) {
+ if ($mimes[$b['extension']] === 1) {
+ include $a;
+ exit;
+ }
+ if ($mimes[$b['extension']] === 2) {
+ highlight_file($a);
+ exit;
+ }
+ header('Content-Type: ' .$mimes[$b['extension']]);
+ header('Content-Length: ' . filesize($a));
+ readfile($a);
+ exit;
+ }
+}
+
+class Extract_Phar
+{
+ static $temp;
+ static $origdir;
+ const GZ = 0x1000;
+ const BZ2 = 0x2000;
+ const MASK = 0x3000;
+ const START = 'index.php';
+ const LEN = XXXX;
+
+ static function go($return = false)
+ {
+ $fp = fopen(__FILE__, 'rb');
+ fseek($fp, self::LEN);
+ $L = unpack('V', $a = (binary)fread($fp, 4));
+ $m = (binary)'';
+
+ do {
+ $read = 8192;
+ if ($L[1] - strlen($m) < 8192) {
+ $read = $L[1] - strlen($m);
+ }
+ $last = (binary)fread($fp, $read);
+ $m .= $last;
+ } while (strlen($last) && strlen($m) < $L[1]);
+
+ if (strlen($m) < $L[1]) {
+ die('ERROR: manifest length read was "' .
+ strlen($m) .'" should be "' .
+ $L[1] . '"');
+ }
+
+ $info = self::_unpack($m);
+ $f = $info['c'];
+
+ if ($f & self::GZ) {
+ if (!function_exists('gzinflate')) {
+ die('Error: zlib extension is not enabled -' .
+ ' gzinflate() function needed for zlib-compressed .phars');
+ }
+ }
+
+ if ($f & self::BZ2) {
+ if (!function_exists('bzdecompress')) {
+ die('Error: bzip2 extension is not enabled -' .
+ ' bzdecompress() function needed for bz2-compressed .phars');
+ }
+ }
+
+ $temp = self::tmpdir();
+
+ if (!$temp || !is_writable($temp)) {
+ $sessionpath = session_save_path();
+ if (strpos ($sessionpath, ";") !== false)
+ $sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+ if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+ die('Could not locate temporary directory to extract phar');
+ }
+ $temp = $sessionpath;
+ }
+
+ $temp .= '/pharextract/'.basename(__FILE__, '.phar');
+ self::$temp = $temp;
+ self::$origdir = getcwd();
+ @mkdir($temp, 0777, true);
+ $temp = realpath($temp);
+
+ if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+ self::_removeTmpFiles($temp, getcwd());
+ @mkdir($temp, 0777, true);
+ @file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+ foreach ($info['m'] as $path => $file) {
+ $a = !file_exists(dirname($temp . '/' . $path));
+ @mkdir(dirname($temp . '/' . $path), 0777, true);
+ clearstatcache();
+
+ if ($path[strlen($path) - 1] == '/') {
+ @mkdir($temp . '/' . $path, 0777);
+ } else {
+ file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+ @chmod($temp . '/' . $path, 0666);
+ }
+ }
+ }
+
+ chdir($temp);
+
+ if (!$return) {
+ include self::START;
+ }
+ }
+
+ static function tmpdir()
+ {
+ if (strpos(PHP_OS, 'WIN') !== false) {
+ if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+ return $var;
+ }
+ if (is_dir('/temp') || mkdir('/temp')) {
+ return realpath('/temp');
+ }
+ return false;
+ }
+ if ($var = getenv('TMPDIR')) {
+ return $var;
+ }
+ return realpath('/tmp');
+ }
+
+ static function _unpack($m)
+ {
+ $info = unpack('V', substr($m, 0, 4));
+ // skip API version, phar flags, alias, metadata
+ $l = unpack('V', substr($m, 10, 4));
+ $m = substr($m, 14 + $l[1]);
+ $s = unpack('V', substr($m, 0, 4));
+ $o = 0;
+ $start = 4 + $s[1];
+ $ret['c'] = 0;
+
+ for ($i = 0; $i < $info[1]; $i++) {
+ // length of the file name
+ $len = unpack('V', substr($m, $start, 4));
+ $start += 4;
+ // file name
+ $savepath = substr($m, $start, $len[1]);
+ $start += $len[1];
+ // retrieve manifest data:
+ // 0 = size, 1 = timestamp, 2 = compressed size, 3 = crc32, 4 = flags
+ // 5 = metadata length
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+ $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+ & 0xffffffff);
+ $ret['m'][$savepath][7] = $o;
+ $o += $ret['m'][$savepath][2];
+ $start += 24 + $ret['m'][$savepath][5];
+ $ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+ }
+ return $ret;
+ }
+
+ static function extractFile($path, $entry, $fp)
+ {
+ $data = '';
+ $c = $entry[2];
+
+ while ($c) {
+ if ($c < 8192) {
+ $data .= @fread($fp, $c);
+ $c = 0;
+ } else {
+ $c -= 8192;
+ $data .= @fread($fp, 8192);
+ }
+ }
+
+ if ($entry[4] & self::GZ) {
+ $data = gzinflate($data);
+ } elseif ($entry[4] & self::BZ2) {
+ $data = bzdecompress($data);
+ }
+
+ if (strlen($data) != $entry[0]) {
+ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+ $stat[7] . ")");
+ }
+
+ if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+ die("Invalid internal .phar file (checksum error)");
+ }
+
+ return $data;
+ }
+
+ static function _removeTmpFiles($temp, $origdir)
+ {
+ chdir($temp);
+
+ foreach (glob('*') as $f) {
+ if (file_exists($f)) {
+ is_dir($f) ? @rmdir($f) : @unlink($f);
+ if (file_exists($f) && is_dir($f)) {
+ self::_removeTmpFiles($f, getcwd());
+ }
+ }
+ }
+
+ @rmdir($temp);
+ clearstatcache();
+ chdir($origdir);
+ }
+}
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
new file mode 100644
index 0000000..924138d
--- /dev/null
+++ b/ext/phar/stream.c
@@ -0,0 +1,1035 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar:// stream wrapper support |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#define PHAR_STREAM 1
+#include "phar_internal.h"
+#include "stream.h"
+#include "dirstream.h"
+
+php_stream_ops phar_ops = {
+ phar_stream_write, /* write */
+ phar_stream_read, /* read */
+ phar_stream_close, /* close */
+ phar_stream_flush, /* flush */
+ "phar stream",
+ phar_stream_seek, /* seek */
+ NULL, /* cast */
+ phar_stream_stat, /* stat */
+ NULL, /* set option */
+};
+
+php_stream_wrapper_ops phar_stream_wops = {
+ phar_wrapper_open_url,
+ NULL, /* phar_wrapper_close */
+ NULL, /* phar_wrapper_stat, */
+ phar_wrapper_stat, /* stat_url */
+ phar_wrapper_open_dir, /* opendir */
+ "phar",
+ phar_wrapper_unlink, /* unlink */
+ phar_wrapper_rename, /* rename */
+ phar_wrapper_mkdir, /* create directory */
+ phar_wrapper_rmdir, /* remove directory */
+};
+
+php_stream_wrapper php_stream_phar_wrapper = {
+ &phar_stream_wops,
+ NULL,
+ 0 /* is_url */
+};
+
+/**
+ * Open a phar file for streams API
+ */
+php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */
+{
+ php_url *resource;
+ char *arch = NULL, *entry = NULL, *error;
+ int arch_len, entry_len;
+
+ if (strlen(filename) < 7 || strncasecmp(filename, "phar://", 7)) {
+ return NULL;
+ }
+ if (mode[0] == 'a') {
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: open mode append not supported");
+ }
+ return NULL;
+ }
+ if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len, 2, (mode[0] == 'w' ? 2 : 0) TSRMLS_CC) == FAILURE) {
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ if (arch && !entry) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch);
+ arch = NULL;
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url or non-existent phar \"%s\"", filename);
+ }
+ }
+ return NULL;
+ }
+ resource = ecalloc(1, sizeof(php_url));
+ resource->scheme = estrndup("phar", 4);
+ resource->host = arch;
+
+ resource->path = entry;
+#if MBO_0
+ if (resource) {
+ fprintf(stderr, "Alias: %s\n", alias);
+ fprintf(stderr, "Scheme: %s\n", resource->scheme);
+/* fprintf(stderr, "User: %s\n", resource->user);*/
+/* fprintf(stderr, "Pass: %s\n", resource->pass ? "***" : NULL);*/
+ fprintf(stderr, "Host: %s\n", resource->host);
+/* fprintf(stderr, "Port: %d\n", resource->port);*/
+ fprintf(stderr, "Path: %s\n", resource->path);
+/* fprintf(stderr, "Query: %s\n", resource->query);*/
+/* fprintf(stderr, "Fragment: %s\n", resource->fragment);*/
+ }
+#endif
+ if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
+ phar_archive_data **pphar = NULL, *phar;
+
+ if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets && FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {
+ pphar = NULL;
+ }
+ if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");
+ }
+ php_url_free(resource);
+ return NULL;
+ }
+ if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, 0, options, &phar, &error TSRMLS_CC) == FAILURE)
+ {
+ if (error) {
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ }
+ efree(error);
+ }
+ php_url_free(resource);
+ return NULL;
+ }
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (error) {
+ spprintf(&error, 0, "Cannot open cached phar '%s' as writeable, copy on write failed", resource->host);
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ }
+ efree(error);
+ }
+ php_url_free(resource);
+ return NULL;
+ }
+ } else {
+ if (phar_open_from_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)
+ {
+ if (error) {
+ if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ }
+ efree(error);
+ }
+ php_url_free(resource);
+ return NULL;
+ }
+ }
+ return resource;
+}
+/* }}} */
+
+/**
+ * used for fopen('phar://...') and company
+ */
+static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ phar_entry_data *idata;
+ char *internal_file;
+ char *error;
+ HashTable *pharcontext;
+ php_url *resource = NULL;
+ php_stream *fpf;
+ zval **pzoption, *metadata;
+ uint host_len;
+
+ if ((resource = phar_parse_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) {
+ return NULL;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", path);
+ return NULL;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", path);
+ return NULL;
+ }
+
+ host_len = strlen(resource->host);
+ phar_request_initialize(TSRMLS_C);
+
+ /* strip leading "/" */
+ internal_file = estrdup(resource->path + 1);
+ if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
+ if (NULL == (idata = phar_get_or_create_entry_data(resource->host, host_len, internal_file, strlen(internal_file), mode, 0, &error, 1 TSRMLS_CC))) {
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ efree(error);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" could not be created in phar \"%s\"", internal_file, resource->host);
+ }
+ efree(internal_file);
+ php_url_free(resource);
+ return NULL;
+ }
+ if (error) {
+ efree(error);
+ }
+ fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
+ php_url_free(resource);
+ efree(internal_file);
+
+ if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
+ pharcontext = HASH_OF(*pzoption);
+ if (idata->internal_file->uncompressed_filesize == 0
+ && idata->internal_file->compressed_filesize == 0
+ && zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
+ && Z_TYPE_PP(pzoption) == IS_LONG
+ && (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
+ ) {
+ idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
+ idata->internal_file->flags |= Z_LVAL_PP(pzoption);
+ }
+ if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
+ if (idata->internal_file->metadata) {
+ zval_ptr_dtor(&idata->internal_file->metadata);
+ idata->internal_file->metadata = NULL;
+ }
+
+ MAKE_STD_ZVAL(idata->internal_file->metadata);
+ metadata = *pzoption;
+ ZVAL_ZVAL(idata->internal_file->metadata, metadata, 1, 0);
+ idata->phar->is_modified = 1;
+ }
+ }
+ if (opened_path) {
+ spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
+ }
+ return fpf;
+ } else {
+ if (!*internal_file && (options & STREAM_OPEN_FOR_INCLUDE)) {
+ /* retrieve the stub */
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, NULL TSRMLS_CC)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "file %s is not a valid phar archive", resource->host);
+ efree(internal_file);
+ php_url_free(resource);
+ return NULL;
+ }
+ if (phar->is_tar || phar->is_zip) {
+ if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, ".phar/stub.php", sizeof(".phar/stub.php")-1, "r", 0, &error, 0 TSRMLS_CC)) || !idata) {
+ goto idata_error;
+ }
+ efree(internal_file);
+ if (opened_path) {
+ spprintf(opened_path, MAXPATHLEN, "%s", phar->fname);
+ }
+ php_url_free(resource);
+ goto phar_stub;
+ } else {
+ phar_entry_info *entry;
+
+ entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info));
+ entry->is_temp_dir = 1;
+ entry->filename = estrndup("", 0);
+ entry->filename_len = 0;
+ entry->phar = phar;
+ entry->offset = entry->offset_abs = 0;
+ entry->compressed_filesize = entry->uncompressed_filesize = phar->halt_offset;
+ entry->is_crc_checked = 1;
+
+ idata = (phar_entry_data *) ecalloc(1, sizeof(phar_entry_data));
+ idata->fp = phar_get_pharfp(phar TSRMLS_CC);
+ idata->phar = phar;
+ idata->internal_file = entry;
+ if (!phar->is_persistent) {
+ ++(entry->phar->refcount);
+ }
+ ++(entry->fp_refcount);
+ php_url_free(resource);
+ if (opened_path) {
+ spprintf(opened_path, MAXPATHLEN, "%s", phar->fname);
+ }
+ efree(internal_file);
+ goto phar_stub;
+ }
+ }
+ /* read-only access is allowed to magic files in .phar directory */
+ if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, strlen(internal_file), "r", 0, &error, 0 TSRMLS_CC)) || !idata) {
+idata_error:
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ efree(error);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" is not a file in phar \"%s\"", internal_file, resource->host);
+ }
+ efree(internal_file);
+ php_url_free(resource);
+ return NULL;
+ }
+ }
+ php_url_free(resource);
+#if MBO_0
+ fprintf(stderr, "Pharname: %s\n", idata->phar->filename);
+ fprintf(stderr, "Filename: %s\n", internal_file);
+ fprintf(stderr, "Entry: %s\n", idata->internal_file->filename);
+ fprintf(stderr, "Size: %u\n", idata->internal_file->uncompressed_filesize);
+ fprintf(stderr, "Compressed: %u\n", idata->internal_file->flags);
+ fprintf(stderr, "Offset: %u\n", idata->internal_file->offset_within_phar);
+ fprintf(stderr, "Cached: %s\n", idata->internal_file->filedata ? "yes" : "no");
+#endif
+
+ /* check length, crc32 */
+ if (!idata->internal_file->is_crc_checked && phar_postprocess_file(idata, idata->internal_file->crc32, &error, 2 TSRMLS_CC) != SUCCESS) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ efree(error);
+ phar_entry_delref(idata TSRMLS_CC);
+ efree(internal_file);
+ return NULL;
+ }
+
+ if (!PHAR_G(cwd_init) && options & STREAM_OPEN_FOR_INCLUDE) {
+ char *entry = idata->internal_file->filename, *cwd;
+
+ PHAR_G(cwd_init) = 1;
+ if ((idata->phar->is_tar || idata->phar->is_zip) && idata->internal_file->filename_len == sizeof(".phar/stub.php")-1 && !strncmp(idata->internal_file->filename, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ /* we're executing the stub, which doesn't count as a file */
+ PHAR_G(cwd_init) = 0;
+ } else if ((cwd = strrchr(entry, '/'))) {
+ PHAR_G(cwd_len) = cwd - entry;
+ PHAR_G(cwd) = estrndup(entry, PHAR_G(cwd_len));
+ } else {
+ /* root directory */
+ PHAR_G(cwd_len) = 0;
+ PHAR_G(cwd) = NULL;
+ }
+ }
+ if (opened_path) {
+ spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename);
+ }
+ efree(internal_file);
+phar_stub:
+ fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
+ return fpf;
+}
+/* }}} */
+
+/**
+ * Used for fclose($fp) where $fp is a phar archive
+ */
+static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
+{
+ phar_entry_delref((phar_entry_data *)stream->abstract TSRMLS_CC);
+
+ return 0;
+}
+/* }}} */
+
+/**
+ * used for fread($fp) and company on a fopen()ed phar file handle
+ */
+static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
+{
+ phar_entry_data *data = (phar_entry_data *)stream->abstract;
+ size_t got;
+ phar_entry_info *entry;
+
+ if (data->internal_file->link) {
+ entry = phar_get_link_source(data->internal_file TSRMLS_CC);
+ } else {
+ entry = data->internal_file;
+ }
+
+ if (entry->is_deleted) {
+ stream->eof = 1;
+ return 0;
+ }
+
+ /* use our proxy position */
+ php_stream_seek(data->fp, data->position + data->zero, SEEK_SET);
+
+ got = php_stream_read(data->fp, buf, MIN(count, entry->uncompressed_filesize - data->position));
+ data->position = php_stream_tell(data->fp) - data->zero;
+ stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
+
+ return got;
+}
+/* }}} */
+
+/**
+ * Used for fseek($fp) on a phar file handle
+ */
+static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+{
+ phar_entry_data *data = (phar_entry_data *)stream->abstract;
+ phar_entry_info *entry;
+ int res;
+ off_t temp;
+
+ if (data->internal_file->link) {
+ entry = phar_get_link_source(data->internal_file TSRMLS_CC);
+ } else {
+ entry = data->internal_file;
+ }
+
+ switch (whence) {
+ case SEEK_END :
+ temp = data->zero + entry->uncompressed_filesize + offset;
+ break;
+ case SEEK_CUR :
+ temp = data->zero + data->position + offset;
+ break;
+ case SEEK_SET :
+ temp = data->zero + offset;
+ break;
+ default:
+ temp = 0;
+ }
+ if (temp > data->zero + (off_t) entry->uncompressed_filesize) {
+ *newoffset = -1;
+ return -1;
+ }
+ if (temp < data->zero) {
+ *newoffset = -1;
+ return -1;
+ }
+ res = php_stream_seek(data->fp, temp, SEEK_SET);
+ *newoffset = php_stream_tell(data->fp) - data->zero;
+ data->position = *newoffset;
+ return res;
+}
+/* }}} */
+
+/**
+ * Used for writing to a phar file
+ */
+static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
+{
+ phar_entry_data *data = (phar_entry_data *) stream->abstract;
+
+ php_stream_seek(data->fp, data->position, SEEK_SET);
+ if (count != php_stream_write(data->fp, buf, count)) {
+ php_stream_wrapper_log_error(stream->wrapper, stream->flags TSRMLS_CC, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, data->internal_file->filename, data->phar->fname);
+ return -1;
+ }
+ data->position = php_stream_tell(data->fp);
+ if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
+ data->internal_file->uncompressed_filesize = data->position;
+ }
+ data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
+ data->internal_file->old_flags = data->internal_file->flags;
+ data->internal_file->is_modified = 1;
+ return count;
+}
+/* }}} */
+
+/**
+ * Used to save work done on a writeable phar
+ */
+static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
+{
+ char *error;
+ int ret;
+ phar_entry_data *data = (phar_entry_data *) stream->abstract;
+
+ if (data->internal_file->is_modified) {
+ data->internal_file->timestamp = time(0);
+ ret = phar_flush(data->phar, 0, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ return ret;
+ } else {
+ return EOF;
+ }
+}
+/* }}} */
+
+ /* {{{ phar_dostat */
+/**
+ * stat an opened phar file handle stream, used by phar_stat()
+ */
+void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, zend_bool is_temp_dir TSRMLS_DC)
+{
+ memset(ssb, 0, sizeof(php_stream_statbuf));
+
+ if (!is_temp_dir && !data->is_dir) {
+ ssb->sb.st_size = data->uncompressed_filesize;
+ ssb->sb.st_mode = data->flags & PHAR_ENT_PERM_MASK;
+ ssb->sb.st_mode |= S_IFREG; /* regular file */
+ /* timestamp is just the timestamp when this was added to the phar */
+#ifdef NETWARE
+ ssb->sb.st_mtime.tv_sec = data->timestamp;
+ ssb->sb.st_atime.tv_sec = data->timestamp;
+ ssb->sb.st_ctime.tv_sec = data->timestamp;
+#else
+ ssb->sb.st_mtime = data->timestamp;
+ ssb->sb.st_atime = data->timestamp;
+ ssb->sb.st_ctime = data->timestamp;
+#endif
+ } else if (!is_temp_dir && data->is_dir) {
+ ssb->sb.st_size = 0;
+ ssb->sb.st_mode = data->flags & PHAR_ENT_PERM_MASK;
+ ssb->sb.st_mode |= S_IFDIR; /* regular directory */
+ /* timestamp is just the timestamp when this was added to the phar */
+#ifdef NETWARE
+ ssb->sb.st_mtime.tv_sec = data->timestamp;
+ ssb->sb.st_atime.tv_sec = data->timestamp;
+ ssb->sb.st_ctime.tv_sec = data->timestamp;
+#else
+ ssb->sb.st_mtime = data->timestamp;
+ ssb->sb.st_atime = data->timestamp;
+ ssb->sb.st_ctime = data->timestamp;
+#endif
+ } else {
+ ssb->sb.st_size = 0;
+ ssb->sb.st_mode = 0777;
+ ssb->sb.st_mode |= S_IFDIR; /* regular directory */
+#ifdef NETWARE
+ ssb->sb.st_mtime.tv_sec = phar->max_timestamp;
+ ssb->sb.st_atime.tv_sec = phar->max_timestamp;
+ ssb->sb.st_ctime.tv_sec = phar->max_timestamp;
+#else
+ ssb->sb.st_mtime = phar->max_timestamp;
+ ssb->sb.st_atime = phar->max_timestamp;
+ ssb->sb.st_ctime = phar->max_timestamp;
+#endif
+ }
+ if (!phar->is_writeable) {
+ ssb->sb.st_mode = (ssb->sb.st_mode & 0555) | (ssb->sb.st_mode & ~0777);
+ }
+
+ ssb->sb.st_nlink = 1;
+ ssb->sb.st_rdev = -1;
+ /* this is only for APC, so use /dev/null device - no chance of conflict there! */
+ ssb->sb.st_dev = 0xc;
+ /* generate unique inode number for alias/filename, so no phars will conflict */
+ if (!is_temp_dir) {
+ ssb->sb.st_ino = data->inode;
+ }
+#ifndef PHP_WIN32
+ ssb->sb.st_blksize = -1;
+ ssb->sb.st_blocks = -1;
+#endif
+}
+/* }}}*/
+
+/**
+ * Stat an opened phar file handle
+ */
+static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
+{
+ phar_entry_data *data = (phar_entry_data *)stream->abstract;
+
+ /* If ssb is NULL then someone is misbehaving */
+ if (!ssb) {
+ return -1;
+ }
+
+ phar_dostat(data->phar, data->internal_file, ssb, 0 TSRMLS_CC);
+ return 0;
+}
+/* }}} */
+
+/**
+ * Stream wrapper stat implementation of stat()
+ */
+static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
+ php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
+{
+ php_url *resource = NULL;
+ char *internal_file, *error;
+ phar_archive_data *phar;
+ phar_entry_info *entry;
+ uint host_len;
+ int internal_file_len;
+
+ if ((resource = phar_parse_url(wrapper, url, "r", flags|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
+ return FAILURE;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ php_url_free(resource);
+ return FAILURE;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ return FAILURE;
+ }
+
+ host_len = strlen(resource->host);
+ phar_request_initialize(TSRMLS_C);
+
+ internal_file = resource->path + 1; /* strip leading "/" */
+ /* find the phar in our trusty global hash indexed by alias (host of phar://blah.phar/file.whatever) */
+ if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ php_url_free(resource);
+ if (error) {
+ efree(error);
+ }
+ return FAILURE;
+ }
+ if (error) {
+ efree(error);
+ }
+ if (*internal_file == '\0') {
+ /* root directory requested */
+ phar_dostat(phar, NULL, ssb, 1 TSRMLS_CC);
+ php_url_free(resource);
+ return SUCCESS;
+ }
+ if (!phar->manifest.arBuckets) {
+ php_url_free(resource);
+ return FAILURE;
+ }
+ internal_file_len = strlen(internal_file);
+ /* search through the manifest of files, and if we have an exact match, it's a file */
+ if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, internal_file_len, (void**)&entry)) {
+ phar_dostat(phar, entry, ssb, 0 TSRMLS_CC);
+ php_url_free(resource);
+ return SUCCESS;
+ }
+ if (zend_hash_exists(&(phar->virtual_dirs), internal_file, internal_file_len)) {
+ phar_dostat(phar, NULL, ssb, 1 TSRMLS_CC);
+ php_url_free(resource);
+ return SUCCESS;
+ }
+ /* check for mounted directories */
+ if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
+ phar_zstr key;
+ char *str_key;
+ ulong unused;
+ uint keylen;
+ HashPosition pos;
+
+ zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos);
+ while (FAILURE != zend_hash_has_more_elements_ex(&phar->mounted_dirs, &pos)) {
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) {
+ break;
+ }
+ PHAR_STR(key, str_key);
+ if ((int)keylen >= internal_file_len || strncmp(str_key, internal_file, keylen)) {
+ zend_hash_move_forward_ex(&phar->mounted_dirs, &pos);
+ PHAR_STR_FREE(str_key);
+ continue;
+ } else {
+ char *test;
+ int test_len;
+ php_stream_statbuf ssbi;
+
+ if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
+ PHAR_STR_FREE(str_key);
+ goto free_resource;
+ }
+ PHAR_STR_FREE(str_key);
+ if (!entry->tmp || !entry->is_mounted) {
+ goto free_resource;
+ }
+ test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + keylen);
+ if (SUCCESS != php_stream_stat_path(test, &ssbi)) {
+ efree(test);
+ zend_hash_move_forward_ex(&phar->mounted_dirs, &pos);
+ continue;
+ }
+ /* mount the file/directory just in time */
+ if (SUCCESS != phar_mount_entry(phar, test, test_len, internal_file, internal_file_len TSRMLS_CC)) {
+ efree(test);
+ goto free_resource;
+ }
+ efree(test);
+ if (SUCCESS != zend_hash_find(&phar->manifest, internal_file, internal_file_len, (void**)&entry)) {
+ goto free_resource;
+ }
+ phar_dostat(phar, entry, ssb, 0 TSRMLS_CC);
+ php_url_free(resource);
+ return SUCCESS;
+ }
+ }
+ }
+free_resource:
+ php_url_free(resource);
+ return FAILURE;
+}
+/* }}} */
+
+/**
+ * Unlink a file within a phar archive
+ */
+static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+{
+ php_url *resource;
+ char *internal_file, *error;
+ int internal_file_len;
+ phar_entry_data *idata;
+ phar_archive_data **pphar;
+ uint host_len;
+
+ if ((resource = phar_parse_url(wrapper, url, "rb", options TSRMLS_CC)) == NULL) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: unlink failed");
+ return 0;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource->scheme || !resource->host || !resource->path) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url);
+ return 0;
+ }
+
+ if (strcasecmp("phar", resource->scheme)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url);
+ return 0;
+ }
+
+ host_len = strlen(resource->host);
+ phar_request_initialize(TSRMLS_C);
+
+ if (FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), resource->host, host_len, (void **) &pphar)) {
+ pphar = NULL;
+ }
+ if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
+ php_url_free(resource);
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");
+ return 0;
+ }
+
+ /* need to copy to strip leading "/", will get touched again */
+ internal_file = estrdup(resource->path + 1);
+ internal_file_len = strlen(internal_file);
+ if (FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, internal_file_len, "r", 0, &error, 1 TSRMLS_CC)) {
+ /* constraints of fp refcount were not met */
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "unlink of \"%s\" failed: %s", url, error);
+ efree(error);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "unlink of \"%s\" failed, file does not exist", url);
+ }
+ efree(internal_file);
+ php_url_free(resource);
+ return 0;
+ }
+ if (error) {
+ efree(error);
+ }
+ if (idata->internal_file->fp_refcount > 1) {
+ /* more than just our fp resource is open for this file */
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", internal_file, resource->host);
+ efree(internal_file);
+ php_url_free(resource);
+ phar_entry_delref(idata TSRMLS_CC);
+ return 0;
+ }
+ php_url_free(resource);
+ efree(internal_file);
+ phar_entry_remove(idata, &error TSRMLS_CC);
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
+ efree(error);
+ }
+ return 1;
+}
+/* }}} */
+
+static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
+{
+ php_url *resource_from, *resource_to;
+ char *error;
+ phar_archive_data *phar, *pfrom, *pto;
+ phar_entry_info *entry;
+ uint host_len;
+ int is_dir = 0;
+ int is_modified = 0;
+
+ error = NULL;
+
+ if ((resource_from = phar_parse_url(wrapper, url_from, "wb", options|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_from);
+ return 0;
+ }
+ if (SUCCESS != phar_get_archive(&pfrom, resource_from->host, strlen(resource_from->host), NULL, 0, &error TSRMLS_CC)) {
+ pfrom = NULL;
+ if (error) {
+ efree(error);
+ }
+ }
+ if (PHAR_G(readonly) && (!pfrom || !pfrom->is_data)) {
+ php_url_free(resource_from);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
+ return 0;
+ }
+
+ if ((resource_to = phar_parse_url(wrapper, url_to, "wb", options|PHP_STREAM_URL_STAT_QUIET TSRMLS_CC)) == NULL) {
+ php_url_free(resource_from);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_to);
+ return 0;
+ }
+ if (SUCCESS != phar_get_archive(&pto, resource_to->host, strlen(resource_to->host), NULL, 0, &error TSRMLS_CC)) {
+ if (error) {
+ efree(error);
+ }
+ pto = NULL;
+ }
+ if (PHAR_G(readonly) && (!pto || !pto->is_data)) {
+ php_url_free(resource_from);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: Write operations disabled by the php.ini setting phar.readonly");
+ return 0;
+ }
+
+ if (strcmp(resource_from->host, resource_to->host)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive", url_from, url_to);
+ return 0;
+ }
+
+ /* we must have at the very least phar://alias.phar/internalfile.php */
+ if (!resource_from->scheme || !resource_from->host || !resource_from->path) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_from);
+ return 0;
+ }
+
+ if (!resource_to->scheme || !resource_to->host || !resource_to->path) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"", url_from, url_to, url_to);
+ return 0;
+ }
+
+ if (strcasecmp("phar", resource_from->scheme)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_from);
+ return 0;
+ }
+
+ if (strcasecmp("phar", resource_to->scheme)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"", url_from, url_to, url_to);
+ return 0;
+ }
+
+ host_len = strlen(resource_from->host);
+
+ if (SUCCESS != phar_get_archive(&phar, resource_from->host, host_len, NULL, 0, &error TSRMLS_CC)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ efree(error);
+ return 0;
+ }
+
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable", url_from, url_to);
+ return 0;
+ }
+
+ if (SUCCESS == zend_hash_find(&(phar->manifest), resource_from->path+1, strlen(resource_from->path)-1, (void **)&entry)) {
+ phar_entry_info new, *source;
+
+ /* perform rename magic */
+ if (entry->is_deleted) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted", url_from, url_to);
+ return 0;
+ }
+ /* transfer all data over to the new entry */
+ memcpy((void *) &new, (void *) entry, sizeof(phar_entry_info));
+ /* mark the old one for deletion */
+ entry->is_deleted = 1;
+ entry->fp = NULL;
+ entry->metadata = 0;
+ entry->link = entry->tmp = NULL;
+ source = entry;
+
+ /* add to the manifest, and then store the pointer to the new guy in entry */
+ zend_hash_add(&(phar->manifest), resource_to->path+1, strlen(resource_to->path)-1, (void **)&new, sizeof(phar_entry_info), (void **) &entry);
+
+ entry->filename = estrdup(resource_to->path+1);
+ if (FAILURE == phar_copy_entry_fp(source, entry, &error TSRMLS_CC)) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ efree(error);
+ zend_hash_del(&(phar->manifest), entry->filename, strlen(entry->filename));
+ return 0;
+ }
+ is_modified = 1;
+ entry->is_modified = 1;
+ entry->filename_len = strlen(entry->filename);
+ is_dir = entry->is_dir;
+ } else {
+ is_dir = zend_hash_exists(&(phar->virtual_dirs), resource_from->path+1, strlen(resource_from->path)-1);
+ if (!is_dir) {
+ /* file does not exist */
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist", url_from, url_to);
+ return 0;
+
+ }
+ }
+
+ /* Rename directory. Update all nested paths */
+ if (is_dir) {
+ int key_type;
+ phar_zstr key, new_key;
+ char *str_key, *new_str_key;
+ uint key_len, new_key_len;
+ ulong unused;
+ uint from_len = strlen(resource_from->path+1);
+ uint to_len = strlen(resource_to->path+1);
+
+ for (zend_hash_internal_pointer_reset(&phar->manifest);
+ HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) &&
+ SUCCESS == zend_hash_get_current_data(&phar->manifest, (void **) &entry);
+ zend_hash_move_forward(&phar->manifest)) {
+
+ PHAR_STR(key, str_key);
+
+ if (!entry->is_deleted &&
+ key_len > from_len &&
+ memcmp(str_key, resource_from->path+1, from_len) == 0 &&
+ IS_SLASH(str_key[from_len])) {
+
+ new_key_len = key_len + to_len - from_len;
+ new_str_key = emalloc(new_key_len+1);
+ memcpy(new_str_key, resource_to->path + 1, to_len);
+ memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
+ new_str_key[new_key_len] = 0;
+
+ is_modified = 1;
+ entry->is_modified = 1;
+ efree(entry->filename);
+ entry->filename = new_str_key;
+ entry->filename_len = new_key_len;
+
+ PHAR_ZSTR(new_str_key, new_key);
+#if PHP_VERSION_ID < 50300
+ zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, NULL);
+#else
+ zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
+#endif
+ }
+ PHAR_STR_FREE(str_key);
+ }
+
+ for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
+ HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL));
+ zend_hash_move_forward(&phar->virtual_dirs)) {
+
+ PHAR_STR(key, str_key);
+
+ if (key_len >= from_len &&
+ memcmp(str_key, resource_from->path+1, from_len) == 0 &&
+ (key_len == from_len || IS_SLASH(str_key[from_len]))) {
+
+ new_key_len = key_len + to_len - from_len;
+ new_str_key = emalloc(new_key_len+1);
+ memcpy(new_str_key, resource_to->path + 1, to_len);
+ memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
+ new_str_key[new_key_len] = 0;
+
+ PHAR_ZSTR(new_str_key, new_key);
+#if PHP_VERSION_ID < 50300
+ zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, NULL);
+#else
+ zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
+#endif
+ efree(new_str_key);
+ }
+ PHAR_STR_FREE(str_key);
+ }
+
+ for (zend_hash_internal_pointer_reset(&phar->mounted_dirs);
+ HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) &&
+ SUCCESS == zend_hash_get_current_data(&phar->mounted_dirs, (void **) &entry);
+ zend_hash_move_forward(&phar->mounted_dirs)) {
+
+ PHAR_STR(key, str_key);
+
+ if (key_len >= from_len &&
+ memcmp(str_key, resource_from->path+1, from_len) == 0 &&
+ (key_len == from_len || IS_SLASH(str_key[from_len]))) {
+
+ new_key_len = key_len + to_len - from_len;
+ new_str_key = emalloc(new_key_len+1);
+ memcpy(new_str_key, resource_to->path + 1, to_len);
+ memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
+ new_str_key[new_key_len] = 0;
+
+ PHAR_ZSTR(new_str_key, new_key);
+#if PHP_VERSION_ID < 50300
+ zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, NULL);
+#else
+ zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
+#endif
+ efree(new_str_key);
+ }
+ PHAR_STR_FREE(str_key);
+ }
+ }
+
+ if (is_modified) {
+ phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
+ efree(error);
+ return 0;
+ }
+ }
+
+ php_url_free(resource_from);
+ php_url_free(resource_to);
+
+ return 1;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/stream.h b/ext/phar/stream.h
new file mode 100644
index 0000000..b22b67a
--- /dev/null
+++ b/ext/phar/stream.h
@@ -0,0 +1,48 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2006-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+BEGIN_EXTERN_C()
+
+php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC);
+void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC);
+
+static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
+static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC);
+static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC);
+static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
+
+/* file/stream handlers */
+static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
+static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
+static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
+static int phar_stream_flush(php_stream *stream TSRMLS_DC);
+static int phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
+END_EXTERN_C()
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/stub.h b/ext/phar/stub.h
new file mode 100644
index 0000000..daafa39
--- /dev/null
+++ b/ext/phar/stub.h
@@ -0,0 +1,34 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension generated stub |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
+{
+ static const char newstub0[] = "<?php\n\n$web = '";
+ static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\nset_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());\nPhar::webPhar(null, $web);\ninclude 'phar://' . __FILE__ . '/' . Extract_Phar::START;\nreturn;\n}\n\nif (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {\nExtract_Phar::go(true);\n$mimes = array(\n'phps' => 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen(";
+ static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File \", $pt, \" Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
+ static const char newstub2[] = "';\nconst LEN = ";
+ static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = (binary)fread($fp, 4));\n$m = (binary)'';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = (binary)fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::ST";
+ static const char newstub3_1[] = "ART;\n}\n}\n\nstatic function tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32((binary)$data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPIL";
+ static const char newstub3_2[] = "ER(); ?>";
+
+ static const int newstub_len = 6665;
+
+ *len = spprintf(stub, name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1, newstub3_2);
+}
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
new file mode 100644
index 0000000..f170335
--- /dev/null
+++ b/ext/phar/tar.c
@@ -0,0 +1,1319 @@
+/*
+ +----------------------------------------------------------------------+
+ | TAR archive support for Phar |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Dmitry Stogov <dmitry@zend.com> |
+ | Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "phar_internal.h"
+
+static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */
+{
+ php_uint32 num = 0;
+ int i = 0;
+
+ while (i < len && buf[i] == ' ') {
+ ++i;
+ }
+
+ while (i < len && buf[i] >= '0' && buf[i] <= '7') {
+ num = num * 8 + (buf[i] - '0');
+ ++i;
+ }
+
+ return num;
+}
+/* }}} */
+
+/* adapted from format_octal() in libarchive
+ *
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+static int phar_tar_octal(char *buf, php_uint32 val, int len) /* {{{ */
+{
+ char *p = buf;
+ int s = len;
+
+ p += len; /* Start at the end and work backwards. */
+ while (s-- > 0) {
+ *--p = (char)('0' + (val & 7));
+ val >>= 3;
+ }
+
+ if (val == 0)
+ return SUCCESS;
+
+ /* If it overflowed, fill field with max value. */
+ while (len-- > 0)
+ *p++ = '7';
+
+ return FAILURE;
+}
+/* }}} */
+
+static php_uint32 phar_tar_checksum(char *buf, int len) /* {{{ */
+{
+ php_uint32 sum = 0;
+ char *end = buf + len;
+
+ while (buf != end) {
+ sum += (unsigned char)*buf;
+ ++buf;
+ }
+ return sum;
+}
+/* }}} */
+
+int phar_is_tar(char *buf, char *fname) /* {{{ */
+{
+ tar_header *header = (tar_header *) buf;
+ php_uint32 checksum = phar_tar_number(header->checksum, sizeof(header->checksum));
+ php_uint32 ret;
+ char save[sizeof(header->checksum)];
+
+ /* assume that the first filename in a tar won't begin with <?php */
+ if (!strncmp(buf, "<?php", sizeof("<?php")-1)) {
+ return 0;
+ }
+
+ memcpy(save, header->checksum, sizeof(header->checksum));
+ memset(header->checksum, ' ', sizeof(header->checksum));
+ ret = (checksum == phar_tar_checksum(buf, 512));
+ memcpy(header->checksum, save, sizeof(header->checksum));
+ if (!ret && strstr(fname, ".tar")) {
+ /* probably a corrupted tar - so we will pretend it is one */
+ return 1;
+ }
+ return ret;
+}
+/* }}} */
+
+int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC);
+
+ if (FAILURE == ret) {
+ return FAILURE;
+ }
+
+ if (pphar) {
+ *pphar = phar;
+ }
+
+ phar->is_data = is_data;
+
+ if (phar->is_tar) {
+ return ret;
+ }
+
+ if (phar->is_brandnew) {
+ phar->is_tar = 1;
+ phar->is_zip = 0;
+ phar->internal_file_start = 0;
+ return SUCCESS;
+ }
+
+ /* we've reached here - the phar exists and is a regular phar */
+ if (error) {
+ spprintf(error, 4096, "phar tar error: \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar", fname);
+ }
+ return FAILURE;
+}
+/* }}} */
+
+static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
+{
+ char *metadata;
+ size_t save = php_stream_tell(fp), read;
+ phar_entry_info *mentry;
+
+ metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1);
+
+ read = php_stream_read(fp, metadata, entry->uncompressed_filesize);
+ if (read != entry->uncompressed_filesize) {
+ efree(metadata);
+ php_stream_seek(fp, save, SEEK_SET);
+ return FAILURE;
+ }
+
+ if (phar_parse_metadata(&metadata, &entry->metadata, entry->uncompressed_filesize TSRMLS_CC) == FAILURE) {
+ /* if not valid serialized data, it is a regular string */
+ efree(metadata);
+ php_stream_seek(fp, save, SEEK_SET);
+ return FAILURE;
+ }
+
+ if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1)) {
+ entry->phar->metadata = entry->metadata;
+ entry->metadata = NULL;
+ } else if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1), (void *)&mentry)) {
+ /* transfer this metadata to the entry it refers */
+ mentry->metadata = entry->metadata;
+ entry->metadata = NULL;
+ }
+
+ efree(metadata);
+ php_stream_seek(fp, save, SEEK_SET);
+ return SUCCESS;
+}
+/* }}} */
+
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+{
+ char buf[512], *actual_alias = NULL, *p;
+ phar_entry_info entry = {0};
+ size_t pos = 0, read, totalsize;
+ tar_header *hdr;
+ php_uint32 sum1, sum2, size, old;
+ phar_archive_data *myphar, **actual;
+ int last_was_longlink = 0;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ php_stream_seek(fp, 0, SEEK_END);
+ totalsize = php_stream_tell(fp);
+ php_stream_seek(fp, 0, SEEK_SET);
+ read = php_stream_read(fp, buf, sizeof(buf));
+
+ if (read != sizeof(buf)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is not a tar file or is truncated", fname);
+ }
+ php_stream_close(fp);
+ return FAILURE;
+ }
+
+ hdr = (tar_header*)buf;
+ old = (memcmp(hdr->magic, "ustar", sizeof("ustar")-1) != 0);
+
+ myphar = (phar_archive_data *) pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist));
+ myphar->is_persistent = PHAR_G(persist);
+ /* estimate number of entries, can't be certain with tar files */
+ zend_hash_init(&myphar->manifest, 2 + (totalsize >> 12),
+ zend_get_hash_value, destroy_phar_manifest_entry, (zend_bool)myphar->is_persistent);
+ zend_hash_init(&myphar->mounted_dirs, 5,
+ zend_get_hash_value, NULL, (zend_bool)myphar->is_persistent);
+ zend_hash_init(&myphar->virtual_dirs, 4 + (totalsize >> 11),
+ zend_get_hash_value, NULL, (zend_bool)myphar->is_persistent);
+ myphar->is_tar = 1;
+ /* remember whether this entire phar was compressed with gz/bzip2 */
+ myphar->flags = compression;
+
+ entry.is_tar = 1;
+ entry.is_crc_checked = 1;
+ entry.phar = myphar;
+ pos += sizeof(buf);
+
+ do {
+ phar_entry_info *newentry;
+
+ pos = php_stream_tell(fp);
+ hdr = (tar_header*) buf;
+ sum1 = phar_tar_number(hdr->checksum, sizeof(hdr->checksum));
+ if (sum1 == 0 && phar_tar_checksum(buf, sizeof(buf)) == 0) {
+ break;
+ }
+ memset(hdr->checksum, ' ', sizeof(hdr->checksum));
+ sum2 = phar_tar_checksum(buf, old?sizeof(old_tar_header):sizeof(tar_header));
+
+ size = entry.uncompressed_filesize = entry.compressed_filesize =
+ phar_tar_number(hdr->size, sizeof(hdr->size));
+
+ if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
+ off_t curloc;
+
+ if (size > 511) {
+ if (error) {
+ spprintf(error, 4096, "phar error: tar-based phar \"%s\" has signature that is larger than 511 bytes, cannot process", fname);
+ }
+bail:
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ curloc = php_stream_tell(fp);
+ read = php_stream_read(fp, buf, size);
+ if (read != size) {
+ if (error) {
+ spprintf(error, 4096, "phar error: tar-based phar \"%s\" signature cannot be read", fname);
+ }
+ goto bail;
+ }
+#ifdef WORDS_BIGENDIAN
+# define PHAR_GET_32(buffer) \
+ (((((unsigned char*)(buffer))[3]) << 24) \
+ | ((((unsigned char*)(buffer))[2]) << 16) \
+ | ((((unsigned char*)(buffer))[1]) << 8) \
+ | (((unsigned char*)(buffer))[0]))
+#else
+# define PHAR_GET_32(buffer) (php_uint32) *(buffer)
+#endif
+ myphar->sig_flags = PHAR_GET_32(buf);
+ if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, myphar->sig_flags, buf + 8, size - 8, fname, &myphar->signature, &myphar->sig_len, error TSRMLS_CC)) {
+ if (error) {
+ char *save = *error;
+ spprintf(error, 4096, "phar error: tar-based phar \"%s\" signature cannot be verified: %s", fname, save);
+ efree(save);
+ }
+ goto bail;
+ }
+ php_stream_seek(fp, curloc + 512, SEEK_SET);
+ /* signature checked out, let's ensure this is the last file in the phar */
+ if (((hdr->typeflag == '\0') || (hdr->typeflag == TAR_FILE)) && size > 0) {
+ /* this is not good enough - seek succeeds even on truncated tars */
+ php_stream_seek(fp, 512, SEEK_CUR);
+ if ((uint)php_stream_tell(fp) > totalsize) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ }
+
+ read = php_stream_read(fp, buf, sizeof(buf));
+
+ if (read != sizeof(buf)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ hdr = (tar_header*) buf;
+ sum1 = phar_tar_number(hdr->checksum, sizeof(hdr->checksum));
+
+ if (sum1 == 0 && phar_tar_checksum(buf, sizeof(buf)) == 0) {
+ break;
+ }
+
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" has entries after signature, invalid phar", fname);
+ }
+
+ goto bail;
+ }
+
+ if (!last_was_longlink && hdr->typeflag == 'L') {
+ last_was_longlink = 1;
+ /* support the ././@LongLink system for storing long filenames */
+ entry.filename_len = entry.uncompressed_filesize;
+
+ /* Check for overflow - bug 61065 */
+ if (entry.filename_len == UINT_MAX) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent);
+
+ read = php_stream_read(fp, entry.filename, entry.filename_len);
+ if (read != entry.filename_len) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ entry.filename[entry.filename_len] = '\0';
+
+ /* skip blank stuff */
+ size = ((size+511)&~511) - size;
+
+ /* this is not good enough - seek succeeds even on truncated tars */
+ php_stream_seek(fp, size, SEEK_CUR);
+ if ((uint)php_stream_tell(fp) > totalsize) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ read = php_stream_read(fp, buf, sizeof(buf));
+
+ if (read != sizeof(buf)) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ continue;
+ } else if (!last_was_longlink && !old && hdr->prefix[0] != 0) {
+ char name[256];
+ int i, j;
+
+ for (i = 0; i < 155; i++) {
+ name[i] = hdr->prefix[i];
+ if (name[i] == '\0') {
+ break;
+ }
+ }
+ name[i++] = '/';
+ for (j = 0; j < 100; j++) {
+ name[i+j] = hdr->name[j];
+ if (name[i+j] == '\0') {
+ break;
+ }
+ }
+
+ entry.filename_len = i+j;
+
+ if (name[entry.filename_len - 1] == '/') {
+ /* some tar programs store directories with trailing slash */
+ entry.filename_len--;
+ }
+ entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent);
+ } else if (!last_was_longlink) {
+ int i;
+
+ /* calculate strlen, which can be no longer than 100 */
+ for (i = 0; i < 100; i++) {
+ if (hdr->name[i] == '\0') {
+ break;
+ }
+ }
+ entry.filename_len = i;
+ entry.filename = pestrndup(hdr->name, i, myphar->is_persistent);
+
+ if (entry.filename[entry.filename_len - 1] == '/') {
+ /* some tar programs store directories with trailing slash */
+ entry.filename[entry.filename_len - 1] = '\0';
+ entry.filename_len--;
+ }
+ }
+ last_was_longlink = 0;
+
+ phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len TSRMLS_CC);
+
+ if (sum1 != sum2) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename);
+ }
+ pefree(entry.filename, myphar->is_persistent);
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag);
+ entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */
+ entry.fp_type = PHAR_FP;
+ entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK;
+ entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime));
+ entry.is_persistent = myphar->is_persistent;
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+#endif
+ if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) {
+ entry.tar_type = TAR_DIR;
+ }
+
+ if (entry.tar_type == TAR_DIR) {
+ entry.is_dir = 1;
+ } else {
+ entry.is_dir = 0;
+ }
+
+ entry.link = NULL;
+
+ if (entry.tar_type == TAR_LINK) {
+ if (!zend_hash_exists(&myphar->manifest, hdr->linkname, strlen(hdr->linkname))) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file - hard link to non-existent file \"%s\"", fname, hdr->linkname);
+ }
+ pefree(entry.filename, entry.is_persistent);
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ entry.link = estrdup(hdr->linkname);
+ } else if (entry.tar_type == TAR_SYMLINK) {
+ entry.link = estrdup(hdr->linkname);
+ }
+ phar_set_inode(&entry TSRMLS_CC);
+ zend_hash_add(&myphar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), (void **) &newentry);
+
+ if (entry.is_persistent) {
+ ++entry.manifest_pos;
+ }
+
+ if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
+ if (FAILURE == phar_tar_process_metadata(newentry, fp TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ }
+
+ if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
+ /* found explicit alias */
+ if (size > 511) {
+ if (error) {
+ spprintf(error, 4096, "phar error: tar-based phar \"%s\" has alias that is larger than 511 bytes, cannot process", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ read = php_stream_read(fp, buf, size);
+
+ if (read == size) {
+ buf[size] = '\0';
+ if (!phar_validate_alias(buf, size)) {
+ if (size > 50) {
+ buf[50] = '.';
+ buf[51] = '.';
+ buf[52] = '.';
+ buf[53] = '\0';
+ }
+
+ if (error) {
+ spprintf(error, 4096, "phar error: invalid alias \"%s\" in tar-based phar \"%s\"", buf, fname);
+ }
+
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ actual_alias = pestrndup(buf, size, myphar->is_persistent);
+ myphar->alias = actual_alias;
+ myphar->alias_len = size;
+ php_stream_seek(fp, pos, SEEK_SET);
+ } else {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to read alias from tar-based phar \"%s\"", fname);
+ }
+
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ }
+
+ size = (size+511)&~511;
+
+ if (((hdr->typeflag == '\0') || (hdr->typeflag == TAR_FILE)) && size > 0) {
+ /* this is not good enough - seek succeeds even on truncated tars */
+ php_stream_seek(fp, size, SEEK_CUR);
+ if ((uint)php_stream_tell(fp) > totalsize) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ }
+
+ read = php_stream_read(fp, buf, sizeof(buf));
+
+ if (read != sizeof(buf)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ } while (read != 0);
+
+ if (zend_hash_exists(&(myphar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ myphar->is_data = 0;
+ } else {
+ myphar->is_data = 1;
+ }
+
+ /* ensure signature set */
+ if (!myphar->is_data && PHAR_G(require_hash) && !myphar->signature) {
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ if (error) {
+ spprintf(error, 0, "tar-based phar \"%s\" does not have a signature", fname);
+ }
+ return FAILURE;
+ }
+
+ myphar->fname = pestrndup(fname, fname_len, myphar->is_persistent);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(myphar->fname, fname_len);
+#endif
+ myphar->fname_len = fname_len;
+ myphar->fp = fp;
+ p = strrchr(myphar->fname, '/');
+
+ if (p) {
+ myphar->ext = memchr(p, '.', (myphar->fname + fname_len) - p);
+ if (myphar->ext == p) {
+ myphar->ext = memchr(p + 1, '.', (myphar->fname + fname_len) - p - 1);
+ }
+ if (myphar->ext) {
+ myphar->ext_len = (myphar->fname + fname_len) - myphar->ext;
+ }
+ }
+
+ phar_request_initialize(TSRMLS_C);
+
+ if (SUCCESS != zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len, (void*)&myphar, sizeof(phar_archive_data*), (void **)&actual)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\" to phar registry", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ myphar = *actual;
+
+ if (actual_alias) {
+ phar_archive_data **fd_ptr;
+
+ myphar->is_temporary_alias = 0;
+
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), actual_alias, myphar->alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, actual_alias, myphar->alias_len TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\", alias is already in use", fname);
+ }
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len);
+ return FAILURE;
+ }
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, myphar->alias_len, (void*)&myphar, sizeof(phar_archive_data*), NULL);
+ } else {
+ phar_archive_data **fd_ptr;
+
+ if (alias_len) {
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to add tar-based phar \"%s\", alias is already in use", fname);
+ }
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), myphar->fname, fname_len);
+ return FAILURE;
+ }
+ }
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&myphar, sizeof(phar_archive_data*), NULL);
+ myphar->alias = pestrndup(alias, alias_len, myphar->is_persistent);
+ myphar->alias_len = alias_len;
+ } else {
+ myphar->alias = pestrndup(myphar->fname, fname_len, myphar->is_persistent);
+ myphar->alias_len = fname_len;
+ }
+
+ myphar->is_temporary_alias = 1;
+ }
+
+ if (pphar) {
+ *pphar = myphar;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+struct _phar_pass_tar_info {
+ php_stream *old;
+ php_stream *new;
+ int free_fp;
+ int free_ufp;
+ char **error;
+};
+
+static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ tar_header header;
+ size_t pos;
+ phar_entry_info *entry = (phar_entry_info *) pDest;
+ struct _phar_pass_tar_info *fp = (struct _phar_pass_tar_info *)argument;
+ char padding[512];
+
+ if (entry->is_mounted) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (entry->is_deleted) {
+ if (entry->fp_refcount <= 0) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ /* we can't delete this in-memory until it is closed */
+ return ZEND_HASH_APPLY_KEEP;
+ }
+ }
+
+ phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC);
+ memset((char *) &header, 0, sizeof(header));
+
+ if (entry->filename_len > 100) {
+ char *boundary;
+ if (entry->filename_len > 256) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+ boundary = entry->filename + entry->filename_len - 101;
+ while (*boundary && *boundary != '/') {
+ ++boundary;
+ }
+ if (!*boundary || ((boundary - entry->filename) > 155)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+ memcpy(header.prefix, entry->filename, boundary - entry->filename);
+ memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename));
+ } else {
+ memcpy(header.name, entry->filename, entry->filename_len);
+ }
+
+ phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1);
+
+ if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, file modification time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ /* calc checksum */
+ header.typeflag = entry->tar_type;
+
+ if (entry->link) {
+ strncpy(header.linkname, entry->link, strlen(entry->link));
+ }
+
+ strncpy(header.magic, "ustar", sizeof("ustar")-1);
+ strncpy(header.version, "00", sizeof("00")-1);
+ strncpy(header.checksum, " ", sizeof(" ")-1);
+ entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header));
+
+ if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ /* write header */
+ entry->header_offset = php_stream_tell(fp->new);
+
+ if (sizeof(header) != php_stream_write(fp->new, (char *) &header, sizeof(header))) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ pos = php_stream_tell(fp->new); /* save start of file within tar */
+
+ /* write contents */
+ if (entry->uncompressed_filesize) {
+ if (FAILURE == phar_open_entry_fp(entry, fp->error, 0 TSRMLS_CC)) {
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ memset(padding, 0, 512);
+ php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompressed_filesize);
+ }
+
+ if (!entry->is_modified && entry->fp_refcount) {
+ /* open file pointers refer to this fp, do not free the stream */
+ switch (entry->fp_type) {
+ case PHAR_FP:
+ fp->free_fp = 0;
+ break;
+ case PHAR_UFP:
+ fp->free_ufp = 0;
+ default:
+ break;
+ }
+ }
+
+ entry->is_modified = 0;
+
+ if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) {
+ if (!entry->fp_refcount) {
+ php_stream_close(entry->fp);
+ }
+ entry->fp = NULL;
+ }
+
+ entry->fp_type = PHAR_FP;
+
+ /* note new location within tar */
+ entry->offset = entry->offset_abs = pos;
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+{
+ php_serialize_data_t metadata_hash;
+
+ if (entry->metadata_str.c) {
+ smart_str_free(&entry->metadata_str);
+ }
+
+ entry->metadata_str.c = 0;
+ entry->metadata_str.len = 0;
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&entry->metadata_str, &metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.len;
+
+ if (entry->fp && entry->fp_type == PHAR_MOD) {
+ php_stream_close(entry->fp);
+ }
+
+ entry->fp_type = PHAR_MOD;
+ entry->is_modified = 1;
+ entry->fp = php_stream_fopen_tmpfile();
+ entry->offset = entry->offset_abs = 0;
+
+ if (entry->metadata_str.len != php_stream_write(entry->fp, entry->metadata_str.c, entry->metadata_str.len)) {
+ spprintf(error, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename);
+ zend_hash_del(&(entry->phar->manifest), entry->filename, entry->filename_len);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+static int phar_tar_setupmetadata(void *pDest, void *argument TSRMLS_DC) /* {{{ */
+{
+ int lookfor_len;
+ struct _phar_pass_tar_info *i = (struct _phar_pass_tar_info *)argument;
+ char *lookfor, **error = i->error;
+ phar_entry_info *entry = (phar_entry_info *)pDest, *metadata, newentry = {0};
+
+ if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
+ if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1)) {
+ return phar_tar_setmetadata(entry->phar->metadata, entry, error TSRMLS_CC);
+ }
+ /* search for the file this metadata entry references */
+ if (entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_exists(&(entry->phar->manifest), entry->filename + sizeof(".phar/.metadata/") - 1, entry->filename_len - (sizeof("/.metadata.bin") - 1 + sizeof(".phar/.metadata/") - 1))) {
+ /* this is orphaned metadata, erase it */
+ return ZEND_HASH_APPLY_REMOVE;
+ }
+ /* we can keep this entry, the file that refers to it exists */
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (!entry->is_modified) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ /* now we are dealing with regular files, so look for metadata */
+ lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename);
+
+ if (!entry->metadata) {
+ zend_hash_del(&(entry->phar->manifest), lookfor, lookfor_len);
+ efree(lookfor);
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (SUCCESS == zend_hash_find(&(entry->phar->manifest), lookfor, lookfor_len, (void **)&metadata)) {
+ int ret;
+ ret = phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC);
+ efree(lookfor);
+ return ret;
+ }
+
+ newentry.filename = lookfor;
+ newentry.filename_len = lookfor_len;
+ newentry.phar = entry->phar;
+ newentry.tar_type = TAR_FILE;
+ newentry.is_tar = 1;
+
+ if (SUCCESS != zend_hash_add(&(entry->phar->manifest), lookfor, lookfor_len, (void *)&newentry, sizeof(phar_entry_info), (void **)&metadata)) {
+ efree(lookfor);
+ spprintf(error, 0, "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ return phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC);
+}
+/* }}} */
+
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info entry = {0};
+ static const char newstub[] = "<?php // tar-based phar archive stub file\n__HALT_COMPILER();";
+ php_stream *oldfile, *newfile, *stubfile;
+ int closeoldfile, free_user_stub, signature_length;
+ struct _phar_pass_tar_info pass;
+ char *buf, *signature, *tmp, sigbuf[8];
+ char halt_stub[] = "__HALT_COMPILER();";
+
+ entry.flags = PHAR_ENT_PERM_DEF_FILE;
+ entry.timestamp = time(NULL);
+ entry.is_modified = 1;
+ entry.is_crc_checked = 1;
+ entry.is_tar = 1;
+ entry.tar_type = '0';
+ entry.phar = phar;
+ entry.fp_type = PHAR_MOD;
+
+ if (phar->is_persistent) {
+ if (error) {
+ spprintf(error, 0, "internal error: attempt to flush cached tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (phar->is_data) {
+ goto nostub;
+ }
+
+ /* set alias */
+ if (!phar->is_temporary_alias && phar->alias_len) {
+ entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ entry.filename_len = sizeof(".phar/alias.txt")-1;
+ entry.fp = php_stream_fopen_tmpfile();
+
+ if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
+ if (error) {
+ spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ entry.uncompressed_filesize = phar->alias_len;
+
+ if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (error) {
+ spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ } else {
+ zend_hash_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ }
+
+ /* set stub */
+ if (user_stub && !defaultstub) {
+ char *pos;
+ if (len < 0) {
+ /* resource passed in */
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (error) {
+ spprintf(error, 0, "unable to access resource to copy stub to new tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ if (len == -1) {
+ len = PHP_STREAM_COPY_ALL;
+ } else {
+ len = -len;
+ }
+ user_stub = 0;
+
+ if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ if (error) {
+ spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ free_user_stub = 1;
+ } else {
+ free_user_stub = 0;
+ }
+
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
+ if (error) {
+ spprintf(error, 0, "illegal stub for tar-based phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ return EOF;
+ }
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
+
+ len = pos - user_stub + 18;
+ entry.fp = php_stream_fopen_tmpfile();
+ entry.uncompressed_filesize = len + 5;
+
+ if ((size_t)len != php_stream_write(entry.fp, user_stub, len)
+ || 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) {
+ if (error) {
+ spprintf(error, 0, "unable to create stub from string in new tar-based phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ php_stream_close(entry.fp);
+ return EOF;
+ }
+
+ entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
+ entry.filename_len = sizeof(".phar/stub.php")-1;
+ zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
+
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ } else {
+ /* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */
+ entry.fp = php_stream_fopen_tmpfile();
+
+ if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) {
+ php_stream_close(entry.fp);
+ if (error) {
+ spprintf(error, 0, "unable to %s stub in%star-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname);
+ }
+ return EOF;
+ }
+
+ entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1;
+ entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
+ entry.filename_len = sizeof(".phar/stub.php")-1;
+
+ if (!defaultstub) {
+ if (!zend_hash_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 0, "unable to create stub in tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ } else {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ }
+ } else {
+ if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 0, "unable to overwrite stub in tar-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ }
+ }
+nostub:
+ if (phar->fp && !phar->is_brandnew) {
+ oldfile = phar->fp;
+ closeoldfile = 0;
+ php_stream_rewind(oldfile);
+ } else {
+ oldfile = php_stream_open_wrapper(phar->fname, "rb", 0, NULL);
+ closeoldfile = oldfile != NULL;
+ }
+
+ newfile = php_stream_fopen_tmpfile();
+
+ if (!newfile) {
+ if (error) {
+ spprintf(error, 0, "unable to create temporary file");
+ }
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+
+ pass.old = oldfile;
+ pass.new = newfile;
+ pass.error = error;
+ pass.free_fp = 1;
+ pass.free_ufp = 1;
+
+ if (phar->metadata) {
+ phar_entry_info *mentry;
+ if (SUCCESS == zend_hash_find(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1, (void **)&mentry)) {
+ if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(phar->metadata, mentry, error TSRMLS_CC)) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+ } else {
+ phar_entry_info newentry = {0};
+
+ newentry.filename = estrndup(".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1);
+ newentry.filename_len = sizeof(".phar/.metadata.bin")-1;
+ newentry.phar = phar;
+ newentry.tar_type = TAR_FILE;
+ newentry.is_tar = 1;
+
+ if (SUCCESS != zend_hash_add(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1, (void *)&newentry, sizeof(phar_entry_info), (void **)&mentry)) {
+ spprintf(error, 0, "phar tar error: unable to add magic metadata file to manifest for phar archive \"%s\"", phar->fname);
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+
+ if (ZEND_HASH_APPLY_KEEP != phar_tar_setmetadata(phar->metadata, mentry, error TSRMLS_CC)) {
+ zend_hash_del(&(phar->manifest), ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1);
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+ }
+ }
+
+ zend_hash_apply_with_argument(&phar->manifest, (apply_func_arg_t) phar_tar_setupmetadata, (void *) &pass TSRMLS_CC);
+
+ if (error && *error) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ /* on error in the hash iterator above, error is set */
+ php_stream_close(newfile);
+ return EOF;
+ }
+
+ zend_hash_apply_with_argument(&phar->manifest, (apply_func_arg_t) phar_tar_writeheaders, (void *) &pass TSRMLS_CC);
+
+ /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
+ if (!phar->is_data || phar->sig_flags) {
+ if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, error TSRMLS_CC)) {
+ if (error) {
+ char *save = *error;
+ spprintf(error, 0, "phar error: unable to write signature to tar-based phar: %s", save);
+ efree(save);
+ }
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ php_stream_close(newfile);
+ return EOF;
+ }
+
+ entry.filename = ".phar/signature.bin";
+ entry.filename_len = sizeof(".phar/signature.bin")-1;
+ entry.fp = php_stream_fopen_tmpfile();
+
+#ifdef WORDS_BIGENDIAN
+# define PHAR_SET_32(var, buffer) \
+ *(php_uint32 *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \
+ | ((((unsigned char*)&(buffer))[2]) << 16) \
+ | ((((unsigned char*)&(buffer))[1]) << 8) \
+ | (((unsigned char*)&(buffer))[0]))
+#else
+# define PHAR_SET_32(var, buffer) *(php_uint32 *)(var) = (php_uint32) (buffer)
+#endif
+ PHAR_SET_32(sigbuf, phar->sig_flags);
+ PHAR_SET_32(sigbuf + 4, signature_length);
+
+ if (8 != (int)php_stream_write(entry.fp, sigbuf, 8) || signature_length != (int)php_stream_write(entry.fp, signature, signature_length)) {
+ efree(signature);
+ if (error) {
+ spprintf(error, 0, "phar error: unable to write signature to tar-based phar %s", phar->fname);
+ }
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ php_stream_close(newfile);
+ return EOF;
+ }
+
+ efree(signature);
+ entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8;
+ /* throw out return value and write the signature */
+ entry.filename_len = phar_tar_writeheaders((void *)&entry, (void *)&pass TSRMLS_CC);
+
+ if (error && *error) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ /* error is set by writeheaders */
+ php_stream_close(newfile);
+ return EOF;
+ }
+ } /* signature */
+
+ /* add final zero blocks */
+ buf = (char *) ecalloc(1024, 1);
+ php_stream_write(newfile, buf, 1024);
+ efree(buf);
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+
+ /* on error in the hash iterator above, error is set */
+ if (error && *error) {
+ php_stream_close(newfile);
+ return EOF;
+ }
+
+ if (phar->fp && pass.free_fp) {
+ php_stream_close(phar->fp);
+ }
+
+ if (phar->ufp) {
+ if (pass.free_ufp) {
+ php_stream_close(phar->ufp);
+ }
+ phar->ufp = NULL;
+ }
+
+ phar->is_brandnew = 0;
+ php_stream_rewind(newfile);
+
+ if (phar->donotflush) {
+ /* deferred flush */
+ phar->fp = newfile;
+ } else {
+ phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
+ if (!phar->fp) {
+ phar->fp = newfile;
+ if (error) {
+ spprintf(error, 0, "unable to open new phar \"%s\" for writing", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (phar->flags & PHAR_FILE_COMPRESSED_GZ) {
+ php_stream_filter *filter;
+ /* to properly compress, we have to tell zlib to add a zlib header */
+ zval filterparams;
+
+ array_init(&filterparams);
+/* this is defined in zlib's zconf.h */
+#ifndef MAX_WBITS
+#define MAX_WBITS 15
+#endif
+ add_assoc_long(&filterparams, "window", MAX_WBITS + 16);
+ filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ zval_dtor(&filterparams);
+
+ if (!filter) {
+ /* copy contents uncompressed rather than lose them */
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ php_stream_close(newfile);
+ if (error) {
+ spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname);
+ }
+ return EOF;
+ }
+
+ php_stream_filter_append(&phar->fp->writefilters, filter);
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(phar->fp);
+ /* use the temp stream as our base */
+ phar->fp = newfile;
+ } else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
+ php_stream_filter *filter;
+
+ filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
+ php_stream_filter_append(&phar->fp->writefilters, filter);
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_close(phar->fp);
+ /* use the temp stream as our base */
+ phar->fp = newfile;
+ } else {
+ phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ /* we could also reopen the file in "rb" mode but there is no need for that */
+ php_stream_close(newfile);
+ }
+ }
+ return EOF;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/tar.h b/ext/phar/tar.h
new file mode 100644
index 0000000..8bfc381
--- /dev/null
+++ b/ext/phar/tar.h
@@ -0,0 +1,101 @@
+#ifndef __PHAR_TAR_H
+#define __PHAR_TAR_H
+/*
+ +----------------------------------------------------------------------+
+ | TAR archive support for Phar |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Dmitry Stogov <dmitry@zend.com> |
+ | Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifdef PHP_WIN32
+#pragma pack(1)
+# define PHAR_TAR_PACK
+#elif defined(__sgi)
+# define PHAR_TAR_PACK
+#elif defined(__GNUC__)
+# define PHAR_TAR_PACK __attribute__((__packed__))
+#else
+# define PHAR_TAR_PACK
+#endif
+
+#if defined(__sgi)
+# pragma pack 0
+#endif
+/**
+ * the format of the header block for a file, in the older UNIX-compatible
+ * TAR format
+ */
+typedef struct _old_tar_header { /* {{{ */
+ char name[100]; /* name of file;
+ directory is indicated by a trailing slash (/) */
+ char mode[8]; /* file mode */
+ char uid[8]; /* owner user ID */
+ char gid[8]; /* owner group ID */
+ char size[12]; /* length of file in bytes */
+ char mtime[12]; /* modify time of file */
+ char checksum[8]; /* checksum for header */
+ char link; /* indicator for links;
+ 1 for a linked file,
+ 2 for a symbolic link,
+ 0 otherwise */
+ char linkname[100]; /* name of linked file */
+} PHAR_TAR_PACK old_tar_header;
+/* }}} */
+
+#if defined(__sgi)
+# pragma pack 0
+#endif
+/**
+ * the new USTAR header format.
+ * Note that tar can determine that the USTAR format is being used by the
+ * presence of the null-terminated string "ustar" in the magic field.
+ */
+typedef struct _tar_header { /* {{{ */
+ char name[100]; /* name of file */
+ char mode[8]; /* file mode */
+ char uid[8]; /* owner user ID */
+ char gid[8]; /* owner group ID */
+ char size[12]; /* length of file in bytes */
+ char mtime[12]; /* modify time of file */
+ char checksum[8]; /* checksum for header */
+ char typeflag; /* type of file
+ 0 Regular file
+ 1 Link to another file already archived
+ 2 Symbolic link
+ 3 Character special device
+ 4 Block special device
+ 5 Directory
+ 6 FIFO special file
+ 7 Reserved */
+ char linkname[100]; /* name of linked file */
+ char magic[6]; /* USTAR indicator */
+ char version[2]; /* USTAR version */
+ char uname[32]; /* owner user name */
+ char gname[32]; /* owner group name */
+ char devmajor[8]; /* device major number */
+ char devminor[8]; /* device minor number */
+ char prefix[155]; /* prefix for file name;
+ the value of the prefix field, if non-null,
+ is prefixed to the name field to allow names
+ longer then 100 characters */
+ char padding[12]; /* unused zeroed bytes */
+} PHAR_TAR_PACK tar_header;
+/* }}} */
+
+#ifdef PHP_WIN32
+#pragma pack()
+#endif
+
+#endif /* __PHAR_TAR_H */
diff --git a/ext/phar/tests/001.phpt b/ext/phar/tests/001.phpt
new file mode 100644
index 0000000..1205e4e
--- /dev/null
+++ b/ext/phar/tests/001.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Phar::apiVersion
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(Phar::apiVersion());
+?>
+===DONE===
+--EXPECT--
+string(5) "1.1.1"
+===DONE===
diff --git a/ext/phar/tests/002.phpt b/ext/phar/tests/002.phpt
new file mode 100644
index 0000000..a7cf0cb
--- /dev/null
+++ b/ext/phar/tests/002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar::mapPhar truncated manifest/improper params
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+Phar::mapPhar(5, 'hio', 'hi');
+
+Phar::mapPhar();
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+__HALT_COMPILER(); ?>
+--EXPECTF--
+Warning: Phar::mapPhar() expects at most 2 parameters, 3 given in %s002.php on line %d
+internal corruption of phar "%s002.php" (truncated manifest at manifest length) \ No newline at end of file
diff --git a/ext/phar/tests/003.phpt b/ext/phar/tests/003.phpt
new file mode 100644
index 0000000..fcc95a8
--- /dev/null
+++ b/ext/phar/tests/003.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Phar::canCompress
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+/* check this works and actually returns the boolean value */
+var_dump(Phar::canCompress() == (
+ extension_loaded("zlib") || extension_loaded("bz2")
+ ));
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/phar/tests/003a.phpt b/ext/phar/tests/003a.phpt
new file mode 100644
index 0000000..37e3107
--- /dev/null
+++ b/ext/phar/tests/003a.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar::canCompress, specific
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(Phar::canCompress(Phar::GZ) == extension_loaded("zlib"));
+var_dump(Phar::canCompress(Phar::BZ2) == extension_loaded("bz2"));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/004.phpt b/ext/phar/tests/004.phpt
new file mode 100644
index 0000000..963a9b4
--- /dev/null
+++ b/ext/phar/tests/004.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar::mapPhar no __HALT_COMPILER();
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--FILE--
+<?php
+try {
+Phar::mapPhar('hio');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+--EXPECTF--
+__HALT_COMPILER(); must be declared in a phar
diff --git a/ext/phar/tests/005.phpt b/ext/phar/tests/005.phpt
new file mode 100644
index 0000000..a6e3449
--- /dev/null
+++ b/ext/phar/tests/005.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar::mapPhar truncated manifest (none)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--FILE--
+<?php
+try {
+Phar::mapPhar('hio');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+__HALT_COMPILER(); ?>()
+--EXPECTF--
+internal corruption of phar "%s" (truncated manifest at manifest length)
diff --git a/ext/phar/tests/006.phpt b/ext/phar/tests/006.phpt
new file mode 100644
index 0000000..b2e8b29
--- /dev/null
+++ b/ext/phar/tests/006.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar::mapPhar truncated manifest (manifest length truncated)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--FILE--
+<?php
+try {
+Phar::mapPhar('hio');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+__HALT_COMPILER(); ?>
+--EXPECTF--
+internal corruption of phar "%s" (truncated manifest at manifest length)
diff --git a/ext/phar/tests/007.phpt b/ext/phar/tests/007.phpt
new file mode 100644
index 0000000..a13c2a4
--- /dev/null
+++ b/ext/phar/tests/007.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar::mapPhar manifest too big
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--FILE--
+<?php
+try {
+Phar::mapPhar('hio');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+__HALT_COMPILER(); ?>~~~~
+--EXPECTF--
+manifest cannot be larger than 100 MB in phar "%s"
diff --git a/ext/phar/tests/008.phpt b/ext/phar/tests/008.phpt
new file mode 100644
index 0000000..664ffea
--- /dev/null
+++ b/ext/phar/tests/008.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar::mapPhar truncated manifest (not enough for manifest length)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--FILE--
+<?php
+$file = "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+$file .= pack('V', 500) . 'notenough';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+try {
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+internal corruption of phar "%s" (truncated manifest header)
diff --git a/ext/phar/tests/009.phpt b/ext/phar/tests/009.phpt
new file mode 100644
index 0000000..61933b3
--- /dev/null
+++ b/ext/phar/tests/009.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar::mapPhar too many manifest entries
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+$file .= (binary) pack(b'VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . (binary) str_repeat((binary)'A', 500);
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+try {
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+internal corruption of phar "%s009.phar.php" (too many manifest entries for size of manifest)
diff --git a/ext/phar/tests/010.phpt b/ext/phar/tests/010.phpt
new file mode 100644
index 0000000..d1e2f40
--- /dev/null
+++ b/ext/phar/tests/010.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar::mapPhar buffer overrun
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+// this fails because the manifest length does not include the other 10 byte manifest data
+
+$manifest = pack('V', 1) . 'a' . pack('VVVVVV', 0, time(), 0, crc32(b''), 0x00000000, 0);
+$file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . 'hio' . pack('V', 0) . $manifest;
+
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+try {
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+echo file_get_contents('phar://hio/a');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+internal corruption of phar "%s" (too many manifest entries for size of manifest)
diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt
new file mode 100644
index 0000000..4a1f0dd
--- /dev/null
+++ b/ext/phar/tests/011.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar::mapPhar filesize too small in manifest
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+// compressed file length does not match incompressed lentgh for an uncompressed file
+
+$files = array();
+$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2);;
+include 'files/phar_test.inc';
+try {
+include $fname;
+echo file_get_contents('phar://hio/a');
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+internal corruption of phar "%s" (compressed and uncompressed size does not match for uncompressed entry)
diff --git a/ext/phar/tests/012.phpt b/ext/phar/tests/012.phpt
new file mode 100644
index 0000000..3246eff
--- /dev/null
+++ b/ext/phar/tests/012.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Phar::mapPhar valid file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+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';
+
+include 'files/phar_test.inc';
+include $fname;
+
+echo file_get_contents('phar://hio/a');
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+a
diff --git a/ext/phar/tests/013.phpt b/ext/phar/tests/013.phpt
new file mode 100644
index 0000000..ae3ae72
--- /dev/null
+++ b/ext/phar/tests/013.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar::mapPhar filesize mismatch
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+// filesize should be 1, and is 2
+
+$files = array();
+$files['a'] = array('cont'=>'a', 'ulen'=>2, 'clen'=>2);
+include 'files/phar_test.inc';
+
+echo file_get_contents($pname.'/a');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (%s file "a") in %s on line %d
diff --git a/ext/phar/tests/014.phpt b/ext/phar/tests/014.phpt
new file mode 100644
index 0000000..cb83ea5
--- /dev/null
+++ b/ext/phar/tests/014.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar::mapPhar filesize mismatch
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+// wrong crc32
+
+$files = array();
+$files['a'] = array('cont'=>'a', 'crc32'=>crc32(b'aX'));
+include 'files/phar_test.inc';
+
+echo file_get_contents($pname.'/a');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d
diff --git a/ext/phar/tests/015.phpt b/ext/phar/tests/015.phpt
new file mode 100644
index 0000000..b93b77e
--- /dev/null
+++ b/ext/phar/tests/015.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar::mapPhar valid file (gzipped)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+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'] = array('cont'=>'a','comp'=>chr(75) . chr(4) . chr(0) /* 'a' gzdeflated */, 'flags'=>0x00001000);
+include 'files/phar_test.inc';
+
+echo file_get_contents($pname .'/a');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+a
diff --git a/ext/phar/tests/015b.phpt b/ext/phar/tests/015b.phpt
new file mode 100644
index 0000000..08ead2d
--- /dev/null
+++ b/ext/phar/tests/015b.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar::mapPhar valid file (bzip2)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
+--INI--
+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'] = array('cont'=>'Hello World', 'comp'=>pack('H*', '425a6834314159265359065c89da0000009780400000400080060490002000310c082031a916c41d41e2ee48a70a1200cb913b40'),'flags'=>0x00002000);
+include 'files/phar_test.inc';
+
+var_dump(file_get_contents($pname . '/a'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(11) "Hello World"
diff --git a/ext/phar/tests/016.phpt b/ext/phar/tests/016.phpt
new file mode 100644
index 0000000..3288e8e
--- /dev/null
+++ b/ext/phar/tests/016.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar::mapPhar invalid file (gzipped file length is too short)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php __HALT_COMPILER(); ?>";
+// file length is too short
+
+$files = array();
+// "hi" gzdeflated
+$files['a'] = array('cont'=>b'a','comp'=> (binary)pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
+$files['b'] = $files['a'];
+$files['c'] = array('cont'=>b'*');
+$files['d'] = $files['a'];
+include 'files/phar_test.inc';
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump(file_get_contents($pname . '/b'));
+var_dump(file_get_contents($pname . '/c'));
+var_dump(file_get_contents($pname . '/d'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
+bool(false)
+
+Warning: file_get_contents(phar://%s/b): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "b") in %s on line %d
+bool(false)
+string(1) "*"
+
+Warning: file_get_contents(phar://%s/d): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "d") in %s on line %d
+bool(false)
diff --git a/ext/phar/tests/016b.phpt b/ext/phar/tests/016b.phpt
new file mode 100644
index 0000000..8fe6682
--- /dev/null
+++ b/ext/phar/tests/016b.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar::mapPhar invalid file (gzipped file length is too short)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+// file length is too short
+
+$files = array();
+$files['a'] = array('cont'=>'a','flags'=>0x00001000, 'clen' => 1);
+include 'files/phar_test.inc';
+
+echo file_get_contents($pname . '/a');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
diff --git a/ext/phar/tests/017.phpt b/ext/phar/tests/017.phpt
new file mode 100644
index 0000000..7c64c40
--- /dev/null
+++ b/ext/phar/tests/017.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: opendir test - no dir specified at all
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php
+Phar::mapPhar('hio');
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != 'phar');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'abc';
+include 'files/phar_test.inc';
+
+include $pname;
+$dir = opendir('phar://hio');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+string(%d) "%s017.phar.php"
+bool(true)
+
+Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory (always use full path to a new phar)
+phar url "phar://hio" is unknown in %s017.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/017U.phpt b/ext/phar/tests/017U.phpt
new file mode 100644
index 0000000..af65b6d
--- /dev/null
+++ b/ext/phar/tests/017U.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: opendir test - no dir specified at all
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != 'phar');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'abc';
+include 'files/phar_test.inc';
+
+include $pname;
+$dir = opendir('phar://hio');
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+unicode(%d) "%s017U.phar.php"
+bool(true)
+
+Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory (always use full path to a new phar)
+phar url "phar://hio" is unknown in %s017U.php on line %d
diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt
new file mode 100644
index 0000000..2e2df47
--- /dev/null
+++ b/ext/phar/tests/018.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar: opendir test, root directory
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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';
+$files['b/a'] = 'b';
+include 'files/phar_test.inc';
+
+include $fname;
+$dir = opendir('phar://hio/');
+while (false !== ($a = readdir($dir))) {
+ var_dump($a);
+ var_dump(is_dir('phar://hio/' . $a));
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(true) \ No newline at end of file
diff --git a/ext/phar/tests/018U.phpt b/ext/phar/tests/018U.phpt
new file mode 100644
index 0000000..c8d798d
--- /dev/null
+++ b/ext/phar/tests/018U.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar: opendir test, root directory
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'a';
+$files['b/a'] = 'b';
+include 'files/phar_test.inc';
+
+include $fname;
+$dir = opendir('phar://hio/');
+while (false !== ($a = readdir($dir))) {
+ var_dump($a);
+ var_dump(is_dir('phar://hio/' . $a));
+}
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+unicode(1) "a"
+bool(false)
+unicode(1) "b"
+bool(true)
diff --git a/ext/phar/tests/019.phpt b/ext/phar/tests/019.phpt
new file mode 100644
index 0000000..0a5a7d7
--- /dev/null
+++ b/ext/phar/tests/019.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Phar: opendir test, subdirectory
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'a';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+
+include 'files/phar_test.inc';
+include $fname;
+
+$dir = opendir('phar://hio/b');
+
+if ($dir) {
+ while (false !== ($a = readdir($dir))) {
+ var_dump($a);
+ var_dump(is_dir('phar://hio/b/' . $a));
+ }
+}
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+%s(1) "a"
+bool(false)
+%s(1) "c"
+bool(true)
diff --git a/ext/phar/tests/019b.phpt b/ext/phar/tests/019b.phpt
new file mode 100644
index 0000000..5a0ef71
--- /dev/null
+++ b/ext/phar/tests/019b.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Phar: opendir test, recurse into
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+include 'files/phar_test.inc';
+include $fname;
+
+function dump($phar, $base)
+{
+ var_dump($phar . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ }
+}
+
+dump('phar://hio', '/');
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(11) "phar://hio/"
+string(2) "/a"
+bool(false)
+string(2) "/b"
+bool(true)
+string(12) "phar://hio/b"
+string(4) "/b/a"
+bool(false)
+string(4) "/b/c"
+bool(true)
+string(14) "phar://hio/b/c"
+string(6) "/b/c/d"
+bool(false)
+string(4) "/bad"
+bool(true)
+string(14) "phar://hio/bad"
+string(6) "/bad/c"
+bool(false)
diff --git a/ext/phar/tests/019bU.phpt b/ext/phar/tests/019bU.phpt
new file mode 100644
index 0000000..c0864aa
--- /dev/null
+++ b/ext/phar/tests/019bU.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Phar: opendir test, recurse into
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'a';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+
+include 'files/phar_test.inc';
+include $fname;
+
+function dump($phar, $base)
+{
+ var_dump($phar . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ }
+}
+
+dump('phar://hio', '/');
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+unicode(11) "phar://hio/"
+unicode(2) "/a"
+bool(false)
+unicode(2) "/b"
+bool(true)
+unicode(12) "phar://hio/b"
+unicode(4) "/b/a"
+bool(false)
+unicode(4) "/b/c"
+bool(true)
+unicode(14) "phar://hio/b/c"
+unicode(6) "/b/c/d"
+bool(false)
+unicode(4) "/bad"
+bool(true)
+unicode(14) "phar://hio/bad"
+unicode(6) "/bad/c"
+bool(false)
diff --git a/ext/phar/tests/019c.phpt b/ext/phar/tests/019c.phpt
new file mode 100644
index 0000000..2cb508c
--- /dev/null
+++ b/ext/phar/tests/019c.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Phar: opendir test, recurse into
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+include 'files/phar_test.inc';
+include $fname;
+
+function dump($phar, $base)
+{
+ var_dump($phar . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ else
+ {
+ var_dump(file_get_contents($phar . $entry));
+ }
+ }
+}
+
+dump('phar://hio', '/');
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(11) "phar://hio/"
+string(2) "/a"
+bool(false)
+string(1) "a"
+string(2) "/b"
+bool(true)
+string(12) "phar://hio/b"
+string(4) "/b/a"
+bool(false)
+string(1) "b"
+string(4) "/b/c"
+bool(true)
+string(14) "phar://hio/b/c"
+string(6) "/b/c/d"
+bool(false)
+string(1) "c"
+string(4) "/bad"
+bool(true)
+string(14) "phar://hio/bad"
+string(6) "/bad/c"
+bool(false)
+string(1) "d"
diff --git a/ext/phar/tests/019cU.phpt b/ext/phar/tests/019cU.phpt
new file mode 100644
index 0000000..36ef6d8
--- /dev/null
+++ b/ext/phar/tests/019cU.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Phar: opendir test, recurse into
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'a';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+include 'files/phar_test.inc';
+include $fname;
+
+function dump($phar, $base)
+{
+ var_dump($phar . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ else
+ {
+ var_dump(file_get_contents($phar . $entry));
+ }
+ }
+}
+
+dump('phar://hio', '/');
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+unicode(11) "phar://hio/"
+unicode(2) "/a"
+bool(false)
+string(1) "a"
+unicode(2) "/b"
+bool(true)
+unicode(12) "phar://hio/b"
+unicode(4) "/b/a"
+bool(false)
+string(1) "b"
+unicode(4) "/b/c"
+bool(true)
+unicode(14) "phar://hio/b/c"
+unicode(6) "/b/c/d"
+bool(false)
+string(1) "c"
+unicode(4) "/bad"
+bool(true)
+unicode(14) "phar://hio/bad"
+unicode(6) "/bad/c"
+bool(false)
+string(1) "d"
diff --git a/ext/phar/tests/020.phpt b/ext/phar/tests/020.phpt
new file mode 100644
index 0000000..7d01681
--- /dev/null
+++ b/ext/phar/tests/020.phpt
@@ -0,0 +1,136 @@
+--TEST--
+Phar: url stat
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?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';
+include 'files/phar_test.inc';
+include $fname;
+
+var_dump(stat('phar://hio/a'), stat('phar://hio/b'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+array(26) {
+ [0]=>
+ int(12)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(33060)
+ [3]=>
+ int(1)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(-1)
+ [7]=>
+ int(1)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ [%sdev"]=>
+ int(12)
+ [%sino"]=>
+ int(%d)
+ [%smode"]=>
+ int(33060)
+ [%snlink"]=>
+ int(1)
+ [%suid"]=>
+ int(0)
+ [%sgid"]=>
+ int(0)
+ [%srdev"]=>
+ int(-1)
+ [%ssize"]=>
+ int(1)
+ [%satime"]=>
+ int(%d)
+ [%smtime"]=>
+ int(%d)
+ [%sctime"]=>
+ int(%d)
+ [%sblksize"]=>
+ int(-1)
+ [%sblocks"]=>
+ int(-1)
+}
+array(26) {
+ [0]=>
+ int(12)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(16749)
+ [3]=>
+ int(1)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(-1)
+ [7]=>
+ int(0)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ [%sdev"]=>
+ int(12)
+ [%sino"]=>
+ int(%d)
+ [%smode"]=>
+ int(16749)
+ [%snlink"]=>
+ int(1)
+ [%suid"]=>
+ int(0)
+ [%sgid"]=>
+ int(0)
+ [%srdev"]=>
+ int(-1)
+ [%ssize"]=>
+ int(0)
+ [%satime"]=>
+ int(%d)
+ [%smtime"]=>
+ int(%d)
+ [%sctime"]=>
+ int(%d)
+ [%sblksize"]=>
+ int(-1)
+ [%sblocks"]=>
+ int(-1)
+} \ No newline at end of file
diff --git a/ext/phar/tests/021.phpt b/ext/phar/tests/021.phpt
new file mode 100644
index 0000000..bfd6576
--- /dev/null
+++ b/ext/phar/tests/021.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Phar: stream stat
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = 'a';
+$files['b/a'] = 'b';
+$files['b/c/d'] = 'c';
+$files['bad/c'] = 'd';
+
+include 'files/phar_test.inc';
+
+include $fname;
+
+$fp = fopen('phar://hio/a', 'r');
+var_dump(fstat($fp));
+fclose($fp);
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+array(26) {
+ [0]=>
+ int(12)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(33060)
+ [3]=>
+ int(1)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(-1)
+ [7]=>
+ int(1)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ [%sdev"]=>
+ int(12)
+ [%sino"]=>
+ int(%d)
+ [%smode"]=>
+ int(33060)
+ [%snlink"]=>
+ int(1)
+ [%suid"]=>
+ int(0)
+ [%sgid"]=>
+ int(0)
+ [%srdev"]=>
+ int(-1)
+ [%ssize"]=>
+ int(1)
+ [%satime"]=>
+ int(%d)
+ [%smtime"]=>
+ int(%d)
+ [%sctime"]=>
+ int(%d)
+ [%sblksize"]=>
+ int(-1)
+ [%sblocks"]=>
+ int(-1)
+} \ No newline at end of file
diff --git a/ext/phar/tests/022.phpt b/ext/phar/tests/022.phpt
new file mode 100644
index 0000000..20c24a0
--- /dev/null
+++ b/ext/phar/tests/022.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Phar: stream stat
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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';
+
+include 'files/phar_test.inc';
+
+include $fname;
+
+$fp = fopen('phar://hio/a', 'r');
+var_dump(ftell($fp));
+echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
+var_dump(ftell($fp));
+echo 'fseek($fp, 1, SEEK_CUR)';var_dump(fseek($fp, 1, SEEK_CUR));
+var_dump(ftell($fp));
+echo 'fseek($fp, -1, SEEK_CUR)';var_dump(fseek($fp, -1, SEEK_CUR));
+var_dump(ftell($fp));
+echo 'fseek($fp, -1, SEEK_END)';var_dump(fseek($fp, -1, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, -7, SEEK_END)';var_dump(fseek($fp, -7, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, 0, SEEK_END)';var_dump(fseek($fp, 0, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, 1, SEEK_END)';var_dump(fseek($fp, 1, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
+var_dump(ftell($fp));
+echo 'fseek($fp, 6)';var_dump(fseek($fp, 6));
+var_dump(ftell($fp));
+echo 'fseek($fp, 8)';var_dump(fseek($fp, 8));
+var_dump(ftell($fp));
+echo 'fseek($fp, -1)';var_dump(fseek($fp, -1));
+var_dump(ftell($fp));
+echo "next\n";
+fseek($fp, 4);
+var_dump(ftell($fp));
+echo 'fseek($fp, -5, SEEK_CUR)';var_dump(fseek($fp, -5, SEEK_CUR));
+var_dump(ftell($fp));
+fseek($fp, 4);
+var_dump(ftell($fp));
+echo 'fseek($fp, 5, SEEK_CUR)';var_dump(fseek($fp, 5, SEEK_CUR));
+var_dump(ftell($fp));
+fseek($fp, 4);
+var_dump(ftell($fp));
+echo 'fseek($fp, -4, SEEK_CUR)';var_dump(fseek($fp, -4, SEEK_CUR));
+var_dump(ftell($fp));
+fseek($fp, 4);
+var_dump(ftell($fp));
+echo 'fseek($fp, 3, SEEK_CUR)';var_dump(fseek($fp, 3, SEEK_CUR));
+var_dump(ftell($fp));
+fclose($fp);
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+exit(0);
+ ?>
+--EXPECT--
+int(0)
+fseek($fp, 1)int(0)
+int(1)
+fseek($fp, 1, SEEK_CUR)int(0)
+int(2)
+fseek($fp, -1, SEEK_CUR)int(0)
+int(1)
+fseek($fp, -1, SEEK_END)int(0)
+int(6)
+fseek($fp, -8, SEEK_END)int(-1)
+bool(false)
+fseek($fp, -7, SEEK_END)int(0)
+int(0)
+fseek($fp, 0, SEEK_END)int(0)
+int(7)
+fseek($fp, 1, SEEK_END)int(-1)
+bool(false)
+fseek($fp, -8, SEEK_END)int(-1)
+bool(false)
+fseek($fp, 6)int(0)
+int(6)
+fseek($fp, 8)int(-1)
+bool(false)
+fseek($fp, -1)int(-1)
+bool(false)
+next
+int(4)
+fseek($fp, -5, SEEK_CUR)int(-1)
+bool(false)
+int(4)
+fseek($fp, 5, SEEK_CUR)int(-1)
+bool(false)
+int(4)
+fseek($fp, -4, SEEK_CUR)int(0)
+int(0)
+int(4)
+fseek($fp, 3, SEEK_CUR)int(0)
+int(7)
diff --git a/ext/phar/tests/023.phpt b/ext/phar/tests/023.phpt
new file mode 100644
index 0000000..808f91d
--- /dev/null
+++ b/ext/phar/tests/023.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: phar:// file_get_contents
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+
+include 'files/phar_test.inc';
+
+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===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(28) "<?php echo "This is a\n"; ?>"
+string(28) "<?php echo "This is b\n"; ?>"
+string(30) "<?php echo "This is b/c\n"; ?>"
+===DONE===
diff --git a/ext/phar/tests/024.phpt b/ext/phar/tests/024.phpt
new file mode 100644
index 0000000..ad30d26
--- /dev/null
+++ b/ext/phar/tests/024.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: phar:// include
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+
+include 'files/phar_test.inc';
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+This is a
+This is b
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/025.phpt b/ext/phar/tests/025.phpt
new file mode 100644
index 0000000..bbb5bc4
--- /dev/null
+++ b/ext/phar/tests/025.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: phar:// include (repeated names)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+
+include 'files/phar_test.inc';
+
+include $pname . '/a';
+include $pname . '/b';
+include $pname . '/b/b';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+This is a
+This is b
+This is b/b
+===DONE===
diff --git a/ext/phar/tests/026.phpt b/ext/phar/tests/026.phpt
new file mode 100644
index 0000000..696fbcf
--- /dev/null
+++ b/ext/phar/tests/026.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: phar:// require from within
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; require \''.$pname.'/b.php\'; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; require \''.$pname.'/b/c.php\'; ?>';
+$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"; ?>';
+
+include 'files/phar_test.inc';
+
+require $pname . '/a.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+This is a
+This is b
+This is b/c
+This is b/d
+This is e
+===DONE===
diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt
new file mode 100644
index 0000000..8736efb
--- /dev/null
+++ b/ext/phar/tests/027.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Phar: phar:// opendir
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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"; require \''.$pname.'/b.php\'; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; require \''.$pname.'/b/c.php\'; ?>';
+$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"; ?>';
+
+include 'files/phar_test.inc';
+
+function dump($phar, $base)
+{
+ var_dump(str_replace(dirname(__FILE__), '*', $phar) . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ }
+}
+
+dump($pname, '/');
+
+$a = opendir($pname);
+// this may stop working in future versions, but is here for code coverage purposes
+echo "fseek on dir handle\n";
+var_dump(fseek($a, 0, SEEK_END), ftell($a));
+var_dump(fseek($a, -1), ftell($a));
+var_dump(fseek($a, 1), ftell($a));
+echo "fwrite on dir handle\n";
+var_dump(fwrite($a, 'hi'));
+var_dump(fstat($a));
+closedir($a);
+echo "opendir edge cases\n";
+var_dump(opendir("phar://"));
+var_dump(opendir("phar://foo.phar/hi"));
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+string(%d) "phar://*/027.phar.php/"
+string(6) "/a.php"
+bool(false)
+string(2) "/b"
+bool(true)
+string(%d) "phar://*/027.phar.php/b"
+string(8) "/b/c.php"
+bool(false)
+string(8) "/b/d.php"
+bool(false)
+string(6) "/b.php"
+bool(false)
+string(6) "/e.php"
+bool(false)
+fseek on dir handle
+int(0)
+int(4)
+int(-1)
+int(4)
+int(0)
+int(1)
+fwrite on dir handle
+int(0)
+bool(false)
+opendir edge cases
+
+Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
+phar url "phar://" is unknown in %s027.php on line %d
+bool(false)
+
+Warning: opendir(phar://foo.phar/hi): failed to open dir: phar error: invalid url or non-existent phar "phar://foo.phar/hi"
+phar url "phar://foo.phar/hi" is unknown in %s027.php on line %d
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/027U.phpt b/ext/phar/tests/027U.phpt
new file mode 100644
index 0000000..6794c52
--- /dev/null
+++ b/ext/phar/tests/027U.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Phar: phar:// opendir
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; require \''.$pname.'/b.php\'; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; require \''.$pname.'/b/c.php\'; ?>';
+$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"; ?>';
+
+include 'files/phar_test.inc';
+
+function dump($phar, $base)
+{
+ var_dump(str_replace(dirname(__FILE__), '*', $phar) . $base);
+ $dir = opendir($phar . $base);
+ if ($base == '/')
+ {
+ $base = '';
+ }
+ while (false !== ($entry = readdir($dir))) {
+ $entry = $base . '/' . $entry;
+ var_dump($entry);
+ var_dump(is_dir($phar . $entry));
+ if (is_dir($phar . $entry))
+ {
+ dump($phar, $entry);
+ }
+ }
+}
+
+dump($pname, '/');
+
+$a = opendir($pname);
+// this may stop working in future versions, but is here for code coverage purposes
+echo "fseek on dir handle\n";
+var_dump(fseek($a, 0, SEEK_END), ftell($a));
+var_dump(fseek($a, -1), ftell($a));
+var_dump(fseek($a, 1), ftell($a));
+echo "fwrite on dir handle\n";
+var_dump(fwrite($a, b'hi'));
+var_dump(fstat($a));
+closedir($a);
+echo "opendir edge cases\n";
+var_dump(opendir("phar://"));
+var_dump(opendir("phar://foo.phar/hi"));
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+unicode(%d) "phar://*/027U.phar.php/"
+unicode(6) "/a.php"
+bool(false)
+unicode(2) "/b"
+bool(true)
+unicode(%d) "phar://*/027U.phar.php/b"
+unicode(8) "/b/c.php"
+bool(false)
+unicode(8) "/b/d.php"
+bool(false)
+unicode(6) "/b.php"
+bool(false)
+unicode(6) "/e.php"
+bool(false)
+fseek on dir handle
+int(0)
+int(4)
+int(-1)
+int(4)
+int(0)
+int(1)
+fwrite on dir handle
+int(0)
+bool(false)
+opendir edge cases
+
+Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
+phar url "phar://" is unknown in %s027U.php on line %d
+bool(false)
+
+Warning: opendir(phar://foo.phar/hi): failed to open dir: phar error: invalid url or non-existent phar "phar://foo.phar/hi"
+phar url "phar://foo.phar/hi" is unknown in %s027U.php on line %d
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/028.phpt b/ext/phar/tests/028.phpt
new file mode 100644
index 0000000..087f822
--- /dev/null
+++ b/ext/phar/tests/028.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar::loadPhar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://hio';
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+$alias = '';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
+$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"; ?>';
+
+include 'files/phar_test.inc';
+
+Phar::loadPhar($fname, 'hio');
+
+include $fname;
+
+echo "======\n";
+
+include $pname . '/a.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+This is b/d
+This is e
+======
+This is a
+This is b
+This is b/c
+This is b/d
+This is e
+===DONE===
diff --git a/ext/phar/tests/029.phpt b/ext/phar/tests/029.phpt
new file mode 100644
index 0000000..41fcec0
--- /dev/null
+++ b/ext/phar/tests/029.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Phar::loadPhar overloading alias names
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname1 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$fname = $fname1;
+$alias = '';
+$pname = 'phar://hio';
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
+$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"; ?>';
+
+include 'files/phar_test.inc';
+
+copy($fname1, $fname2);
+
+var_dump(Phar::loadPhar($fname1, 'hio'));
+var_dump(Phar::loadPhar($fname1, 'copy'));
+$a = new Phar($fname1);
+try
+{
+ var_dump(Phar::loadPhar($fname2, 'copy'));
+}
+catch (Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php');
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+alias "copy" is already used for archive "%s029.1.phar.php" cannot be overloaded with "%s029.2.phar.php"
+===DONE===
diff --git a/ext/phar/tests/030.phpt b/ext/phar/tests/030.phpt
new file mode 100644
index 0000000..e1e94db
--- /dev/null
+++ b/ext/phar/tests/030.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Phar::loadPhar ignoring alias
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include \''.$pname.'/b.php\'; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; include \''.$pname.'/b/c.php\'; ?>';
+$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"; ?>';
+$files['.phar/test'] = '<?php bad boy ?>';
+
+include 'files/phar_test.inc';
+
+Phar::loadPhar($fname);
+
+require $pname . '/a.php';
+
+$p = new Phar($fname);
+var_dump(isset($p['.phar/test']));
+try {
+$p['.phar/test'];
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+This is b/d
+This is e
+bool(false)
+Cannot directly get any files or directories in magic ".phar" directory
+===DONE===
diff --git a/ext/phar/tests/031.phpt b/ext/phar/tests/031.phpt
new file mode 100644
index 0000000..4d59886
--- /dev/null
+++ b/ext/phar/tests/031.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar: include and parser error
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 3;
+
+require_once 'files/phar_oo_test.inc';
+
+Phar::loadPhar($fname);
+
+$pname = 'phar://' . $fname . '/a.php';
+
+var_dump(file_get_contents($pname));
+require $pname;
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+string(25) "<?php echo new new class;"
+
+Parse error: %s in phar://%sphar_oo_test.phar.php/a.php on line %d
diff --git a/ext/phar/tests/032.phpt b/ext/phar/tests/032.phpt
new file mode 100644
index 0000000..faf3dcb
--- /dev/null
+++ b/ext/phar/tests/032.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: require hash
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=1
+--FILE--
+<?php
+
+$pharconfig = 0;
+
+require_once 'files/phar_oo_test.inc';
+
+try {
+Phar::loadPhar($fname);
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+
+phar "%sphar_oo_test.phar.php" does not have a signature===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/033.phpt b/ext/phar/tests/033.phpt
new file mode 100644
index 0000000..d53c7f5
--- /dev/null
+++ b/ext/phar/tests/033.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar::chmod
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$pname = 'phar://hio';
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
+$files['dir/'] = '';
+$hasdir = 1;
+include 'files/phar_test.inc';
+$a = new Phar($fname);
+var_dump($a['a.php']->isExecutable());
+$a['a.php']->chmod(0777);
+var_dump($a['a.php']->isExecutable());
+$a['a.php']->chmod(0666);
+var_dump($a['a.php']->isExecutable());
+echo "test dir\n";
+var_dump($a['dir']->isDir());
+var_dump($a['dir']->isReadable());
+$a['dir']->chmod(000);
+var_dump($a['dir']->isReadable());
+$a['dir']->chmod(0666);
+var_dump($a['dir']->isReadable());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(false)
+test dir
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/033a.phpt b/ext/phar/tests/033a.phpt
new file mode 100644
index 0000000..4586f35
--- /dev/null
+++ b/ext/phar/tests/033a.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar::chmod
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$pname = 'phar://hio';
+$file = b'<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
+include 'files/phar_test.inc';
+try {
+ $a = new Phar($fname);
+ var_dump($a['a.php']->isExecutable());
+ $a['a.php']->chmod(0777);
+ var_dump($a['a.php']->isExecutable());
+ $a['a.php']->chmod(0666);
+ var_dump($a['a.php']->isExecutable());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+?>
+--EXPECTF--
+bool(false)
+Cannot modify permissions for file "a.php" in phar "%s033a.1.phar.php", write operations are prohibited
+===DONE===
diff --git a/ext/phar/tests/addfuncs.phpt b/ext/phar/tests/addfuncs.phpt
new file mode 100644
index 0000000..4312bff
--- /dev/null
+++ b/ext/phar/tests/addfuncs.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: addFile/addFromString
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$phar = new Phar($fname);
+$phar->addFromString('a', 'hi');
+echo file_get_contents($pname . '/a') . "\n";
+$phar->addFile($pname . '/a', 'b');
+echo file_get_contents($pname . '/b') . "\n";
+try {
+$phar->addFile($pname . '/a');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar->addFile($pname . '/a', 'a');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar->addFile(dirname(__FILE__) . '/does/not/exist');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar->addFile($pname . '/a', '.phar/stub.php');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar->addFromString('.phar/stub.php', 'hi');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+hi
+hi
+Entry phar://%saddfuncs.phar.php/a does not exist and cannot be created: phar error: invalid path "phar://%saddfuncs.phar.php/a" contains double slash
+Entry a does not exist and cannot be created: phar error: file "a" in phar "%saddfuncs.phar.php" cannot be opened for writing, readable file pointers are open
+phar error: unable to open file "%s/does/not/exist" to add to phar archive
+Cannot create any files in magic ".phar" directory
+Cannot create any files in magic ".phar" directory
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/alias_acrobatics.phpt b/ext/phar/tests/alias_acrobatics.phpt
new file mode 100644
index 0000000..1bb20a4
--- /dev/null
+++ b/ext/phar/tests/alias_acrobatics.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: alias edge cases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar';
+
+$p = new Phar($fname);
+
+$p->setAlias('foo');
+$p['unused'] = 'hi';
+try {
+$a = new Phar($fname2, 0, 'foo');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+copy($fname, $fname2);
+echo "2\n";
+try {
+$a = new Phar($fname2);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+$b = new Phar($fname, 0, 'another');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
+?>
+--EXPECTF--
+alias "foo" is already used for archive "%salias_acrobatics.phar" cannot be overloaded with "%salias_acrobatics.2.phar"
+2
+Cannot open archive "%salias_acrobatics.2.phar", alias is already in use by existing archive
+alias "another" is already used for archive "%salias_acrobatics.phar" cannot be overloaded with "%salias_acrobatics.phar"
+===DONE===
diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt
new file mode 100644
index 0000000..3179697
--- /dev/null
+++ b/ext/phar/tests/badparameters.phpt
@@ -0,0 +1,186 @@
+--TEST--
+Phar: bad parameters to various methods
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+ini_set('phar.readonly', 1);
+Phar::mungServer('hi');
+Phar::createDefaultStub(array());
+Phar::loadPhar(array());
+Phar::canCompress('hi');
+$a = new Phar(array());
+$a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
+$a->convertToExecutable(array());
+$a->convertToData(array());
+$b = new PharData(dirname(__FILE__) . '/whatever.tar');
+$c = new PharData(dirname(__FILE__) . '/whatever.zip');
+$b->delete(array());
+try {
+$a->delete('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$b->delete('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+echo $a->getPath() . "\n";
+try {
+$a->setAlias('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$b->setAlias('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 0);
+$a->setAlias(array());
+ini_set('phar.readonly', 1);
+try {
+$b->stopBuffering();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$a->setStub('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$b->setStub('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 0);
+$a->setStub(array());
+ini_set('phar.readonly', 1);
+try {
+$b->setDefaultStub('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->setDefaultStub(array());
+try {
+$a->setDefaultStub('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$a->setSignatureAlgorithm(Phar::MD5);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->compress(array());
+try {
+$a->compress(1);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->compressFiles(array());
+try {
+$a->decompressFiles();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->copy(array());
+try {
+$a->copy('a', 'b');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->offsetExists(array());
+$a->offsetGet(array());
+ini_set('phar.readonly', 0);
+$a->offsetSet(array());
+ini_set('phar.readonly', 1);
+$b->offsetUnset(array());
+try {
+$a->offsetUnset('a');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a->addEmptyDir(array());
+$a->addFile(array());
+$a->addFromString(array());
+try {
+$a->setMetadata('a');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 0);
+$a->setMetadata(1,2);
+ini_set('phar.readonly', 1);
+try {
+$a->delMetadata();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+Warning: Phar::mungServer() expects parameter 1 to be array, %string given in %sbadparameters.php on line %d
+
+Warning: Phar::createDefaultStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::loadPhar() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::canCompress() expects parameter 1 to be long, %string given in %sbadparameters.php on line %d
+
+Warning: Phar::__construct() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::convertToExecutable() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+
+Warning: Phar::convertToData() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+
+Warning: PharData::delete() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+Cannot write out phar archive, phar is read-only
+Entry oops does not exist and cannot be deleted
+%sfiles/frontcontroller10.phar
+Cannot write out phar archive, phar is read-only
+A Phar alias cannot be set in a plain tar archive
+
+Warning: Phar::setAlias() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+Cannot change stub, phar is read-only
+A Phar stub cannot be set in a plain tar archive
+
+Warning: Phar::setStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+A Phar stub cannot be set in a plain tar archive
+
+Warning: Phar::setDefaultStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+Cannot change stub: phar.readonly=1
+Cannot set signature algorithm, phar is read-only
+
+Warning: Phar::compress() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Cannot compress phar archive, phar is read-only
+
+Warning: Phar::compressFiles() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
+Phar is readonly, cannot change compression
+
+Warning: Phar::copy() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
+Cannot copy "a" to "b", phar is read-only
+
+Warning: Phar::offsetExists() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::offsetGet() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::offsetSet() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
+
+Warning: PharData::offsetUnset() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+Write operations disabled by the php.ini setting phar.readonly
+
+Warning: Phar::addEmptyDir() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::addFile() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+
+Warning: Phar::addFromString() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
+Write operations disabled by the php.ini setting phar.readonly
+
+Warning: Phar::setMetadata() expects exactly 1 parameter, 2 given in %sbadparameters.php on line %d
+Write operations disabled by the php.ini setting phar.readonly
+===DONE===
diff --git a/ext/phar/tests/bug13727.phpt b/ext/phar/tests/bug13727.phpt
new file mode 100644
index 0000000..e742b95
--- /dev/null
+++ b/ext/phar/tests/bug13727.phpt
@@ -0,0 +1,4136 @@
+--TEST--
+Phar: SLOW TEST bug #13727: "Number of files in the Phar" limited to 2042
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (getenv('SKIP_SLOW_TESTS')) die('skip'); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$dirName = dirname(__FILE__);
+$pname = 'phar://' . $fname;
+$pArchive="DataArchive.phar";
+$p = new Phar($fname, 0, $pArchive);
+for ($i = 0; $i < 4*1024; $i++){
+ echo("$i\n");
+ if (!is_dir($fileDir="$dirName/test_data"))
+ mkdir($fileDir, 0777, true);
+ file_put_contents("$fileDir/$i", "");
+ $p->addFile("$fileDir/$i", "$dirName");
+}
+echo("\n Written Files($i)\n");
+?>
+===DONE===
+--CLEAN--
+<?php
+$dirName = dirname(__FILE__);
+$fileDir="$dirName/test_data";
+for ($i = 0; $i < 4*1024; $i++){
+ unlink("$fileDir/$i");
+}
+rmdir($fileDir);
+unlink($dirName . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
+947
+948
+949
+950
+951
+952
+953
+954
+955
+956
+957
+958
+959
+960
+961
+962
+963
+964
+965
+966
+967
+968
+969
+970
+971
+972
+973
+974
+975
+976
+977
+978
+979
+980
+981
+982
+983
+984
+985
+986
+987
+988
+989
+990
+991
+992
+993
+994
+995
+996
+997
+998
+999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+2911
+2912
+2913
+2914
+2915
+2916
+2917
+2918
+2919
+2920
+2921
+2922
+2923
+2924
+2925
+2926
+2927
+2928
+2929
+2930
+2931
+2932
+2933
+2934
+2935
+2936
+2937
+2938
+2939
+2940
+2941
+2942
+2943
+2944
+2945
+2946
+2947
+2948
+2949
+2950
+2951
+2952
+2953
+2954
+2955
+2956
+2957
+2958
+2959
+2960
+2961
+2962
+2963
+2964
+2965
+2966
+2967
+2968
+2969
+2970
+2971
+2972
+2973
+2974
+2975
+2976
+2977
+2978
+2979
+2980
+2981
+2982
+2983
+2984
+2985
+2986
+2987
+2988
+2989
+2990
+2991
+2992
+2993
+2994
+2995
+2996
+2997
+2998
+2999
+3000
+3001
+3002
+3003
+3004
+3005
+3006
+3007
+3008
+3009
+3010
+3011
+3012
+3013
+3014
+3015
+3016
+3017
+3018
+3019
+3020
+3021
+3022
+3023
+3024
+3025
+3026
+3027
+3028
+3029
+3030
+3031
+3032
+3033
+3034
+3035
+3036
+3037
+3038
+3039
+3040
+3041
+3042
+3043
+3044
+3045
+3046
+3047
+3048
+3049
+3050
+3051
+3052
+3053
+3054
+3055
+3056
+3057
+3058
+3059
+3060
+3061
+3062
+3063
+3064
+3065
+3066
+3067
+3068
+3069
+3070
+3071
+3072
+3073
+3074
+3075
+3076
+3077
+3078
+3079
+3080
+3081
+3082
+3083
+3084
+3085
+3086
+3087
+3088
+3089
+3090
+3091
+3092
+3093
+3094
+3095
+3096
+3097
+3098
+3099
+3100
+3101
+3102
+3103
+3104
+3105
+3106
+3107
+3108
+3109
+3110
+3111
+3112
+3113
+3114
+3115
+3116
+3117
+3118
+3119
+3120
+3121
+3122
+3123
+3124
+3125
+3126
+3127
+3128
+3129
+3130
+3131
+3132
+3133
+3134
+3135
+3136
+3137
+3138
+3139
+3140
+3141
+3142
+3143
+3144
+3145
+3146
+3147
+3148
+3149
+3150
+3151
+3152
+3153
+3154
+3155
+3156
+3157
+3158
+3159
+3160
+3161
+3162
+3163
+3164
+3165
+3166
+3167
+3168
+3169
+3170
+3171
+3172
+3173
+3174
+3175
+3176
+3177
+3178
+3179
+3180
+3181
+3182
+3183
+3184
+3185
+3186
+3187
+3188
+3189
+3190
+3191
+3192
+3193
+3194
+3195
+3196
+3197
+3198
+3199
+3200
+3201
+3202
+3203
+3204
+3205
+3206
+3207
+3208
+3209
+3210
+3211
+3212
+3213
+3214
+3215
+3216
+3217
+3218
+3219
+3220
+3221
+3222
+3223
+3224
+3225
+3226
+3227
+3228
+3229
+3230
+3231
+3232
+3233
+3234
+3235
+3236
+3237
+3238
+3239
+3240
+3241
+3242
+3243
+3244
+3245
+3246
+3247
+3248
+3249
+3250
+3251
+3252
+3253
+3254
+3255
+3256
+3257
+3258
+3259
+3260
+3261
+3262
+3263
+3264
+3265
+3266
+3267
+3268
+3269
+3270
+3271
+3272
+3273
+3274
+3275
+3276
+3277
+3278
+3279
+3280
+3281
+3282
+3283
+3284
+3285
+3286
+3287
+3288
+3289
+3290
+3291
+3292
+3293
+3294
+3295
+3296
+3297
+3298
+3299
+3300
+3301
+3302
+3303
+3304
+3305
+3306
+3307
+3308
+3309
+3310
+3311
+3312
+3313
+3314
+3315
+3316
+3317
+3318
+3319
+3320
+3321
+3322
+3323
+3324
+3325
+3326
+3327
+3328
+3329
+3330
+3331
+3332
+3333
+3334
+3335
+3336
+3337
+3338
+3339
+3340
+3341
+3342
+3343
+3344
+3345
+3346
+3347
+3348
+3349
+3350
+3351
+3352
+3353
+3354
+3355
+3356
+3357
+3358
+3359
+3360
+3361
+3362
+3363
+3364
+3365
+3366
+3367
+3368
+3369
+3370
+3371
+3372
+3373
+3374
+3375
+3376
+3377
+3378
+3379
+3380
+3381
+3382
+3383
+3384
+3385
+3386
+3387
+3388
+3389
+3390
+3391
+3392
+3393
+3394
+3395
+3396
+3397
+3398
+3399
+3400
+3401
+3402
+3403
+3404
+3405
+3406
+3407
+3408
+3409
+3410
+3411
+3412
+3413
+3414
+3415
+3416
+3417
+3418
+3419
+3420
+3421
+3422
+3423
+3424
+3425
+3426
+3427
+3428
+3429
+3430
+3431
+3432
+3433
+3434
+3435
+3436
+3437
+3438
+3439
+3440
+3441
+3442
+3443
+3444
+3445
+3446
+3447
+3448
+3449
+3450
+3451
+3452
+3453
+3454
+3455
+3456
+3457
+3458
+3459
+3460
+3461
+3462
+3463
+3464
+3465
+3466
+3467
+3468
+3469
+3470
+3471
+3472
+3473
+3474
+3475
+3476
+3477
+3478
+3479
+3480
+3481
+3482
+3483
+3484
+3485
+3486
+3487
+3488
+3489
+3490
+3491
+3492
+3493
+3494
+3495
+3496
+3497
+3498
+3499
+3500
+3501
+3502
+3503
+3504
+3505
+3506
+3507
+3508
+3509
+3510
+3511
+3512
+3513
+3514
+3515
+3516
+3517
+3518
+3519
+3520
+3521
+3522
+3523
+3524
+3525
+3526
+3527
+3528
+3529
+3530
+3531
+3532
+3533
+3534
+3535
+3536
+3537
+3538
+3539
+3540
+3541
+3542
+3543
+3544
+3545
+3546
+3547
+3548
+3549
+3550
+3551
+3552
+3553
+3554
+3555
+3556
+3557
+3558
+3559
+3560
+3561
+3562
+3563
+3564
+3565
+3566
+3567
+3568
+3569
+3570
+3571
+3572
+3573
+3574
+3575
+3576
+3577
+3578
+3579
+3580
+3581
+3582
+3583
+3584
+3585
+3586
+3587
+3588
+3589
+3590
+3591
+3592
+3593
+3594
+3595
+3596
+3597
+3598
+3599
+3600
+3601
+3602
+3603
+3604
+3605
+3606
+3607
+3608
+3609
+3610
+3611
+3612
+3613
+3614
+3615
+3616
+3617
+3618
+3619
+3620
+3621
+3622
+3623
+3624
+3625
+3626
+3627
+3628
+3629
+3630
+3631
+3632
+3633
+3634
+3635
+3636
+3637
+3638
+3639
+3640
+3641
+3642
+3643
+3644
+3645
+3646
+3647
+3648
+3649
+3650
+3651
+3652
+3653
+3654
+3655
+3656
+3657
+3658
+3659
+3660
+3661
+3662
+3663
+3664
+3665
+3666
+3667
+3668
+3669
+3670
+3671
+3672
+3673
+3674
+3675
+3676
+3677
+3678
+3679
+3680
+3681
+3682
+3683
+3684
+3685
+3686
+3687
+3688
+3689
+3690
+3691
+3692
+3693
+3694
+3695
+3696
+3697
+3698
+3699
+3700
+3701
+3702
+3703
+3704
+3705
+3706
+3707
+3708
+3709
+3710
+3711
+3712
+3713
+3714
+3715
+3716
+3717
+3718
+3719
+3720
+3721
+3722
+3723
+3724
+3725
+3726
+3727
+3728
+3729
+3730
+3731
+3732
+3733
+3734
+3735
+3736
+3737
+3738
+3739
+3740
+3741
+3742
+3743
+3744
+3745
+3746
+3747
+3748
+3749
+3750
+3751
+3752
+3753
+3754
+3755
+3756
+3757
+3758
+3759
+3760
+3761
+3762
+3763
+3764
+3765
+3766
+3767
+3768
+3769
+3770
+3771
+3772
+3773
+3774
+3775
+3776
+3777
+3778
+3779
+3780
+3781
+3782
+3783
+3784
+3785
+3786
+3787
+3788
+3789
+3790
+3791
+3792
+3793
+3794
+3795
+3796
+3797
+3798
+3799
+3800
+3801
+3802
+3803
+3804
+3805
+3806
+3807
+3808
+3809
+3810
+3811
+3812
+3813
+3814
+3815
+3816
+3817
+3818
+3819
+3820
+3821
+3822
+3823
+3824
+3825
+3826
+3827
+3828
+3829
+3830
+3831
+3832
+3833
+3834
+3835
+3836
+3837
+3838
+3839
+3840
+3841
+3842
+3843
+3844
+3845
+3846
+3847
+3848
+3849
+3850
+3851
+3852
+3853
+3854
+3855
+3856
+3857
+3858
+3859
+3860
+3861
+3862
+3863
+3864
+3865
+3866
+3867
+3868
+3869
+3870
+3871
+3872
+3873
+3874
+3875
+3876
+3877
+3878
+3879
+3880
+3881
+3882
+3883
+3884
+3885
+3886
+3887
+3888
+3889
+3890
+3891
+3892
+3893
+3894
+3895
+3896
+3897
+3898
+3899
+3900
+3901
+3902
+3903
+3904
+3905
+3906
+3907
+3908
+3909
+3910
+3911
+3912
+3913
+3914
+3915
+3916
+3917
+3918
+3919
+3920
+3921
+3922
+3923
+3924
+3925
+3926
+3927
+3928
+3929
+3930
+3931
+3932
+3933
+3934
+3935
+3936
+3937
+3938
+3939
+3940
+3941
+3942
+3943
+3944
+3945
+3946
+3947
+3948
+3949
+3950
+3951
+3952
+3953
+3954
+3955
+3956
+3957
+3958
+3959
+3960
+3961
+3962
+3963
+3964
+3965
+3966
+3967
+3968
+3969
+3970
+3971
+3972
+3973
+3974
+3975
+3976
+3977
+3978
+3979
+3980
+3981
+3982
+3983
+3984
+3985
+3986
+3987
+3988
+3989
+3990
+3991
+3992
+3993
+3994
+3995
+3996
+3997
+3998
+3999
+4000
+4001
+4002
+4003
+4004
+4005
+4006
+4007
+4008
+4009
+4010
+4011
+4012
+4013
+4014
+4015
+4016
+4017
+4018
+4019
+4020
+4021
+4022
+4023
+4024
+4025
+4026
+4027
+4028
+4029
+4030
+4031
+4032
+4033
+4034
+4035
+4036
+4037
+4038
+4039
+4040
+4041
+4042
+4043
+4044
+4045
+4046
+4047
+4048
+4049
+4050
+4051
+4052
+4053
+4054
+4055
+4056
+4057
+4058
+4059
+4060
+4061
+4062
+4063
+4064
+4065
+4066
+4067
+4068
+4069
+4070
+4071
+4072
+4073
+4074
+4075
+4076
+4077
+4078
+4079
+4080
+4081
+4082
+4083
+4084
+4085
+4086
+4087
+4088
+4089
+4090
+4091
+4092
+4093
+4094
+4095
+
+ Written Files(4096)
+===DONE===
diff --git a/ext/phar/tests/bug13786.phpt b/ext/phar/tests/bug13786.phpt
new file mode 100644
index 0000000..572d1eb
--- /dev/null
+++ b/ext/phar/tests/bug13786.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: bug #13786: "PHP crashes on phar recreate after unlink"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+try {
+for ($i = 0; $i < 2; $i++) {
+ $fname = "DataArchive.phar";
+ $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . $fname;
+ $phar = new Phar($path);
+ $phar->addFromString($i, "file $i in $fname");
+ var_dump(file_get_contents($phar[$i]));
+ unset($phar);
+ unlink($path);
+}
+
+echo("\nWritten files: $i\n");
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+string(26) "file 0 in DataArchive.phar"
+unable to seek to start of file "0" while creating new phar "%sDataArchive.phar"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt
new file mode 100644
index 0000000..80356af
--- /dev/null
+++ b/ext/phar/tests/bug45218_SLOWTEST.phpt
@@ -0,0 +1,6092 @@
+--TEST--
+Phar::buildFromIterator() iterator, too many files for open file handles (Bug #45218)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.txt';
+file_put_contents($fname2, 'a');
+class myIterator implements Iterator
+{
+ var $a;
+ var $count = 1;
+
+ function next() {
+ return (++$this->count < 3000) ? 'f' . $this->count : false;
+ }
+ function current() {
+ if (($this->count % 100) === 0) {
+ echo $this->count, "\n";
+ }
+ return $GLOBALS['fname2'];
+ }
+ function key() {
+ return 'f' . $this->count;
+ }
+ function valid() {
+ return $this->count < 3000;
+ }
+ function rewind() {
+ $this->count = 1;
+ return $GLOBALS['fname2'];
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar($fname);
+ $ret = $phar->buildFromIterator(new myIterator);
+ foreach ($ret as $a => $val) {
+ $ret[$a] = str_replace(dirname($fname2) . DIRECTORY_SEPARATOR, '*', $val);
+ }
+ var_dump($ret);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.txt');
+__halt_compiler();
+?>
+--EXPECT--
+100
+200
+300
+400
+500
+600
+700
+800
+900
+1000
+1100
+1200
+1300
+1400
+1500
+1600
+1700
+1800
+1900
+2000
+2100
+2200
+2300
+2400
+2500
+2600
+2700
+2800
+2900
+array(2999) {
+ ["f1"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f3"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f4"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f5"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f6"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f7"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f8"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f9"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f10"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f11"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f12"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f13"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f14"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f15"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f16"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f17"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f18"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f19"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f20"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f21"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f22"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f23"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f24"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f25"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f26"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f27"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f28"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f29"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f30"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f31"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f32"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f33"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f34"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f35"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f36"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f37"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f38"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f39"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f40"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f41"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f42"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f43"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f44"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f45"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f46"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f47"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f48"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f49"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f50"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f51"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f52"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f53"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f54"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f55"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f56"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f57"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f58"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f59"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f60"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f61"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f62"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f63"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f64"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f65"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f66"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f67"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f68"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f69"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f70"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f71"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f72"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f73"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f74"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f75"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f76"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f77"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f78"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f79"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f80"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f81"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f82"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f83"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f84"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f85"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f86"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f87"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f88"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f89"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f90"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f91"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f92"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f93"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f94"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f95"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f96"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f97"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f98"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f99"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f100"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f101"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f102"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f103"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f104"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f105"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f106"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f107"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f108"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f109"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f110"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f111"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f112"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f113"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f114"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f115"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f116"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f117"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f118"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f119"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f120"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f121"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f122"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f123"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f124"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f125"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f126"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f127"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f128"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f129"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f130"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f131"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f132"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f133"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f134"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f135"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f136"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f137"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f138"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f139"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f140"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f141"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f142"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f143"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f144"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f145"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f146"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f147"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f148"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f149"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f150"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f151"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f152"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f153"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f154"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f155"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f156"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f157"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f158"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f159"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f160"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f161"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f162"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f163"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f164"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f165"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f166"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f167"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f168"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f169"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f170"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f171"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f172"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f173"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f174"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f175"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f176"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f177"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f178"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f179"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f180"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f181"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f182"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f183"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f184"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f185"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f186"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f187"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f188"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f189"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f190"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f191"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f192"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f193"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f194"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f195"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f196"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f197"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f198"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f199"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f200"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f201"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f202"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f203"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f204"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f205"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f206"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f207"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f208"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f209"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f210"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f211"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f212"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f213"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f214"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f215"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f216"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f217"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f218"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f219"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f220"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f221"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f222"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f223"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f224"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f225"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f226"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f227"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f228"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f229"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f230"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f231"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f232"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f233"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f234"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f235"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f236"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f237"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f238"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f239"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f240"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f241"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f242"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f243"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f244"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f245"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f246"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f247"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f248"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f249"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f250"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f251"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f252"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f253"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f254"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f255"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f256"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f257"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f258"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f259"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f260"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f261"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f262"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f263"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f264"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f265"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f266"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f267"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f268"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f269"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f270"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f271"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f272"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f273"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f274"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f275"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f276"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f277"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f278"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f279"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f280"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f281"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f282"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f283"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f284"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f285"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f286"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f287"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f288"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f289"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f290"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f291"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f292"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f293"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f294"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f295"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f296"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f297"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f298"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f299"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f300"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f301"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f302"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f303"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f304"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f305"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f306"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f307"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f308"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f309"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f310"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f311"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f312"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f313"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f314"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f315"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f316"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f317"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f318"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f319"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f320"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f321"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f322"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f323"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f324"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f325"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f326"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f327"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f328"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f329"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f330"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f331"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f332"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f333"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f334"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f335"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f336"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f337"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f338"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f339"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f340"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f341"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f342"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f343"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f344"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f345"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f346"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f347"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f348"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f349"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f350"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f351"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f352"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f353"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f354"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f355"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f356"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f357"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f358"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f359"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f360"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f361"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f362"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f363"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f364"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f365"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f366"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f367"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f368"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f369"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f370"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f371"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f372"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f373"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f374"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f375"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f376"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f377"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f378"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f379"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f380"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f381"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f382"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f383"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f384"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f385"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f386"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f387"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f388"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f389"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f390"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f391"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f392"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f393"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f394"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f395"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f396"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f397"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f398"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f399"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f400"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f401"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f402"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f403"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f404"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f405"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f406"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f407"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f408"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f409"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f410"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f411"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f412"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f413"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f414"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f415"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f416"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f417"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f418"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f419"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f420"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f421"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f422"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f423"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f424"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f425"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f426"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f427"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f428"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f429"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f430"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f431"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f432"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f433"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f434"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f435"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f436"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f437"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f438"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f439"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f440"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f441"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f442"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f443"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f444"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f445"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f446"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f447"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f448"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f449"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f450"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f451"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f452"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f453"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f454"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f455"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f456"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f457"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f458"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f459"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f460"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f461"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f462"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f463"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f464"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f465"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f466"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f467"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f468"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f469"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f470"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f471"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f472"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f473"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f474"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f475"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f476"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f477"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f478"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f479"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f480"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f481"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f482"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f483"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f484"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f485"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f486"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f487"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f488"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f489"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f490"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f491"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f492"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f493"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f494"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f495"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f496"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f497"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f498"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f499"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f500"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f501"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f502"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f503"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f504"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f505"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f506"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f507"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f508"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f509"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f510"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f511"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f512"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f513"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f514"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f515"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f516"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f517"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f518"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f519"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f520"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f521"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f522"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f523"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f524"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f525"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f526"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f527"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f528"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f529"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f530"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f531"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f532"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f533"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f534"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f535"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f536"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f537"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f538"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f539"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f540"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f541"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f542"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f543"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f544"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f545"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f546"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f547"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f548"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f549"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f550"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f551"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f552"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f553"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f554"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f555"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f556"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f557"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f558"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f559"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f560"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f561"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f562"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f563"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f564"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f565"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f566"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f567"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f568"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f569"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f570"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f571"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f572"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f573"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f574"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f575"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f576"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f577"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f578"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f579"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f580"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f581"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f582"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f583"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f584"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f585"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f586"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f587"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f588"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f589"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f590"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f591"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f592"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f593"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f594"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f595"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f596"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f597"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f598"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f599"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f600"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f601"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f602"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f603"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f604"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f605"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f606"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f607"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f608"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f609"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f610"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f611"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f612"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f613"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f614"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f615"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f616"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f617"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f618"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f619"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f620"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f621"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f622"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f623"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f624"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f625"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f626"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f627"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f628"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f629"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f630"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f631"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f632"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f633"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f634"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f635"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f636"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f637"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f638"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f639"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f640"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f641"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f642"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f643"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f644"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f645"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f646"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f647"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f648"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f649"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f650"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f651"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f652"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f653"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f654"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f655"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f656"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f657"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f658"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f659"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f660"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f661"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f662"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f663"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f664"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f665"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f666"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f667"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f668"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f669"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f670"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f671"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f672"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f673"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f674"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f675"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f676"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f677"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f678"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f679"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f680"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f681"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f682"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f683"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f684"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f685"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f686"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f687"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f688"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f689"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f690"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f691"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f692"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f693"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f694"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f695"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f696"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f697"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f698"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f699"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f700"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f701"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f702"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f703"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f704"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f705"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f706"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f707"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f708"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f709"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f710"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f711"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f712"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f713"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f714"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f715"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f716"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f717"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f718"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f719"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f720"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f721"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f722"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f723"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f724"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f725"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f726"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f727"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f728"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f729"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f730"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f731"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f732"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f733"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f734"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f735"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f736"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f737"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f738"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f739"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f740"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f741"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f742"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f743"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f744"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f745"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f746"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f747"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f748"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f749"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f750"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f751"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f752"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f753"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f754"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f755"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f756"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f757"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f758"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f759"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f760"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f761"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f762"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f763"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f764"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f765"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f766"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f767"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f768"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f769"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f770"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f771"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f772"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f773"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f774"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f775"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f776"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f777"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f778"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f779"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f780"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f781"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f782"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f783"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f784"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f785"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f786"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f787"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f788"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f789"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f790"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f791"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f792"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f793"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f794"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f795"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f796"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f797"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f798"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f799"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f800"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f801"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f802"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f803"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f804"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f805"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f806"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f807"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f808"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f809"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f810"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f811"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f812"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f813"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f814"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f815"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f816"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f817"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f818"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f819"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f820"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f821"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f822"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f823"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f824"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f825"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f826"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f827"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f828"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f829"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f830"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f831"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f832"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f833"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f834"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f835"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f836"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f837"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f838"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f839"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f840"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f841"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f842"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f843"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f844"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f845"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f846"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f847"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f848"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f849"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f850"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f851"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f852"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f853"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f854"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f855"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f856"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f857"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f858"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f859"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f860"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f861"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f862"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f863"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f864"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f865"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f866"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f867"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f868"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f869"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f870"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f871"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f872"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f873"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f874"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f875"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f876"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f877"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f878"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f879"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f880"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f881"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f882"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f883"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f884"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f885"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f886"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f887"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f888"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f889"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f890"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f891"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f892"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f893"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f894"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f895"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f896"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f897"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f898"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f899"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f900"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f901"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f902"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f903"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f904"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f905"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f906"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f907"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f908"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f909"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f910"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f911"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f912"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f913"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f914"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f915"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f916"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f917"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f918"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f919"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f920"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f921"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f922"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f923"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f924"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f925"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f926"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f927"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f928"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f929"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f930"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f931"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f932"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f933"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f934"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f935"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f936"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f937"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f938"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f939"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f940"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f941"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f942"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f943"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f944"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f945"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f946"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f947"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f948"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f949"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f950"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f951"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f952"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f953"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f954"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f955"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f956"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f957"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f958"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f959"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f960"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f961"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f962"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f963"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f964"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f965"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f966"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f967"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f968"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f969"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f970"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f971"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f972"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f973"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f974"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f975"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f976"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f977"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f978"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f979"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f980"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f981"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f982"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f983"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f984"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f985"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f986"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f987"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f988"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f989"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f990"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f991"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f992"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f993"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f994"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f995"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f996"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f997"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f998"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f999"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1000"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1001"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1002"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1003"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1004"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1005"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1006"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1007"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1008"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1009"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1010"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1011"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1012"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1013"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1014"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1015"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1016"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1017"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1018"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1019"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1020"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1021"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1022"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1023"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1024"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1025"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1026"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1027"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1028"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1029"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1030"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1031"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1032"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1033"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1034"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1035"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1036"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1037"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1038"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1039"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1040"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1041"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1042"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1043"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1044"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1045"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1046"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1047"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1048"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1049"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1050"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1051"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1052"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1053"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1054"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1055"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1056"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1057"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1058"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1059"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1060"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1061"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1062"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1063"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1064"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1065"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1066"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1067"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1068"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1069"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1070"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1071"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1072"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1073"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1074"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1075"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1076"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1077"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1078"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1079"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1080"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1081"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1082"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1083"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1084"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1085"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1086"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1087"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1088"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1089"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1090"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1091"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1092"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1093"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1094"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1095"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1096"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1097"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1098"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1099"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1100"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1101"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1102"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1103"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1104"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1105"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1106"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1107"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1108"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1109"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1110"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1111"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1112"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1113"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1114"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1115"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1116"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1117"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1118"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1119"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1120"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1121"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1122"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1123"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1124"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1125"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1126"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1127"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1128"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1129"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1130"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1131"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1132"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1133"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1134"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1135"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1136"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1137"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1138"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1139"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1140"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1141"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1142"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1143"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1144"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1145"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1146"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1147"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1148"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1149"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1150"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1151"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1152"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1153"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1154"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1155"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1156"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1157"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1158"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1159"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1160"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1161"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1162"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1163"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1164"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1165"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1166"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1167"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1168"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1169"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1170"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1171"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1172"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1173"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1174"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1175"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1176"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1177"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1178"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1179"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1180"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1181"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1182"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1183"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1184"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1185"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1186"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1187"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1188"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1189"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1190"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1191"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1192"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1193"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1194"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1195"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1196"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1197"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1198"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1199"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1200"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1201"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1202"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1203"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1204"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1205"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1206"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1207"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1208"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1209"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1210"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1211"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1212"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1213"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1214"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1215"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1216"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1217"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1218"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1219"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1220"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1221"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1222"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1223"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1224"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1225"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1226"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1227"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1228"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1229"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1230"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1231"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1232"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1233"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1234"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1235"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1236"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1237"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1238"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1239"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1240"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1241"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1242"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1243"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1244"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1245"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1246"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1247"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1248"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1249"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1250"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1251"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1252"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1253"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1254"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1255"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1256"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1257"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1258"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1259"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1260"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1261"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1262"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1263"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1264"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1265"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1266"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1267"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1268"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1269"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1270"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1271"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1272"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1273"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1274"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1275"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1276"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1277"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1278"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1279"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1280"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1281"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1282"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1283"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1284"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1285"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1286"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1287"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1288"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1289"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1290"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1291"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1292"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1293"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1294"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1295"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1296"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1297"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1298"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1299"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1300"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1301"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1302"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1303"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1304"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1305"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1306"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1307"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1308"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1309"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1310"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1311"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1312"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1313"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1314"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1315"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1316"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1317"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1318"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1319"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1320"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1321"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1322"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1323"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1324"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1325"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1326"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1327"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1328"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1329"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1330"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1331"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1332"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1333"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1334"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1335"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1336"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1337"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1338"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1339"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1340"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1341"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1342"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1343"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1344"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1345"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1346"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1347"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1348"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1349"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1350"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1351"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1352"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1353"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1354"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1355"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1356"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1357"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1358"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1359"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1360"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1361"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1362"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1363"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1364"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1365"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1366"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1367"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1368"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1369"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1370"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1371"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1372"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1373"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1374"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1375"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1376"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1377"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1378"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1379"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1380"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1381"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1382"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1383"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1384"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1385"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1386"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1387"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1388"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1389"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1390"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1391"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1392"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1393"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1394"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1395"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1396"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1397"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1398"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1399"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1400"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1401"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1402"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1403"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1404"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1405"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1406"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1407"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1408"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1409"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1410"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1411"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1412"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1413"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1414"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1415"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1416"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1417"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1418"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1419"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1420"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1421"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1422"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1423"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1424"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1425"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1426"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1427"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1428"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1429"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1430"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1431"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1432"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1433"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1434"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1435"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1436"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1437"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1438"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1439"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1440"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1441"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1442"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1443"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1444"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1445"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1446"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1447"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1448"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1449"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1450"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1451"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1452"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1453"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1454"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1455"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1456"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1457"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1458"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1459"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1460"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1461"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1462"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1463"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1464"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1465"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1466"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1467"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1468"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1469"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1470"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1471"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1472"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1473"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1474"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1475"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1476"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1477"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1478"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1479"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1480"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1481"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1482"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1483"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1484"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1485"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1486"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1487"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1488"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1489"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1490"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1491"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1492"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1493"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1494"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1495"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1496"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1497"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1498"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1499"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1500"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1501"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1502"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1503"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1504"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1505"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1506"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1507"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1508"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1509"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1510"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1511"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1512"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1513"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1514"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1515"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1516"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1517"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1518"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1519"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1520"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1521"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1522"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1523"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1524"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1525"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1526"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1527"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1528"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1529"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1530"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1531"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1532"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1533"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1534"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1535"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1536"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1537"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1538"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1539"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1540"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1541"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1542"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1543"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1544"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1545"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1546"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1547"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1548"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1549"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1550"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1551"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1552"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1553"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1554"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1555"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1556"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1557"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1558"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1559"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1560"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1561"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1562"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1563"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1564"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1565"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1566"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1567"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1568"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1569"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1570"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1571"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1572"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1573"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1574"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1575"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1576"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1577"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1578"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1579"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1580"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1581"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1582"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1583"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1584"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1585"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1586"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1587"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1588"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1589"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1590"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1591"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1592"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1593"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1594"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1595"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1596"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1597"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1598"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1599"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1600"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1601"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1602"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1603"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1604"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1605"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1606"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1607"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1608"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1609"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1610"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1611"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1612"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1613"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1614"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1615"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1616"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1617"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1618"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1619"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1620"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1621"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1622"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1623"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1624"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1625"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1626"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1627"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1628"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1629"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1630"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1631"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1632"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1633"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1634"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1635"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1636"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1637"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1638"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1639"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1640"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1641"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1642"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1643"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1644"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1645"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1646"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1647"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1648"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1649"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1650"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1651"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1652"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1653"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1654"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1655"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1656"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1657"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1658"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1659"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1660"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1661"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1662"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1663"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1664"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1665"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1666"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1667"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1668"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1669"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1670"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1671"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1672"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1673"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1674"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1675"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1676"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1677"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1678"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1679"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1680"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1681"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1682"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1683"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1684"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1685"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1686"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1687"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1688"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1689"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1690"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1691"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1692"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1693"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1694"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1695"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1696"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1697"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1698"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1699"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1700"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1701"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1702"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1703"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1704"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1705"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1706"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1707"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1708"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1709"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1710"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1711"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1712"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1713"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1714"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1715"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1716"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1717"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1718"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1719"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1720"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1721"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1722"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1723"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1724"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1725"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1726"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1727"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1728"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1729"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1730"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1731"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1732"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1733"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1734"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1735"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1736"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1737"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1738"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1739"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1740"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1741"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1742"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1743"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1744"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1745"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1746"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1747"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1748"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1749"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1750"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1751"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1752"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1753"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1754"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1755"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1756"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1757"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1758"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1759"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1760"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1761"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1762"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1763"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1764"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1765"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1766"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1767"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1768"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1769"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1770"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1771"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1772"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1773"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1774"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1775"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1776"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1777"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1778"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1779"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1780"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1781"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1782"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1783"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1784"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1785"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1786"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1787"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1788"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1789"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1790"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1791"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1792"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1793"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1794"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1795"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1796"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1797"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1798"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1799"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1800"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1801"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1802"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1803"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1804"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1805"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1806"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1807"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1808"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1809"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1810"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1811"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1812"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1813"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1814"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1815"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1816"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1817"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1818"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1819"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1820"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1821"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1822"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1823"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1824"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1825"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1826"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1827"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1828"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1829"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1830"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1831"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1832"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1833"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1834"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1835"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1836"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1837"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1838"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1839"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1840"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1841"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1842"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1843"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1844"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1845"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1846"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1847"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1848"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1849"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1850"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1851"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1852"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1853"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1854"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1855"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1856"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1857"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1858"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1859"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1860"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1861"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1862"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1863"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1864"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1865"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1866"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1867"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1868"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1869"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1870"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1871"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1872"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1873"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1874"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1875"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1876"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1877"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1878"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1879"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1880"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1881"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1882"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1883"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1884"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1885"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1886"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1887"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1888"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1889"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1890"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1891"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1892"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1893"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1894"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1895"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1896"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1897"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1898"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1899"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1900"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1901"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1902"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1903"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1904"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1905"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1906"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1907"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1908"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1909"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1910"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1911"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1912"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1913"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1914"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1915"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1916"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1917"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1918"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1919"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1920"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1921"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1922"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1923"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1924"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1925"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1926"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1927"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1928"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1929"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1930"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1931"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1932"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1933"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1934"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1935"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1936"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1937"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1938"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1939"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1940"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1941"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1942"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1943"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1944"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1945"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1946"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1947"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1948"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1949"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1950"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1951"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1952"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1953"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1954"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1955"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1956"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1957"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1958"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1959"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1960"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1961"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1962"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1963"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1964"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1965"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1966"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1967"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1968"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1969"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1970"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1971"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1972"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1973"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1974"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1975"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1976"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1977"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1978"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1979"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1980"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1981"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1982"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1983"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1984"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1985"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1986"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1987"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1988"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1989"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1990"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1991"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1992"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1993"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1994"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1995"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1996"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1997"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1998"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f1999"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2000"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2001"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2002"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2003"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2004"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2005"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2006"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2007"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2008"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2009"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2010"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2011"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2012"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2013"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2014"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2015"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2016"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2017"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2018"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2019"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2020"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2021"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2022"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2023"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2024"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2025"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2026"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2027"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2028"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2029"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2030"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2031"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2032"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2033"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2034"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2035"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2036"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2037"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2038"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2039"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2040"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2041"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2042"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2043"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2044"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2045"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2046"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2047"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2048"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2049"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2050"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2051"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2052"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2053"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2054"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2055"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2056"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2057"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2058"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2059"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2060"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2061"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2062"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2063"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2064"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2065"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2066"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2067"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2068"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2069"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2070"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2071"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2072"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2073"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2074"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2075"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2076"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2077"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2078"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2079"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2080"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2081"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2082"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2083"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2084"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2085"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2086"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2087"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2088"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2089"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2090"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2091"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2092"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2093"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2094"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2095"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2096"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2097"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2098"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2099"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2100"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2101"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2102"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2103"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2104"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2105"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2106"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2107"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2108"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2109"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2110"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2111"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2112"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2113"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2114"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2115"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2116"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2117"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2118"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2119"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2120"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2121"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2122"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2123"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2124"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2125"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2126"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2127"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2128"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2129"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2130"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2131"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2132"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2133"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2134"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2135"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2136"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2137"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2138"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2139"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2140"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2141"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2142"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2143"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2144"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2145"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2146"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2147"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2148"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2149"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2150"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2151"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2152"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2153"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2154"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2155"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2156"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2157"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2158"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2159"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2160"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2161"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2162"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2163"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2164"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2165"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2166"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2167"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2168"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2169"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2170"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2171"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2172"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2173"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2174"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2175"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2176"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2177"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2178"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2179"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2180"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2181"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2182"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2183"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2184"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2185"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2186"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2187"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2188"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2189"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2190"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2191"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2192"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2193"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2194"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2195"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2196"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2197"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2198"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2199"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2200"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2201"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2202"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2203"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2204"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2205"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2206"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2207"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2208"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2209"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2210"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2211"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2212"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2213"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2214"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2215"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2216"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2217"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2218"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2219"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2220"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2221"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2222"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2223"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2224"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2225"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2226"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2227"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2228"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2229"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2230"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2231"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2232"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2233"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2234"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2235"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2236"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2237"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2238"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2239"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2240"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2241"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2242"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2243"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2244"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2245"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2246"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2247"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2248"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2249"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2250"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2251"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2252"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2253"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2254"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2255"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2256"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2257"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2258"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2259"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2260"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2261"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2262"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2263"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2264"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2265"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2266"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2267"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2268"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2269"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2270"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2271"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2272"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2273"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2274"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2275"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2276"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2277"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2278"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2279"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2280"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2281"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2282"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2283"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2284"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2285"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2286"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2287"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2288"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2289"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2290"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2291"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2292"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2293"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2294"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2295"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2296"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2297"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2298"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2299"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2300"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2301"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2302"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2303"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2304"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2305"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2306"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2307"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2308"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2309"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2310"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2311"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2312"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2313"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2314"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2315"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2316"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2317"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2318"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2319"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2320"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2321"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2322"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2323"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2324"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2325"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2326"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2327"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2328"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2329"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2330"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2331"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2332"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2333"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2334"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2335"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2336"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2337"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2338"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2339"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2340"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2341"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2342"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2343"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2344"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2345"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2346"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2347"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2348"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2349"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2350"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2351"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2352"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2353"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2354"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2355"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2356"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2357"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2358"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2359"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2360"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2361"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2362"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2363"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2364"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2365"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2366"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2367"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2368"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2369"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2370"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2371"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2372"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2373"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2374"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2375"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2376"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2377"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2378"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2379"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2380"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2381"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2382"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2383"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2384"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2385"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2386"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2387"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2388"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2389"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2390"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2391"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2392"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2393"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2394"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2395"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2396"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2397"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2398"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2399"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2400"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2401"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2402"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2403"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2404"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2405"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2406"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2407"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2408"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2409"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2410"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2411"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2412"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2413"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2414"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2415"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2416"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2417"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2418"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2419"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2420"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2421"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2422"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2423"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2424"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2425"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2426"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2427"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2428"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2429"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2430"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2431"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2432"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2433"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2434"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2435"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2436"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2437"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2438"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2439"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2440"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2441"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2442"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2443"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2444"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2445"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2446"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2447"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2448"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2449"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2450"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2451"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2452"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2453"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2454"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2455"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2456"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2457"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2458"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2459"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2460"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2461"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2462"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2463"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2464"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2465"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2466"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2467"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2468"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2469"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2470"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2471"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2472"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2473"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2474"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2475"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2476"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2477"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2478"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2479"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2480"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2481"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2482"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2483"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2484"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2485"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2486"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2487"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2488"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2489"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2490"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2491"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2492"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2493"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2494"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2495"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2496"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2497"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2498"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2499"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2500"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2501"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2502"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2503"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2504"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2505"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2506"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2507"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2508"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2509"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2510"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2511"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2512"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2513"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2514"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2515"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2516"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2517"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2518"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2519"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2520"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2521"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2522"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2523"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2524"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2525"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2526"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2527"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2528"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2529"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2530"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2531"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2532"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2533"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2534"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2535"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2536"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2537"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2538"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2539"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2540"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2541"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2542"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2543"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2544"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2545"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2546"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2547"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2548"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2549"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2550"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2551"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2552"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2553"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2554"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2555"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2556"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2557"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2558"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2559"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2560"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2561"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2562"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2563"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2564"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2565"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2566"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2567"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2568"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2569"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2570"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2571"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2572"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2573"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2574"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2575"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2576"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2577"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2578"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2579"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2580"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2581"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2582"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2583"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2584"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2585"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2586"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2587"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2588"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2589"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2590"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2591"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2592"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2593"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2594"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2595"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2596"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2597"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2598"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2599"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2600"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2601"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2602"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2603"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2604"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2605"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2606"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2607"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2608"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2609"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2610"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2611"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2612"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2613"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2614"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2615"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2616"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2617"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2618"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2619"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2620"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2621"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2622"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2623"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2624"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2625"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2626"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2627"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2628"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2629"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2630"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2631"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2632"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2633"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2634"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2635"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2636"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2637"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2638"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2639"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2640"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2641"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2642"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2643"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2644"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2645"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2646"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2647"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2648"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2649"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2650"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2651"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2652"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2653"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2654"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2655"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2656"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2657"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2658"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2659"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2660"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2661"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2662"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2663"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2664"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2665"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2666"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2667"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2668"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2669"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2670"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2671"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2672"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2673"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2674"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2675"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2676"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2677"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2678"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2679"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2680"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2681"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2682"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2683"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2684"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2685"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2686"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2687"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2688"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2689"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2690"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2691"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2692"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2693"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2694"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2695"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2696"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2697"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2698"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2699"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2700"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2701"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2702"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2703"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2704"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2705"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2706"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2707"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2708"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2709"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2710"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2711"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2712"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2713"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2714"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2715"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2716"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2717"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2718"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2719"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2720"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2721"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2722"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2723"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2724"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2725"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2726"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2727"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2728"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2729"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2730"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2731"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2732"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2733"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2734"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2735"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2736"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2737"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2738"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2739"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2740"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2741"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2742"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2743"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2744"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2745"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2746"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2747"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2748"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2749"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2750"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2751"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2752"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2753"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2754"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2755"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2756"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2757"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2758"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2759"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2760"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2761"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2762"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2763"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2764"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2765"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2766"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2767"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2768"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2769"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2770"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2771"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2772"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2773"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2774"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2775"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2776"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2777"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2778"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2779"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2780"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2781"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2782"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2783"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2784"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2785"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2786"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2787"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2788"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2789"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2790"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2791"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2792"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2793"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2794"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2795"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2796"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2797"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2798"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2799"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2800"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2801"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2802"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2803"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2804"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2805"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2806"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2807"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2808"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2809"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2810"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2811"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2812"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2813"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2814"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2815"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2816"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2817"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2818"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2819"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2820"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2821"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2822"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2823"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2824"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2825"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2826"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2827"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2828"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2829"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2830"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2831"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2832"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2833"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2834"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2835"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2836"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2837"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2838"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2839"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2840"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2841"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2842"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2843"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2844"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2845"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2846"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2847"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2848"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2849"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2850"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2851"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2852"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2853"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2854"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2855"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2856"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2857"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2858"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2859"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2860"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2861"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2862"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2863"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2864"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2865"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2866"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2867"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2868"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2869"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2870"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2871"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2872"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2873"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2874"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2875"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2876"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2877"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2878"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2879"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2880"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2881"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2882"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2883"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2884"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2885"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2886"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2887"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2888"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2889"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2890"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2891"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2892"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2893"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2894"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2895"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2896"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2897"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2898"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2899"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2900"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2901"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2902"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2903"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2904"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2905"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2906"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2907"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2908"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2909"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2910"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2911"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2912"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2913"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2914"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2915"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2916"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2917"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2918"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2919"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2920"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2921"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2922"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2923"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2924"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2925"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2926"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2927"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2928"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2929"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2930"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2931"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2932"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2933"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2934"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2935"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2936"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2937"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2938"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2939"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2940"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2941"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2942"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2943"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2944"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2945"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2946"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2947"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2948"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2949"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2950"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2951"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2952"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2953"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2954"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2955"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2956"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2957"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2958"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2959"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2960"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2961"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2962"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2963"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2964"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2965"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2966"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2967"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2968"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2969"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2970"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2971"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2972"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2973"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2974"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2975"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2976"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2977"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2978"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2979"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2980"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2981"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2982"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2983"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2984"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2985"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2986"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2987"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2988"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2989"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2990"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2991"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2992"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2993"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2994"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2995"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2996"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2997"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2998"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+ ["f2999"]=>
+ string(22) "*bug45218_SLOWTEST.txt"
+}
+===DONE===
diff --git a/ext/phar/tests/bug45218_SLOWTESTU.phpt b/ext/phar/tests/bug45218_SLOWTESTU.phpt
new file mode 100644
index 0000000..1639691
--- /dev/null
+++ b/ext/phar/tests/bug45218_SLOWTESTU.phpt
@@ -0,0 +1,6092 @@
+--TEST--
+Phar::buildFromIterator() iterator, too many files for open file handles (Bug #45218)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow tests excluded by request");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.txt';
+file_put_contents($fname2, 'a');
+class myIterator implements Iterator
+{
+ var $a;
+ var $count = 1;
+
+ function next() {
+ return (++$this->count < 3000) ? 'f' . $this->count : false;
+ }
+ function current() {
+ if (($this->count % 100) === 0) {
+ echo $this->count, "\n";
+ }
+ return $GLOBALS['fname2'];
+ }
+ function key() {
+ return 'f' . $this->count;
+ }
+ function valid() {
+ return $this->count < 3000;
+ }
+ function rewind() {
+ $this->count = 1;
+ return $GLOBALS['fname2'];
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar($fname);
+ $ret = $phar->buildFromIterator(new myIterator);
+ foreach ($ret as $a => $val) {
+ $ret[$a] = str_replace(dirname($fname2) . DIRECTORY_SEPARATOR, '*', $val);
+ }
+ var_dump($ret);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.txt');
+__halt_compiler();
+?>
+--EXPECT--
+100
+200
+300
+400
+500
+600
+700
+800
+900
+1000
+1100
+1200
+1300
+1400
+1500
+1600
+1700
+1800
+1900
+2000
+2100
+2200
+2300
+2400
+2500
+2600
+2700
+2800
+2900
+array(2999) {
+ ["f1"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f3"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f4"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f5"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f6"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f7"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f8"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f9"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f10"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f11"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f12"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f13"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f14"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f15"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f16"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f17"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f18"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f19"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f20"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f21"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f22"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f23"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f24"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f25"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f26"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f27"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f28"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f29"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f30"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f31"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f32"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f33"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f34"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f35"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f36"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f37"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f38"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f39"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f40"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f41"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f42"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f43"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f44"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f45"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f46"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f47"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f48"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f49"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f50"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f51"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f52"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f53"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f54"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f55"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f56"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f57"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f58"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f59"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f60"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f61"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f62"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f63"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f64"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f65"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f66"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f67"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f68"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f69"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f70"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f71"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f72"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f73"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f74"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f75"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f76"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f77"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f78"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f79"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f80"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f81"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f82"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f83"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f84"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f85"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f86"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f87"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f88"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f89"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f90"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f91"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f92"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f93"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f94"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f95"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f96"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f97"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f98"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f99"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f100"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f101"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f102"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f103"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f104"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f105"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f106"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f107"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f108"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f109"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f110"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f111"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f112"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f113"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f114"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f115"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f116"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f117"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f118"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f119"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f120"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f121"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f122"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f123"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f124"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f125"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f126"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f127"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f128"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f129"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f130"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f131"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f132"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f133"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f134"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f135"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f136"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f137"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f138"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f139"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f140"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f141"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f142"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f143"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f144"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f145"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f146"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f147"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f148"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f149"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f150"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f151"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f152"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f153"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f154"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f155"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f156"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f157"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f158"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f159"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f160"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f161"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f162"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f163"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f164"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f165"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f166"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f167"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f168"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f169"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f170"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f171"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f172"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f173"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f174"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f175"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f176"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f177"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f178"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f179"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f180"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f181"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f182"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f183"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f184"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f185"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f186"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f187"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f188"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f189"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f190"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f191"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f192"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f193"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f194"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f195"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f196"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f197"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f198"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f199"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f200"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f201"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f202"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f203"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f204"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f205"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f206"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f207"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f208"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f209"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f210"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f211"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f212"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f213"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f214"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f215"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f216"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f217"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f218"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f219"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f220"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f221"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f222"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f223"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f224"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f225"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f226"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f227"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f228"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f229"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f230"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f231"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f232"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f233"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f234"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f235"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f236"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f237"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f238"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f239"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f240"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f241"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f242"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f243"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f244"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f245"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f246"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f247"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f248"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f249"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f250"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f251"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f252"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f253"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f254"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f255"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f256"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f257"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f258"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f259"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f260"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f261"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f262"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f263"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f264"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f265"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f266"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f267"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f268"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f269"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f270"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f271"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f272"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f273"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f274"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f275"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f276"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f277"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f278"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f279"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f280"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f281"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f282"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f283"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f284"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f285"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f286"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f287"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f288"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f289"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f290"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f291"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f292"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f293"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f294"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f295"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f296"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f297"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f298"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f299"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f300"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f301"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f302"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f303"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f304"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f305"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f306"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f307"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f308"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f309"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f310"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f311"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f312"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f313"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f314"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f315"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f316"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f317"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f318"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f319"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f320"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f321"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f322"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f323"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f324"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f325"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f326"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f327"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f328"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f329"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f330"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f331"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f332"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f333"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f334"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f335"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f336"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f337"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f338"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f339"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f340"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f341"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f342"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f343"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f344"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f345"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f346"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f347"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f348"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f349"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f350"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f351"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f352"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f353"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f354"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f355"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f356"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f357"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f358"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f359"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f360"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f361"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f362"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f363"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f364"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f365"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f366"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f367"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f368"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f369"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f370"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f371"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f372"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f373"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f374"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f375"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f376"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f377"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f378"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f379"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f380"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f381"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f382"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f383"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f384"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f385"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f386"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f387"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f388"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f389"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f390"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f391"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f392"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f393"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f394"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f395"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f396"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f397"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f398"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f399"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f400"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f401"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f402"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f403"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f404"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f405"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f406"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f407"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f408"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f409"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f410"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f411"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f412"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f413"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f414"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f415"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f416"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f417"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f418"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f419"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f420"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f421"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f422"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f423"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f424"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f425"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f426"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f427"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f428"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f429"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f430"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f431"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f432"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f433"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f434"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f435"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f436"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f437"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f438"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f439"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f440"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f441"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f442"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f443"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f444"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f445"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f446"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f447"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f448"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f449"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f450"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f451"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f452"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f453"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f454"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f455"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f456"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f457"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f458"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f459"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f460"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f461"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f462"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f463"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f464"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f465"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f466"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f467"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f468"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f469"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f470"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f471"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f472"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f473"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f474"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f475"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f476"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f477"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f478"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f479"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f480"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f481"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f482"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f483"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f484"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f485"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f486"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f487"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f488"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f489"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f490"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f491"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f492"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f493"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f494"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f495"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f496"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f497"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f498"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f499"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f500"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f501"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f502"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f503"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f504"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f505"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f506"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f507"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f508"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f509"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f510"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f511"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f512"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f513"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f514"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f515"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f516"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f517"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f518"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f519"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f520"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f521"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f522"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f523"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f524"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f525"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f526"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f527"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f528"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f529"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f530"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f531"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f532"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f533"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f534"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f535"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f536"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f537"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f538"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f539"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f540"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f541"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f542"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f543"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f544"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f545"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f546"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f547"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f548"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f549"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f550"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f551"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f552"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f553"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f554"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f555"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f556"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f557"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f558"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f559"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f560"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f561"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f562"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f563"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f564"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f565"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f566"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f567"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f568"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f569"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f570"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f571"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f572"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f573"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f574"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f575"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f576"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f577"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f578"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f579"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f580"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f581"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f582"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f583"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f584"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f585"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f586"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f587"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f588"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f589"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f590"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f591"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f592"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f593"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f594"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f595"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f596"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f597"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f598"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f599"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f600"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f601"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f602"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f603"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f604"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f605"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f606"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f607"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f608"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f609"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f610"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f611"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f612"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f613"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f614"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f615"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f616"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f617"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f618"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f619"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f620"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f621"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f622"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f623"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f624"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f625"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f626"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f627"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f628"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f629"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f630"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f631"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f632"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f633"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f634"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f635"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f636"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f637"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f638"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f639"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f640"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f641"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f642"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f643"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f644"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f645"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f646"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f647"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f648"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f649"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f650"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f651"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f652"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f653"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f654"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f655"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f656"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f657"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f658"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f659"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f660"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f661"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f662"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f663"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f664"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f665"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f666"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f667"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f668"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f669"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f670"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f671"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f672"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f673"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f674"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f675"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f676"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f677"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f678"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f679"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f680"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f681"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f682"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f683"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f684"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f685"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f686"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f687"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f688"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f689"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f690"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f691"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f692"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f693"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f694"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f695"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f696"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f697"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f698"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f699"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f700"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f701"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f702"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f703"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f704"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f705"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f706"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f707"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f708"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f709"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f710"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f711"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f712"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f713"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f714"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f715"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f716"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f717"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f718"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f719"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f720"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f721"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f722"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f723"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f724"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f725"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f726"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f727"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f728"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f729"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f730"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f731"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f732"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f733"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f734"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f735"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f736"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f737"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f738"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f739"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f740"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f741"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f742"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f743"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f744"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f745"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f746"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f747"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f748"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f749"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f750"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f751"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f752"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f753"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f754"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f755"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f756"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f757"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f758"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f759"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f760"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f761"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f762"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f763"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f764"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f765"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f766"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f767"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f768"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f769"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f770"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f771"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f772"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f773"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f774"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f775"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f776"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f777"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f778"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f779"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f780"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f781"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f782"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f783"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f784"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f785"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f786"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f787"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f788"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f789"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f790"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f791"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f792"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f793"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f794"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f795"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f796"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f797"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f798"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f799"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f800"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f801"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f802"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f803"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f804"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f805"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f806"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f807"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f808"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f809"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f810"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f811"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f812"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f813"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f814"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f815"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f816"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f817"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f818"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f819"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f820"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f821"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f822"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f823"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f824"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f825"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f826"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f827"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f828"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f829"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f830"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f831"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f832"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f833"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f834"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f835"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f836"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f837"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f838"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f839"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f840"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f841"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f842"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f843"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f844"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f845"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f846"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f847"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f848"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f849"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f850"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f851"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f852"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f853"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f854"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f855"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f856"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f857"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f858"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f859"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f860"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f861"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f862"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f863"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f864"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f865"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f866"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f867"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f868"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f869"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f870"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f871"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f872"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f873"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f874"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f875"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f876"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f877"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f878"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f879"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f880"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f881"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f882"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f883"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f884"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f885"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f886"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f887"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f888"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f889"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f890"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f891"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f892"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f893"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f894"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f895"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f896"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f897"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f898"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f899"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f900"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f901"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f902"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f903"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f904"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f905"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f906"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f907"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f908"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f909"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f910"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f911"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f912"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f913"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f914"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f915"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f916"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f917"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f918"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f919"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f920"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f921"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f922"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f923"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f924"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f925"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f926"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f927"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f928"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f929"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f930"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f931"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f932"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f933"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f934"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f935"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f936"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f937"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f938"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f939"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f940"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f941"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f942"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f943"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f944"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f945"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f946"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f947"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f948"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f949"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f950"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f951"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f952"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f953"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f954"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f955"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f956"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f957"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f958"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f959"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f960"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f961"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f962"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f963"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f964"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f965"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f966"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f967"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f968"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f969"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f970"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f971"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f972"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f973"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f974"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f975"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f976"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f977"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f978"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f979"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f980"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f981"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f982"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f983"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f984"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f985"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f986"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f987"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f988"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f989"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f990"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f991"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f992"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f993"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f994"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f995"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f996"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f997"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f998"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f999"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1000"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1001"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1002"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1003"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1004"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1005"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1006"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1007"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1008"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1009"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1010"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1011"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1012"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1013"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1014"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1015"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1016"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1017"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1018"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1019"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1020"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1021"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1022"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1023"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1024"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1025"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1026"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1027"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1028"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1029"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1030"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1031"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1032"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1033"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1034"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1035"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1036"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1037"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1038"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1039"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1040"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1041"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1042"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1043"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1044"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1045"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1046"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1047"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1048"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1049"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1050"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1051"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1052"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1053"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1054"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1055"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1056"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1057"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1058"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1059"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1060"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1061"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1062"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1063"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1064"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1065"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1066"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1067"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1068"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1069"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1070"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1071"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1072"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1073"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1074"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1075"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1076"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1077"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1078"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1079"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1080"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1081"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1082"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1083"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1084"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1085"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1086"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1087"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1088"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1089"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1090"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1091"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1092"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1093"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1094"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1095"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1096"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1097"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1098"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1099"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1100"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1101"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1102"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1103"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1104"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1105"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1106"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1107"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1108"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1109"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1110"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1111"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1112"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1113"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1114"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1115"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1116"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1117"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1118"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1119"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1120"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1121"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1122"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1123"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1124"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1125"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1126"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1127"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1128"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1129"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1130"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1131"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1132"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1133"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1134"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1135"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1136"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1137"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1138"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1139"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1140"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1141"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1142"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1143"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1144"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1145"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1146"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1147"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1148"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1149"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1150"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1151"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1152"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1153"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1154"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1155"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1156"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1157"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1158"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1159"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1160"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1161"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1162"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1163"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1164"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1165"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1166"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1167"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1168"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1169"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1170"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1171"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1172"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1173"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1174"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1175"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1176"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1177"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1178"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1179"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1180"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1181"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1182"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1183"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1184"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1185"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1186"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1187"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1188"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1189"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1190"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1191"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1192"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1193"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1194"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1195"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1196"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1197"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1198"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1199"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1200"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1201"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1202"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1203"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1204"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1205"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1206"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1207"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1208"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1209"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1210"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1211"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1212"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1213"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1214"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1215"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1216"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1217"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1218"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1219"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1220"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1221"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1222"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1223"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1224"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1225"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1226"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1227"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1228"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1229"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1230"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1231"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1232"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1233"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1234"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1235"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1236"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1237"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1238"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1239"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1240"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1241"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1242"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1243"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1244"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1245"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1246"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1247"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1248"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1249"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1250"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1251"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1252"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1253"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1254"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1255"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1256"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1257"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1258"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1259"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1260"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1261"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1262"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1263"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1264"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1265"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1266"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1267"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1268"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1269"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1270"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1271"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1272"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1273"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1274"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1275"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1276"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1277"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1278"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1279"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1280"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1281"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1282"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1283"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1284"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1285"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1286"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1287"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1288"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1289"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1290"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1291"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1292"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1293"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1294"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1295"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1296"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1297"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1298"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1299"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1300"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1301"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1302"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1303"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1304"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1305"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1306"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1307"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1308"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1309"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1310"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1311"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1312"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1313"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1314"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1315"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1316"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1317"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1318"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1319"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1320"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1321"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1322"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1323"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1324"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1325"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1326"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1327"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1328"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1329"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1330"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1331"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1332"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1333"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1334"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1335"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1336"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1337"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1338"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1339"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1340"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1341"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1342"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1343"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1344"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1345"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1346"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1347"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1348"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1349"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1350"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1351"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1352"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1353"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1354"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1355"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1356"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1357"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1358"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1359"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1360"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1361"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1362"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1363"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1364"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1365"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1366"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1367"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1368"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1369"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1370"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1371"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1372"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1373"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1374"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1375"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1376"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1377"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1378"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1379"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1380"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1381"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1382"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1383"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1384"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1385"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1386"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1387"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1388"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1389"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1390"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1391"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1392"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1393"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1394"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1395"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1396"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1397"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1398"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1399"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1400"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1401"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1402"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1403"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1404"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1405"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1406"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1407"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1408"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1409"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1410"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1411"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1412"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1413"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1414"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1415"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1416"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1417"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1418"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1419"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1420"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1421"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1422"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1423"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1424"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1425"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1426"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1427"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1428"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1429"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1430"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1431"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1432"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1433"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1434"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1435"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1436"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1437"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1438"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1439"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1440"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1441"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1442"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1443"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1444"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1445"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1446"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1447"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1448"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1449"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1450"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1451"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1452"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1453"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1454"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1455"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1456"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1457"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1458"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1459"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1460"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1461"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1462"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1463"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1464"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1465"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1466"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1467"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1468"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1469"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1470"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1471"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1472"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1473"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1474"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1475"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1476"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1477"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1478"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1479"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1480"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1481"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1482"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1483"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1484"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1485"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1486"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1487"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1488"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1489"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1490"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1491"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1492"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1493"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1494"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1495"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1496"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1497"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1498"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1499"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1500"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1501"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1502"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1503"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1504"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1505"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1506"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1507"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1508"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1509"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1510"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1511"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1512"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1513"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1514"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1515"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1516"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1517"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1518"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1519"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1520"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1521"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1522"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1523"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1524"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1525"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1526"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1527"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1528"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1529"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1530"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1531"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1532"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1533"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1534"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1535"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1536"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1537"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1538"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1539"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1540"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1541"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1542"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1543"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1544"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1545"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1546"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1547"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1548"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1549"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1550"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1551"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1552"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1553"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1554"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1555"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1556"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1557"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1558"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1559"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1560"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1561"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1562"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1563"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1564"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1565"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1566"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1567"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1568"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1569"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1570"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1571"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1572"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1573"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1574"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1575"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1576"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1577"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1578"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1579"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1580"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1581"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1582"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1583"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1584"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1585"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1586"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1587"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1588"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1589"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1590"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1591"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1592"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1593"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1594"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1595"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1596"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1597"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1598"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1599"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1600"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1601"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1602"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1603"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1604"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1605"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1606"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1607"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1608"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1609"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1610"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1611"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1612"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1613"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1614"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1615"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1616"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1617"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1618"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1619"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1620"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1621"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1622"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1623"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1624"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1625"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1626"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1627"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1628"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1629"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1630"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1631"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1632"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1633"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1634"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1635"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1636"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1637"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1638"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1639"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1640"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1641"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1642"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1643"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1644"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1645"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1646"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1647"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1648"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1649"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1650"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1651"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1652"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1653"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1654"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1655"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1656"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1657"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1658"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1659"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1660"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1661"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1662"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1663"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1664"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1665"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1666"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1667"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1668"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1669"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1670"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1671"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1672"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1673"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1674"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1675"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1676"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1677"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1678"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1679"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1680"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1681"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1682"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1683"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1684"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1685"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1686"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1687"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1688"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1689"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1690"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1691"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1692"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1693"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1694"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1695"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1696"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1697"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1698"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1699"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1700"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1701"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1702"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1703"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1704"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1705"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1706"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1707"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1708"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1709"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1710"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1711"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1712"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1713"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1714"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1715"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1716"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1717"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1718"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1719"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1720"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1721"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1722"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1723"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1724"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1725"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1726"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1727"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1728"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1729"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1730"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1731"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1732"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1733"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1734"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1735"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1736"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1737"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1738"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1739"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1740"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1741"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1742"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1743"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1744"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1745"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1746"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1747"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1748"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1749"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1750"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1751"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1752"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1753"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1754"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1755"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1756"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1757"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1758"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1759"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1760"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1761"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1762"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1763"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1764"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1765"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1766"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1767"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1768"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1769"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1770"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1771"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1772"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1773"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1774"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1775"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1776"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1777"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1778"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1779"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1780"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1781"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1782"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1783"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1784"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1785"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1786"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1787"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1788"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1789"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1790"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1791"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1792"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1793"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1794"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1795"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1796"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1797"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1798"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1799"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1800"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1801"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1802"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1803"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1804"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1805"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1806"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1807"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1808"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1809"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1810"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1811"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1812"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1813"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1814"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1815"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1816"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1817"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1818"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1819"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1820"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1821"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1822"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1823"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1824"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1825"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1826"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1827"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1828"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1829"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1830"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1831"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1832"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1833"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1834"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1835"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1836"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1837"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1838"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1839"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1840"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1841"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1842"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1843"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1844"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1845"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1846"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1847"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1848"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1849"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1850"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1851"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1852"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1853"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1854"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1855"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1856"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1857"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1858"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1859"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1860"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1861"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1862"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1863"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1864"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1865"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1866"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1867"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1868"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1869"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1870"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1871"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1872"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1873"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1874"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1875"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1876"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1877"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1878"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1879"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1880"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1881"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1882"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1883"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1884"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1885"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1886"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1887"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1888"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1889"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1890"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1891"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1892"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1893"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1894"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1895"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1896"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1897"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1898"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1899"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1900"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1901"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1902"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1903"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1904"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1905"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1906"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1907"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1908"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1909"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1910"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1911"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1912"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1913"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1914"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1915"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1916"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1917"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1918"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1919"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1920"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1921"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1922"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1923"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1924"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1925"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1926"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1927"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1928"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1929"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1930"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1931"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1932"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1933"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1934"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1935"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1936"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1937"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1938"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1939"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1940"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1941"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1942"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1943"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1944"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1945"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1946"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1947"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1948"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1949"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1950"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1951"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1952"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1953"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1954"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1955"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1956"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1957"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1958"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1959"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1960"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1961"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1962"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1963"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1964"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1965"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1966"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1967"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1968"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1969"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1970"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1971"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1972"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1973"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1974"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1975"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1976"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1977"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1978"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1979"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1980"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1981"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1982"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1983"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1984"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1985"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1986"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1987"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1988"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1989"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1990"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1991"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1992"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1993"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1994"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1995"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1996"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1997"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1998"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f1999"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2000"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2001"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2002"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2003"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2004"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2005"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2006"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2007"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2008"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2009"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2010"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2011"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2012"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2013"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2014"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2015"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2016"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2017"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2018"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2019"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2020"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2021"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2022"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2023"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2024"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2025"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2026"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2027"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2028"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2029"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2030"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2031"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2032"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2033"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2034"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2035"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2036"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2037"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2038"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2039"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2040"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2041"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2042"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2043"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2044"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2045"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2046"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2047"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2048"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2049"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2050"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2051"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2052"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2053"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2054"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2055"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2056"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2057"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2058"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2059"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2060"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2061"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2062"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2063"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2064"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2065"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2066"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2067"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2068"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2069"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2070"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2071"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2072"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2073"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2074"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2075"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2076"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2077"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2078"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2079"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2080"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2081"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2082"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2083"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2084"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2085"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2086"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2087"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2088"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2089"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2090"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2091"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2092"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2093"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2094"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2095"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2096"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2097"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2098"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2099"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2100"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2101"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2102"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2103"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2104"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2105"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2106"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2107"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2108"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2109"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2110"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2111"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2112"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2113"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2114"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2115"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2116"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2117"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2118"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2119"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2120"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2121"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2122"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2123"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2124"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2125"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2126"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2127"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2128"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2129"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2130"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2131"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2132"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2133"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2134"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2135"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2136"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2137"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2138"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2139"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2140"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2141"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2142"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2143"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2144"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2145"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2146"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2147"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2148"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2149"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2150"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2151"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2152"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2153"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2154"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2155"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2156"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2157"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2158"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2159"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2160"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2161"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2162"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2163"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2164"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2165"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2166"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2167"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2168"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2169"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2170"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2171"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2172"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2173"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2174"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2175"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2176"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2177"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2178"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2179"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2180"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2181"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2182"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2183"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2184"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2185"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2186"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2187"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2188"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2189"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2190"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2191"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2192"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2193"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2194"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2195"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2196"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2197"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2198"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2199"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2200"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2201"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2202"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2203"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2204"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2205"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2206"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2207"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2208"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2209"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2210"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2211"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2212"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2213"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2214"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2215"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2216"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2217"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2218"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2219"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2220"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2221"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2222"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2223"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2224"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2225"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2226"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2227"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2228"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2229"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2230"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2231"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2232"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2233"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2234"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2235"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2236"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2237"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2238"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2239"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2240"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2241"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2242"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2243"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2244"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2245"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2246"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2247"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2248"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2249"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2250"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2251"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2252"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2253"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2254"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2255"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2256"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2257"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2258"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2259"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2260"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2261"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2262"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2263"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2264"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2265"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2266"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2267"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2268"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2269"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2270"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2271"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2272"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2273"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2274"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2275"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2276"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2277"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2278"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2279"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2280"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2281"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2282"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2283"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2284"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2285"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2286"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2287"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2288"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2289"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2290"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2291"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2292"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2293"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2294"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2295"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2296"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2297"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2298"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2299"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2300"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2301"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2302"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2303"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2304"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2305"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2306"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2307"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2308"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2309"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2310"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2311"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2312"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2313"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2314"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2315"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2316"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2317"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2318"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2319"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2320"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2321"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2322"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2323"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2324"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2325"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2326"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2327"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2328"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2329"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2330"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2331"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2332"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2333"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2334"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2335"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2336"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2337"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2338"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2339"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2340"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2341"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2342"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2343"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2344"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2345"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2346"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2347"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2348"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2349"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2350"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2351"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2352"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2353"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2354"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2355"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2356"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2357"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2358"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2359"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2360"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2361"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2362"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2363"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2364"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2365"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2366"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2367"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2368"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2369"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2370"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2371"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2372"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2373"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2374"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2375"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2376"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2377"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2378"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2379"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2380"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2381"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2382"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2383"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2384"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2385"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2386"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2387"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2388"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2389"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2390"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2391"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2392"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2393"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2394"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2395"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2396"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2397"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2398"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2399"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2400"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2401"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2402"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2403"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2404"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2405"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2406"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2407"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2408"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2409"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2410"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2411"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2412"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2413"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2414"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2415"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2416"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2417"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2418"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2419"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2420"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2421"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2422"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2423"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2424"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2425"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2426"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2427"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2428"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2429"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2430"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2431"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2432"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2433"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2434"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2435"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2436"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2437"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2438"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2439"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2440"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2441"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2442"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2443"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2444"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2445"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2446"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2447"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2448"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2449"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2450"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2451"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2452"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2453"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2454"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2455"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2456"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2457"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2458"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2459"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2460"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2461"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2462"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2463"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2464"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2465"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2466"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2467"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2468"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2469"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2470"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2471"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2472"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2473"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2474"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2475"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2476"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2477"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2478"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2479"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2480"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2481"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2482"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2483"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2484"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2485"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2486"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2487"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2488"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2489"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2490"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2491"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2492"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2493"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2494"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2495"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2496"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2497"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2498"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2499"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2500"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2501"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2502"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2503"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2504"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2505"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2506"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2507"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2508"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2509"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2510"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2511"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2512"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2513"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2514"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2515"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2516"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2517"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2518"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2519"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2520"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2521"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2522"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2523"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2524"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2525"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2526"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2527"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2528"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2529"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2530"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2531"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2532"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2533"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2534"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2535"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2536"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2537"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2538"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2539"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2540"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2541"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2542"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2543"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2544"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2545"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2546"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2547"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2548"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2549"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2550"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2551"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2552"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2553"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2554"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2555"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2556"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2557"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2558"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2559"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2560"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2561"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2562"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2563"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2564"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2565"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2566"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2567"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2568"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2569"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2570"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2571"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2572"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2573"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2574"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2575"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2576"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2577"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2578"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2579"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2580"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2581"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2582"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2583"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2584"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2585"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2586"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2587"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2588"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2589"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2590"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2591"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2592"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2593"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2594"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2595"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2596"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2597"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2598"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2599"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2600"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2601"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2602"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2603"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2604"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2605"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2606"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2607"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2608"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2609"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2610"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2611"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2612"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2613"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2614"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2615"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2616"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2617"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2618"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2619"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2620"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2621"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2622"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2623"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2624"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2625"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2626"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2627"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2628"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2629"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2630"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2631"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2632"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2633"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2634"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2635"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2636"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2637"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2638"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2639"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2640"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2641"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2642"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2643"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2644"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2645"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2646"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2647"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2648"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2649"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2650"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2651"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2652"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2653"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2654"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2655"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2656"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2657"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2658"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2659"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2660"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2661"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2662"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2663"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2664"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2665"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2666"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2667"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2668"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2669"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2670"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2671"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2672"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2673"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2674"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2675"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2676"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2677"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2678"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2679"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2680"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2681"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2682"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2683"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2684"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2685"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2686"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2687"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2688"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2689"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2690"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2691"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2692"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2693"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2694"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2695"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2696"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2697"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2698"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2699"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2700"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2701"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2702"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2703"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2704"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2705"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2706"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2707"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2708"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2709"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2710"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2711"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2712"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2713"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2714"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2715"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2716"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2717"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2718"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2719"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2720"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2721"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2722"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2723"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2724"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2725"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2726"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2727"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2728"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2729"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2730"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2731"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2732"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2733"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2734"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2735"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2736"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2737"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2738"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2739"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2740"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2741"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2742"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2743"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2744"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2745"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2746"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2747"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2748"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2749"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2750"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2751"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2752"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2753"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2754"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2755"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2756"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2757"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2758"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2759"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2760"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2761"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2762"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2763"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2764"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2765"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2766"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2767"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2768"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2769"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2770"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2771"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2772"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2773"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2774"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2775"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2776"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2777"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2778"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2779"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2780"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2781"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2782"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2783"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2784"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2785"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2786"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2787"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2788"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2789"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2790"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2791"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2792"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2793"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2794"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2795"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2796"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2797"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2798"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2799"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2800"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2801"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2802"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2803"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2804"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2805"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2806"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2807"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2808"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2809"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2810"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2811"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2812"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2813"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2814"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2815"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2816"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2817"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2818"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2819"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2820"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2821"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2822"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2823"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2824"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2825"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2826"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2827"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2828"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2829"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2830"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2831"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2832"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2833"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2834"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2835"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2836"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2837"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2838"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2839"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2840"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2841"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2842"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2843"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2844"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2845"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2846"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2847"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2848"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2849"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2850"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2851"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2852"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2853"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2854"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2855"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2856"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2857"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2858"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2859"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2860"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2861"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2862"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2863"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2864"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2865"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2866"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2867"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2868"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2869"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2870"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2871"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2872"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2873"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2874"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2875"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2876"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2877"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2878"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2879"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2880"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2881"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2882"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2883"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2884"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2885"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2886"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2887"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2888"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2889"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2890"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2891"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2892"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2893"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2894"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2895"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2896"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2897"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2898"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2899"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2900"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2901"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2902"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2903"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2904"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2905"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2906"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2907"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2908"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2909"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2910"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2911"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2912"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2913"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2914"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2915"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2916"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2917"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2918"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2919"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2920"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2921"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2922"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2923"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2924"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2925"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2926"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2927"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2928"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2929"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2930"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2931"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2932"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2933"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2934"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2935"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2936"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2937"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2938"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2939"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2940"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2941"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2942"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2943"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2944"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2945"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2946"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2947"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2948"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2949"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2950"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2951"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2952"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2953"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2954"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2955"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2956"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2957"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2958"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2959"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2960"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2961"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2962"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2963"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2964"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2965"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2966"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2967"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2968"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2969"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2970"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2971"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2972"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2973"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2974"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2975"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2976"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2977"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2978"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2979"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2980"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2981"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2982"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2983"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2984"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2985"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2986"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2987"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2988"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2989"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2990"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2991"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2992"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2993"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2994"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2995"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2996"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2997"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2998"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+ ["f2999"]=>
+ unicode(23) "*bug45218_SLOWTESTU.txt"
+}
+===DONE===
diff --git a/ext/phar/tests/bug46032.phpt b/ext/phar/tests/bug46032.phpt
new file mode 100644
index 0000000..7700e9b
--- /dev/null
+++ b/ext/phar/tests/bug46032.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: bug #46032: PharData::__construct wrong memory read
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (getenv('SKIP_SLOW_TESTS')) die('skip'); ?>
+--FILE--
+<?php
+
+$a = dirname(__FILE__) .'/mytest';
+
+try {
+ new phar($a);
+} catch (exception $e) { }
+
+var_dump($a);
+
+try {
+ new phar($a);
+} catch (exception $e) { }
+
+var_dump($a);
+
+new phardata('0000000000000000000');
+?>
+===DONE===
+--EXPECTF--
+%string|unicode%(%d) "%smytest"
+%string|unicode%(%d) "%smytest"
+
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '0000000000000000000', file extension (or combination) not recognised or the directory does not exist' in %sbug46032.php:%d
+Stack trace:
+#0 %sbug46032.php(%d): PharData->__construct('000000000000000...')
+#1 {main}
+ thrown in %sbug46032.php on line %d
diff --git a/ext/phar/tests/bug46060.phpt b/ext/phar/tests/bug46060.phpt
new file mode 100644
index 0000000..1ca346e
--- /dev/null
+++ b/ext/phar/tests/bug46060.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: Bug #46060: addEmptyDir() breaks
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (getenv('SKIP_SLOW_TESTS')) die('skip'); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
+
+$phar = new PharData($fname);
+$phar->addEmptyDir('blah/');
+$phar->addFromString('test/', '');
+
+copy($fname, $fname2);
+$phar = new PharData($fname2);
+
+var_dump($phar['blah']->isDir(), $phar['test']->isDir());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(true)
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/bug46178.phpt b/ext/phar/tests/bug46178.phpt
new file mode 100644
index 0000000..9dab621
--- /dev/null
+++ b/ext/phar/tests/bug46178.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar: PHP bug #46178: "memory leak in ext/phar"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+
+$phar = new Phar($fname);
+$phar['long/path/name.txt'] = 'hi';
+$phar->addEmptyDir('long/path');
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
+--EXPECT--
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug47085.phpt b/ext/phar/tests/bug47085.phpt
new file mode 100644
index 0000000..9aaaed0
--- /dev/null
+++ b/ext/phar/tests/bug47085.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar: PHP bug #47085: "rename() returns true even if the file in PHAR does not exist"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+
+$phar = new Phar($fname, 0, 'a.phar');
+$phar['x'] = 'hi';
+unset($phar);
+rename("phar://a.phar/x", "phar://a.phar/y");
+var_dump(rename("phar://a.phar/x", "phar://a.phar/y"));
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
+--EXPECTF--
+Warning: rename(): phar error: cannot rename "phar://a.phar/x" to "phar://a.phar/y" from extracted phar archive, source does not exist in %sbug47085.php on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug48377.2.phpt b/ext/phar/tests/bug48377.2.phpt
new file mode 100644
index 0000000..be2a0e1
--- /dev/null
+++ b/ext/phar/tests/bug48377.2.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar: PHP bug #48377 "error message unclear on converting phar with existing file" test #2
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
+
+$phar = new PharData($fname);
+$phar['x'] = 'hi';
+try {
+ $phar->convertToData(Phar::ZIP, Phar::NONE, '.2.phar.zip');
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
+--EXPECTF--
+data phar "%sbug48377.2.phar.zip" has invalid extension 2.phar.zip
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug48377.phpt b/ext/phar/tests/bug48377.phpt
new file mode 100644
index 0000000..6282a15
--- /dev/null
+++ b/ext/phar/tests/bug48377.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: PHP bug #48377 "error message unclear on converting phar with existing file"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
+
+touch($fname2);
+
+$phar = new Phar($fname, 0, 'a.phar');
+$phar['x'] = 'hi';
+try {
+ $phar->convertToData(Phar::ZIP, Phar::NONE, 'zip');
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
+--EXPECTF--
+phar "%sbug48377.zip" exists and must be unlinked prior to conversion
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug52013.phpt b/ext/phar/tests/bug52013.phpt
new file mode 100644
index 0000000..5ee37e7
--- /dev/null
+++ b/ext/phar/tests/bug52013.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test for bug 52013 about Phar::decompressFiles().
+--DESCRIPTION--
+Test for a bug where Phar::decompressFiles() mistakenly throws BadMethodCallException.
+http://bugs.php.net/bug.php?id=52013
+--CREDITS--
+Frederic Hardy frederic.hardy@mageekbox.net
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip test needs zlib extension enabled to compress archives with gzip");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+open_basedir=
+--FILE--
+<?php
+mkdir(dirname(__FILE__) . '/testdir');
+file_put_contents(dirname(__FILE__) . '/testdir/1.php', str_repeat(' ', 1455));
+
+$phar = new Phar(dirname(__FILE__) . '/compressed.phar');
+$phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php$/');
+$phar->setSignatureAlgorithm(Phar::SHA1);
+$phar->compressFiles(Phar::GZ);
+$phar->decompressFiles();
+
+echo 'ok';
+?>
+--CLEAN--
+<?php
+if (is_file(dirname(__FILE__) . '/testdir/1.php'))
+ unlink(dirname(__FILE__) . '/testdir/1.php');
+if (is_dir(dirname(__FILE__) . '/testdir'))
+ rmdir(dirname(__FILE__) . '/testdir');
+if (is_file(dirname(__FILE__) . '/compressed.phar'))
+ unlink(dirname(__FILE__) . '/compressed.phar');
+?>
+--EXPECT--
+ok
diff --git a/ext/phar/tests/bug53872.phpt b/ext/phar/tests/bug53872.phpt
new file mode 100644
index 0000000..fd332fd
--- /dev/null
+++ b/ext/phar/tests/bug53872.phpt
@@ -0,0 +1,28 @@
+--TEST--
+bug#53872 (internal corruption of phar)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip Test needs ext/zlib");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p=new Phar('bug53872-phar.phar');
+$p->buildFromDirectory(__DIR__ . "/bug53872/");
+$p->setStub('<?php __HALT_COMPILER();?\>');
+$p->compressFiles(Phar::GZ);
+
+print(file_get_contents('phar://bug53872-phar.phar/first.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/second.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/third.txt'));
+?>
+--CLEAN--
+<?php
+unlink("bug53872-phar.phar");
+?>
+--EXPECT--
+content of first.txt
+content of third.txt
+
diff --git a/ext/phar/tests/bug53872/first.txt b/ext/phar/tests/bug53872/first.txt
new file mode 100644
index 0000000..90a4d1f
--- /dev/null
+++ b/ext/phar/tests/bug53872/first.txt
@@ -0,0 +1 @@
+content of first.txt
diff --git a/ext/phar/tests/bug53872/second.txt b/ext/phar/tests/bug53872/second.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ext/phar/tests/bug53872/second.txt
diff --git a/ext/phar/tests/bug53872/third.txt b/ext/phar/tests/bug53872/third.txt
new file mode 100644
index 0000000..4f283cd
--- /dev/null
+++ b/ext/phar/tests/bug53872/third.txt
@@ -0,0 +1 @@
+content of third.txt
diff --git a/ext/phar/tests/bug54395.phpt b/ext/phar/tests/bug54395.phpt
new file mode 100644
index 0000000..091ed32
--- /dev/null
+++ b/ext/phar/tests/bug54395.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #54395 (Phar::mount() crashes when calling with wrong parameters)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+
+try {
+ phar::mount(1,1);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+string(25) "Mounting of 1 to 1 failed"
diff --git a/ext/phar/tests/bug60164.phpt b/ext/phar/tests/bug60164.phpt
new file mode 100644
index 0000000..8fd5de5
--- /dev/null
+++ b/ext/phar/tests/bug60164.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar: verify stub of specific length does not break __HALT_COMPILER(); scanning in php
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$phar = __DIR__ . '/files/stuboflength1041.phar';
+foreach (new RecursiveIteratorIterator(new Phar($phar, null, 'stuboflength1041.phar')) as $item) {
+ var_dump($item->getFileName());
+}
+?>
+===DONE===
+--EXPECT--
+string(5) "a.php"
+string(5) "b.php"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt
new file mode 100644
index 0000000..1b6cd7a
--- /dev/null
+++ b/ext/phar/tests/bug60261.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #60261 (phar dos null pointer)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+
+$nx = new Phar();
+try {
+ $nx->getLinkTarget();
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+
+Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on line %d
+SplFileInfo::getLinkTarget(): Empty filename
diff --git a/ext/phar/tests/cache_list/copyonwrite1.phar.phpt b/ext/phar/tests/cache_list/copyonwrite1.phar.phpt
new file mode 100644
index 0000000..90b0a8f
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite1.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 1 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite1.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write.phar
+--EXPECT--
+hi
+changed
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite10.phar.phpt b/ext/phar/tests/cache_list/copyonwrite10.phar.phpt
new file mode 100644
index 0000000..3d5b7fe
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite10.phar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar: copy-on-write test 10 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite10.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write10.phar
+--EXPECTF--
+string(214) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$a = fopen("phar://" . __FILE__ . "/test.txt", "r");
+$p->setStub($a);
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+<?php __HALT_COMPILER(); ?>
+
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite11.phar.phpt b/ext/phar/tests/cache_list/copyonwrite11.phar.phpt
new file mode 100644
index 0000000..6538816
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite11.phar.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar: copy-on-write test 11 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite11.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write11.phar
+--EXPECTF--
+string(174) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setDefaultStub();
+echo strlen($p2->getStub()),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+6685
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite12.phar.phpt b/ext/phar/tests/cache_list/copyonwrite12.phar.phpt
new file mode 100644
index 0000000..40b5441
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite12.phar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar: copy-on-write test 12 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite12.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write12.phar
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(40) "0163F471460EA74F7636268D28289BF5A1E8BD72"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(32) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite13.phar.phpt b/ext/phar/tests/cache_list/copyonwrite13.phar.phpt
new file mode 100644
index 0000000..fc47174
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite13.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 13 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite13.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write13.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite14.phar.phpt b/ext/phar/tests/cache_list/copyonwrite14.phar.phpt
new file mode 100644
index 0000000..11201ac
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite14.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 14 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite14.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write14.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite15.phar.phpt b/ext/phar/tests/cache_list/copyonwrite15.phar.phpt
new file mode 100644
index 0000000..6e46289
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite15.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 15 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite15.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write15.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite16.phar.phpt b/ext/phar/tests/cache_list/copyonwrite16.phar.phpt
new file mode 100644
index 0000000..f17784c
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite16.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 16 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite16.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write16.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite17.phar.phpt b/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
new file mode 100644
index 0000000..158c049
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 17 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite17.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write17.phar
+--EXPECTF--
+NULL
+%string|unicode%(2) "hi"
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite18.phar.phpt b/ext/phar/tests/cache_list/copyonwrite18.phar.phpt
new file mode 100644
index 0000000..3e65f5a
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite18.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 18 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite18.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write18.phar
+--EXPECTF--
+100666
+100444
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite19.phar.phpt b/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
new file mode 100644
index 0000000..6e03554
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 19 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite19.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write19.phar
+--EXPECTF--
+string(2) "hi"
+%string|unicode%(3) "hi2"
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite2.phar.phpt b/ext/phar/tests/cache_list/copyonwrite2.phar.phpt
new file mode 100644
index 0000000..8d21c81
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite2.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: copy-on-write test 2 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite2.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write2.phar
+--EXPECT--
+string(2) "hi"
+bool(true)
+string(2) "hi"
+bool(true)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite20.phar.phpt b/ext/phar/tests/cache_list/copyonwrite20.phar.phpt
new file mode 100644
index 0000000..acce574
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite20.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 20 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite20.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write20.phar
+--EXPECTF--
+string(2) "hi"
+NULL
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite21.phar.phpt b/ext/phar/tests/cache_list/copyonwrite21.phar.phpt
new file mode 100644
index 0000000..8960ea7
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite21.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 21 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite21.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write21.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite22.phar.phpt b/ext/phar/tests/cache_list/copyonwrite22.phar.phpt
new file mode 100644
index 0000000..7cba216
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite22.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 22 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite22.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write22.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite23.phar.phpt b/ext/phar/tests/cache_list/copyonwrite23.phar.phpt
new file mode 100644
index 0000000..292e5af
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite23.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: copy-on-write test 23 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite23.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write23.phar
+--EXPECTF--
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite24.phar.phpt b/ext/phar/tests/cache_list/copyonwrite24.phar.phpt
new file mode 100644
index 0000000..69197f2
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite24.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 24 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite24.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write24.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite25.phar.phpt b/ext/phar/tests/cache_list/copyonwrite25.phar.phpt
new file mode 100644
index 0000000..b661cb6
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite25.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar: copy-on-write test 25 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite25.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write25.phar
+--EXPECTF--
+bool(false)
+bool(true)
+<?php __HALT_COMPILER();
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite3.phar.phpt b/ext/phar/tests/cache_list/copyonwrite3.phar.phpt
new file mode 100644
index 0000000..7e2c94c
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite3.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar: copy-on-write test 3 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite3.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write3.phar
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite4.phar.phpt b/ext/phar/tests/cache_list/copyonwrite4.phar.phpt
new file mode 100644
index 0000000..20ff78e
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite4.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 4 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite4.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write4.phar
+--EXPECT--
+bool(false)
+bool(true)
+string(2) "hi"
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite4a.phpt b/ext/phar/tests/cache_list/copyonwrite4a.phpt
new file mode 100644
index 0000000..1945e31
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite4a.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar: copy-on-write test 4a [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite4.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(file_exists('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'));
+Phar::mount('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt', 'phar://' . dirname(__FILE__) . '/files/write4.phar/tobemounted');
+var_dump(file_exists('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'), file_get_contents('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'));
+?>
+===DONE===
+--EXPECT--
+bool(false)
+bool(true)
+string(2) "hi"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite5.phar.phpt b/ext/phar/tests/cache_list/copyonwrite5.phar.phpt
new file mode 100644
index 0000000..89990a7
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite5.phar.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Phar: copy-on-write test 5 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite5.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write5.phar
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/copyonwrite5/file1');
+unlink(dirname(__FILE__) . '/copyonwrite5/file2');
+rmdir(dirname(__FILE__) . '/copyonwrite5');
+?>
+--EXPECTF--
+array(2) {
+ ["file1"]=>
+ string(%d) "%sfile1"
+ ["file2"]=>
+ string(%d) "%sfile2"
+}
+phar://%scopyonwrite5.phar.php%cfile1 file1
+phar://%scopyonwrite5.phar.php%cfile2 file2
+phar://%scopyonwrite5.phar.php%chi hi
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite6.phar.phpt b/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
new file mode 100644
index 0000000..661fef4
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: copy-on-write test 6 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite6.phar.php
+phar.readonly=0
+open_basedir=
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip PHP 5.3+ required"); ?>
+--FILE_EXTERNAL--
+files/write6.phar
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/copyonwrite6/file1');
+unlink(dirname(__FILE__) . '/copyonwrite6/file2');
+rmdir(dirname(__FILE__) . '/copyonwrite6');
+?>
+--EXPECTF--
+array(2) {
+ ["file1"]=>
+ string(%d) "%sfile1"
+ ["file2"]=>
+ string(%d) "%sfile2"
+}
+phar://%scopyonwrite6.phar.php%cfile1 file1
+phar://%scopyonwrite6.phar.php%cfile2 file2
+phar://%scopyonwrite6.phar.php%chi hi
+ok
diff --git a/ext/phar/tests/cache_list/copyonwrite7.phar.phpt b/ext/phar/tests/cache_list/copyonwrite7.phar.phpt
new file mode 100644
index 0000000..d6faded
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite7.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 7 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite7.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write7.phar
+--EXPECT--
+bool(true)
+bool(false)
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite8.phar.phpt b/ext/phar/tests/cache_list/copyonwrite8.phar.phpt
new file mode 100644
index 0000000..7217d33
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite8.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 8 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite8.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write8.phar
+--EXPECTF--
+string(%s) "%scopyonwrite8.phar.php"
+hi
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite9.phar.phpt b/ext/phar/tests/cache_list/copyonwrite9.phar.phpt
new file mode 100644
index 0000000..ffda956
--- /dev/null
+++ b/ext/phar/tests/cache_list/copyonwrite9.phar.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar: copy-on-write test 9 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite9.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write9.phar
+--EXPECTF--
+string(188) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setStub("<?php __HALT"."_COMPILER();");
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+<?php __HALT_COMPILER(); ?>
+
+ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/blog.phar b/ext/phar/tests/cache_list/files/blog.phar
new file mode 100644
index 0000000..58c8a3b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/blog.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/blog.phar.inc b/ext/phar/tests/cache_list/files/blog.phar.inc
new file mode 100644
index 0000000..62d86c5
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/blog.phar.inc
@@ -0,0 +1,20 @@
+<?php
+
+$fname = dirname(__FILE__) . '/blog.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php if(file_exists(dirname(__FILE__) . "/files/config.xml")) {
+ Phar::mount("config.xml", dirname(__FILE__) . "/files/config.xml");
+}
+Phar::webPhar("blog", "index.php");
+__HALT_COMPILER(); ?>');
+$phar['index.php'] = '<?php if (!file_exists("config.xml")) {
+ include "install.php";
+ exit;
+}
+var_dump(file_get_contents("config.xml"));
+?>';
+$phar['install.php'] = '<?php echo "install\n"; ?>';
+
+?>
diff --git a/ext/phar/tests/cache_list/files/config.xml b/ext/phar/tests/cache_list/files/config.xml
new file mode 100644
index 0000000..cf0dbc5
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/config.xml
@@ -0,0 +1,9 @@
+<xml version="1.0" encoding="UTF-8">
+<config>
+ <database>
+ <host>localhost</name>
+ <user>squirrel</user>
+ <pass>nuts</pass>
+ <db>hoard</db>
+ </database>
+</config>
diff --git a/ext/phar/tests/cache_list/files/extracted.inc b/ext/phar/tests/cache_list/files/extracted.inc
new file mode 100644
index 0000000..a6e5224
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/extracted.inc
@@ -0,0 +1 @@
+<?php var_dump(__FILE__); ?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller.phar b/ext/phar/tests/cache_list/files/frontcontroller.phar
new file mode 100644
index 0000000..626bf48
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller.phar.inc
new file mode 100644
index 0000000..80d42e8
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a['index.php'] = 'here is my index';
+$a->setStub('<?php
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller10.phar b/ext/phar/tests/cache_list/files/frontcontroller10.phar
new file mode 100644
index 0000000..078ce75
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller10.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000..4c139db
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller11.phar b/ext/phar/tests/cache_list/files/frontcontroller11.phar
new file mode 100644
index 0000000..61ea843
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller11.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000..0863508
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar b/ext/phar/tests/cache_list/files/frontcontroller12.phar
new file mode 100644
index 0000000..1cf3629
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000..f1e4645
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller13.phar b/ext/phar/tests/cache_list/files/frontcontroller13.phar
new file mode 100644
index 0000000..750ff27
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller13.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc
new file mode 100644
index 0000000..0bfef46
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller13.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller13.phar');
+$a['index.php'] = '<?php
+var_dump("test");
+include "oof/test.php";';
+$a['oof/test.php'] = '<?php
+var_dump("oof/test.php");
+include "./hi.php";';
+$a['oof/hi.php'] = '<?php
+var_dump("hi");';
+$a->setStub('<?php
+Phar::webPhar();
+__HALT_COMPILER();'); \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar b/ext/phar/tests/cache_list/files/frontcontroller14.phar
new file mode 100644
index 0000000..ebc3e9b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
new file mode 100644
index 0000000..23104a6
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller14.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller14.phar');
+$a['html/index.php'] = '<?php
+var_dump($_SERVER[b"PATH_INFO"]);
+var_dump($_SERVER[b"PATH_TRANSLATED"]);
+';
+$a->setStub('<?php
+function s($a)
+{
+ return "/html/index.php";
+}
+Phar::interceptFileFuncs();
+Phar::mungServer(array("PHP_SELF", "REQUEST_URI"));
+Phar::webPhar("whatever", "/html/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar b/ext/phar/tests/cache_list/files/frontcontroller16.phar
new file mode 100644
index 0000000..cce5db5
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc
new file mode 100644
index 0000000..3c9986d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller16.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller16.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here"));
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller17.phar b/ext/phar/tests/cache_list/files/frontcontroller17.phar
new file mode 100644
index 0000000..b83d41f
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller17.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc
new file mode 100644
index 0000000..85b8729
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller17.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller17.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "sort");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller18.phar b/ext/phar/tests/cache_list/files/frontcontroller18.phar
new file mode 100644
index 0000000..c447f39
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller18.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc
new file mode 100644
index 0000000..847a713
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller18.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller18.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+function s($a)
+{
+}
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "s");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller19.phar b/ext/phar/tests/cache_list/files/frontcontroller19.phar
new file mode 100644
index 0000000..bdf8ee1
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller19.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc
new file mode 100644
index 0000000..ba84ac4
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc
@@ -0,0 +1,25 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller19.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller19.phar');
+$a['start/index.php'] = '<?php
+echo "start/index.php\n";
+include "./another.php";
+';
+$a['start/another.php'] = '<?php
+echo "start/another.php\n";
+include "../another.php";
+?>';
+$a['another.php'] = '<?php
+echo "another.php\n";
+?>';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+try {
+Phar::webPhar("test.phar", "/start/index.php");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller2.phar b/ext/phar/tests/cache_list/files/frontcontroller2.phar
new file mode 100644
index 0000000..0dd0e7f
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller2.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000..653c796
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "a.php");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar b/ext/phar/tests/cache_list/files/frontcontroller3.phar
new file mode 100644
index 0000000..35a23ea
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000..6f9126f
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => "a.phps");
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar b/ext/phar/tests/cache_list/files/frontcontroller4.phar
new file mode 100644
index 0000000..8359461
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000..daf807e
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => false);
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller5.phar b/ext/phar/tests/cache_list/files/frontcontroller5.phar
new file mode 100644
index 0000000..f206b59
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller5.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000..d2d810c
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller6.phar b/ext/phar/tests/cache_list/files/frontcontroller6.phar
new file mode 100644
index 0000000..f4a8265
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller6.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000..5c900eb
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("blah" => 100));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller7.phar b/ext/phar/tests/cache_list/files/frontcontroller7.phar
new file mode 100644
index 0000000..07884b2
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller7.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000..6849702
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("blah" => null));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar b/ext/phar/tests/cache_list/files/frontcontroller8.phar
new file mode 100644
index 0000000..c9c0e40
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000..8629f08
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar');
+$a['a.phps'] = 'hio1';
+$a['a1.phps'] = '<?php var_dump($_SERVER[b"REQUEST_URI"], $_SERVER[b"PATH_INFO"]);';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a['404.php'] = 'My 404 is rawesome';
+$a['noext'] = 'hi';
+$a['unknown.ext'] = '<?php var_dump("hi");';
+$a['bigfile.txt'] = str_repeat('a', 8193);
+$a['fatalerror.phps'] = '<?php oopsie_daisy();';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", "404.php", array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller9.phar b/ext/phar/tests/cache_list/files/frontcontroller9.phar
new file mode 100644
index 0000000..39ca28c
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller9.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000..00861f6
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::mungServer(array());
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/md5.phar b/ext/phar/tests/cache_list/files/md5.phar
new file mode 100644
index 0000000..8ca2f84
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/md5.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/nophar.phar b/ext/phar/tests/cache_list/files/nophar.phar
new file mode 100644
index 0000000..4eb3083
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/nophar.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/nophar.phar.inc b/ext/phar/tests/cache_list/files/nophar.phar.inc
new file mode 100644
index 0000000..36d5628
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/nophar.phar.inc
@@ -0,0 +1,10 @@
+<?php
+$fname = dirname(__FILE__) . '/nophar.phar';
+@unlink($fname);
+$p = new Phar($fname);
+$p['index.php'] = '<?php include "b/c.php";' . "\n";
+$p['web.php'] = '<?php echo "web\n";';
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("index.php", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub($p->createDefaultStub('index.php', 'web.php'));
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/openssl.phar b/ext/phar/tests/cache_list/files/openssl.phar
new file mode 100644
index 0000000..f3864d7
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/openssl.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/openssl.phar.pubkey b/ext/phar/tests/cache_list/files/openssl.phar.pubkey
new file mode 100644
index 0000000..7dd79ac
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/openssl.phar.pubkey
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA3ADUiKZIEhekYShzPCZ3LFbg
+rDuV44jH94OdJQfqaCQBvZXqMoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzB
+mx9bFipOX2W2ouKS2YoHeIoR9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5
+agpkVsHLNJWbz/nPVwIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/cache_list/files/phar_oo_test.inc b/ext/phar/tests/cache_list/files/phar_oo_test.inc
new file mode 100644
index 0000000..9863e8d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/phar_oo_test.inc
@@ -0,0 +1,49 @@
+<?php
+
+ini_set('date.timezone', 'GMT');
+
+$fname = dirname(__FILE__) . '/phar_oo_test.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+
+if (!isset($pharconfig)) $pharconfig = 0;
+
+switch($pharconfig)
+{
+ default:
+ case 0:
+ $files['a.php'] = '<?php echo "This is a.php\n"; ?>';
+ $files['b.php'] = '<?php echo "This is b.php\n"; ?>';
+ $files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>';
+ $files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>';
+ $files['e.php'] = '<?php echo "This is e.php\n"; ?>';
+ break;
+ case 1:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+EOF;
+ break;
+ case 2:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+4
+5,5
+
+7,777
+EOF;
+ break;
+ case 3:
+ $files['a.php'] = '<?php echo new new class;';
+ break;
+}
+
+$ftime = mktime(12, 0, 0, 3, 1, 2006);
+include 'phar_test.inc';
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/phar_test.inc b/ext/phar/tests/cache_list/files/phar_test.inc
new file mode 100644
index 0000000..f82471d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/phar_test.inc
@@ -0,0 +1,78 @@
+<?php
+
+if (function_exists('date_default_timezone_set')) {
+ date_default_timezone_set('UTC');
+}
+
+$manifest = (binary)'';
+$glags = 0;
+
+foreach($files as $name => $cont)
+{
+ global $gflags, $files;
+
+ $comp = NULL;
+ $crc32= NULL;
+ $clen = NULL;
+ $ulen = NULL;
+ $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
+ $flags= 0;
+ $perm = 0x000001B6;
+ $meta = NULL;
+
+ // overwrite if array
+ if (is_array($cont))
+ {
+ foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what)
+ {
+ if (isset($cont[$what]))
+ {
+ $$what = $cont[$what];
+ }
+ }
+ }
+
+ // 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((binary)$cont);
+ if (isset($meta)) $meta = serialize($meta);
+
+ // write manifest entry
+ $manifest .= pack('V', strlen($name)) . (binary)$name;
+ $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
+
+ // globals
+ $gflags |= $flags;
+ $files[$name] = $comp;
+}
+
+if (!isset($alias)) $alias = 'hio';
+
+if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
+
+$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
+$file = (binary)$file;
+$file .= pack('V', strlen($manifest)) . $manifest;
+
+foreach($files as $cont)
+{
+ $file .= (binary)$cont;
+}
+
+file_put_contents($fname, $file);
+
+if (@$gzip) {
+ $fp = gzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+if (@$bz2) {
+ $fp = bzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/private.pem b/ext/phar/tests/cache_list/files/private.pem
new file mode 100644
index 0000000..e4f4883
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/private.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDA3ADUiKZIEhekYShzPCZ3LFbgrDuV44jH94OdJQfqaCQBvZXq
+MoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzBmx9bFipOX2W2ouKS2YoHeIoR
+9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5agpkVsHLNJWbz/nPVwIDAQAB
+AoGAGiS4qBbuE48ATXQuO5DH1hfYnxQ575Oskw7mdIL0k74SQ3ojvF+kXae6fVni
+UQZ76JgRWKYZa2kRDymwLZXpxVbiGL9dDvQY8ZENDtWOy9s7TDtxNixbZloKBopg
+J7G1B05LgetR3dgFnQOwt+e3kOu72RpS7thyBaUm8zHCRSECQQDw+h5uxE7i9CC8
+KHyJlwGoR28KZgrSpo74yWhQ+b1lzxQ+rk2wToFD/p+WNe/nf78YUl/cq0LngCKH
+Y7t228VLAkEAzOHzAjuDlGGzK6Kpe67iKgXd+GpKwPr9iaFfmzABOkRwQug4LCN7
+skmzCX5pzxqMZW1xNICjeDjWsMA3d4EypQJBAJyXPA1onYaXc2oxuPPD3/zVJpAQ
+TTojp8Z9Qr9T+kJdNV+h7rQB37gqjtOSiynY9nm8lbSUya4bstRd96S+HU8CQQCp
+yBAd6H2oZ7IXVeuHACyRUF1ab5LVCukxtVXJ/2T1CSPSfieWhC0MWMCR/HzoUALK
+RoBKVtOgW9GllRQh5yG1AkARVYbvj0XBy6XUpe5WZsLNWwpw1JreRsygcPXYh8bs
+nxhCdHNHJQ01lRDMjvNLtI8a5YjJE/IeW76T2mPCiJZI
+-----END RSA PRIVATE KEY-----
diff --git a/ext/phar/tests/cache_list/files/sha1.phar b/ext/phar/tests/cache_list/files/sha1.phar
new file mode 100644
index 0000000..c7e9e7e
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha1.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/sha256.phar b/ext/phar/tests/cache_list/files/sha256.phar
new file mode 100644
index 0000000..81459ee
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha256.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/sha512.phar b/ext/phar/tests/cache_list/files/sha512.phar
new file mode 100644
index 0000000..a747381
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha512.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write.phar b/ext/phar/tests/cache_list/files/write.phar
new file mode 100644
index 0000000..7acdaa6
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write.phar.inc b/ext/phar/tests/cache_list/files/write.phar.inc
new file mode 100644
index 0000000..eb722af
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write.phar.inc
@@ -0,0 +1,20 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+echo $phar["test.txt"]->getContent();
+$phar["test.txt"] = "changed
+";
+echo $phar["test.txt"]->getContent();
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar->setMetadata('hi');
+$phar['test.txt'] = "hi
+";
+$phar['test.txt']->setMetadata('hi');
+?>
diff --git a/ext/phar/tests/cache_list/files/write10.phar b/ext/phar/tests/cache_list/files/write10.phar
new file mode 100644
index 0000000..473f0a1
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write10.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write10.phar.inc b/ext/phar/tests/cache_list/files/write10.phar.inc
new file mode 100644
index 0000000..a23b5e5
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write10.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write10.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$a = fopen("phar://" . __FILE__ . "/test.txt", "r");
+$p->setStub($a);
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write11.phar b/ext/phar/tests/cache_list/files/write11.phar
new file mode 100644
index 0000000..bb8d33f
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write11.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write11.phar.inc b/ext/phar/tests/cache_list/files/write11.phar.inc
new file mode 100644
index 0000000..d255264
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write11.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write11.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setDefaultStub();
+echo strlen($p2->getStub()),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write12.phar b/ext/phar/tests/cache_list/files/write12.phar
new file mode 100644
index 0000000..bff1456
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write12.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write12.phar.inc b/ext/phar/tests/cache_list/files/write12.phar.inc
new file mode 100644
index 0000000..f0c01eb
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write12.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write12.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getSignature());
+$p2 = new Phar(__FILE__);
+$p->setSignatureAlgorithm(Phar::MD5);
+var_dump($p->getSignature());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write13.phar b/ext/phar/tests/cache_list/files/write13.phar
new file mode 100644
index 0000000..46ca14d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write13.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write13.phar.inc b/ext/phar/tests/cache_list/files/write13.phar.inc
new file mode 100644
index 0000000..e8b6f33
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write13.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write13.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p2 = new Phar(__FILE__);
+$p->compressFiles(Phar::GZ);
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write14.phar b/ext/phar/tests/cache_list/files/write14.phar
new file mode 100644
index 0000000..4482752
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write14.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write14.phar.inc b/ext/phar/tests/cache_list/files/write14.phar.inc
new file mode 100644
index 0000000..c2b0448
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write14.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write14.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p2 = new Phar(__FILE__);
+$p->decompressFiles();
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar->compressFiles(Phar::GZ);
+?>
diff --git a/ext/phar/tests/cache_list/files/write15.phar b/ext/phar/tests/cache_list/files/write15.phar
new file mode 100644
index 0000000..c6190b7
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write15.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write15.phar.inc b/ext/phar/tests/cache_list/files/write15.phar.inc
new file mode 100644
index 0000000..d30f6c8
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write15.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write15.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["copied"]));
+$p->copy("test.txt","copied");
+var_dump(isset($p["copied"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write16.phar b/ext/phar/tests/cache_list/files/write16.phar
new file mode 100644
index 0000000..05106ea
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write16.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write16.phar.inc b/ext/phar/tests/cache_list/files/write16.phar.inc
new file mode 100644
index 0000000..b7a1b38
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write16.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write16.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["test.txt"]));
+unset($p["test.txt"]);
+var_dump(isset($p["test.txt"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar['test2.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write17.phar b/ext/phar/tests/cache_list/files/write17.phar
new file mode 100644
index 0000000..52ddb5e
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write17.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write17.phar.inc b/ext/phar/tests/cache_list/files/write17.phar.inc
new file mode 100644
index 0000000..47f5ea3
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write17.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write17.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getMetadata());
+$p->setMetadata("hi");
+var_dump($p->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write18.phar b/ext/phar/tests/cache_list/files/write18.phar
new file mode 100644
index 0000000..3fc9fe1
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write18.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write18.phar.inc b/ext/phar/tests/cache_list/files/write18.phar.inc
new file mode 100644
index 0000000..fca867d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write18.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write18.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+echo decoct(fileperms("phar://" . __FILE__ . "/test.txt")),"\n";
+$p["test.txt"]->chmod(0444);
+echo decoct(fileperms("phar://" . __FILE__ . "/test.txt")),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->chmod(0666);
+?>
diff --git a/ext/phar/tests/cache_list/files/write19.phar b/ext/phar/tests/cache_list/files/write19.phar
new file mode 100644
index 0000000..9e8b7ee
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write19.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write19.phar.inc b/ext/phar/tests/cache_list/files/write19.phar.inc
new file mode 100644
index 0000000..55115ad
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write19.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write19.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->getMetadata());
+$p["test.txt"]->setMetadata("hi2");
+var_dump($p["test.txt"]->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->setMetadata("hi");
+?>
diff --git a/ext/phar/tests/cache_list/files/write2.phar b/ext/phar/tests/cache_list/files/write2.phar
new file mode 100644
index 0000000..0941025
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write2.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write2.phar.inc b/ext/phar/tests/cache_list/files/write2.phar.inc
new file mode 100644
index 0000000..7a4e2e3
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write2.phar.inc
@@ -0,0 +1,23 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write2.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+var_dump($phar->getMetadata());
+mkdir("phar://" . __FILE__ . "/test");
+var_dump(is_dir("phar://" . __FILE__ . "/test"));
+$phar2 = new Phar(__FILE__);
+var_dump($phar2->getMetadata());
+var_dump(isset($phar["test"]));
+var_dump(isset($phar2["test"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar->setMetadata('hi');
+$phar['test.txt'] = "hi
+";
+$phar['test.txt']->setMetadata('hi');
+?>
diff --git a/ext/phar/tests/cache_list/files/write20.phar b/ext/phar/tests/cache_list/files/write20.phar
new file mode 100644
index 0000000..6109264
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write20.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write20.phar.inc b/ext/phar/tests/cache_list/files/write20.phar.inc
new file mode 100644
index 0000000..d356bfb
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write20.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write20.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->getMetadata());
+$p["test.txt"]->delMetadata();
+var_dump($p["test.txt"]->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->setMetadata("hi");
+?>
diff --git a/ext/phar/tests/cache_list/files/write21.phar b/ext/phar/tests/cache_list/files/write21.phar
new file mode 100644
index 0000000..fad2165
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write21.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write21.phar.inc b/ext/phar/tests/cache_list/files/write21.phar.inc
new file mode 100644
index 0000000..79bfb20
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write21.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write21.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p["test.txt"]->compress(Phar::GZ);
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write22.phar b/ext/phar/tests/cache_list/files/write22.phar
new file mode 100644
index 0000000..c3c5ce1
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write22.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write22.phar.inc b/ext/phar/tests/cache_list/files/write22.phar.inc
new file mode 100644
index 0000000..861cabb
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write22.phar.inc
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write22.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p["test.txt"]->decompress();
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar['test.txt']->compress(Phar::GZ);
+?>
diff --git a/ext/phar/tests/cache_list/files/write23.phar b/ext/phar/tests/cache_list/files/write23.phar
new file mode 100644
index 0000000..2246f61
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write23.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write23.phar.inc b/ext/phar/tests/cache_list/files/write23.phar.inc
new file mode 100644
index 0000000..ac92a85
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write23.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write23.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["test.txt"]), isset($p["newname"]));
+rename("phar://" . __FILE__ . "/test.txt", "phar://" . __FILE__ . "/newname");
+var_dump(isset($p["test.txt"]), isset($p["newname"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write24.phar b/ext/phar/tests/cache_list/files/write24.phar
new file mode 100644
index 0000000..36972f3
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write24.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write24.phar.inc b/ext/phar/tests/cache_list/files/write24.phar.inc
new file mode 100644
index 0000000..216f7c4
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write24.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write24.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["newname"]));
+$fp = fopen("phar://" . __FILE__ . "/newname", "w");
+fwrite($fp, b"hi");
+fclose($fp);
+var_dump(isset($p["newname"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write25.phar b/ext/phar/tests/cache_list/files/write25.phar
new file mode 100644
index 0000000..93b301c
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write25.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write25.phar.inc b/ext/phar/tests/cache_list/files/write25.phar.inc
new file mode 100644
index 0000000..60a6978
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write25.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write25.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["mounted"]));
+Phar::mount("mounted", "phar://" . __FILE__ . "/test.txt");
+var_dump(isset($p["mounted"]));
+echo $p["mounted"]->getContent(),"\nok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write3.phar b/ext/phar/tests/cache_list/files/write3.phar
new file mode 100644
index 0000000..5ce4a95
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write3.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write3.phar.inc b/ext/phar/tests/cache_list/files/write3.phar.inc
new file mode 100644
index 0000000..686c065
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write3.phar.inc
@@ -0,0 +1,21 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write3.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+clearstatcache();
+var_dump(file_exists("phar://" . __FILE__ . "/test"), is_dir("phar://" . __FILE__ . "/test"));
+rmdir("phar://" . __FILE__ . "/test");
+clearstatcache();
+var_dump(file_exists("phar://" . __FILE__ . "/test"), is_dir("phar://" . __FILE__ . "/test"));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar->setMetadata('hi');
+$phar['test.txt'] = "hi
+";
+$phar['test.txt']->setMetadata('hi');
+$phar->addEmptyDir('test');
+?>
diff --git a/ext/phar/tests/cache_list/files/write4.phar b/ext/phar/tests/cache_list/files/write4.phar
new file mode 100644
index 0000000..c267bab
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write4.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write4.phar.inc b/ext/phar/tests/cache_list/files/write4.phar.inc
new file mode 100644
index 0000000..5b476ed
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write4.phar.inc
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write4.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+clearstatcache();
+Phar::mount("test.txt", "phar://" . __FILE__ . "/tobemounted");
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"), file_get_contents("phar://" . __FILE__ . "/test.txt"));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['tobemounted'] = "hi";
+?>
diff --git a/ext/phar/tests/cache_list/files/write5.phar b/ext/phar/tests/cache_list/files/write5.phar
new file mode 100644
index 0000000..52635b4
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write5.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write5.phar.inc b/ext/phar/tests/cache_list/files/write5.phar.inc
new file mode 100644
index 0000000..5e7b9bb
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write5.phar.inc
@@ -0,0 +1,29 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write5.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+$d = dirname(__FILE__) . "/copyonwrite5";
+mkdir($d);
+file_put_contents($d . "/file1", "file1\n");
+file_put_contents($d . "/file2", "file2\n");
+$arr = $phar->buildFromDirectory($d);
+ksort($arr);
+var_dump($arr);
+$phar2 = new Phar(__FILE__);
+$arr = array();
+foreach ($phar2 as $name => $file) {
+ $arr[$name] = $file->getContent();
+}
+ksort($arr);
+foreach ($arr as $name => $content) {
+ echo $name, " ", $content;
+}
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['hi'] = "hi\n";
+?>
diff --git a/ext/phar/tests/cache_list/files/write6.phar b/ext/phar/tests/cache_list/files/write6.phar
new file mode 100644
index 0000000..e3e4341
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write6.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write6.phar.inc b/ext/phar/tests/cache_list/files/write6.phar.inc
new file mode 100644
index 0000000..3ba5db3
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write6.phar.inc
@@ -0,0 +1,30 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write6.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+$d = dirname(__FILE__) . "/copyonwrite6";
+mkdir($d);
+file_put_contents($d . "/file1", "file1\n");
+file_put_contents($d . "/file2", "file2\n");
+$arr = $phar->buildFromIterator(new RecursiveDirectoryIterator($d, RecursiveDirectoryIterator::SKIP_DOTS),$d);
+$arr = $phar->buildFromDirectory($d);
+ksort($arr);
+var_dump($arr);
+$phar2 = new Phar(__FILE__);
+$arr = array();
+foreach ($phar2 as $name => $file) {
+ $arr[$name] = $file->getContent();
+}
+ksort($arr);
+foreach ($arr as $name => $content) {
+ echo $name, " ", $content;
+}
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['hi'] = "hi\n";
+?>
diff --git a/ext/phar/tests/cache_list/files/write7.phar b/ext/phar/tests/cache_list/files/write7.phar
new file mode 100644
index 0000000..e5854ec
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write7.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write7.phar.inc b/ext/phar/tests/cache_list/files/write7.phar.inc
new file mode 100644
index 0000000..ef5b8b2
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write7.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write7.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+$p->delete("test.txt");
+clearstatcache();
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>
diff --git a/ext/phar/tests/cache_list/files/write8.phar b/ext/phar/tests/cache_list/files/write8.phar
new file mode 100644
index 0000000..d5d63be
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write8.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write8.phar.inc b/ext/phar/tests/cache_list/files/write8.phar.inc
new file mode 100644
index 0000000..2b733a7
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write8.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write8.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getAlias());
+$p2 = new Phar(__FILE__);
+$p->setAlias("hi");
+echo $p2->getAlias(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>
diff --git a/ext/phar/tests/cache_list/files/write9.phar b/ext/phar/tests/cache_list/files/write9.phar
new file mode 100644
index 0000000..c012c17
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write9.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write9.phar.inc b/ext/phar/tests/cache_list/files/write9.phar.inc
new file mode 100644
index 0000000..ed3e681
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/write9.phar.inc
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write9.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setStub("<?php __HALT"."_COMPILER();");
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>
diff --git a/ext/phar/tests/cache_list/files/zfapp.tgz b/ext/phar/tests/cache_list/files/zfapp.tgz
new file mode 100644
index 0000000..fcaec86
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/zfapp.tgz
Binary files differ
diff --git a/ext/phar/tests/cache_list/frontcontroller1.phpt b/ext/phar/tests/cache_list/frontcontroller1.phpt
new file mode 100644
index 0000000..d0d5552
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller1.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller other
+--INI--
+phar.cache_list={PWD}/frontcontroller1.php [cache_list]
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller1.php
+REQUEST_URI=/frontcontroller1.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: image/jpeg
+Content-length: 3
+--EXPECT--
+hio
diff --git a/ext/phar/tests/cache_list/frontcontroller10.phpt b/ext/phar/tests/cache_list/frontcontroller10.phpt
new file mode 100644
index 0000000..00177d4
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller10.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar front controller rewrite access denied [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller10.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller10.php
+REQUEST_URI=/frontcontroller10.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller4.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+Status: 403 Access Denied
+--EXPECT--
+<html>
+ <head>
+ <title>Access Denied</title>
+ </head>
+ <body>
+ <h1>403 - File /hi Access Denied</h1>
+ </body>
+</html>
diff --git a/ext/phar/tests/cache_list/frontcontroller11.phpt b/ext/phar/tests/cache_list/frontcontroller11.phpt
new file mode 100644
index 0000000..25b147e
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller11.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar front controller mime type extension is not a string [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller11.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller11.php
+REQUEST_URI=/frontcontroller11.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller5.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.php:2
+Stack trace:
+#0 %sfrontcontroller11.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller11.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller12.phpt b/ext/phar/tests/cache_list/frontcontroller12.phpt
new file mode 100644
index 0000000..cfc7d0e
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller12.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type unknown int [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller12.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller12.php
+REQUEST_URI=/frontcontroller12.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller6.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.php:2
+Stack trace:
+#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller12.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller13.phpt b/ext/phar/tests/cache_list/frontcontroller13.phpt
new file mode 100644
index 0000000..e6c9dee
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller13.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type not string/int [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller13.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller13.php
+REQUEST_URI=/frontcontroller13.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller7.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.php:2
+Stack trace:
+#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller13.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller14.phpt b/ext/phar/tests/cache_list/frontcontroller14.phpt
new file mode 100644
index 0000000..bbd9637
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller14.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller mime type override, other [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller14.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller14.php
+REQUEST_URI=/frontcontroller14.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: foo/bar
+Content-length: 4
+--EXPECT--
+hio2
diff --git a/ext/phar/tests/cache_list/frontcontroller15.phpt b/ext/phar/tests/cache_list/frontcontroller15.phpt
new file mode 100644
index 0000000..d142a5d
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller15.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type override, Phar::PHPS [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller15.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller15.php
+REQUEST_URI=/frontcontroller15.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
+
diff --git a/ext/phar/tests/cache_list/frontcontroller16.phpt b/ext/phar/tests/cache_list/frontcontroller16.phpt
new file mode 100644
index 0000000..10bebdc
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller16.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller mime type override, Phar::PHP [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller16.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller16.php
+REQUEST_URI=/frontcontroller16.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio1
+
diff --git a/ext/phar/tests/cache_list/frontcontroller17.phpt b/ext/phar/tests/cache_list/frontcontroller17.phpt
new file mode 100644
index 0000000..35d3ae4
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller17.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller mime type unknown [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller17.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller17.php
+REQUEST_URI=/frontcontroller17.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+Content-length: 4
+--EXPECT--
+hio3
+
diff --git a/ext/phar/tests/cache_list/frontcontroller18.phpt b/ext/phar/tests/cache_list/frontcontroller18.phpt
new file mode 100644
index 0000000..5e94bf6
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller18.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller $_SERVER munging failure [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller18.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller18.php
+REQUEST_URI=/frontcontroller18.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller9.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.php:2
+Stack trace:
+#0 %sfrontcontroller18.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller18.php on line 2
diff --git a/ext/phar/tests/cache_list/frontcontroller19.phpt b/ext/phar/tests/cache_list/frontcontroller19.phpt
new file mode 100644
index 0000000..bed0b1d
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller19.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller $_SERVER munging failure 2 [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller19.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller19.php
+REQUEST_URI=/frontcontroller19.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller10.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.php:2
+Stack trace:
+#0 %sfrontcontroller19.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller19.php on line 2
diff --git a/ext/phar/tests/cache_list/frontcontroller2.phpt b/ext/phar/tests/cache_list/frontcontroller2.phpt
new file mode 100644
index 0000000..67ccfc1
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller2.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller PHP test [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list=frontcontroller2.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller2.php
+REQUEST_URI=/frontcontroller2.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio
diff --git a/ext/phar/tests/cache_list/frontcontroller20.phpt b/ext/phar/tests/cache_list/frontcontroller20.phpt
new file mode 100644
index 0000000..bf333c7
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller20.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller $_SERVER munging failure 3 [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller20.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller20.php
+REQUEST_URI=/frontcontroller20.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller11.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.php:2
+Stack trace:
+#0 %sfrontcontroller20.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller20.php on line 2
diff --git a/ext/phar/tests/cache_list/frontcontroller21.phpt b/ext/phar/tests/cache_list/frontcontroller21.phpt
new file mode 100644
index 0000000..829f298
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller21.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar front controller $_SERVER munging success [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller21.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller21.php
+REQUEST_URI=/frontcontroller21.php/index.php?test=hi
+PATH_INFO=/index.php
+QUERY_STRING=test=hi
+--FILE_EXTERNAL--
+files/frontcontroller12.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%unicode|string%(10) "/index.php"
+string(10) "/index.php"
+string(%d) "phar://%sfrontcontroller21.php/index.php"
+string(18) "/index.php?test=hi"
+string(32) "/frontcontroller21.php/index.php"
+string(22) "/frontcontroller21.php"
+string(%d) "%sfrontcontroller21.php"
+string(40) "/frontcontroller21.php/index.php?test=hi" \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller22.phpt b/ext/phar/tests/cache_list/frontcontroller22.phpt
new file mode 100644
index 0000000..2769b01
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller22.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar front controller include from cwd test 1 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller22.phpt
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller22.php
+REQUEST_URI=/frontcontroller22.php/index.php
+PATH_INFO=/index.php
+--FILE_EXTERNAL--
+files/frontcontroller13.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%string|unicode%(4) "test"
+%string|unicode%(12) "oof/test.php"
+
+Warning: include(./hi.php): failed to open stream: No such file or directory in phar://%s/oof/test.php on line %d
+
+Warning: include(): Failed opening './hi.php' for inclusion (include_path='%s') in phar://%soof/test.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller23.phpt b/ext/phar/tests/cache_list/frontcontroller23.phpt
new file mode 100644
index 0000000..3da9631
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller23.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller with generic action router test [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller23.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller23.php
+REQUEST_URI=/frontcontroller23.php/hi/there
+PATH_INFO=/hi/there
+--FILE_EXTERNAL--
+files/frontcontroller14.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+string(9) "/hi/there"
+string(%d) "phar://%sfrontcontroller23.php/html/index.php" \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller24.phpt b/ext/phar/tests/cache_list/frontcontroller24.phpt
new file mode 100644
index 0000000..561826b
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller24.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with custom 404 php script [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller24.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller24.php
+REQUEST_URI=/frontcontroller24.php/unknown/file
+PATH_INFO=/unknown/file
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+My 404 is rawesome \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller25.phpt b/ext/phar/tests/cache_list/frontcontroller25.phpt
new file mode 100644
index 0000000..a877939
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller25.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller with extra path_info [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller25.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller25.php
+REQUEST_URI=/frontcontroller25.php/a1.phps/extra/stuff
+PATH_INFO=/a1.phps/extra/stuff
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+string(42) "/frontcontroller25.php/a1.phps/extra/stuff"
+string(12) "/extra/stuff" \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller26.phpt b/ext/phar/tests/cache_list/frontcontroller26.phpt
new file mode 100644
index 0000000..86a1c14
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller26.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with unknown extension mime type [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller26.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller26.php
+REQUEST_URI=/frontcontroller26.php/unknown.ext
+PATH_INFO=/unknown.ext
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+--EXPECTF--
+<?php var_dump("hi"); \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller27.phpt b/ext/phar/tests/cache_list/frontcontroller27.phpt
new file mode 100644
index 0000000..4a76e02
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller27.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with no extension [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller27.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller27.php
+REQUEST_URI=/frontcontroller27.php/noext
+PATH_INFO=/noext
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/plain;charset=UTF-8
+--EXPECTF--
+hi \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller28.phpt b/ext/phar/tests/cache_list/frontcontroller28.phpt
new file mode 100644
index 0000000..80059a9
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller28.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with huge file [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller28.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller28.php
+REQUEST_URI=/frontcontroller28.php/bigfile.txt
+PATH_INFO=/bigfile.txt
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/plain;charset=UTF-8
+--EXPECT--
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
diff --git a/ext/phar/tests/cache_list/frontcontroller29.phpt b/ext/phar/tests/cache_list/frontcontroller29.phpt
new file mode 100644
index 0000000..1cd8f96
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller29.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with fatal error in php file [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller29.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller29.php
+REQUEST_URI=/frontcontroller29.php/fatalerror.phps
+PATH_INFO=/fatalerror.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps on line 1 \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller3.phpt b/ext/phar/tests/cache_list/frontcontroller3.phpt
new file mode 100644
index 0000000..1c1b479
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller3.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller phps [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller3.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller3.php
+REQUEST_URI=/frontcontroller3.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
diff --git a/ext/phar/tests/cache_list/frontcontroller30.phpt b/ext/phar/tests/cache_list/frontcontroller30.phpt
new file mode 100644
index 0000000..5a63da8
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller30.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller with weird SCRIPT_NAME [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller30.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/huh?
+REQUEST_URI=/huh?
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTF--
+oops did not run
+%a \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller31.phpt b/ext/phar/tests/cache_list/frontcontroller31.phpt
new file mode 100644
index 0000000..9ef1221
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller31.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with invalid callback for rewrites [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller31.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller31.php
+REQUEST_URI=/frontcontroller31.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller16.phar
+--EXPECT--
+phar error: invalid rewrite callback \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller32.phpt b/ext/phar/tests/cache_list/frontcontroller32.phpt
new file mode 100644
index 0000000..5911690
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller32.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with valid callback that is not good [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller32.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller32.php
+REQUEST_URI=/frontcontroller32.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller17.phar
+--EXPECTF--
+%ahar error: failed to call rewrite callback \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller33.phpt b/ext/phar/tests/cache_list/frontcontroller33.phpt
new file mode 100644
index 0000000..9573854
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller33.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with valid callback that does not return any value [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller33.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller33.php
+REQUEST_URI=/frontcontroller33.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller18.phar
+--EXPECTF--
+phar error: rewrite callback must return a string or false \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller34.phpt b/ext/phar/tests/cache_list/frontcontroller34.phpt
new file mode 100644
index 0000000..83c22f5
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller34.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller with cwd [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller34.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller34.php
+REQUEST_URI=/frontcontroller34.php/start/index.php
+PATH_INFO=/start/index.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller19.phar
+--EXPECT--
+start/index.php
+start/another.php
+another.php
diff --git a/ext/phar/tests/cache_list/frontcontroller4.phpt b/ext/phar/tests/cache_list/frontcontroller4.phpt
new file mode 100644
index 0000000..5cf3682
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller4.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller index.php relocate (no /) [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller4.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller4.php
+REQUEST_URI=/frontcontroller4.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller4.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/cache_list/frontcontroller5.phpt b/ext/phar/tests/cache_list/frontcontroller5.phpt
new file mode 100644
index 0000000..2c738d7
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller5.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller index.php relocate [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller5.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller5.php
+REQUEST_URI=/frontcontroller5.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller5.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/cache_list/frontcontroller6.phpt b/ext/phar/tests/cache_list/frontcontroller6.phpt
new file mode 100644
index 0000000..2480be4
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller6.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar front controller 404 [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller6.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller6.php
+REQUEST_URI=/frontcontroller6.php/notfound.php
+PATH_INFO=/notfound.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /notfound.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller7.phpt b/ext/phar/tests/cache_list/frontcontroller7.phpt
new file mode 100644
index 0000000..a8a88a9
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller7.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller alternate index file [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller7.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller7.php
+REQUEST_URI=/frontcontroller7.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller2.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller7.php/a.php
+--EXPECT--
diff --git a/ext/phar/tests/cache_list/frontcontroller8.phpt b/ext/phar/tests/cache_list/frontcontroller8.phpt
new file mode 100644
index 0000000..bf9b390
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller8.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar front controller no index file 404 [cache_list]
+--INI--
+phar.cache_list={PWD}/frontcontroller8.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller8.php
+REQUEST_URI=/frontcontroller8.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller3.phar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /index.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/frontcontroller9.phpt b/ext/phar/tests/cache_list/frontcontroller9.phpt
new file mode 100644
index 0000000..1a8b916
--- /dev/null
+++ b/ext/phar/tests/cache_list/frontcontroller9.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller rewrite array [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/frontcontroller9.php
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller9.php
+REQUEST_URI=/frontcontroller9.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller3.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code> \ No newline at end of file
diff --git a/ext/phar/tests/cached_manifest_1.phpt b/ext/phar/tests/cached_manifest_1.phpt
new file mode 100644
index 0000000..af58523
--- /dev/null
+++ b/ext/phar/tests/cached_manifest_1.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar: phar.cache_list basic read test
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.cache_list={PWD}/files/nophar.phar
+--FILE--
+<?php
+$pname = 'phar://' . dirname(__FILE__) . '/files/nophar.phar';
+var_dump(file_get_contents($pname . '/b/c.php'));
+$a = opendir($pname);
+while (false !== ($b = readdir($a))) {
+var_dump($b);
+}
+foreach (new RecursiveIteratorIterator(new Phar($pname)) as $f) {
+ var_dump($f->getPathName());
+}
+var_dump(is_dir($pname . '/b'));
+var_dump(is_dir($pname . '/d'));
+var_dump(is_dir($pname . '/b/c.php'));
+?>
+===DONE===
+--EXPECTF--
+string(131) "<?php echo "in b\n";$a = fopen("index.php", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";"
+string(1) "b"
+string(1) "d"
+string(9) "index.php"
+string(7) "web.php"
+string(%d) "phar://%snophar.phar/b%cc.php"
+string(%d) "phar://%snophar.phar%cd"
+string(%d) "phar://%snophar.phar%cindex.php"
+string(%d) "phar://%snophar.phar%cweb.php"
+bool(true)
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/cached_manifest_1U.phpt b/ext/phar/tests/cached_manifest_1U.phpt
new file mode 100644
index 0000000..df77f07
--- /dev/null
+++ b/ext/phar/tests/cached_manifest_1U.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar: phar.cache_list basic read test
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.cache_list={PWD}/files/nophar.phar
+--FILE--
+<?php
+$pname = 'phar://' . dirname(__FILE__) . '/files/nophar.phar';
+var_dump(file_get_contents($pname . '/b/c.php'));
+$a = opendir($pname);
+while (false !== ($b = readdir($a))) {
+var_dump($b);
+}
+foreach (new RecursiveIteratorIterator(new Phar($pname)) as $f) {
+ var_dump($f->getPathName());
+}
+var_dump(is_dir($pname . '/b'));
+var_dump(is_dir($pname . '/d'));
+var_dump(is_dir($pname . '/b/c.php'));
+?>
+===DONE===
+--EXPECTF--
+string(131) "<?php echo "in b\n";$a = fopen("index.php", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";"
+unicode(1) "b"
+unicode(1) "d"
+unicode(9) "index.php"
+unicode(7) "web.php"
+string(%d) "phar://%snophar.phar/b%cc.php"
+string(%d) "phar://%snophar.phar%cd"
+string(%d) "phar://%snophar.phar%cindex.php"
+string(%d) "phar://%snophar.phar%cweb.php"
+bool(true)
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt
new file mode 100644
index 0000000..d6c469d
--- /dev/null
+++ b/ext/phar/tests/create_new_and_modify.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Phar: create and modify phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+@unlink($fname);
+
+file_put_contents($pname . '/a.php', "brand new!\n");
+
+$phar = new Phar($fname);
+$sig1 = $phar->getSignature();
+
+include $pname . '/a.php';
+
+file_put_contents($pname .'/a.php', "modified!\n");
+file_put_contents($pname .'/b.php', "another!\n");
+
+$phar = new Phar($fname);
+$sig2 = $phar->getSignature();
+
+var_dump($sig1[b'hash']);
+var_dump($sig2[b'hash']);
+var_dump($sig1[b'hash'] != $sig2[b'hash']);
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+brand new!
+string(40) "%s"
+string(40) "%s"
+bool(true)
+modified!
+another!
+===DONE===
diff --git a/ext/phar/tests/create_new_phar.phpt b/ext/phar/tests/create_new_phar.phpt
new file mode 100644
index 0000000..ec57c27
--- /dev/null
+++ b/ext/phar/tests/create_new_phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar: create a completely new phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
+ 'brand new!');
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+brand new!
+===DONE===
diff --git a/ext/phar/tests/create_new_phar_b.phpt b/ext/phar/tests/create_new_phar_b.phpt
new file mode 100644
index 0000000..39fc31e
--- /dev/null
+++ b/ext/phar/tests/create_new_phar_b.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Phar: create a completely new phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+
+file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
+ 'brand new!');
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: file_put_contents(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %screate_new_phar_b.php on line %d
+
+Warning: include(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: %s in %screate_new_phar_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%screate_new_phar_b.phar.php/a.php' for inclusion (include_path='%s') in %screate_new_phar_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/create_new_phar_c.phpt b/ext/phar/tests/create_new_phar_c.phpt
new file mode 100644
index 0000000..6beaa2e
--- /dev/null
+++ b/ext/phar/tests/create_new_phar_c.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: create a completely new phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
+ 'brand new!');
+
+$phar = new Phar(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
+
+var_dump($phar->getSignature());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(40) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+===DONE===
diff --git a/ext/phar/tests/create_path_error.phpt b/ext/phar/tests/create_path_error.phpt
new file mode 100644
index 0000000..d3fc035
--- /dev/null
+++ b/ext/phar/tests/create_path_error.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar: create with illegal path
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+@unlink($fname);
+
+file_put_contents($pname . '/a.php?', "query");
+file_put_contents($pname . '/b.php?bla', "query");
+
+var_dump(file_get_contents($pname . '/a.php'));
+var_dump(file_get_contents($pname . '/b.php'));
+
+function error_handler($errno, $errmsg)
+{
+ echo "Error: $errmsg\n";
+}
+
+set_error_handler('error_handler');
+
+$checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php');
+foreach($checks as $check)
+{
+ file_put_contents($pname . '/' . $check, "error");
+}
+
+$phar = new Phar($fname);
+$checks = array("a\0");
+foreach($checks as $check)
+{
+ try
+ {
+ $phar[$check] = 'error';
+ }
+ catch(Exception $e)
+ {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+ }
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+string(5) "query"
+string(5) "query"
+Error: file_put_contents(phar://%s//): failed to open stream: phar error: file "" in phar "%s" cannot be empty
+Error: file_put_contents(phar://%s/.): failed to open stream: phar error: file "" in phar "%s" cannot be empty
+Error: file_put_contents(phar://%s/../): failed to open stream: phar error: file "" in phar "%s" cannot be empty
+Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: file "" in phar "%s" cannot be empty
+Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character
+===DONE===
diff --git a/ext/phar/tests/delete.phpt b/ext/phar/tests/delete.phpt
new file mode 100644
index 0000000..1d98509
--- /dev/null
+++ b/ext/phar/tests/delete.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar: delete test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+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';
+include 'files/phar_test.inc';
+include $fname;
+$phar = new Phar($fname);
+
+echo file_get_contents($pname . '/a') . "\n";
+$phar->delete('a');
+echo file_get_contents($pname . '/a') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+a
+
+Warning: file_get_contents(phar://%sdelete.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.php" in %sdelete.php on line 16 \ No newline at end of file
diff --git a/ext/phar/tests/delete_in_phar.phpt b/ext/phar/tests/delete_in_phar.phpt
new file mode 100644
index 0000000..4842d27
--- /dev/null
+++ b/ext/phar/tests/delete_in_phar.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Phar: delete a file within a .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+unlink($pname . '/b/c.php');
+?>
+===AFTER===
+<?php
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.php" in %sdelete_in_phar.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
+
+===DONE===
+ \ No newline at end of file
diff --git a/ext/phar/tests/delete_in_phar_b.phpt b/ext/phar/tests/delete_in_phar_b.phpt
new file mode 100644
index 0000000..a6d5b3a
--- /dev/null
+++ b/ext/phar/tests/delete_in_phar_b.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: delete a file within a .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+unlink($pname . '/b/c.php');
+?>
+===AFTER===
+<?php
+include $pname . '/a.php';
+include $pname . '/b.php';
+include $pname . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+
+Warning: unlink(): phar error: write operations disabled by the php.ini setting phar.readonly in %sdelete_in_phar_b.php on line %d
+===AFTER===
+This is a
+This is b
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/delete_in_phar_confirm.phpt b/ext/phar/tests/delete_in_phar_confirm.phpt
new file mode 100644
index 0000000..13a8d0d
--- /dev/null
+++ b/ext/phar/tests/delete_in_phar_confirm.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar: delete a file within a .phar (confirm disk file is changed)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+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($fname);
+if ($md5 == $md52) echo 'file was not modified';
+?>
+===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';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar_confirm.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.php" in %sdelete_in_phar_confirm.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/dir.phpt b/ext/phar/tests/dir.phpt
new file mode 100644
index 0000000..a8f9d3f
--- /dev/null
+++ b/ext/phar/tests/dir.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Phar: mkdir/rmdir test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$pname2 = 'phar://' . $fname2;
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$pname3 = 'phar://' . $fname3;
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::PHAR));
+
+$phar->addEmptyDir('test');
+var_dump($phar['test']->isDir());
+var_dump($phar['test/']->isDir());
+copy($fname, $fname2);
+mkdir($pname . '/another/dir/');
+var_dump($phar['another/dir']->isDir());
+rmdir($pname . '/another/dir/');
+copy($fname, $fname3);
+clearstatcache();
+var_dump(file_exists($pname . '/another/dir/'));
+var_dump(file_exists($pname2 . '/test/'));
+var_dump(file_exists($pname3 . '/another/dir/'));
+ini_set('phar.readonly', 1);
+mkdir($pname . '/fails');
+ini_set('phar.readonly', 0);
+// create new phar by mkdir
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
+file_put_contents('phar://' . dirname(__FILE__) . '/ok.phar/sub/directory.txt', 'hi');
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/sub');
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/sub/directory.txt');
+file_put_contents(dirname(__FILE__) . '/oops.phar', '<?php this should screw em up __HALT_COMPILER();');
+mkdir('phar://' . dirname(__FILE__) . '/oops.phar/fails');
+
+mkdir('phar://');
+rmdir('phar://');
+rmdir('phar://' . dirname(__FILE__) . '/unknown.phar/hi');
+ini_set('phar.readonly', 1);
+rmdir($pname . '/another/dir');
+ini_set('phar.readonly', 0);
+rmdir($pname);
+rmdir($pname . '/');
+mkdir($pname . '/');
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/ok.phar'); ?>
+<?php unlink(dirname(__FILE__) . '/oops.phar'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+
+Warning: mkdir(): phar error: cannot create directory "phar://%sdir.phar.php/fails", write operations disabled in %sdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "fails" in phar "%sok.phar", directory already exists in %sdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "sub" in phar "%sok.phar", directory already exists in %sdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "sub/directory.txt" in phar "%sok.phar", phar error: path "sub/directory.txt" exists and is a not a directory in %sdir.php on line %d
+
+Warning: mkdir(): internal corruption of phar "%soops.phar" (truncated manifest at stub end) in %sdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "phar://", no phar archive specified in %sdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "phar://", no phar archive specified, or phar archive does not exist in %sdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "hi" in phar "%sunknown.phar", directory does not exist in %sdir.php on line %d
+
+Warning: rmdir(): phar error: cannot rmdir directory "phar://%sdir.phar.php/another/dir", write operations disabled in %sdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "" in phar "%sdir.phar.php", directory does not exist in %sdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "" in phar "%sdir.phar.php", directory does not exist in %sdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "" in phar "%sdir.phar.php", phar error: invalid path "" must not be empty in %sdir.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/fatal_error_webphar.phpt b/ext/phar/tests/fatal_error_webphar.phpt
new file mode 100644
index 0000000..dd6e096
--- /dev/null
+++ b/ext/phar/tests/fatal_error_webphar.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar web-based phar with fatal error
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/fatal_error_webphar.php
+REQUEST_URI=/fatal_error_webphar.php/index.php
+PATH_INFO=/index.php
+--FILE_EXTERNAL--
+files/pear2coverage.phar.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+string(9) "\Web\View"
+
+Parse error: syntax error, unexpected %s, expecting %s in phar://%r([A-Za-z]:)?%r/%sfatal_error_webphar.php/Web/View.php on line 380
diff --git a/ext/phar/tests/fgc_edgecases.phpt b/ext/phar/tests/fgc_edgecases.phpt
new file mode 100644
index 0000000..2699834
--- /dev/null
+++ b/ext/phar/tests/fgc_edgecases.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Phar: test edge cases of file_get_contents() function interception
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+Phar::interceptFileFuncs();
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+file_get_contents(array());
+chdir(dirname(__FILE__));
+file_put_contents($fname, "blah\n");
+file_put_contents("foob", "test\n");
+echo file_get_contents($fname);
+unlink($fname);
+mkdir($pname . '/oops');
+
+file_put_contents($pname . '/foo/hi', '<?php
+echo file_get_contents("foo/" . basename(__FILE__));
+$context = stream_context_create();
+file_get_contents("./hi", 0, $context, 0, -1);
+echo file_get_contents("foob");
+set_include_path("' . addslashes(dirname(__FILE__)) . '");
+echo file_get_contents("foob", true);
+echo file_get_contents("./hi", 0, $context);
+echo file_get_contents("../oops");
+echo file_get_contents("./hi", 0, $context, 50000);
+echo file_get_contents("./hi");
+echo file_get_contents("./hi", 0, $context, 0, 0);
+?>
+');
+
+include $pname . '/foo/hi';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+Warning: file_get_contents() expects parameter 1 to be a valid path, array given in %sfgc_edgecases.php on line %d
+blah
+<?php
+echo file_get_contents("foo/" . basename(__FILE__));
+$context = stream_context_create();
+file_get_contents("./hi", 0, $context, 0, -1);
+echo file_get_contents("foob");
+set_include_path("%stests");
+echo file_get_contents("foob", true);
+echo file_get_contents("./hi", 0, $context);
+echo file_get_contents("../oops");
+echo file_get_contents("./hi", 0, $context, 50000);
+echo file_get_contents("./hi");
+echo file_get_contents("./hi", 0, $context, 0, 0);
+?>
+
+Warning: file_get_contents(): length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
+test
+test
+<?php
+echo file_get_contents("foo/" . basename(__FILE__));
+$context = stream_context_create();
+file_get_contents("./hi", 0, $context, 0, -1);
+echo file_get_contents("foob");
+set_include_path("%stests");
+echo file_get_contents("foob", true);
+echo file_get_contents("./hi", 0, $context);
+echo file_get_contents("../oops");
+echo file_get_contents("./hi", 0, $context, 50000);
+echo file_get_contents("./hi");
+echo file_get_contents("./hi", 0, $context, 0, 0);
+?>
+
+Warning: file_get_contents(phar://%sfgc_edgecases.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
+
+Warning: file_get_contents(): Failed to seek to position 50000 in the stream in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
+<?php
+echo file_get_contents("foo/" . basename(__FILE__));
+$context = stream_context_create();
+file_get_contents("./hi", 0, $context, 0, -1);
+echo file_get_contents("foob");
+set_include_path("%stests");
+echo file_get_contents("foob", true);
+echo file_get_contents("./hi", 0, $context);
+echo file_get_contents("../oops");
+echo file_get_contents("./hi", 0, $context, 50000);
+echo file_get_contents("./hi");
+echo file_get_contents("./hi", 0, $context, 0, 0);
+?>
+===DONE===
diff --git a/ext/phar/tests/file_get_contents.phpt b/ext/phar/tests/file_get_contents.phpt
new file mode 100644
index 0000000..fcc9d64
--- /dev/null
+++ b/ext/phar/tests/file_get_contents.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar: test file_get_contents() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+echo file_get_contents("dir/file1.txt");
+echo file_get_contents("file1.txt", true);
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+Phar::interceptFileFuncs();
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+hihi===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/files/blog.phar b/ext/phar/tests/files/blog.phar
new file mode 100644
index 0000000..fd8890d
--- /dev/null
+++ b/ext/phar/tests/files/blog.phar
Binary files differ
diff --git a/ext/phar/tests/files/blog.phar.inc b/ext/phar/tests/files/blog.phar.inc
new file mode 100644
index 0000000..c2599ab
--- /dev/null
+++ b/ext/phar/tests/files/blog.phar.inc
@@ -0,0 +1,22 @@
+<?php
+
+$fname = dirname(__FILE__) . '/blog.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+Phar::interceptFileFuncs();
+if(file_exists(dirname(__FILE__) . "/files/config.xml")) {
+ Phar::mount("config.xml", dirname(__FILE__) . "/files/config.xml");
+}
+Phar::webPhar("blog", "index.php");
+__HALT_COMPILER(); ?>');
+$phar['index.php'] = '<?php if (!file_exists("config.xml")) {
+ include "install.php";
+ exit;
+}
+var_dump(str_replace("\r\n", "\n", file_get_contents("config.xml")));
+?>';
+$phar['install.php'] = '<?php echo "install\n"; ?>';
+
+?>
diff --git a/ext/phar/tests/files/config.xml b/ext/phar/tests/files/config.xml
new file mode 100644
index 0000000..cf0dbc5
--- /dev/null
+++ b/ext/phar/tests/files/config.xml
@@ -0,0 +1,9 @@
+<xml version="1.0" encoding="UTF-8">
+<config>
+ <database>
+ <host>localhost</name>
+ <user>squirrel</user>
+ <pass>nuts</pass>
+ <db>hoard</db>
+ </database>
+</config>
diff --git a/ext/phar/tests/files/extracted.inc b/ext/phar/tests/files/extracted.inc
new file mode 100644
index 0000000..a6e5224
--- /dev/null
+++ b/ext/phar/tests/files/extracted.inc
@@ -0,0 +1 @@
+<?php var_dump(__FILE__); ?>
diff --git a/ext/phar/tests/files/frontcontroller.phar b/ext/phar/tests/files/frontcontroller.phar
new file mode 100644
index 0000000..626bf48
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller.phar.inc b/ext/phar/tests/files/frontcontroller.phar.inc
new file mode 100644
index 0000000..80d42e8
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a['index.php'] = 'here is my index';
+$a->setStub('<?php
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller10.phar b/ext/phar/tests/files/frontcontroller10.phar
new file mode 100644
index 0000000..078ce75
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller10.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller10.phar.inc b/ext/phar/tests/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000..4c139db
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller11.phar b/ext/phar/tests/files/frontcontroller11.phar
new file mode 100644
index 0000000..61ea843
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller11.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller11.phar.inc b/ext/phar/tests/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000..0863508
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller12.phar b/ext/phar/tests/files/frontcontroller12.phar
new file mode 100644
index 0000000..315c290
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller12.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller12.phar.inc b/ext/phar/tests/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000..f1e4645
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller13.phar b/ext/phar/tests/files/frontcontroller13.phar
new file mode 100644
index 0000000..750ff27
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller13.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller13.phar.inc b/ext/phar/tests/files/frontcontroller13.phar.inc
new file mode 100644
index 0000000..0bfef46
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller13.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller13.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller13.phar');
+$a['index.php'] = '<?php
+var_dump("test");
+include "oof/test.php";';
+$a['oof/test.php'] = '<?php
+var_dump("oof/test.php");
+include "./hi.php";';
+$a['oof/hi.php'] = '<?php
+var_dump("hi");';
+$a->setStub('<?php
+Phar::webPhar();
+__HALT_COMPILER();'); \ No newline at end of file
diff --git a/ext/phar/tests/files/frontcontroller14.phar b/ext/phar/tests/files/frontcontroller14.phar
new file mode 100644
index 0000000..2bca006
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller14.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller14.phar.inc b/ext/phar/tests/files/frontcontroller14.phar.inc
new file mode 100644
index 0000000..23104a6
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller14.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller14.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller14.phar');
+$a['html/index.php'] = '<?php
+var_dump($_SERVER[b"PATH_INFO"]);
+var_dump($_SERVER[b"PATH_TRANSLATED"]);
+';
+$a->setStub('<?php
+function s($a)
+{
+ return "/html/index.php";
+}
+Phar::interceptFileFuncs();
+Phar::mungServer(array("PHP_SELF", "REQUEST_URI"));
+Phar::webPhar("whatever", "/html/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller16.phar b/ext/phar/tests/files/frontcontroller16.phar
new file mode 100644
index 0000000..cce5db5
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller16.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller16.phar.inc b/ext/phar/tests/files/frontcontroller16.phar.inc
new file mode 100644
index 0000000..3c9986d
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller16.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller16.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller16.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here"));
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller17.phar b/ext/phar/tests/files/frontcontroller17.phar
new file mode 100644
index 0000000..b83d41f
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller17.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller17.phar.inc b/ext/phar/tests/files/frontcontroller17.phar.inc
new file mode 100644
index 0000000..85b8729
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller17.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller17.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller17.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "sort");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller18.phar b/ext/phar/tests/files/frontcontroller18.phar
new file mode 100644
index 0000000..c447f39
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller18.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller18.phar.inc b/ext/phar/tests/files/frontcontroller18.phar.inc
new file mode 100644
index 0000000..847a713
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller18.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller18.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller18.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+function s($a)
+{
+}
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "s");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller19.phar b/ext/phar/tests/files/frontcontroller19.phar
new file mode 100644
index 0000000..bdf8ee1
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller19.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller19.phar.inc b/ext/phar/tests/files/frontcontroller19.phar.inc
new file mode 100644
index 0000000..ba84ac4
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller19.phar.inc
@@ -0,0 +1,25 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller19.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller19.phar');
+$a['start/index.php'] = '<?php
+echo "start/index.php\n";
+include "./another.php";
+';
+$a['start/another.php'] = '<?php
+echo "start/another.php\n";
+include "../another.php";
+?>';
+$a['another.php'] = '<?php
+echo "another.php\n";
+?>';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+try {
+Phar::webPhar("test.phar", "/start/index.php");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller2.phar b/ext/phar/tests/files/frontcontroller2.phar
new file mode 100644
index 0000000..0dd0e7f
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller2.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller2.phar.inc b/ext/phar/tests/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000..653c796
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "a.php");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller3.phar b/ext/phar/tests/files/frontcontroller3.phar
new file mode 100644
index 0000000..5c5ff9c
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller3.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller3.phar.inc b/ext/phar/tests/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000..c209594
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => b"a.phps");
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller4.phar b/ext/phar/tests/files/frontcontroller4.phar
new file mode 100644
index 0000000..004d1ff
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller4.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller4.phar.inc b/ext/phar/tests/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000..daf807e
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => false);
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller5.phar b/ext/phar/tests/files/frontcontroller5.phar
new file mode 100644
index 0000000..4dee4e3
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller5.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller5.phar.inc b/ext/phar/tests/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000..d2d810c
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller6.phar b/ext/phar/tests/files/frontcontroller6.phar
new file mode 100644
index 0000000..f4a8265
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller6.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller6.phar.inc b/ext/phar/tests/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000..61f7807
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => 100));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller7.phar b/ext/phar/tests/files/frontcontroller7.phar
new file mode 100644
index 0000000..07884b2
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller7.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller7.phar.inc b/ext/phar/tests/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000..f2bd72b
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => null));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller8.phar b/ext/phar/tests/files/frontcontroller8.phar
new file mode 100644
index 0000000..27280a3
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller8.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller8.phar.inc b/ext/phar/tests/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000..8629f08
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller8.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar');
+$a['a.phps'] = 'hio1';
+$a['a1.phps'] = '<?php var_dump($_SERVER[b"REQUEST_URI"], $_SERVER[b"PATH_INFO"]);';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a['404.php'] = 'My 404 is rawesome';
+$a['noext'] = 'hi';
+$a['unknown.ext'] = '<?php var_dump("hi");';
+$a['bigfile.txt'] = str_repeat('a', 8193);
+$a['fatalerror.phps'] = '<?php oopsie_daisy();';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", "404.php", array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/frontcontroller9.phar b/ext/phar/tests/files/frontcontroller9.phar
new file mode 100644
index 0000000..39ca28c
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller9.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller9.phar.inc b/ext/phar/tests/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000..00861f6
--- /dev/null
+++ b/ext/phar/tests/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::mungServer(array());
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/files/include_path.phar b/ext/phar/tests/files/include_path.phar
new file mode 100644
index 0000000..89fa1f8
--- /dev/null
+++ b/ext/phar/tests/files/include_path.phar
Binary files differ
diff --git a/ext/phar/tests/files/include_path.phar.inc b/ext/phar/tests/files/include_path.phar.inc
new file mode 100644
index 0000000..448c87f
--- /dev/null
+++ b/ext/phar/tests/files/include_path.phar.inc
@@ -0,0 +1,19 @@
+<?php
+// test advanced example
+$phar = new Phar(dirname(__FILE__) . '/include_path.phar');
+$phar2 = new Phar(dirname(__FILE__) . '/include_path2.phar');
+$phar2['file1.php'] = 'file1.php
+';
+$phar2['test/file1.php'] = 'test/file1.php
+';
+$phar['hello/test.php'] = '<?php
+include "file1.php";';
+
+$phar->setStub("<?php
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . dirname(__FILE__) . '/files/include_path2.phar' );
+include 'phar://' . __FILE__ . '/hello/test.php';
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . dirname(__FILE__) . '/files/include_path2.phar/test');
+include 'phar://' . __FILE__ . '/hello/test.php';
+echo \"ok\\n\";
+__HALT_COMPILER();
+?>");
diff --git a/ext/phar/tests/files/include_path2.phar b/ext/phar/tests/files/include_path2.phar
new file mode 100644
index 0000000..bb0ba79
--- /dev/null
+++ b/ext/phar/tests/files/include_path2.phar
Binary files differ
diff --git a/ext/phar/tests/files/md5.phar b/ext/phar/tests/files/md5.phar
new file mode 100644
index 0000000..8ca2f84
--- /dev/null
+++ b/ext/phar/tests/files/md5.phar
Binary files differ
diff --git a/ext/phar/tests/files/nophar.phar b/ext/phar/tests/files/nophar.phar
new file mode 100644
index 0000000..4eb3083
--- /dev/null
+++ b/ext/phar/tests/files/nophar.phar
Binary files differ
diff --git a/ext/phar/tests/files/nophar.phar.inc b/ext/phar/tests/files/nophar.phar.inc
new file mode 100644
index 0000000..36d5628
--- /dev/null
+++ b/ext/phar/tests/files/nophar.phar.inc
@@ -0,0 +1,10 @@
+<?php
+$fname = dirname(__FILE__) . '/nophar.phar';
+@unlink($fname);
+$p = new Phar($fname);
+$p['index.php'] = '<?php include "b/c.php";' . "\n";
+$p['web.php'] = '<?php echo "web\n";';
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("index.php", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub($p->createDefaultStub('index.php', 'web.php'));
+?> \ No newline at end of file
diff --git a/ext/phar/tests/files/notbogus.zip b/ext/phar/tests/files/notbogus.zip
new file mode 100644
index 0000000..19ea96f
--- /dev/null
+++ b/ext/phar/tests/files/notbogus.zip
Binary files differ
diff --git a/ext/phar/tests/files/openssl.cnf b/ext/phar/tests/files/openssl.cnf
new file mode 100644
index 0000000..10e6907
--- /dev/null
+++ b/ext/phar/tests/files/openssl.cnf
@@ -0,0 +1,43 @@
+[ req ]
+default_bits = 1024
+default_keyfile = privkey.pem
+distinguished_name = req_distinguished_name
+attributes = req_attributes
+x509_extensions = v3_ca # The extentions to add to the self signed cert
+string_mask = MASK:4294967295
+
+
+[ req_distinguished_name ]
+countryName = Country Name (2 letter code)
+countryName_default = AU
+countryName_min = 2
+countryName_max = 2
+stateOrProvinceName = State or Province Name (full name)
+stateOrProvinceName_default = Some-State
+localityName = Locality Name (eg, city)
+0.organizationName = Organization Name (eg, company)
+0.organizationName_default = Internet Widgits Pty Ltd
+organizationalUnitName = Organizational Unit Name (eg, section)
+commonName = Common Name (eg, YOUR name)
+commonName_max = 64
+emailAddress = Email Address
+emailAddress_max = 64
+
+[ req_attributes ]
+challengePassword = A challenge password
+challengePassword_min = 4
+challengePassword_max = 20
+unstructuredName = An optional company name
+
+[ v3_req ]
+basicConstraints = CA:FALSE
+keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+[ v3_ca ]
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid:always,issuer:always
+basicConstraints = CA:true
+
+[ usr_cert ]
+basicConstraints=CA:FALSE
+
diff --git a/ext/phar/tests/files/openssl.phar b/ext/phar/tests/files/openssl.phar
new file mode 100644
index 0000000..f3864d7
--- /dev/null
+++ b/ext/phar/tests/files/openssl.phar
Binary files differ
diff --git a/ext/phar/tests/files/openssl.phar.pubkey b/ext/phar/tests/files/openssl.phar.pubkey
new file mode 100644
index 0000000..7dd79ac
--- /dev/null
+++ b/ext/phar/tests/files/openssl.phar.pubkey
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA3ADUiKZIEhekYShzPCZ3LFbg
+rDuV44jH94OdJQfqaCQBvZXqMoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzB
+mx9bFipOX2W2ouKS2YoHeIoR9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5
+agpkVsHLNJWbz/nPVwIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/files/pear2coverage.phar.php b/ext/phar/tests/files/pear2coverage.phar.php
new file mode 100644
index 0000000..621b0d0
--- /dev/null
+++ b/ext/phar/tests/files/pear2coverage.phar.php
Binary files differ
diff --git a/ext/phar/tests/files/phar_oo_test.inc b/ext/phar/tests/files/phar_oo_test.inc
new file mode 100644
index 0000000..e92b444
--- /dev/null
+++ b/ext/phar/tests/files/phar_oo_test.inc
@@ -0,0 +1,49 @@
+<?php
+
+ini_set('date.timezone', 'GMT');
+
+$fname = dirname(__FILE__) . '/phar_oo_test.phar.php';
+$pname = 'phar://' . $fname;
+$file = (binary)'<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+
+if (!isset($pharconfig)) $pharconfig = 0;
+
+switch($pharconfig)
+{
+ default:
+ case 0:
+ $files['a.php'] = '<?php echo "This is a.php\n"; ?>';
+ $files['b.php'] = '<?php echo "This is b.php\n"; ?>';
+ $files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>';
+ $files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>';
+ $files['e.php'] = '<?php echo "This is e.php\n"; ?>';
+ break;
+ case 1:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+EOF;
+ break;
+ case 2:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+4
+5,5
+
+7,777
+EOF;
+ break;
+ case 3:
+ $files['a.php'] = '<?php echo new new class;';
+ break;
+}
+
+$ftime = mktime(12, 0, 0, 3, 1, 2006);
+include 'phar_test.inc';
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/files/phar_test.inc b/ext/phar/tests/files/phar_test.inc
new file mode 100644
index 0000000..30ccf20
--- /dev/null
+++ b/ext/phar/tests/files/phar_test.inc
@@ -0,0 +1,78 @@
+<?php
+
+if (function_exists('date_default_timezone_set')) {
+ date_default_timezone_set('UTC');
+}
+
+$manifest = (binary)'';
+$gflags = 0;
+
+foreach($files as $name => $cont)
+{
+ global $gflags, $files;
+
+ $comp = NULL;
+ $crc32= NULL;
+ $clen = NULL;
+ $ulen = NULL;
+ $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
+ $flags= 0;
+ $perm = 0x000001B6;
+ $meta = NULL;
+
+ // overwrite if array
+ if (is_array($cont))
+ {
+ foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what)
+ {
+ if (isset($cont[$what]))
+ {
+ $$what = $cont[$what];
+ }
+ }
+ }
+
+ // 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((binary)$cont);
+ if (isset($meta)) $meta = serialize($meta);
+
+ // write manifest entry
+ $manifest .= pack('V', strlen($name)) . (binary)$name;
+ $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
+
+ // globals
+ $gflags |= $flags;
+ $files[$name] = $comp;
+}
+
+if (!isset($alias)) $alias = 'hio';
+
+if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
+
+$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
+$file = (binary)$file;
+$file .= pack('V', strlen($manifest)) . $manifest;
+
+foreach($files as $cont)
+{
+ $file .= (binary)$cont;
+}
+
+file_put_contents($fname, $file);
+
+if (@$gzip) {
+ $fp = gzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+if (@$bz2) {
+ $fp = bzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/files/private.pem b/ext/phar/tests/files/private.pem
new file mode 100644
index 0000000..e4f4883
--- /dev/null
+++ b/ext/phar/tests/files/private.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDA3ADUiKZIEhekYShzPCZ3LFbgrDuV44jH94OdJQfqaCQBvZXq
+MoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzBmx9bFipOX2W2ouKS2YoHeIoR
+9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5agpkVsHLNJWbz/nPVwIDAQAB
+AoGAGiS4qBbuE48ATXQuO5DH1hfYnxQ575Oskw7mdIL0k74SQ3ojvF+kXae6fVni
+UQZ76JgRWKYZa2kRDymwLZXpxVbiGL9dDvQY8ZENDtWOy9s7TDtxNixbZloKBopg
+J7G1B05LgetR3dgFnQOwt+e3kOu72RpS7thyBaUm8zHCRSECQQDw+h5uxE7i9CC8
+KHyJlwGoR28KZgrSpo74yWhQ+b1lzxQ+rk2wToFD/p+WNe/nf78YUl/cq0LngCKH
+Y7t228VLAkEAzOHzAjuDlGGzK6Kpe67iKgXd+GpKwPr9iaFfmzABOkRwQug4LCN7
+skmzCX5pzxqMZW1xNICjeDjWsMA3d4EypQJBAJyXPA1onYaXc2oxuPPD3/zVJpAQ
+TTojp8Z9Qr9T+kJdNV+h7rQB37gqjtOSiynY9nm8lbSUya4bstRd96S+HU8CQQCp
+yBAd6H2oZ7IXVeuHACyRUF1ab5LVCukxtVXJ/2T1CSPSfieWhC0MWMCR/HzoUALK
+RoBKVtOgW9GllRQh5yG1AkARVYbvj0XBy6XUpe5WZsLNWwpw1JreRsygcPXYh8bs
+nxhCdHNHJQ01lRDMjvNLtI8a5YjJE/IeW76T2mPCiJZI
+-----END RSA PRIVATE KEY-----
diff --git a/ext/phar/tests/files/sha1.phar b/ext/phar/tests/files/sha1.phar
new file mode 100644
index 0000000..c7e9e7e
--- /dev/null
+++ b/ext/phar/tests/files/sha1.phar
Binary files differ
diff --git a/ext/phar/tests/files/sha256.phar b/ext/phar/tests/files/sha256.phar
new file mode 100644
index 0000000..81459ee
--- /dev/null
+++ b/ext/phar/tests/files/sha256.phar
Binary files differ
diff --git a/ext/phar/tests/files/sha512.phar b/ext/phar/tests/files/sha512.phar
new file mode 100644
index 0000000..a747381
--- /dev/null
+++ b/ext/phar/tests/files/sha512.phar
Binary files differ
diff --git a/ext/phar/tests/files/stuboflength1041.phar b/ext/phar/tests/files/stuboflength1041.phar
new file mode 100644
index 0000000..d90fb8f
--- /dev/null
+++ b/ext/phar/tests/files/stuboflength1041.phar
Binary files differ
diff --git a/ext/phar/tests/files/stuboflength1041.phar.inc b/ext/phar/tests/files/stuboflength1041.phar.inc
new file mode 100644
index 0000000..28ce842
--- /dev/null
+++ b/ext/phar/tests/files/stuboflength1041.phar.inc
@@ -0,0 +1,21 @@
+<?php
+
+@unlink(__DIR__ . '/stuboflength1041.phar');
+
+$phar = new Phar('./stuboflength1041.phar');
+$phar['a.php'] = 'hi1';
+$phar['b.php'] = 'hi2';
+
+$phar->setStub('<?php
+/***stub of length 1041 including the halt compiler*********************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+************************************************************************************************
+*********************************************/
+__HALT_COMPILER();'); \ No newline at end of file
diff --git a/ext/phar/tests/files/zfapp.tgz b/ext/phar/tests/files/zfapp.tgz
new file mode 100644
index 0000000..fcaec86
--- /dev/null
+++ b/ext/phar/tests/files/zfapp.tgz
Binary files differ
diff --git a/ext/phar/tests/fopen.phpt b/ext/phar/tests/fopen.phpt
new file mode 100644
index 0000000..5b694d6
--- /dev/null
+++ b/ext/phar/tests/fopen.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Phar: test fopen() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) == '5.2') die("skip PHP >= 5.3 required for this test");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$a = fopen(__FILE__, 'rb'); // this satisfies 1 line of code coverage
+fclose($a);
+$a = fopen(); // this satisfies another line of code coverage
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+$a = fopen("dir/file1.txt", "r");
+echo fread($a, 2);
+fclose($a);
+$a = fopen("file1.txt", "r", true);
+echo fread($a, 2);
+fclose($a);
+$a = fopen("notfound.txt", "r", true);
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: fopen() expects at least 2 parameters, 0 given in %sfopen.php on line %d
+hihi
+Warning: fopen(notfound.txt): failed to open stream: No such file or directory in phar://%sfopen.phar.php/index.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/fopen5.2.phpt b/ext/phar/tests/fopen5.2.phpt
new file mode 100644
index 0000000..aa064f1
--- /dev/null
+++ b/ext/phar/tests/fopen5.2.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Phar: test fopen() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) != '5.2') die("skip PHP 5.2 required for this test");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$a = fopen(__FILE__, 'rb'); // this satisfies 1 line of code coverage
+fclose($a);
+$a = fopen(); // this satisfies another line of code coverage
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+$a = fopen("dir/file1.txt", "r");
+echo fread($a, 2);
+fclose($a);
+$a = fopen("file1.txt", "r", true);
+echo fread($a, 2);
+fclose($a);
+$a = fopen("notfound.txt", "r", true);
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: fopen() expects at least 2 parameters, 0 given in %sfopen5.2.php on line %d
+hihi
+Warning: fopen(phar://%sfopen5.2.phar.php/notfound.txt): failed to open stream: phar error: "notfound.txt" is not a file in phar "%sfopen5.2.phar.php" in phar://%sfopen5.2.phar.php/index.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/fopen_edgecases.phpt b/ext/phar/tests/fopen_edgecases.phpt
new file mode 100644
index 0000000..4c28ff3
--- /dev/null
+++ b/ext/phar/tests/fopen_edgecases.phpt
@@ -0,0 +1,124 @@
+--TEST--
+Phar: fopen/stat/fseek/unlink/rename edge cases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar.php';
+$pname = 'phar://' . $fname;
+$pname2 = 'phar://' . $fname2;
+$pname3 = 'phar://' . $fname3;
+
+// create in cwd
+chdir(dirname(__FILE__));
+file_put_contents('phar://fopen_edgetest.phar/hi', 'hi');
+// append
+$a = fopen($pname . '/b/c.php', 'a');
+// invalid pharname
+$a = fopen($pname . '.phar.gz', 'r');
+// test phar_open_url() with quiet stat for code coverage
+var_dump(file_exists($pname . '.phar.gz/hi'));
+// test open for write with new phar
+$a = fopen($pname . '/hi', 'w');
+fclose($a);
+// test open for write with corrupted phar
+file_put_contents($fname2, '<?php oh crap __HALT_COMPILER();');
+$a = fopen($pname2 . '/hi', 'w');
+$a = fopen('phar://', 'r');
+$a = fopen('phar://foo.phar', 'r');
+
+file_put_contents($pname . '/hi', 'hi');
+$a = fopen($pname . '/hi', 'r');
+var_dump(fseek($a, 1), ftell($a));
+var_dump(fseek($a, 1, SEEK_CUR), ftell($a));
+fclose($a);
+
+var_dump(stat('phar://'));
+var_dump(stat('phar://foo.phar'));
+var_dump(is_dir($pname));
+
+// this tests coverage of the case where the phar exists and has no files
+$phar = new Phar($fname3);
+var_dump(file_exists($pname3 . '/test'));
+
+unlink($pname2 . '/hi');
+unlink('phar://');
+unlink('phar://foo.phar');
+unlink($pname . '/oops');
+
+rename('phar://', 'phar://');
+rename($pname . '/hi', 'phar://');
+rename('phar://foo.phar/hi', 'phar://');
+rename($pname . '/hi', 'phar://foo.phar/hi');
+
+ini_set('phar.readonly', 1);
+rename($pname . '/hi', $pname . '/there');
+ini_set('phar.readonly', 0);
+Phar::unlinkArchive($fname);
+file_put_contents($pname . '/test.php', '<?php
+$a = fopen("./notfound.php", "r");
+?>');
+include $pname . '/test.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/fopen_edgetest.phar');
+--EXPECTF--
+Warning: fopen(phar://%sfopen_edgecases.phar.php/b/c.php): failed to open stream: phar error: open mode append not supported in %sfopen_edgecases.php on line %d
+
+Warning: fopen(phar://%sfopen_edgecases.phar.php.phar.gz): failed to open stream: phar error: invalid url or non-existent phar "phar://%sfopen_edgecases.phar.php.phar.gz" in %sfopen_edgecases.php on line %d
+bool(false)
+
+Warning: fopen(phar://%sfopen_edgecases.2.phar.php/hi): failed to open stream: internal corruption of phar "%sfopen_edgecases.2.phar.php" (truncated manifest at stub end) in %sfopen_edgecases.php on line %d
+
+Warning: fopen(phar://): failed to open stream: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar) in %sfopen_edgecases.php on line %d
+
+Warning: fopen(phar://foo.phar): failed to open stream: %s in %sfopen_edgecases.php on line %d
+int(0)
+int(1)
+int(0)
+int(2)
+
+Warning: stat(): stat failed for phar:// in %sfopen_edgecases.php on line %d
+bool(false)
+
+Warning: stat(): stat failed for phar://foo.phar in %sfopen_edgecases.php on line %d
+bool(false)
+bool(true)
+bool(false)
+
+Warning: unlink(): internal corruption of phar "%sfopen_edgecases.2.phar.php" (truncated manifest at stub end) in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): phar error: unlink failed in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar) in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): phar error: unlink failed in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): phar error: invalid url or non-existent phar "phar://foo.phar" in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): phar error: unlink failed in %sfopen_edgecases.php on line %d
+
+Warning: unlink(): unlink of "phar://%sfopen_edgecases.phar.php/oops" failed, file does not exist in %sfopen_edgecases.php on line %d
+
+Warning: rename(): phar error: cannot rename "phar://" to "phar://": invalid or non-writable url "phar://" in %sfopen_edgecases.php on line %d
+
+Warning: rename(): phar error: cannot rename "phar://%sfopen_edgecases.phar.php/hi" to "phar://": invalid or non-writable url "phar://" in %sfopen_edgecases.php on line %d
+
+Warning: rename(): phar error: cannot rename "phar://foo.phar/hi" to "phar://": invalid or non-writable url "phar://" in %sfopen_edgecases.php on line %d
+
+Warning: rename(): phar error: cannot rename "phar://%sfopen_edgecases.phar.php/hi" to "phar://foo.phar/hi", not within the same phar archive in %sfopen_edgecases.php on line %d
+
+Warning: rename(): phar error: cannot rename "phar://%sfopen_edgecases.phar.php/hi" to "phar://%sfopen_edgecases.phar.php/there": invalid or non-writable url "phar://%sfopen_edgecases.phar.php/hi" in %sfopen_edgecases.php on line %d
+
+Warning: fopen(./notfound.php): failed to open stream: No such file or directory in phar://%sfopen_edgecases.phar.php/test.php on line %d
+
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/fopen_edgecases2.phpt b/ext/phar/tests/fopen_edgecases2.phpt
new file mode 100644
index 0000000..d55c97d
--- /dev/null
+++ b/ext/phar/tests/fopen_edgecases2.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: test edge cases of fopen() function interception #2
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(phpversion(), '6.0', '>=')) die('skip parameter parsing changed in 6.0'); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+fopen(array(), 'r');
+chdir(dirname(__FILE__));
+file_put_contents($fname, b"blah\n");
+file_put_contents("foob", b"test\n");
+$a = fopen($fname, 'rb');
+echo fread($a, 1000);
+fclose($a);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', b'<?php
+$context = stream_context_create();
+$a = fopen("foob", "rb", false, $context);
+echo fread($a, 1000);
+fclose($a);
+fopen("../oops", "r");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+Warning: fopen() expects parameter 1 to be a valid path, array given in %sfopen_edgecases2.php on line %d
+blah
+test
+
+Warning: fopen(phar://%sfopen_edgecases2.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2.phar.php/foo/hi on line %d
+===DONE===
diff --git a/ext/phar/tests/fopen_edgecases2U.phpt b/ext/phar/tests/fopen_edgecases2U.phpt
new file mode 100644
index 0000000..09c7b00
--- /dev/null
+++ b/ext/phar/tests/fopen_edgecases2U.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: test edge cases of fopen() function interception #2 (PHP 6)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "6.0.0-dev", "<")) die("skip Unicode support required"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+fopen(array(), 'r');
+chdir(dirname(__FILE__));
+file_put_contents($fname, b"blah\n");
+file_put_contents("foob", b"test\n");
+$a = fopen($fname, 'rb');
+echo fread($a, 1000);
+fclose($a);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', b'<?php
+$context = stream_context_create();
+$a = fopen("foob", "rb", false, $context);
+echo fread($a, 1000);
+fclose($a);
+fopen("../oops", "r");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+Notice: Array to string conversion in %sfopen_edgecases2U.php on line 6
+
+Warning: fopen(Array): failed to open stream: No such file or directory in %sfopen_edgecases2U.php on line 6
+blah
+test
+
+Warning: fopen(phar://%sfopen_edgecases2U.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2U.phar.php/foo/hi on line 6
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/front.phar.phpt b/ext/phar/tests/front.phar.phpt
new file mode 100644
index 0000000..bab8ada
--- /dev/null
+++ b/ext/phar/tests/front.phar.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar front controller with mounted external file
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/front.phar.php
+REQUEST_URI=/front.phar.php/index.php
+PATH_INFO=/index.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/blog.phar
+--EXPECTF--
+string(%d) "<xml version="1.0" encoding="UTF-8">
+<config>
+ <database>
+ <host>localhost</name>
+ <user>squirrel</user>
+ <pass>nuts</pass>
+ <db>hoard</db>
+ </database>
+</config>
+"
diff --git a/ext/phar/tests/frontcontroller1.phpt b/ext/phar/tests/frontcontroller1.phpt
new file mode 100644
index 0000000..7093323
--- /dev/null
+++ b/ext/phar/tests/frontcontroller1.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller other
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller1.php
+REQUEST_URI=/frontcontroller1.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: image/jpeg
+Content-length: 3
+--EXPECT--
+hio
diff --git a/ext/phar/tests/frontcontroller10.phpt b/ext/phar/tests/frontcontroller10.phpt
new file mode 100644
index 0000000..667d5c2
--- /dev/null
+++ b/ext/phar/tests/frontcontroller10.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar front controller rewrite access denied
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller10.php
+REQUEST_URI=/frontcontroller10.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller4.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+Status: 403 Access Denied
+--EXPECT--
+<html>
+ <head>
+ <title>Access Denied</title>
+ </head>
+ <body>
+ <h1>403 - File /hi Access Denied</h1>
+ </body>
+</html>
diff --git a/ext/phar/tests/frontcontroller11.phpt b/ext/phar/tests/frontcontroller11.phpt
new file mode 100644
index 0000000..1e6f1a0
--- /dev/null
+++ b/ext/phar/tests/frontcontroller11.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type extension is not a string
+--INI--
+default_charset=
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller11.php
+REQUEST_URI=/frontcontroller11.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller5.phar
+--EXPECTHEADERS--
+Content-type: text/html
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.php:2
+Stack trace:
+#0 %sfrontcontroller11.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller11.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller12.phpt b/ext/phar/tests/frontcontroller12.phpt
new file mode 100644
index 0000000..956ea1c
--- /dev/null
+++ b/ext/phar/tests/frontcontroller12.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type unknown int
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller12.php
+REQUEST_URI=/frontcontroller12.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller6.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.php:2
+Stack trace:
+#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller12.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller13.phpt b/ext/phar/tests/frontcontroller13.phpt
new file mode 100644
index 0000000..717e569
--- /dev/null
+++ b/ext/phar/tests/frontcontroller13.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type not string/int
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller13.php
+REQUEST_URI=/frontcontroller13.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller7.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.php:2
+Stack trace:
+#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller13.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller14.phpt b/ext/phar/tests/frontcontroller14.phpt
new file mode 100644
index 0000000..2bdb145
--- /dev/null
+++ b/ext/phar/tests/frontcontroller14.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller mime type override, other
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller14.php
+REQUEST_URI=/frontcontroller14.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: foo/bar
+Content-length: 4
+--EXPECT--
+hio2
diff --git a/ext/phar/tests/frontcontroller15.phpt b/ext/phar/tests/frontcontroller15.phpt
new file mode 100644
index 0000000..3700980
--- /dev/null
+++ b/ext/phar/tests/frontcontroller15.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type override, Phar::PHPS
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller15.php
+REQUEST_URI=/frontcontroller15.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
+
diff --git a/ext/phar/tests/frontcontroller16.phpt b/ext/phar/tests/frontcontroller16.phpt
new file mode 100644
index 0000000..712af40
--- /dev/null
+++ b/ext/phar/tests/frontcontroller16.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller mime type override, Phar::PHP
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller16.php
+REQUEST_URI=/frontcontroller16.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio1
+
diff --git a/ext/phar/tests/frontcontroller17.phpt b/ext/phar/tests/frontcontroller17.phpt
new file mode 100644
index 0000000..233e2e2
--- /dev/null
+++ b/ext/phar/tests/frontcontroller17.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller mime type unknown
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller17.php
+REQUEST_URI=/frontcontroller17.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+Content-length: 4
+--EXPECT--
+hio3
+
diff --git a/ext/phar/tests/frontcontroller18.phpt b/ext/phar/tests/frontcontroller18.phpt
new file mode 100644
index 0000000..19aea45
--- /dev/null
+++ b/ext/phar/tests/frontcontroller18.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller18.php
+REQUEST_URI=/frontcontroller18.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller9.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.php:2
+Stack trace:
+#0 %sfrontcontroller18.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller18.php on line 2
diff --git a/ext/phar/tests/frontcontroller19.phpt b/ext/phar/tests/frontcontroller19.phpt
new file mode 100644
index 0000000..9adafa2
--- /dev/null
+++ b/ext/phar/tests/frontcontroller19.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure 2
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller19.php
+REQUEST_URI=/frontcontroller19.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller10.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.php:2
+Stack trace:
+#0 %sfrontcontroller19.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller19.php on line 2
diff --git a/ext/phar/tests/frontcontroller2.phpt b/ext/phar/tests/frontcontroller2.phpt
new file mode 100644
index 0000000..d0744de
--- /dev/null
+++ b/ext/phar/tests/frontcontroller2.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller PHP test
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller2.php
+REQUEST_URI=/frontcontroller2.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio
diff --git a/ext/phar/tests/frontcontroller20.phpt b/ext/phar/tests/frontcontroller20.phpt
new file mode 100644
index 0000000..45e2bfc
--- /dev/null
+++ b/ext/phar/tests/frontcontroller20.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure 3
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller20.php
+REQUEST_URI=/frontcontroller20.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller11.phar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.php:2
+Stack trace:
+#0 %sfrontcontroller20.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller20.php on line 2
diff --git a/ext/phar/tests/frontcontroller21.phpt b/ext/phar/tests/frontcontroller21.phpt
new file mode 100644
index 0000000..bf50c6e
--- /dev/null
+++ b/ext/phar/tests/frontcontroller21.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar front controller $_SERVER munging success
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller21.php
+REQUEST_URI=/frontcontroller21.php/index.php?test=hi
+PATH_INFO=/index.php
+QUERY_STRING=test=hi
+--FILE_EXTERNAL--
+files/frontcontroller12.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%unicode|string%(10) "/index.php"
+string(10) "/index.php"
+string(%d) "phar://%sfrontcontroller21.php/index.php"
+string(18) "/index.php?test=hi"
+string(32) "/frontcontroller21.php/index.php"
+string(22) "/frontcontroller21.php"
+string(%d) "%sfrontcontroller21.php"
+string(40) "/frontcontroller21.php/index.php?test=hi" \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller22.phpt b/ext/phar/tests/frontcontroller22.phpt
new file mode 100644
index 0000000..b85c1eb
--- /dev/null
+++ b/ext/phar/tests/frontcontroller22.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller include from cwd test 1
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller22.php
+REQUEST_URI=/frontcontroller22.php/index.php
+PATH_INFO=/index.php
+--FILE_EXTERNAL--
+files/frontcontroller13.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%unicode|string%(4) "test"
+%unicode|string%(12) "oof/test.php"
+
+Warning: include(./hi.php): failed to open stream: No such file or directory in phar://%s/oof/test.php on line %d
+
+Warning: include(): Failed opening './hi.php' for inclusion (include_path='%s') in phar://%soof/test.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller23.phpt b/ext/phar/tests/frontcontroller23.phpt
new file mode 100644
index 0000000..24464c9
--- /dev/null
+++ b/ext/phar/tests/frontcontroller23.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with generic action router test
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller23.php
+REQUEST_URI=/frontcontroller23.php/hi/there
+PATH_INFO=/hi/there
+--FILE_EXTERNAL--
+files/frontcontroller14.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+string(9) "/hi/there"
+string(%d) "phar://%sfrontcontroller23.php/html/index.php" \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller24.phpt b/ext/phar/tests/frontcontroller24.phpt
new file mode 100644
index 0000000..767971e
--- /dev/null
+++ b/ext/phar/tests/frontcontroller24.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with custom 404 php script
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller24.php
+REQUEST_URI=/frontcontroller24.php/unknown/file
+PATH_INFO=/unknown/file
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+My 404 is rawesome \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller25.phpt b/ext/phar/tests/frontcontroller25.phpt
new file mode 100644
index 0000000..9b383de
--- /dev/null
+++ b/ext/phar/tests/frontcontroller25.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller with extra path_info
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller25.php
+REQUEST_URI=/frontcontroller25.php/a1.phps/extra/stuff
+PATH_INFO=/a1.phps/extra/stuff
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+string(42) "/frontcontroller25.php/a1.phps/extra/stuff"
+string(12) "/extra/stuff" \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller26.phpt b/ext/phar/tests/frontcontroller26.phpt
new file mode 100644
index 0000000..a8097b0
--- /dev/null
+++ b/ext/phar/tests/frontcontroller26.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller with unknown extension mime type
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller26.php
+REQUEST_URI=/frontcontroller26.php/unknown.ext
+PATH_INFO=/unknown.ext
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+--EXPECTF--
+<?php var_dump("hi"); \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller27.phpt b/ext/phar/tests/frontcontroller27.phpt
new file mode 100644
index 0000000..16203f6
--- /dev/null
+++ b/ext/phar/tests/frontcontroller27.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with no extension
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller27.php
+REQUEST_URI=/frontcontroller27.php/noext
+PATH_INFO=/noext
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/plain;charset=UTF-8
+--EXPECTF--
+hi \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller28.phpt b/ext/phar/tests/frontcontroller28.phpt
new file mode 100644
index 0000000..5778008
--- /dev/null
+++ b/ext/phar/tests/frontcontroller28.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with huge file
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller28.php
+REQUEST_URI=/frontcontroller28.php/bigfile.txt
+PATH_INFO=/bigfile.txt
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/plain;charset=UTF-8
+--EXPECT--
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
diff --git a/ext/phar/tests/frontcontroller29.phpt b/ext/phar/tests/frontcontroller29.phpt
new file mode 100644
index 0000000..0afc179
--- /dev/null
+++ b/ext/phar/tests/frontcontroller29.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller with fatal error in php file
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller29.php
+REQUEST_URI=/frontcontroller29.php/fatalerror.phps
+PATH_INFO=/fatalerror.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps on line 1 \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller3.phpt b/ext/phar/tests/frontcontroller3.phpt
new file mode 100644
index 0000000..ac36485
--- /dev/null
+++ b/ext/phar/tests/frontcontroller3.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller phps
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller3.php
+REQUEST_URI=/frontcontroller3.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
diff --git a/ext/phar/tests/frontcontroller30.phpt b/ext/phar/tests/frontcontroller30.phpt
new file mode 100644
index 0000000..de6960c
--- /dev/null
+++ b/ext/phar/tests/frontcontroller30.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Phar front controller with weird SCRIPT_NAME
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/huh?
+REQUEST_URI=/huh?
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTF--
+oops did not run
+%a \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller31.phpt b/ext/phar/tests/frontcontroller31.phpt
new file mode 100644
index 0000000..13c305d
--- /dev/null
+++ b/ext/phar/tests/frontcontroller31.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller with invalid callback for rewrites
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller31.php
+REQUEST_URI=/frontcontroller31.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller16.phar
+--EXPECT--
+phar error: invalid rewrite callback \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller32.phpt b/ext/phar/tests/frontcontroller32.phpt
new file mode 100644
index 0000000..58f6fff
--- /dev/null
+++ b/ext/phar/tests/frontcontroller32.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller with valid callback that is not good
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller32.php
+REQUEST_URI=/frontcontroller32.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller17.phar
+--EXPECTF--
+%ahar error: failed to call rewrite callback \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller33.phpt b/ext/phar/tests/frontcontroller33.phpt
new file mode 100644
index 0000000..8593e31
--- /dev/null
+++ b/ext/phar/tests/frontcontroller33.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller with valid callback that does not return any value
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller33.php
+REQUEST_URI=/frontcontroller33.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller18.phar
+--EXPECTF--
+phar error: rewrite callback must return a string or false \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller34.phpt b/ext/phar/tests/frontcontroller34.phpt
new file mode 100644
index 0000000..34a49de
--- /dev/null
+++ b/ext/phar/tests/frontcontroller34.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller with cwd
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller34.php
+REQUEST_URI=/frontcontroller34.php/start/index.php
+PATH_INFO=/start/index.php
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--FILE_EXTERNAL--
+files/frontcontroller19.phar
+--EXPECT--
+start/index.php
+start/another.php
+another.php
diff --git a/ext/phar/tests/frontcontroller4.phpt b/ext/phar/tests/frontcontroller4.phpt
new file mode 100644
index 0000000..f2482b9
--- /dev/null
+++ b/ext/phar/tests/frontcontroller4.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Phar front controller index.php relocate (no /)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller4.php
+REQUEST_URI=/frontcontroller4.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller4.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/frontcontroller5.phpt b/ext/phar/tests/frontcontroller5.phpt
new file mode 100644
index 0000000..1990a2b
--- /dev/null
+++ b/ext/phar/tests/frontcontroller5.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller index.php relocate
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller5.php
+REQUEST_URI=/frontcontroller5.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller5.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/frontcontroller6.phpt b/ext/phar/tests/frontcontroller6.phpt
new file mode 100644
index 0000000..1a2cc2c
--- /dev/null
+++ b/ext/phar/tests/frontcontroller6.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller 404
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller6.php
+REQUEST_URI=/frontcontroller6.php/notfound.php
+PATH_INFO=/notfound.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /notfound.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller7.phpt b/ext/phar/tests/frontcontroller7.phpt
new file mode 100644
index 0000000..aff2087
--- /dev/null
+++ b/ext/phar/tests/frontcontroller7.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller alternate index file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller7.php
+REQUEST_URI=/frontcontroller7.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller2.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller7.php/a.php
+--EXPECT--
diff --git a/ext/phar/tests/frontcontroller8.phpt b/ext/phar/tests/frontcontroller8.phpt
new file mode 100644
index 0000000..36e3206
--- /dev/null
+++ b/ext/phar/tests/frontcontroller8.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller no index file 404
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller8.php
+REQUEST_URI=/frontcontroller8.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller3.phar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /index.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller9.phpt b/ext/phar/tests/frontcontroller9.phpt
new file mode 100644
index 0000000..d47a289
--- /dev/null
+++ b/ext/phar/tests/frontcontroller9.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller rewrite array
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller9.php
+REQUEST_URI=/frontcontroller9.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller3.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code> \ No newline at end of file
diff --git a/ext/phar/tests/include_path.phpt b/ext/phar/tests/include_path.phpt
new file mode 100644
index 0000000..5f9462c
--- /dev/null
+++ b/ext/phar/tests/include_path.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: include_path with phar:// wrapper
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
+$a = new Phar($fname);
+$a['file1.php'] = 'file1.php
+';
+$a['test/file1.php'] = 'test/file1.php
+';
+unset($a);
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . $fname);
+include 'file1.php';
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . $fname . '/test');
+include 'file1.php';
+include 'file2.php';
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
+?>
+--EXPECTF--
+file1.php
+test/file1.php
+
+Warning: include(file2.php): failed to open stream: No such file or directory in %sinclude_path.php on line %d
+
+Warning: include(): Failed opening 'file2.php' for inclusion (include_path='%sphar://%stempmanifest1.phar.php/test') in %sinclude_path.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/include_path_advanced.phpt b/ext/phar/tests/include_path_advanced.phpt
new file mode 100644
index 0000000..6feee42
--- /dev/null
+++ b/ext/phar/tests/include_path_advanced.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Phar: include_path advanced code coverage test
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/include_path.phar
+--EXPECT--
+file1.php
+test/file1.php
+ok \ No newline at end of file
diff --git a/ext/phar/tests/ini_set.phpt b/ext/phar/tests/ini_set.phpt
new file mode 100644
index 0000000..7ccd6ea
--- /dev/null
+++ b/ext/phar/tests/ini_set.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: test ini_set with readonly and require_hash enabled
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+?>
+--INI--
+phar.require_hash=1
+phar.readonly=1
+--FILE--
+<?php
+var_dump(ini_set('phar.require_hash', 1));
+var_dump(ini_set('phar.readonly', 1));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+var_dump(false, false);
+} else {
+var_dump(ini_set('phar.require_hash', 0));
+var_dump(ini_set('phar.readonly', 0));
+}
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+bool(false)
+bool(false)
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
diff --git a/ext/phar/tests/ini_set_off.phpt b/ext/phar/tests/ini_set_off.phpt
new file mode 100644
index 0000000..878f8bf
--- /dev/null
+++ b/ext/phar/tests/ini_set_off.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Phar: test ini_set with readonly and require_hash disabled
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(ini_set('phar.require_hash', 1));
+var_dump(ini_set('phar.readonly', 1));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+var_dump(Phar::canWrite());
+?>
+yes
+<?php
+var_dump(ini_set('phar.require_hash', 'yes'));
+var_dump(ini_set('phar.readonly', 'yes'));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+var_dump(Phar::canWrite());
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+?>
+on
+<?php
+var_dump(ini_set('phar.require_hash', 'on'));
+var_dump(ini_set('phar.readonly', 'on'));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+var_dump(Phar::canWrite());
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+?>
+true
+<?php
+var_dump(ini_set('phar.require_hash', 'true'));
+var_dump(ini_set('phar.readonly', 'true'));
+var_dump(Phar::canWrite());
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+?>
+0
+<?php
+var_dump(ini_set('phar.require_hash', 0));
+var_dump(ini_set('phar.readonly', 0));
+var_dump(Phar::canWrite());
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+?>
+===DONE===
+--EXPECT--
+string(1) "0"
+string(1) "0"
+string(1) "1"
+string(1) "1"
+bool(true)
+yes
+string(1) "0"
+string(1) "0"
+string(3) "yes"
+string(3) "yes"
+bool(false)
+on
+string(1) "0"
+string(1) "0"
+string(2) "on"
+string(2) "on"
+bool(false)
+true
+string(1) "0"
+string(1) "0"
+bool(false)
+string(4) "true"
+string(4) "true"
+0
+string(4) "true"
+string(4) "true"
+bool(true)
+string(1) "0"
+string(1) "0"
+===DONE===
diff --git a/ext/phar/tests/ini_set_offU.phpt b/ext/phar/tests/ini_set_offU.phpt
new file mode 100644
index 0000000..150cbed
--- /dev/null
+++ b/ext/phar/tests/ini_set_offU.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Phar: test ini_set with readonly and require_hash disabled
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(ini_set('phar.require_hash', 1));
+var_dump(ini_set('phar.readonly', 1));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+var_dump(Phar::canWrite());
+?>
+yes
+<?php
+var_dump(ini_set('phar.require_hash', 'yes'));
+var_dump(ini_set('phar.readonly', 'yes'));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+var_dump(Phar::canWrite());
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+?>
+on
+<?php
+var_dump(ini_set('phar.require_hash', 'on'));
+var_dump(ini_set('phar.readonly', 'on'));
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+var_dump(Phar::canWrite());
+ini_set('phar.require_hash', 0);
+ini_set('phar.readonly', 0);
+?>
+true
+<?php
+var_dump(ini_set('phar.require_hash', 'true'));
+var_dump(ini_set('phar.readonly', 'true'));
+var_dump(Phar::canWrite());
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+?>
+0
+<?php
+var_dump(ini_set('phar.require_hash', 0));
+var_dump(ini_set('phar.readonly', 0));
+var_dump(Phar::canWrite());
+var_dump(ini_get('phar.require_hash'));
+var_dump(ini_get('phar.readonly'));
+?>
+===DONE===
+--EXPECT--
+unicode(1) "0"
+unicode(1) "0"
+unicode(1) "1"
+unicode(1) "1"
+bool(true)
+yes
+unicode(1) "0"
+unicode(1) "0"
+unicode(3) "yes"
+unicode(3) "yes"
+bool(false)
+on
+unicode(1) "0"
+unicode(1) "0"
+unicode(2) "on"
+unicode(2) "on"
+bool(false)
+true
+unicode(1) "0"
+unicode(1) "0"
+bool(false)
+unicode(4) "true"
+unicode(4) "true"
+0
+unicode(4) "true"
+unicode(4) "true"
+bool(true)
+unicode(1) "0"
+unicode(1) "0"
+===DONE===
diff --git a/ext/phar/tests/invalid_alias.phpt b/ext/phar/tests/invalid_alias.phpt
new file mode 100644
index 0000000..dc0c71e
--- /dev/null
+++ b/ext/phar/tests/invalid_alias.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: set alias with invalid alias containing / \ : or ;
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+
+$p = new Phar($fname);
+try {
+ $p->setAlias('hi/');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ $p->setAlias('hi\\l');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $p->setAlias('hil;');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $p->setAlias(':hil');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECTF--
+Invalid alias "hi/" specified for phar "%sinvalid_alias.phar"
+Invalid alias "hi\l" specified for phar "%sinvalid_alias.phar"
+Invalid alias "hil;" specified for phar "%sinvalid_alias.phar"
+Invalid alias ":hil" specified for phar "%sinvalid_alias.phar"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/invalid_setstubalias.phpt b/ext/phar/tests/invalid_setstubalias.phpt
new file mode 100644
index 0000000..04cb779
--- /dev/null
+++ b/ext/phar/tests/invalid_setstubalias.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar: invalid set alias or stub via array access
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$p = new Phar($fname);
+try {
+ $p['.phar/stub.php'] = 'hi';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ $p['.phar/alias.txt'] = 'hi';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+$p = new Phar($fname2);
+try {
+ $p['.phar/stub.php'] = 'hi';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ $p['.phar/alias.txt'] = 'hi';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+?>
+--EXPECTF--
+Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.tar", use setStub
+Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.tar", use setAlias
+Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.zip", use setStub
+Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.zip", use setAlias
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/metadata_read.phpt b/ext/phar/tests/metadata_read.phpt
new file mode 100644
index 0000000..5c37382
--- /dev/null
+++ b/ext/phar/tests/metadata_read.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar with meta-data (read)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+NULL
+string(8) "hi there"
+array(2) {
+ [0]=>
+ string(2) "hi"
+ [1]=>
+ string(5) "there"
+}
+array(2) {
+ ["hi"]=>
+ string(5) "there"
+ ["foo"]=>
+ string(3) "bar"
+}
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/metadata_readU.phpt b/ext/phar/tests/metadata_readU.phpt
new file mode 100644
index 0000000..7197ead
--- /dev/null
+++ b/ext/phar/tests/metadata_readU.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar with meta-data (read)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+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'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+NULL
+unicode(8) "hi there"
+array(2) {
+ [0]=>
+ unicode(2) "hi"
+ [1]=>
+ unicode(5) "there"
+}
+array(2) {
+ [u"hi"]=>
+ unicode(5) "there"
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/metadata_write.phpt b/ext/phar/tests/metadata_write.phpt
new file mode 100644
index 0000000..1aaa30d
--- /dev/null
+++ b/ext/phar/tests/metadata_write.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar with meta-data (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/metadata_writeU.phpt b/ext/phar/tests/metadata_writeU.phpt
new file mode 100644
index 0000000..dc0764b
--- /dev/null
+++ b/ext/phar/tests/metadata_writeU.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar with meta-data (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/metadata_write_commit.phpt b/ext/phar/tests/metadata_write_commit.phpt
new file mode 100644
index 0000000..fd2f107
--- /dev/null
+++ b/ext/phar/tests/metadata_write_commit.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Phar with meta-data (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+$phar->startBuffering();
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+$phar->stopBuffering();
+
+unset($phar);
+
+$phar = new Phar($fname);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/metadata_write_commitU.phpt b/ext/phar/tests/metadata_write_commitU.phpt
new file mode 100644
index 0000000..712a6f5
--- /dev/null
+++ b/ext/phar/tests/metadata_write_commitU.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Phar with meta-data (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+$phar->startBuffering();
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+$phar->stopBuffering();
+
+unset($phar);
+
+$phar = new Phar($fname);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/mkdir.phpt b/ext/phar/tests/mkdir.phpt
new file mode 100644
index 0000000..45c1d46
--- /dev/null
+++ b/ext/phar/tests/mkdir.phpt
@@ -0,0 +1,47 @@
+--TEST--
+phar: mkdir/rmdir edge cases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+Phar::interceptFileFuncs();
+mkdir('phar://');
+mkdir('phar://foo.phar');
+$a = new Phar($fname);
+$a['a'] = 'hi';
+mkdir($pname . '/a');
+rmdir('phar://');
+rmdir('phar://foo.phar');
+rmdir($pname . '/a');
+$a->addEmptyDir('bb');
+$a->addEmptyDir('bb');
+try {
+$a->addEmptyDir('.phar');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Warning: mkdir(): phar error: cannot create directory "phar://", no phar archive specified in %smkdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "" in phar "foo.phar", phar error: invalid path "" must not be empty in %smkdir.php on line %d
+
+Warning: mkdir(): phar error: cannot create directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "phar://", no phar archive specified, or phar archive does not exist in %smkdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "" in phar "foo.phar", directory does not exist in %smkdir.php on line %d
+
+Warning: rmdir(): phar error: cannot remove directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
+Cannot create a directory in magic ".phar" directory
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/mounteddir.phpt b/ext/phar/tests/mounteddir.phpt
new file mode 100644
index 0000000..e130895
--- /dev/null
+++ b/ext/phar/tests/mounteddir.phpt
@@ -0,0 +1,118 @@
+--TEST--
+Phar: mounted manifest directory test
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
+$pname = 'phar://' . $fname;
+
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+Phar::mount("testit", dirname(Phar::running(0)) . "/testit");
+echo file_get_contents(Phar::running(1) . "/testit/extfile.php"), "\n";
+echo file_get_contents(Phar::running(1) . "/testit/directory"), "\n";
+echo file_get_contents(Phar::running(1) . "/testit/existing.txt"), "\n";
+include "testit/extfile.php";
+include "testit/extfile2.php";
+try {
+Phar::mount(".phar/stub.php", dirname(Phar::running(0)) . "/testit/extfile.php");
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>';
+$a['testit/existing.txt'] = 'oops';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+unset($a);
+mkdir(dirname(__FILE__) . '/testit');
+mkdir(dirname(__FILE__) . '/testit/directory');
+file_put_contents(dirname(__FILE__) . '/testit/extfile.php', '<?php
+var_dump(__FILE__);
+?>');
+file_put_contents(dirname(__FILE__) . '/testit/extfile2.php', '<?php
+var_dump(__FILE__);
+?>');
+include dirname(__FILE__) . '/testit/extfile.php';
+include $fname;
+
+$a = opendir($pname . '/testit');
+$out = array();
+while (false !== ($b = readdir($a))) {
+ $out[] = $b;
+}
+sort($out);
+foreach ($out as $b) {
+ echo "$b\n";
+}
+$out = array();
+foreach (new Phar($pname . '/testit') as $b) {
+ $out[] = $b->getPathName();
+}
+sort($out);
+foreach ($out as $b) {
+ echo "$b\n";
+}
+try {
+Phar::mount($pname . '/testit', 'another\\..\\mistake');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/notfound', dirname(__FILE__) . '/this/does/not/exist');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/testit', dirname(__FILE__));
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/testit/extfile.php', dirname(__FILE__));
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
+@unlink(dirname(__FILE__) . '/testit/extfile.php');
+@unlink(dirname(__FILE__) . '/testit/extfile2.php');
+@rmdir(dirname(__FILE__) . '/testit/directory');
+@rmdir(dirname(__FILE__) . '/testit');
+
+?>
+--EXPECTF--
+string(%d) "%sextfile.php"
+<?php
+var_dump(__FILE__);
+?>
+
+Warning: file_get_contents(phar://%stempmanifest1.phar.php/testit/directory): failed to open stream: phar error: path "testit/directory" is a directory in phar://%stempmanifest1.phar.php/index.php on line %d
+
+oops
+string(%d) "phar://%sextfile.php"
+string(%d) "phar://%sextfile2.php"
+Mounting of .phar/stub.php to %sextfile.php within phar %stests/tempmanifest1.phar.php failed
+.
+..
+directory
+extfile.php
+extfile2.php
+phar://%stempmanifest1.phar.php/testit%cdirectory
+phar://%stempmanifest1.phar.php/testit%cextfile.php
+phar://%stempmanifest1.phar.php/testit%cextfile2.php
+Mounting of /testit to another\..\mistake within phar %stempmanifest1.phar.php failed
+Mounting of /notfound to %stests/this/does/not/exist within phar %stempmanifest1.phar.php failed
+Mounting of /testit to %stests within phar %stests/tempmanifest1.phar.php failed
+Mounting of /testit/extfile.php to %stests within phar %stests/tempmanifest1.phar.php failed
+===DONE===
diff --git a/ext/phar/tests/mounteddirU.phpt b/ext/phar/tests/mounteddirU.phpt
new file mode 100644
index 0000000..d05cb00
--- /dev/null
+++ b/ext/phar/tests/mounteddirU.phpt
@@ -0,0 +1,118 @@
+--TEST--
+Phar: mounted manifest directory test
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
+$pname = 'phar://' . $fname;
+
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+Phar::mount("testit", dirname(Phar::running(0)) . "/testit");
+echo file_get_contents(Phar::running(1) . "/testit/extfile.php"), "\n";
+echo file_get_contents(Phar::running(1) . "/testit/directory"), "\n";
+echo file_get_contents(Phar::running(1) . "/testit/existing.txt"), "\n";
+include "testit/extfile.php";
+include "testit/extfile2.php";
+try {
+Phar::mount(".phar/stub.php", dirname(Phar::running(0)) . "/testit/extfile.php");
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>';
+$a['testit/existing.txt'] = 'oops';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+unset($a);
+mkdir(dirname(__FILE__) . '/testit');
+mkdir(dirname(__FILE__) . '/testit/directory');
+file_put_contents(dirname(__FILE__) . '/testit/extfile.php', '<?php
+var_dump(__FILE__);
+?>');
+file_put_contents(dirname(__FILE__) . '/testit/extfile2.php', '<?php
+var_dump(__FILE__);
+?>');
+include dirname(__FILE__) . '/testit/extfile.php';
+include $fname;
+
+$a = opendir($pname . '/testit');
+$out = array();
+while (false !== ($b = readdir($a))) {
+ $out[] = $b;
+}
+sort($out);
+foreach ($out as $b) {
+ echo "$b\n";
+}
+$out = array();
+foreach (new Phar($pname . '/testit') as $b) {
+ $out[] = $b->getPathName();
+}
+sort($out);
+foreach ($out as $b) {
+ echo "$b\n";
+}
+try {
+Phar::mount($pname . '/testit', 'another\\..\\mistake');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/notfound', dirname(__FILE__) . '/this/does/not/exist');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/testit', dirname(__FILE__));
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+Phar::mount($pname . '/testit/extfile.php', dirname(__FILE__));
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
+@unlink(dirname(__FILE__) . '/testit/extfile.php');
+@unlink(dirname(__FILE__) . '/testit/extfile2.php');
+@rmdir(dirname(__FILE__) . '/testit/directory');
+@rmdir(dirname(__FILE__) . '/testit');
+
+?>
+--EXPECTF--
+unicode(%d) "%sextfile.php"
+<?php
+var_dump(__FILE__);
+?>
+
+Warning: file_get_contents(phar://%stempmanifest1.phar.php/testit/directory): failed to open stream: phar error: path "testit/directory" is a directory in phar://%stempmanifest1.phar.php/index.php on line %d
+
+oops
+unicode(%d) "phar://%sextfile.php"
+unicode(%d) "phar://%sextfile2.php"
+Mounting of .phar/stub.php to %sextfile.php within phar %stests/tempmanifest1.phar.php failed
+.
+..
+directory
+extfile.php
+extfile2.php
+phar://%stempmanifest1.phar.php/testit%cdirectory
+phar://%stempmanifest1.phar.php/testit%cextfile.php
+phar://%stempmanifest1.phar.php/testit%cextfile2.php
+Mounting of /testit to another\..\mistake within phar %stempmanifest1.phar.php failed
+Mounting of /notfound to %stests/this/does/not/exist within phar %stempmanifest1.phar.php failed
+Mounting of /testit to %stests within phar %stests/tempmanifest1.phar.php failed
+Mounting of /testit/extfile.php to %stests within phar %stests/tempmanifest1.phar.php failed
+===DONE===
diff --git a/ext/phar/tests/nophar.phpt b/ext/phar/tests/nophar.phpt
new file mode 100644
index 0000000..d97df8a
--- /dev/null
+++ b/ext/phar/tests/nophar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: phar run without pecl/phar with default stub
+--SKIPIF--
+<?php if (extension_loaded("phar")) die("skip Phar extension must be disabled for this test"); ?>
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/nophar.phar';
+?>
+===DONE===
+--EXPECT--
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/nophar_web.phpt b/ext/phar/tests/nophar_web.phpt
new file mode 100644
index 0000000..7ee67b4
--- /dev/null
+++ b/ext/phar/tests/nophar_web.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Phar: default web stub, no phar extension
+--SKIPIF--
+<?php if (extension_loaded("phar")) die("skip Phar extension must be disabled for this test"); ?>
+--ENV--
+SCRIPT_NAME=/nophar.phar
+REQUEST_URI=/nophar.phar
+--FILE_EXTERNAL--
+files/nophar.phar
+--EXPECT--
+web
diff --git a/ext/phar/tests/open_for_write_existing.phpt b/ext/phar/tests/open_for_write_existing.phpt
new file mode 100644
index 0000000..9d27cd8
--- /dev/null
+++ b/ext/phar/tests/open_for_write_existing.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+extra
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_b.phpt b/ext/phar/tests/open_for_write_existing_b.phpt
new file mode 100644
index 0000000..ef48906
--- /dev/null
+++ b/ext/phar/tests/open_for_write_existing_b.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/open_for_write_existing_b_5_2.phpt
new file mode 100644
index 0000000..03edd54
--- /dev/null
+++ b/ext/phar/tests/open_for_write_existing_b_5_2.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b_5_2.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_c.phpt b/ext/phar/tests/open_for_write_existing_c.phpt
new file mode 100644
index 0000000..f64d538
--- /dev/null
+++ b/ext/phar/tests/open_for_write_existing_c.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/open_for_write_existing_c_5_2.phpt
new file mode 100644
index 0000000..2d5a983
--- /dev/null
+++ b/ext/phar/tests/open_for_write_existing_c_5_2.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c_5_2.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile.phpt b/ext/phar/tests/open_for_write_newfile.phpt
new file mode 100644
index 0000000..735e3b4
--- /dev/null
+++ b/ext/phar/tests/open_for_write_newfile.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+This is b/c
+extra
+===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile_b.phpt b/ext/phar/tests/open_for_write_newfile_b.phpt
new file mode 100644
index 0000000..45131c4
--- /dev/null
+++ b/ext/phar/tests/open_for_write_newfile_b.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.php" in %sopen_for_write_newfile_b.php on line 22
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/open_for_write_newfile_b_5_2.phpt
new file mode 100644
index 0000000..7d43f1c
--- /dev/null
+++ b/ext/phar/tests/open_for_write_newfile_b_5_2.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b_5_2.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b_5_2.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b_5_2.phar.php" in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b_5_2.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile_c.phpt b/ext/phar/tests/open_for_write_newfile_c.phpt
new file mode 100644
index 0000000..d790051
--- /dev/null
+++ b/ext/phar/tests/open_for_write_newfile_c.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/open_for_write_newfile_c_5_2.phpt
new file mode 100644
index 0000000..421aa98
--- /dev/null
+++ b/ext/phar/tests/open_for_write_newfile_c_5_2.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c_5_2.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c_5_2.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c_5_2.phar.php" in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c_5_2.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/opendir.phpt b/ext/phar/tests/opendir.phpt
new file mode 100644
index 0000000..ca6e391
--- /dev/null
+++ b/ext/phar/tests/opendir.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: test opendir() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+$a = opendir("dir");
+if ($a) {
+ while (false !== ($e = readdir($a))) {
+ echo $e;
+ }
+}
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+Phar::interceptFileFuncs();
+set_include_path("phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+echo "\n";
+opendir('phar://');
+opendir('phar://hi.phar');
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+file1.txtfile2.txtfile3.txt
+
+Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
+phar url "phar://" is unknown in %sopendir.php on line %d
+
+Warning: opendir(phar://hi.phar): failed to open dir: phar error: invalid url or non-existent phar "phar://hi.phar"
+phar url "phar://hi.phar" is unknown in %sopendir.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/opendir_edgecases.phpt b/ext/phar/tests/opendir_edgecases.phpt
new file mode 100644
index 0000000..be899df
--- /dev/null
+++ b/ext/phar/tests/opendir_edgecases.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: test edge cases of opendir() function interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+Phar::interceptFileFuncs();
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+opendir(array());
+
+mkdir(dirname(__FILE__) . '/poo');
+chdir(dirname(__FILE__));
+
+$a = opendir('poo');
+
+$arr = array();
+while (false !== ($b = readdir($a))) {
+ $arr[] = $b;
+}
+sort($arr);
+foreach ($arr as $b) {
+ echo "$b\n";
+}
+
+closedir($a);
+
+file_put_contents($pname . '/foo', '<?php
+$context = stream_context_create();
+$a = opendir(".", $context);
+$res = array();
+while (false !== ($b = readdir($a))) {
+$res[] = $b;
+}
+sort($res);
+foreach ($res as $b) {
+echo "$b\n";
+}
+opendir("oops");
+?>');
+
+include $pname . '/foo';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo');
+--EXPECTF--
+Warning: opendir() expects parameter 1 to be a valid path, array given in %sopendir_edgecases.php on line %d
+.
+..
+foo
+
+Warning: opendir(phar://%sopendir_edgecases.phar.php/oops): failed to open dir: %s in phar://%sopendir_edgecases.phar.php/foo on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_begin_setstub_commit.phpt b/ext/phar/tests/phar_begin_setstub_commit.phpt
new file mode 100644
index 0000000..9d3e383
--- /dev/null
+++ b/ext/phar/tests/phar_begin_setstub_commit.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar');
+?>
+--EXPECT--
+bool(false)
+bool(true)
+string(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+string(5) "Hello"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/phar_begin_setstub_commitU.phpt b/ext/phar/tests/phar_begin_setstub_commitU.phpt
new file mode 100644
index 0000000..805e762
--- /dev/null
+++ b/ext/phar/tests/phar_begin_setstub_commitU.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar');
+?>
+--EXPECT--
+bool(false)
+bool(true)
+unicode(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+unicode(5) "Hello"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory1.phpt b/ext/phar/tests/phar_buildfromdirectory1.phpt
new file mode 100644
index 0000000..63e06fa
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory1.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Phar::buildFromDirectory() - readonly
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+try {
+ ini_set('phar.readonly', 1);
+ $phar->buildFromDirectory(1);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%s(24) "UnexpectedValueException"
+Cannot write to archive - write operations restricted by INI setting
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory2-win.phpt b/ext/phar/tests/phar_buildfromdirectory2-win.phpt
new file mode 100644
index 0000000..9dbcf96
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory2-win.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar::buildFromDirectory() - non-directory passed as first parameter
+--SKIPIF--
+<?php
+ if (!extension_loaded("phar")) die("skip");
+ if (substr(PHP_OS, 0, 3) != "WIN") die("skip Windows only test");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+ $phar->buildFromDirectory(1);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%s(24) "UnexpectedValueException"
+RecursiveDirectoryIterator::__construct(1,1): The system cannot find the file specified. (code: 2)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory2.phpt b/ext/phar/tests/phar_buildfromdirectory2.phpt
new file mode 100644
index 0000000..639ff0b
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar::buildFromDirectory() - non-directory passed as first parameter
+--SKIPIF--
+<?php
+ if (!extension_loaded("phar")) die("skip");
+ if (substr(PHP_OS, 0, 3) == "WIN") die("skip not for Windows");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+ $phar->buildFromDirectory(1);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%s(24) "UnexpectedValueException"
+RecursiveDirectoryIterator::__construct(1): failed to open dir: No such file or directory
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory3.phpt b/ext/phar/tests/phar_buildfromdirectory3.phpt
new file mode 100644
index 0000000..2134cbd
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory3.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Phar::buildFromDirectory() - object passed as second parameter
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ $phar->buildFromDirectory('files', new stdClass);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Warning: Phar::buildFromDirectory() expects parameter 2 to be %string, object given in %sphar_buildfromdirectory3.php on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory4.phpt b/ext/phar/tests/phar_buildfromdirectory4.phpt
new file mode 100644
index 0000000..683ac4b
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory4.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar::buildFromDirectory(), directory exists
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+open_basedir=
+--FILE--
+<?php
+
+mkdir(dirname(__FILE__).'/testdir');
+foreach(range(1, 4) as $i) {
+ file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i");
+}
+
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+ $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir');
+ asort($a);
+ var_dump($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+
+var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar'));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+foreach(range(1, 4) as $i) {
+ unlink(dirname(__FILE__) . "/testdir/file$i.txt");
+}
+rmdir(dirname(__FILE__) . '/testdir');
+?>
+--EXPECTF--
+array(4) {
+ ["file1.txt"]=>
+ string(%d) "%stestdir%cfile1.txt"
+ ["file2.txt"]=>
+ string(%d) "%stestdir%cfile2.txt"
+ ["file3.txt"]=>
+ string(%d) "%stestdir%cfile3.txt"
+ ["file4.txt"]=>
+ string(%d) "%stestdir%cfile4.txt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory5.phpt b/ext/phar/tests/phar_buildfromdirectory5.phpt
new file mode 100644
index 0000000..51e5cec
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory5.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Phar::buildFromDirectory() with matching regex
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+mkdir(dirname(__FILE__).'/testdir');
+foreach(range(1, 4) as $i) {
+ file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i");
+}
+
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+ $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.txt/');
+ asort($a);
+ var_dump($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+
+var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar'));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+foreach(range(1, 4) as $i) {
+ unlink(dirname(__FILE__) . "/testdir/file$i.txt");
+}
+rmdir(dirname(__FILE__) . '/testdir');
+?>
+--EXPECTF--
+array(4) {
+ ["file1.txt"]=>
+ string(%d) "%stestdir%cfile1.txt"
+ ["file2.txt"]=>
+ string(%d) "%stestdir%cfile2.txt"
+ ["file3.txt"]=>
+ string(%d) "%stestdir%cfile3.txt"
+ ["file4.txt"]=>
+ string(%d) "%stestdir%cfile4.txt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromdirectory6.phpt b/ext/phar/tests/phar_buildfromdirectory6.phpt
new file mode 100644
index 0000000..99566c1
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromdirectory6.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Phar::buildFromDirectory() with non-matching regex
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+mkdir(dirname(__FILE__).'/testdir', 0777);
+foreach(range(1, 4) as $i) {
+ file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i");
+}
+
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar');
+ var_dump($phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php$/'));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+
+var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar'));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromdirectory.phar');
+foreach(range(1, 4) as $i) {
+ unlink(dirname(__FILE__) . "/testdir/file$i.txt");
+}
+rmdir(dirname(__FILE__) . '/testdir');
+?>
+--EXPECT--
+array(0) {
+}
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator1.phpt b/ext/phar/tests/phar_buildfromiterator1.phpt
new file mode 100644
index 0000000..238ede6
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator1.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Phar::buildFromIterator() readonly
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+try {
+ ini_set('phar.readonly', 1);
+ $phar->buildFromIterator(1);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%s(24) "UnexpectedValueException"
+Cannot write out phar archive, phar is read-only
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator10.phpt b/ext/phar/tests/phar_buildfromiterator10.phpt
new file mode 100644
index 0000000..024277e
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator10.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Phar::buildFromIterator() RegexIterator(RecursiveIteratorIterator), SplFileInfo as current
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ $dir = new RecursiveDirectoryIterator('.');
+ $iter = new RecursiveIteratorIterator($dir);
+ $a = $phar->buildFromIterator(new RegexIterator($iter, '/_\d{3}\.phpt$/'), dirname(__FILE__) . DIRECTORY_SEPARATOR);
+ asort($a);
+ var_dump($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+array(35) {
+ ["phar_ctx_001.phpt"]=>
+ string(%d) "%sphar_ctx_001.phpt"
+ ["phar_get_supported_signatures_001.phpt"]=>
+ string(%d) "%sphar_get_supported_signatures_001.phpt"
+ ["phar_get_supported_signatures_002.phpt"]=>
+ string(%d) "%sphar_get_supported_signatures_002.phpt"
+ ["phar_oo_001.phpt"]=>
+ string(%d) "%sphar_oo_001.phpt"
+ ["phar_oo_002.phpt"]=>
+ string(%d) "%sphar_oo_002.phpt"
+ ["phar_oo_003.phpt"]=>
+ string(%d) "%sphar_oo_003.phpt"
+ ["phar_oo_004.phpt"]=>
+ string(%d) "%sphar_oo_004.phpt"
+ ["phar_oo_005.phpt"]=>
+ string(%d) "%sphar_oo_005.phpt"
+ ["phar_oo_006.phpt"]=>
+ string(%d) "%sphar_oo_006.phpt"
+ ["phar_oo_007.phpt"]=>
+ string(%d) "%sphar_oo_007.phpt"
+ ["phar_oo_008.phpt"]=>
+ string(%d) "%sphar_oo_008.phpt"
+ ["phar_oo_009.phpt"]=>
+ string(%d) "%sphar_oo_009.phpt"
+ ["phar_oo_010.phpt"]=>
+ string(%d) "%sphar_oo_010.phpt"
+ ["phar_oo_011.phpt"]=>
+ string(%d) "%sphar_oo_011.phpt"
+ ["phar_oo_012.phpt"]=>
+ string(%d) "%sphar_oo_012.phpt"
+ ["phar_oo_compressed_001.phpt"]=>
+ string(%d) "%sphar_oo_compressed_001.phpt"
+ ["phar_oo_compressed_002.phpt"]=>
+ string(%d) "%sphar_oo_compressed_002.phpt"
+ ["phpinfo_001.phpt"]=>
+ string(%d) "%sphpinfo_001.phpt"
+ ["phpinfo_002.phpt"]=>
+ string(%d) "%sphpinfo_002.phpt"
+ ["phpinfo_003.phpt"]=>
+ string(%d) "%sphpinfo_003.phpt"
+ ["phpinfo_004.phpt"]=>
+ string(%d) "%sphpinfo_004.phpt"
+ ["tar/tar_001.phpt"]=>
+ string(%d) "%star%ctar_001.phpt"
+ ["tar/tar_002.phpt"]=>
+ string(%d) "%star%ctar_002.phpt"
+ ["tar/tar_003.phpt"]=>
+ string(%d) "%star%ctar_003.phpt"
+ ["tar/tar_004.phpt"]=>
+ string(%d) "%star%ctar_004.phpt"
+ ["zip/corrupt_001.phpt"]=>
+ string(%d) "%szip%ccorrupt_001.phpt"
+ ["zip/corrupt_002.phpt"]=>
+ string(%d) "%szip%ccorrupt_002.phpt"
+ ["zip/corrupt_003.phpt"]=>
+ string(%d) "%szip%ccorrupt_003.phpt"
+ ["zip/corrupt_004.phpt"]=>
+ string(%d) "%szip%ccorrupt_004.phpt"
+ ["zip/corrupt_005.phpt"]=>
+ string(%d) "%szip%ccorrupt_005.phpt"
+ ["zip/corrupt_006.phpt"]=>
+ string(%d) "%szip%ccorrupt_006.phpt"
+ ["zip/corrupt_007.phpt"]=>
+ string(%d) "%szip%ccorrupt_007.phpt"
+ ["zip/corrupt_008.phpt"]=>
+ string(%d) "%szip%ccorrupt_008.phpt"
+ ["zip/corrupt_009.phpt"]=>
+ string(%d) "%szip%ccorrupt_009.phpt"
+ ["zip/corrupt_010.phpt"]=>
+ string(%d) "%szip%ccorrupt_010.phpt"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator2.phpt b/ext/phar/tests/phar_buildfromiterator2.phpt
new file mode 100644
index 0000000..cdc2df1
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator2.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Phar::buildFromIterator() wrong object
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ $phar->buildFromIterator(new stdClass);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Warning: Phar::buildFromIterator() expects parameter 1 to be Traversable, object given in %sphar_buildfromiterator2.php on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator3.phpt b/ext/phar/tests/phar_buildfromiterator3.phpt
new file mode 100644
index 0000000..4a3bc7c
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator3.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Phar::buildFromIterator() iterator, but object passed
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ $phar->buildFromIterator(new myIterator(array()), new stdClass);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Warning: Phar::buildFromIterator() expects parameter 2 to be %string, object given in %sphar_buildfromiterator3.php on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator4.phpt b/ext/phar/tests/phar_buildfromiterator4.phpt
new file mode 100644
index 0000000..cd26138
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator4.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file passed in
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(
+ array(
+ 'a' => basename(__FILE__, 'php') . 'phpt',
+ // demonstrate that none of these are added
+ '.phar/stub.php' => basename(__FILE__, 'php') . 'phpt',
+ '.phar/alias.txt' => basename(__FILE__, 'php') . 'phpt',
+ '.phar/oops' => basename(__FILE__, 'php') . 'phpt',
+ ))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+current
+key
+next
+valid
+current
+key
+next
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "%sphar_buildfromiterator4.phpt"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt
new file mode 100644
index 0000000..8431c12
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator5.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar::buildFromIterator() iterator, iterator returns non-string
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid value (must return a string)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt
new file mode 100644
index 0000000..9c506c8
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator6.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, key is int
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid key (must return a string)
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator7.phpt b/ext/phar/tests/phar_buildfromiterator7.phpt
new file mode 100644
index 0000000..2bac4c8
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator7.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, file can't be opened
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned a file that could not be opened "phar_buildfromiterator7./oopsie/there.phpt"
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator8.phpt b/ext/phar/tests/phar_buildfromiterator8.phpt
new file mode 100644
index 0000000..bb1b780
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator8.phpt
@@ -0,0 +1,95 @@
+--TEST--
+Phar::buildFromIterator() RegexIterator(DirectoryIterator), SplFileInfo as current
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^\d{0,3}\.phpt\\z|^\.\\z|^\.\.\\z/'), dirname(__FILE__) . DIRECTORY_SEPARATOR);
+ asort($a);
+ var_dump($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+array(33) {
+ ["001.phpt"]=>
+ string(%d) "%s001.phpt"
+ ["002.phpt"]=>
+ string(%d) "%s002.phpt"
+ ["003.phpt"]=>
+ string(%d) "%s003.phpt"
+ ["004.phpt"]=>
+ string(%d) "%s004.phpt"
+ ["005.phpt"]=>
+ string(%d) "%s005.phpt"
+ ["006.phpt"]=>
+ string(%d) "%s006.phpt"
+ ["007.phpt"]=>
+ string(%d) "%s007.phpt"
+ ["008.phpt"]=>
+ string(%d) "%s008.phpt"
+ ["009.phpt"]=>
+ string(%d) "%s009.phpt"
+ ["010.phpt"]=>
+ string(%d) "%s010.phpt"
+ ["011.phpt"]=>
+ string(%d) "%s011.phpt"
+ ["012.phpt"]=>
+ string(%d) "%s012.phpt"
+ ["013.phpt"]=>
+ string(%d) "%s013.phpt"
+ ["014.phpt"]=>
+ string(%d) "%s014.phpt"
+ ["015.phpt"]=>
+ string(%d) "%s015.phpt"
+ ["016.phpt"]=>
+ string(%d) "%s016.phpt"
+ ["017.phpt"]=>
+ string(%d) "%s017.phpt"
+ ["018.phpt"]=>
+ string(%d) "%s018.phpt"
+ ["019.phpt"]=>
+ string(%d) "%s019.phpt"
+ ["020.phpt"]=>
+ string(%d) "%s020.phpt"
+ ["021.phpt"]=>
+ string(%d) "%s021.phpt"
+ ["022.phpt"]=>
+ string(%d) "%s022.phpt"
+ ["023.phpt"]=>
+ string(%d) "%s023.phpt"
+ ["024.phpt"]=>
+ string(%d) "%s024.phpt"
+ ["025.phpt"]=>
+ string(%d) "%s025.phpt"
+ ["026.phpt"]=>
+ string(%d) "%s026.phpt"
+ ["027.phpt"]=>
+ string(%d) "%s027.phpt"
+ ["028.phpt"]=>
+ string(%d) "%s028.phpt"
+ ["029.phpt"]=>
+ string(%d) "%s029.phpt"
+ ["030.phpt"]=>
+ string(%d) "%s030.phpt"
+ ["031.phpt"]=>
+ string(%d) "%s031.phpt"
+ ["032.phpt"]=>
+ string(%d) "%s032.phpt"
+ ["033.phpt"]=>
+ string(%d) "%s033.phpt"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_buildfromiterator9.phpt b/ext/phar/tests/phar_buildfromiterator9.phpt
new file mode 100644
index 0000000..0b56307
--- /dev/null
+++ b/ext/phar/tests/phar_buildfromiterator9.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file resource passed in
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r')))));
+ fclose($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "[stream]"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_bz2.phpt b/ext/phar/tests/phar_bz2.phpt
new file mode 100644
index 0000000..0e6e3ec
--- /dev/null
+++ b/ext/phar/tests/phar_bz2.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar: bzipped phar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/phar_bz2.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/phar_bz2.2.phar';
+$pname2 = 'phar://' . $fname2;
+
+$file = '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+__HALT_COMPILER();';
+
+$files = array();
+$files['tar_004.php'] = '<?php var_dump(__FILE__);';
+$files['internal/file/here'] = "hi there!\n";
+$files['internal/dir/'] = '';
+$files['dir/'] = '';
+$bz2 = true;
+
+include 'files/phar_test.inc';
+
+include $fname;
+
+$a = new Phar($fname);
+$a['test'] = 'hi';
+copy($fname, $fname2);
+$a->setAlias('another');
+$b = new Phar($fname2);
+var_dump($b->isFileFormat(Phar::PHAR));
+var_dump($b->isCompressed() == Phar::BZ2);
+// additional code coverage
+$b->isFileFormat(array());
+try {
+$b->isFileFormat(25);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/phar_bz2.phar');
+@unlink(dirname(__FILE__) . '/phar_bz2.2.phar');
+?>
+--EXPECTF--
+%unicode|string%(9) "it worked"
+%unicode|string%(%d) "phar://%sphar_bz2.phar/tar_004.php"
+bool(true)
+bool(true)
+
+Warning: Phar::isFileFormat() expects parameter 1 to be long, array given in %sphar_bz2.php on line %d
+Unknown file format specified
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt
new file mode 100644
index 0000000..8e36681
--- /dev/null
+++ b/ext/phar/tests/phar_commitwrite.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar::setStub()/stopBuffering()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
+$p['file1.txt'] = 'hi';
+$p->stopBuffering();
+var_dump(strlen($p->getStub()));
+$p->setStub("<?php
+function __autoload(\$class)
+{
+ include 'phar://' . str_replace('_', '/', \$class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER();
+?>");
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+int(6683)
+string(200) "<?php
+function __autoload($class)
+{
+ include 'phar://' . str_replace('_', '/', $class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/phar_construct_invalidurl.phpt b/ext/phar/tests/phar_construct_invalidurl.phpt
new file mode 100644
index 0000000..30a4687
--- /dev/null
+++ b/ext/phar/tests/phar_construct_invalidurl.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar object passed URL
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+ $a = new Phar('http://should.fail.com');
+} catch (UnexpectedValueException $e) {
+ echo $e->getMessage(),"\n";
+}
+try {
+ $a = new Phar('http://');
+} catch (UnexpectedValueException $e) {
+ echo $e->getMessage(),"\n";
+}
+try {
+ $a = new Phar('http:/');
+} catch (UnexpectedValueException $e) {
+ echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--EXPECT--
+Cannot create a phar archive from a URL like "http://should.fail.com". Phar objects can only be created from local files
+Cannot create a phar archive from a URL like "http://". Phar objects can only be created from local files
+Cannot create phar 'http:/', file extension (or combination) not recognised or the directory does not exist
+===DONE===
diff --git a/ext/phar/tests/phar_convert_again.phpt b/ext/phar/tests/phar_convert_again.phpt
new file mode 100644
index 0000000..bbf2c66
--- /dev/null
+++ b/ext/phar/tests/phar_convert_again.phpt
@@ -0,0 +1,205 @@
+--TEST--
+Phar::conversion to other formats
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.tbz';
+$pname = 'phar://' . $fname;
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+$zip = $phar->convertToData(Phar::ZIP);
+echo $zip->getPath() . "\n";
+$tgz = $phar->convertToData(Phar::TAR, Phar::GZ);
+echo $tgz->getPath() . "\n";
+$tbz = $phar->convertToData(Phar::TAR, Phar::BZ2);
+echo $tbz->getPath() . "\n";
+try {
+$phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+copy($tbz->getPath(), $fname2);
+$tbz = new PharData($fname2);
+$phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
+echo $phar->getPath() . "\n";
+$phar['a'] = 'hi';
+$phar['a']->setMetadata('hi');
+$zip = $phar->convertToExecutable(Phar::ZIP);
+echo $zip->getPath() . "\n";
+echo $zip['a']->getMetadata() . "\n";
+$data = $zip->convertToData();
+echo $data->getPath() . "\n";
+// extra code coverage
+try {
+$data->setStub('hi');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$data->setDefaultStub();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$data->setAlias('hi');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$tar = $phar->convertToExecutable(Phar::TAR);
+echo $tar->getPath() . "\n";
+$data = $tar->convertToData();
+echo $data->getPath() . "\n";
+$tgz = $tar->convertToExecutable(null, Phar::GZ);
+echo $tgz->getPath() . "\n";
+try {
+$tgz->convertToExecutable(25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToExecutable(Phar::ZIP, Phar::GZ);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToExecutable(Phar::ZIP, Phar::BZ2);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar->convertToData();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(Phar::PHAR);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(Phar::ZIP, Phar::GZ);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(Phar::ZIP, Phar::BZ2);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToExecutable(Phar::TAR, 25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(Phar::TAR, 25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+// extra code coverage
+try {
+$data->setStub('hi');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$data->setAlias('hi');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$data->setDefaultStub();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$tgz->convertToData(Phar::TAR, Phar::GZ, '.phar.tgz.oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+try {
+$phar->convertToExecutable(Phar::TAR, Phar::GZ, '.tgz.oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+try {
+$tgz->convertToData(Phar::TAR, Phar::GZ, '.phar/.tgz.oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.bz2');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.tbz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.tar.gz');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+%sphar_convert_again.zip
+%sphar_convert_again.tar.gz
+%sphar_convert_again.tar.bz2
+Unable to add newly converted phar "%sphar_convert_again.phar" to the list of phars, a phar with that name already exists
+%sphar_convert_again2.phar
+%sphar_convert_again2.phar.zip
+hi
+%sphar_convert_again2.zip
+A Phar stub cannot be set in a plain zip archive
+A Phar stub cannot be set in a plain zip archive
+A Phar alias cannot be set in a plain zip archive
+%sphar_convert_again2.phar.tar
+%sphar_convert_again2.tar
+%sphar_convert_again2.phar.tar.gz
+Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP
+Cannot compress entire archive with gzip, zip archives do not support whole-archive compression
+Cannot compress entire archive with bz2, zip archives do not support whole-archive compression
+Cannot write out data phar archive, use Phar::TAR or Phar::ZIP
+Cannot write out data phar archive, use Phar::TAR or Phar::ZIP
+Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP
+Cannot compress entire archive with gzip, zip archives do not support whole-archive compression
+Cannot compress entire archive with bz2, zip archives do not support whole-archive compression
+Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2
+Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2
+A Phar stub cannot be set in a plain tar archive
+A Phar alias cannot be set in a plain tar archive
+A Phar stub cannot be set in a plain tar archive
+data phar "%sphar_convert_again2.phar.tgz.oops" has invalid extension phar.tgz.oops
+phar "%sphar_convert_again2.tgz.oops" has invalid extension tgz.oops
+data phar "%sphar_convert_again2.phar/.tgz.oops" has invalid extension phar/.tgz.oops
+===DONE===
diff --git a/ext/phar/tests/phar_convert_repeated.phpt b/ext/phar/tests/phar_convert_repeated.phpt
new file mode 100644
index 0000000..e4b1fe4
--- /dev/null
+++ b/ext/phar/tests/phar_convert_repeated.phpt
@@ -0,0 +1,149 @@
+--TEST--
+Phar::convertToZip|Tar|Phar() repeated (phar_based archives)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+echo "=================== new Phar() =======================\n";
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToTar() =====================\n";
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToZip() =====================\n";
+
+$phar = $phar->convertToExecutable(Phar::ZIP);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToPhar() ====================\n";
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.2.phar');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump(strlen($phar->getStub()));
+var_dump($phar->getAlias());
+
+echo "================= convertToZip() =====================\n";
+
+$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '.2.phar.zip');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToTar() =====================\n";
+
+$phar = $phar->convertToExecutable(Phar::TAR, Phar::NONE, '2.phar.tar');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToZip() =====================\n";
+
+$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '3.phar.zip');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar');
+?>
+--EXPECTF--
+=================== new Phar() =======================
+bool(true)
+bool(false)
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(3) "hio"
+================= convertToTar() =====================
+bool(false)
+bool(true)
+bool(false)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+string(%d) "%sphar_convert_repeated.phar.tar"
+================= convertToZip() =====================
+bool(false)
+bool(false)
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+NULL
+================= convertToPhar() ====================
+bool(true)
+bool(false)
+bool(false)
+int(6683)
+NULL
+================= convertToZip() =====================
+bool(false)
+bool(false)
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+NULL
+================= convertToTar() =====================
+bool(false)
+bool(true)
+bool(false)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+NULL
+================= convertToZip() =====================
+bool(false)
+bool(false)
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+NULL
+===DONE===
diff --git a/ext/phar/tests/phar_convert_repeated_b.phpt b/ext/phar/tests/phar_convert_repeated_b.phpt
new file mode 100644
index 0000000..10e6973
--- /dev/null
+++ b/ext/phar/tests/phar_convert_repeated_b.phpt
@@ -0,0 +1,118 @@
+--TEST--
+PharData::convertToZip|Tar|Phar() repeated (phardata_based archives)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
+
+echo "=================== new PharData() ==================\n";
+$phar = new PharData($fname);
+$phar['a'] = 'a';
+$phar['b'] = 'b';
+$phar['c'] = 'c';
+
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToTar() =====================\n";
+
+$phar = $phar->convertToData(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToZip() =====================\n";
+
+$phar = $phar->convertToData(Phar::ZIP, Phar::NONE, '.1.zip');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToPhar() ====================\n";
+
+try {
+ $phar = $phar->convertToExecutable(Phar::PHAR);
+ var_dump($phar->isFileFormat(Phar::PHAR));
+ var_dump($phar->isFileFormat(Phar::TAR));
+ var_dump($phar->isFileFormat(Phar::ZIP));
+ var_dump(strlen($phar->getStub()));
+ var_dump($phar->getAlias());
+} catch(Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+echo "================ convertToTar(GZ) ====================\n";
+
+$phar = $phar->convertToData(Phar::TAR, Phar::GZ, '.2.tar');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+
+echo "================= convertToPhar() ====================\n";
+
+try {
+ $phar = $phar->convertToExecutable(Phar::PHAR);
+ var_dump($phar->isFileFormat(Phar::PHAR));
+ var_dump($phar->isFileFormat(Phar::TAR));
+ var_dump($phar->isFileFormat(Phar::ZIP));
+ var_dump(strlen($phar->getStub()));
+ var_dump($phar->getAlias());
+} catch(Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.zip');
+?>
+--EXPECT--
+=================== new PharData() ==================
+bool(false)
+bool(false)
+bool(true)
+string(0) ""
+NULL
+================= convertToTar() =====================
+bool(false)
+bool(true)
+bool(false)
+string(0) ""
+NULL
+================= convertToZip() =====================
+bool(false)
+bool(false)
+bool(true)
+string(0) ""
+NULL
+================= convertToPhar() ====================
+Cannot write out executable phar archive, phar is read-only
+================ convertToTar(GZ) ====================
+bool(false)
+bool(true)
+bool(false)
+string(0) ""
+NULL
+================= convertToPhar() ====================
+Cannot write out executable phar archive, phar is read-only
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_convert_tar.phpt b/ext/phar/tests/phar_convert_tar.phpt
new file mode 100644
index 0000000..d4031ec
--- /dev/null
+++ b/ext/phar/tests/phar_convert_tar.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar::convertToTar()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+copy($fname2, $fname3);
+
+$phar = new Phar($fname3);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/phar_convert_tar2.phpt b/ext/phar/tests/phar_convert_tar2.phpt
new file mode 100644
index 0000000..f0f0f69
--- /dev/null
+++ b/ext/phar/tests/phar_convert_tar2.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar::convertToTar() gzip compressed
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.gz';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed());
+var_dump($phar->getStub());
+
+$phar = $phar->convertToExecutable(Phar::TAR, Phar::GZ);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed());
+var_dump($phar->getStub());
+
+copy($fname2, $fname3);
+
+$phar = new Phar($fname3);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed() == Phar::GZ);
+var_dump($phar->getStub());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECT--
+bool(false)
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+int(4096)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/phar_convert_tar3.phpt b/ext/phar/tests/phar_convert_tar3.phpt
new file mode 100644
index 0000000..52fd0f5
--- /dev/null
+++ b/ext/phar/tests/phar_convert_tar3.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar::convertToTar() bz2 compressed
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed());
+var_dump($phar->getStub());
+
+$phar = $phar->convertToExecutable(Phar::TAR, Phar::BZ2);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed());
+var_dump($phar->getStub());
+
+copy($fname2 . '.bz2', $fname3);
+
+$phar = new Phar($fname3);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->isCompressed() == Phar::BZ2);
+var_dump($phar->getStub());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.bz2');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+int(8192)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/phar_convert_zip.phpt b/ext/phar/tests/phar_convert_zip.phpt
new file mode 100644
index 0000000..734551e
--- /dev/null
+++ b/ext/phar/tests/phar_convert_zip.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Phar::convertToZip()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+
+$phar = $phar->convertToExecutable(Phar::ZIP);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+
+copy($fname2, $fname3);
+
+$phar = new Phar($fname3);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/phar_copy.phpt b/ext/phar/tests/phar_copy.phpt
new file mode 100644
index 0000000..382b7f0
--- /dev/null
+++ b/ext/phar/tests/phar_copy.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Phar: copy()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.php';
+
+$pname = 'phar://'.$fname;
+$iname = '/file.txt';
+$ename = '/error/..';
+
+$p = new Phar($fname);
+
+try
+{
+ $p['a'] = 'hi';
+ $p->startBuffering();
+ $p->copy('a', 'b');
+ echo file_get_contents($p['b']->getPathName());
+ $p['a']->compress(Phar::GZ);
+ $p['b']->setMetadata('a');
+ $p->copy('b', 'c');
+ $p->stopBuffering();
+ echo file_get_contents($p['c']->getPathName());
+ copy($fname, $fname2);
+ $p->copy('a', $ename);
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly',1);
+$p2 = new Phar($fname2);
+echo "\n";
+echo 'a: ' , file_get_contents($p2['a']->getPathName());
+echo 'b: ' ,file_get_contents($p2['b']->getPathName());
+echo 'c: ' ,file_get_contents($p2['c']->getPathName()), $p2['c']->getMetaData(), "\n";
+ini_set('phar.readonly', 0);
+try {
+$p2->copy('notexisting', 'another');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$p2->copy('a', 'b');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$p2['a']->compress(Phar::GZ);
+$p2->copy('a', 'd');
+echo $p2['d']->getContent() . "\n";
+try {
+$p2->copy('d', '.phar/stub.php');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+$p2->copy('.phar/stub.php', 'd');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?>
+--EXPECTF--
+hihifile "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s
+
+a: hib: hic: hia
+file "notexisting" cannot be copied to file "another", file does not exist in %sphar_copy2.phar.php
+file "a" cannot be copied to file "b", file must not already exist in phar %sphar_copy2.phar.php
+hi
+file "d" cannot be copied to file ".phar/stub.php", cannot copy to Phar meta-file in %sphar_copy2.phar.php
+file ".phar/stub.php" cannot be copied to file "d", cannot copy Phar meta-file in %sphar_copy2.phar.php
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt
new file mode 100644
index 0000000..1828fe7
--- /dev/null
+++ b/ext/phar/tests/phar_create_in_cwd.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: attempt to create a Phar with relative path
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+try {
+ $p = new Phar('brandnewphar.phar');
+ $p['file1.txt'] = 'hi';
+ var_dump(strlen($p->getStub()));
+ $p->setStub("<?php
+function __autoload(\$class)
+{
+ include 'phar://' . str_replace('_', '/', \$class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER();
+?>");
+ var_dump($p->getStub());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar');
+?>
+--EXPECT--
+int(6683)
+string(200) "<?php
+function __autoload($class)
+{
+ include 'phar://' . str_replace('_', '/', $class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/phar_createdefaultstub.phpt b/ext/phar/tests/phar_createdefaultstub.phpt
new file mode 100644
index 0000000..abc9ad8
--- /dev/null
+++ b/ext/phar/tests/phar_createdefaultstub.phpt
@@ -0,0 +1,929 @@
+--TEST--
+Phar: Phar::createDefaultStub() with and without arg
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+var_dump(Phar::createDefaultStub());
+echo "============================================================================\n";
+echo "============================================================================\n";
+var_dump(Phar::createDefaultStub('my/custom/thingy.php'));
+echo "============================================================================\n";
+echo "============================================================================\n";
+var_dump(strlen(Phar::createDefaultStub(str_repeat('a', 400))));
+echo "============================================================================\n";
+echo "============================================================================\n";
+var_dump(Phar::createDefaultStub(str_repeat('a', 401)));
+} catch(Exception $e) {
+echo $e->getMessage() . "\n";
+}
+echo "============================================================================\n";
+echo "============================================================================\n";
+echo "============================================================================\n";
+echo "============================================================================\n";
+try {
+var_dump(Phar::createDefaultStub('my/custom/thingy.php', 'the/web.php'));
+echo "============================================================================\n";
+echo "============================================================================\n";
+var_dump(strlen(Phar::createDefaultStub('index.php', str_repeat('a', 400))));
+var_dump(Phar::createDefaultStub('hio', str_repeat('a', 401)));
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECT--
+string(6683) "<?php
+
+$web = 'index.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'index.php';
+const LEN = 6685;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>"
+============================================================================
+============================================================================
+string(6694) "<?php
+
+$web = 'index.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'my/custom/thingy.php';
+const LEN = 6696;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>"
+============================================================================
+============================================================================
+int(7074)
+============================================================================
+============================================================================
+Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
+============================================================================
+============================================================================
+============================================================================
+============================================================================
+string(6696) "<?php
+
+$web = 'the/web.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'my/custom/thingy.php';
+const LEN = 6698;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>"
+============================================================================
+============================================================================
+int(7074)
+Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
+===DONE===
diff --git a/ext/phar/tests/phar_ctx_001.phpt b/ext/phar/tests/phar_ctx_001.phpt
new file mode 100644
index 0000000..72edc5a
--- /dev/null
+++ b/ext/phar/tests/phar_ctx_001.phpt
@@ -0,0 +1,100 @@
+--TEST--
+Phar context
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3))));
+$context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
+
+file_put_contents($pname . '/a', b'new a', 0); // no compression
+file_put_contents($pname . '/b', b'new b', 0, $context);
+file_put_contents($pname . '/d', b'new d', 0, $context2);
+
+$phar = new Phar($fname);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump($phar['a']->getMetaData());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump($phar['b']->getMetaData());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+var_dump($phar['c']->getMetaData());
+var_dump(file_get_contents($pname . '/d'));
+var_dump($phar['d']->isCompressed());
+var_dump($phar['d']->getMetaData());
+$context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
+$fp = fopen($pname . '/b', 'r+', 0, $context2);
+fclose($fp);
+?>
+==AFTER==
+<?php
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump($phar['b']->getMetaData());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECT--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(5) "new a"
+bool(false)
+NULL
+string(5) "new b"
+bool(true)
+array(2) {
+ [0]=>
+ int(2)
+ ["hi"]=>
+ int(3)
+}
+string(1) "c"
+bool(false)
+NULL
+string(5) "new d"
+bool(false)
+array(1) {
+ [0]=>
+ int(4)
+}
+==AFTER==
+string(5) "new b"
+bool(true)
+array(1) {
+ [0]=>
+ int(4)
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_decompress.phpt b/ext/phar/tests/phar_decompress.phpt
new file mode 100644
index 0000000..abf385a
--- /dev/null
+++ b/ext/phar/tests/phar_decompress.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Phar::decompress()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.gz';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+$gz = $phar->compress(Phar::GZ);
+copy($gz->getPath(), $fname2);
+$a = new Phar($fname2);
+var_dump($a->isCompressed());
+$unc = $a->compress(Phar::NONE);
+echo $unc->getPath() . "\n";
+$unc2 = $gz->decompress();
+echo $unc2->getPath() . "\n";
+$unc3 = $gz->decompress('hooba.phar');
+echo $unc3->getPath() . "\n";
+$gz->decompress(array());
+$zip = $phar->convertToData(Phar::ZIP);
+ini_set('phar.readonly', 1);
+try {
+$gz->decompress();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$zip->decompress();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.hooba.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+?>
+--EXPECTF--
+int(4096)
+%sphar_decompress2.phar
+%sphar_decompress.phar
+%sphar_decompress.hooba.phar
+
+Warning: Phar::decompress() expects parameter 1 to be %string, array given in %sphar_decompress.php on line %d
+Cannot decompress phar archive, phar is read-only
+Cannot decompress zip-based archives with whole-archive compression
+===DONE===
diff --git a/ext/phar/tests/phar_dir_iterate.phpt b/ext/phar/tests/phar_dir_iterate.phpt
new file mode 100644
index 0000000..04968f2
--- /dev/null
+++ b/ext/phar/tests/phar_dir_iterate.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar object: iterate test with sub-directories and RecursiveIteratorIterator
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+
+$phar = new Phar($fname);
+$phar['top.txt'] = 'hi';
+$phar['sub/top.txt'] = 'there';
+$phar['another.file.txt'] = 'wowee';
+$newphar = new Phar($fname);
+foreach (new RecursiveIteratorIterator($newphar) as $path => $obj) {
+ var_dump($obj->getPathName());
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+string(%d) "phar://%sphar_dir_iterate.phar.php%canother.file.txt"
+string(%d) "phar://%sphar_dir_iterate.phar.php/sub%ctop.txt"
+string(%d) "phar://%sphar_dir_iterate.phar.php%ctop.txt"
+===DONE===
diff --git a/ext/phar/tests/phar_dotted_path.phpt b/ext/phar/tests/phar_dotted_path.phpt
new file mode 100644
index 0000000..f6d626e
--- /dev/null
+++ b/ext/phar/tests/phar_dotted_path.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Phar: create new Phar with broken.dirname in path
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+default_charset=
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$dir = dirname(__FILE__) . '/broken.dirname';
+mkdir($dir, 0777);
+
+$fname = $dir . '/dotted_path.phar';
+$stub = Phar::createDefaultStub();
+$file = $stub;
+
+$files = array();
+$files['a'] = 'this is a';
+$files['b'] = 'this is b';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+foreach ($phar as $entry) {
+ echo file_get_contents($entry)."\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/broken.dirname/dotted_path.phar');
+rmdir(dirname(__FILE__) . '/broken.dirname');
+?>
+--EXPECT--
+this is a
+this is b
+===DONE===
diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt
new file mode 100644
index 0000000..01d65f9
--- /dev/null
+++ b/ext/phar/tests/phar_extract.phpt
@@ -0,0 +1,150 @@
+--TEST--
+Phar: Phar::extractTo()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
+$pname = 'phar://' . $fname;
+
+$a = new Phar($fname);
+$a['file1.txt'] = 'hi';
+$a['file2.txt'] = 'hi2';
+$a['subdir/ectory/file.txt'] = 'hi3';
+$a->mount($pname . '/mount', __FILE__);
+$a->addEmptyDir('one/level');
+
+$a->extractTo(dirname(__FILE__) . '/extract', 'mount');
+$a->extractTo(dirname(__FILE__) . '/extract');
+
+$out = array();
+
+foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) {
+ $out[] = $p;
+}
+
+sort($out);
+
+foreach ($out as $b) {
+ echo "$b\n";
+}
+
+$a->extractTo(dirname(__FILE__) . '/extract1', 'file1.txt');
+var_dump(file_get_contents(dirname(__FILE__) . '/extract1/file1.txt'));
+
+$a->extractTo(dirname(__FILE__) . '/extract1', 'subdir/ectory/file.txt');
+var_dump(file_get_contents(dirname(__FILE__) . '/extract1/subdir/ectory/file.txt'));
+
+$a->extractTo(dirname(__FILE__) . '/extract2', array('file2.txt', 'one/level'));
+var_dump(file_get_contents(dirname(__FILE__) . '/extract2/file2.txt'));
+var_dump(is_dir(dirname(__FILE__) . '/extract2/one/level'));
+
+try {
+ $a->extractTo(dirname(__FILE__) . '/whatever', 134);
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$a->extractTo(array());
+
+try {
+ $a->extractTo('');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+file_put_contents(dirname(__FILE__) . '/oops', 'I is file');
+
+try {
+ $a->extractTo(dirname(__FILE__) . '/oops', 'file1.txt');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ $a->extractTo(dirname(__FILE__) . '/oops1', array(array(), 'file1.txt'));
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ $a->extractTo(dirname(__FILE__) . '/extract', 'file1.txt');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+file_put_contents(dirname(__FILE__) . '/extract/file1.txt', 'first');
+var_dump(file_get_contents(dirname(__FILE__) . '/extract/file1.txt'));
+
+$a->extractTo(dirname(__FILE__) . '/extract', 'file1.txt', true);
+var_dump(file_get_contents(dirname(__FILE__) . '/extract/file1.txt'));
+
+try {
+ $a->extractTo(str_repeat('a', 20000), 'file1.txt');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$a[str_repeat('a', 20000)] = 'long';
+
+try {
+ $a->extractTo(dirname(__FILE__) . '/extract', str_repeat('a', 20000));
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@rmdir(dirname(__FILE__) . '/whatever');
+@unlink(dirname(__FILE__) . '/oops');
+@rmdir(dirname(__FILE__) . '/oops1');
+@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
+$e = dirname(__FILE__) . '/extract/';
+@unlink($e . 'file1.txt');
+@unlink($e . 'file2.txt');
+@unlink($e . 'subdir/ectory/file.txt');
+@rmdir($e . 'subdir/ectory');
+@rmdir($e . 'subdir');
+@rmdir($e . 'one/level');
+@rmdir($e . 'one');
+@rmdir($e);
+$e = dirname(__FILE__) . '/extract1/';
+@unlink($e . 'file1.txt');
+@unlink($e . 'subdir/ectory/file.txt');
+@rmdir($e . 'subdir/ectory');
+@rmdir($e . 'subdir');
+@rmdir($e);
+$e = dirname(__FILE__) . '/extract2/';
+@unlink($e . 'file2.txt');
+@rmdir($e . 'one/level');
+@rmdir($e . 'one');
+@rmdir($e);
+?>
+--EXPECTF--
+%sextract%cfile1.txt
+%sextract%cfile2.txt
+%sextract%cone
+%sextract%csubdir
+%sextract%csubdir%cectory
+%sextract%csubdir%cectory%cfile.txt
+string(2) "hi"
+string(3) "hi3"
+string(3) "hi2"
+bool(false)
+Invalid argument, expected a filename (string) or array of filenames
+
+Warning: Phar::extractTo() expects parameter 1 to be %string, array given in %sphar_extract.php on line %d
+Invalid argument, extraction path must be non-zero length
+Unable to use path "%soops" for extraction, it is a file, must be a directory
+Invalid argument, array of filenames to extract contains non-string value
+Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "file1.txt" to "%sextract/file1.txt", path already exists
+string(5) "first"
+string(2) "hi"
+Cannot extract to "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...", destination directory is too long for filesystem
+Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." to "%s...", extracted filename is too long for filesystem
+===DONE===
diff --git a/ext/phar/tests/phar_extract2.phpt b/ext/phar/tests/phar_extract2.phpt
new file mode 100644
index 0000000..cac509f
--- /dev/null
+++ b/ext/phar/tests/phar_extract2.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar: Phar::extractTo() - .phar safety
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/tempmanifest2.phar.php';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setDefaultStub();
+$phar->setAlias('fred');
+$phar['file1.txt'] = 'hi';
+$phar['file2.txt'] = 'hi2';
+$phar['subdir/ectory/file.txt'] = 'hi3';
+$phar->mount($pname . '/mount', __FILE__);
+$phar->addEmptyDir('one/level');
+
+$phar->extractTo(dirname(__FILE__) . '/extract', 'mount');
+$phar->extractTo(dirname(__FILE__) . '/extract');
+$out = array();
+
+foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) {
+ $extracted[] = $path;
+}
+
+sort($extracted);
+
+foreach ($extracted as $out) {
+ echo "$out\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tempmanifest2.phar.php');
+$dir = dirname(__FILE__) . '/extract/';
+@unlink($dir . 'file1.txt');
+@unlink($dir . 'file2.txt');
+@unlink($dir . 'subdir/ectory/file.txt');
+@rmdir($dir . 'subdir/ectory');
+@rmdir($dir . 'subdir');
+@rmdir($dir . 'one/level');
+@rmdir($dir . 'one');
+@rmdir($dir);
+$dir = dirname(__FILE__) . '/extract1/';
+@rmdir($dir);
+?>
+--EXPECTF--
+%sextract%cfile1.txt
+%sextract%cfile2.txt
+%sextract%cone
+%sextract%csubdir
+%sextract%csubdir%cectory
+%sextract%csubdir%cectory%cfile.txt
+===DONE===
diff --git a/ext/phar/tests/phar_extract3.phpt b/ext/phar/tests/phar_extract3.phpt
new file mode 100644
index 0000000..df85211
--- /dev/null
+++ b/ext/phar/tests/phar_extract3.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: Phar::extractTo() - check that phar exists
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/files/bogus.zip';
+$fname2 = dirname(__FILE__) . '/files/notbogus.zip';
+$extract = dirname(__FILE__) . '/test';
+
+$phar = new PharData($fname);
+
+try {
+ $phar->extractTo($extract);
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$phar = new PharData($fname2);
+foreach ($phar as $filename) {
+ echo "$filename\n";
+}
+
+try {
+ $phar->extractTo($extract);
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir = dirname(__FILE__) . '/test/';
+@unlink($dir . 'stuff.txt');
+@unlink($dir . 'nonsense.txt');
+@rmdir($dir);
+?>
+--EXPECTF--
+Invalid argument, %sfiles/bogus.zip cannot be found
+phar://%sfiles/notbogus.zip%cnonsense.txt
+phar://%sfiles/notbogus.zip%cstuff.txt
+===DONE===
diff --git a/ext/phar/tests/phar_get_supported_signatures_001.phpt b/ext/phar/tests/phar_get_supported_signatures_001.phpt
new file mode 100644
index 0000000..64874f6
--- /dev/null
+++ b/ext/phar/tests/phar_get_supported_signatures_001.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Phar::getSupportedSignatures()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (extension_loaded("hash")) die("skip extension hash conflicts");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedSignatures());
+?>
+===DONE===
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(3) "MD5"
+ [1]=>
+ string(5) "SHA-1"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_get_supported_signatures_001a.phpt b/ext/phar/tests/phar_get_supported_signatures_001a.phpt
new file mode 100644
index 0000000..ad929df
--- /dev/null
+++ b/ext/phar/tests/phar_get_supported_signatures_001a.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Phar::getSupportedSignatures()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (extension_loaded("hash")) die("skip extension hash conflicts");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedSignatures());
+?>
+===DONE===
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ string(3) "MD5"
+ [1]=>
+ string(5) "SHA-1"
+ [2]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_get_supported_signatures_002.phpt b/ext/phar/tests/phar_get_supported_signatures_002.phpt
new file mode 100644
index 0000000..3c5cf7f
--- /dev/null
+++ b/ext/phar/tests/phar_get_supported_signatures_002.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar::getSupportedSignatures()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedSignatures());
+?>
+===DONE===
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ string(3) "MD5"
+ [1]=>
+ string(5) "SHA-1"
+ [2]=>
+ string(7) "SHA-256"
+ [3]=>
+ string(7) "SHA-512"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_get_supported_signatures_002a.phpt b/ext/phar/tests/phar_get_supported_signatures_002a.phpt
new file mode 100644
index 0000000..32437a3
--- /dev/null
+++ b/ext/phar/tests/phar_get_supported_signatures_002a.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar::getSupportedSignatures()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedSignatures());
+?>
+===DONE===
+--EXPECT--
+array(5) {
+ [0]=>
+ string(3) "MD5"
+ [1]=>
+ string(5) "SHA-1"
+ [2]=>
+ string(7) "SHA-256"
+ [3]=>
+ string(7) "SHA-512"
+ [4]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_get_supportedcomp1.phpt b/ext/phar/tests/phar_get_supportedcomp1.phpt
new file mode 100644
index 0000000..d32e12c
--- /dev/null
+++ b/ext/phar/tests/phar_get_supportedcomp1.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar::getSupportedCompression() (bz2 and zlib)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedCompression());
+?>
+===DONE===
+--EXPECT--
+array(2) {
+ [0]=>
+ string(2) "GZ"
+ [1]=>
+ string(5) "BZIP2"
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_get_supportedcomp2.phpt b/ext/phar/tests/phar_get_supportedcomp2.phpt
new file mode 100644
index 0000000..c607724
--- /dev/null
+++ b/ext/phar/tests/phar_get_supportedcomp2.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar::getSupportedCompression() (bz2 only)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not available"); ?>
+<?php if (extension_loaded("zlib")) die("skip zlib is available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedCompression());
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ [0]=>
+ string(5) "BZIP2"
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_get_supportedcomp3.phpt b/ext/phar/tests/phar_get_supportedcomp3.phpt
new file mode 100644
index 0000000..c300407
--- /dev/null
+++ b/ext/phar/tests/phar_get_supportedcomp3.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar::getSupportedCompression() (zlib only)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (extension_loaded("bz2")) die("skip bz2 is available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+var_dump(Phar::getSupportedCompression());
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ [0]=>
+ string(2) "GZ"
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_get_supportedcomp4.phpt b/ext/phar/tests/phar_get_supportedcomp4.phpt
new file mode 100644
index 0000000..fba2c71
--- /dev/null
+++ b/ext/phar/tests/phar_get_supportedcomp4.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar::getSupportedCompression() (none)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (extension_loaded("bz2")) die("skip bz2 is available"); ?>
+<?php if (extension_loaded("zlib")) die("skip zlib is available"); ?>
+--FILE--
+<?php
+var_dump(Phar::getSupportedCompression());
+?>
+===DONE===
+--EXPECT--
+array(0) {
+}
+===DONE===
diff --git a/ext/phar/tests/phar_gobyebye-win32.phpt b/ext/phar/tests/phar_gobyebye-win32.phpt
new file mode 100644
index 0000000..43c8c77
--- /dev/null
+++ b/ext/phar/tests/phar_gobyebye-win32.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");
+if (strpos(PHP_OS, 'WIN') === false) die("skip Extra warning on Windows.");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.php';
+$pname = 'phar://' . $fname;
+file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
+file_put_contents($pname . '/foo/hi', '<?php
+include "' . addslashes($fname2) . '";
+readfile("foo/hi");
+fopen("foo/hi", "r");
+echo file_get_contents("foo/hi");
+var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
+opendir("foo/hi");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
+--EXPECTF--
+Warning: readfile(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: fopen(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: file_get_contents(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: opendir(foo/hi,foo/hi): The system cannot find the path specified. (code: 3) in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+
+Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_gobyebye.phpt b/ext/phar/tests/phar_gobyebye.phpt
new file mode 100644
index 0000000..93e153b
--- /dev/null
+++ b/ext/phar/tests/phar_gobyebye.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
+--SKIPIF--
+<?php
+if (defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip");
+if (!extension_loaded("phar")) die("skip");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.php';
+$pname = 'phar://' . $fname;
+file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
+file_put_contents($pname . '/foo/hi', '<?php
+include "' . addslashes($fname2) . '";
+readfile("foo/hi");
+fopen("foo/hi", "r");
+echo file_get_contents("foo/hi");
+var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
+opendir("foo/hi");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
+--EXPECTF--
+Warning: readfile(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
+
+Warning: fopen(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
+
+Warning: file_get_contents(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
+
+Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
+===DONE===
diff --git a/ext/phar/tests/phar_gzip.phpt b/ext/phar/tests/phar_gzip.phpt
new file mode 100644
index 0000000..c722834
--- /dev/null
+++ b/ext/phar/tests/phar_gzip.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar: gzipped phar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/phar_gzip.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/phar_gzip.2.phar';
+$pname2 = 'phar://' . $fname2;
+
+$file = '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+__HALT_COMPILER();';
+
+$files = array();
+$files['tar_004.php'] = '<?php var_dump(__FILE__);';
+$files['internal/file/here'] = "hi there!\n";
+$files['internal/dir/'] = '';
+$files['dir/'] = '';
+$gzip = true;
+
+include 'files/phar_test.inc';
+
+include $fname;
+
+$a = new Phar($fname);
+$a['test'] = 'hi';
+copy($fname, $fname2);
+$a->setAlias('another');
+$b = new Phar($fname2);
+var_dump($b->isFileFormat(Phar::PHAR));
+var_dump($b->isCompressed() == Phar::GZ);
+$a = stat($pname . '/test');
+$b = stat($pname2 . '/test');
+if ($a['mtime'] != $b['mtime']) {
+ echo "timestamp changed, was $a[mtime], now $b[mtime]!\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/phar_gzip.phar');
+@unlink(dirname(__FILE__) . '/phar_gzip.2.phar');
+?>
+--EXPECTF--
+string(9) "it worked"
+string(%d) "phar://%sphar_gzip.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_gzipU.phpt b/ext/phar/tests/phar_gzipU.phpt
new file mode 100644
index 0000000..662f862
--- /dev/null
+++ b/ext/phar/tests/phar_gzipU.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: gzipped phar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/phar_gzip.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/phar_gzip.2.phar';
+$pname2 = 'phar://' . $fname2;
+
+$file = '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+__HALT_COMPILER();';
+
+$files = array();
+$files['tar_004.php'] = '<?php var_dump(__FILE__);';
+$files['internal/file/here'] = "hi there!\n";
+$files['internal/dir/'] = '';
+$files['dir/'] = '';
+$gzip = true;
+
+include 'files/phar_test.inc';
+
+include $fname;
+
+$a = new Phar($fname);
+$a['test'] = 'hi';
+copy($fname, $fname2);
+$a->setAlias('another');
+$b = new Phar($fname2);
+var_dump($b->isFileFormat(Phar::PHAR));
+var_dump($b->isCompressed() == Phar::GZ);
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/phar_gzip.phar');
+@unlink(dirname(__FILE__) . '/phar_gzip.2.phar');
+?>
+--EXPECTF--
+unicode(9) "it worked"
+unicode(%d) "phar://%sphar_gzip.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_isvalidpharfilename.phpt b/ext/phar/tests/phar_isvalidpharfilename.phpt
new file mode 100644
index 0000000..dee9b7d
--- /dev/null
+++ b/ext/phar/tests/phar_isvalidpharfilename.phpt
@@ -0,0 +1,140 @@
+--TEST--
+Phar: Phar::isValidPharFilename()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.readonly=1
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+Phar::isValidPharFilename(array());
+echo "*\n";
+var_dump(Phar::isValidPharFilename('*'));
+var_dump(Phar::isValidPharFilename('*', true));
+var_dump(Phar::isValidPharFilename('*', false));
+
+echo "\nboo.phar\n";
+var_dump(Phar::isValidPharFilename('boo.phar'));
+var_dump(Phar::isValidPharFilename('boo.phar', true));
+var_dump(Phar::isValidPharFilename('boo.phar', false));
+
+echo "\nboo.tar\n";
+var_dump(Phar::isValidPharFilename('boo.tar'));
+var_dump(Phar::isValidPharFilename('boo.tar', true));
+var_dump(Phar::isValidPharFilename('boo.tar', false));
+
+echo "\nboo.phar.tar\n";
+var_dump(Phar::isValidPharFilename('boo.phar.tar'));
+var_dump(Phar::isValidPharFilename('boo.phar.tar', true));
+var_dump(Phar::isValidPharFilename('boo.phar.tar', false));
+
+mkdir(dirname(__FILE__) . '/.phar');
+
+echo "\n.phar/boo.tar\n";
+var_dump(Phar::isValidPharFilename('.phar/boo.tar'));
+var_dump(Phar::isValidPharFilename('.phar/boo.tar', true));
+var_dump(Phar::isValidPharFilename('.phar/boo.tar', false));
+
+echo "\n.phar.tar\n";
+var_dump(Phar::isValidPharFilename('.phar.tar'));
+var_dump(Phar::isValidPharFilename('.phar.tar', true));
+var_dump(Phar::isValidPharFilename('.phar.tar', false));
+
+echo "\n.phar.phar\n";
+var_dump(Phar::isValidPharFilename('.phar.phar'));
+var_dump(Phar::isValidPharFilename('.phar.phar', true));
+var_dump(Phar::isValidPharFilename('.phar.phar', false));
+
+echo "\n.phar.phart\n";
+var_dump(Phar::isValidPharFilename('.phar.phart'));
+var_dump(Phar::isValidPharFilename('.phar.phart', true));
+var_dump(Phar::isValidPharFilename('.phar.phart', false));
+
+echo "\nmy.pharmy\n";
+var_dump(Phar::isValidPharFilename('my.pharmy'));
+var_dump(Phar::isValidPharFilename('my.pharmy', true));
+var_dump(Phar::isValidPharFilename('my.pharmy', false));
+
+echo "\nphar.zip\n";
+var_dump(Phar::isValidPharFilename('phar.zip'));
+var_dump(Phar::isValidPharFilename('phar.zip', true));
+var_dump(Phar::isValidPharFilename('phar.zip', false));
+
+echo "\nphar.zip.phar\n";
+var_dump(Phar::isValidPharFilename('phar.zip.phar'));
+var_dump(Phar::isValidPharFilename('phar.zip.phar', true));
+var_dump(Phar::isValidPharFilename('phar.zip.phar', false));
+
+echo "\ndir.phar.php\n";
+var_dump(Phar::isValidPharFilename('dir.phar.php'));
+var_dump(Phar::isValidPharFilename('dir.phar.php', true));
+var_dump(Phar::isValidPharFilename('dir.phar.php', false));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__) . '/.phar');
+--EXPECTF--
+Warning: Phar::isValidPharFilename() expects parameter 1 to be %string, array given in %sphar_isvalidpharfilename.php on line %d
+*
+bool(false)
+bool(false)
+bool(false)
+
+boo.phar
+bool(true)
+bool(true)
+bool(false)
+
+boo.tar
+bool(false)
+bool(false)
+bool(true)
+
+boo.phar.tar
+bool(true)
+bool(true)
+bool(false)
+
+.phar/boo.tar
+bool(false)
+bool(false)
+bool(true)
+
+.phar.tar
+bool(false)
+bool(false)
+bool(true)
+
+.phar.phar
+bool(true)
+bool(true)
+bool(false)
+
+.phar.phart
+bool(false)
+bool(false)
+bool(true)
+
+my.pharmy
+bool(false)
+bool(false)
+bool(true)
+
+phar.zip
+bool(false)
+bool(false)
+bool(true)
+
+phar.zip.phar
+bool(true)
+bool(true)
+bool(false)
+
+dir.phar.php
+bool(true)
+bool(true)
+bool(false)
+===DONE===
+
diff --git a/ext/phar/tests/phar_magic.phpt b/ext/phar/tests/phar_magic.phpt
new file mode 100644
index 0000000..7c60589
--- /dev/null
+++ b/ext/phar/tests/phar_magic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: include/fopen magic
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$p = new Phar($fname);
+$p['a'] = '<?php include "b/c.php";' . "\n";
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub('<?php
+set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
+include "phar://" . __FILE__ . "/a";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/phar_metadata_read.phpt b/ext/phar/tests/phar_metadata_read.phpt
new file mode 100644
index 0000000..2d6586d
--- /dev/null
+++ b/ext/phar/tests/phar_metadata_read.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Phar with metadata (read)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+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();
+$pmeta = 'hi there';
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+var_dump($phar->hasMetaData());
+var_dump($phar->getMetaData());
+var_dump($phar->delMetaData());
+var_dump($phar->getMetaData());
+var_dump($phar->delMetaData());
+var_dump($phar->getMetaData());
+foreach($files as $name => $cont) {
+ echo " meta $name\n";
+ var_dump($phar[$name]->hasMetadata());
+ var_dump($phar[$name]->getMetadata());
+ var_dump($phar[$name]->delMetadata());
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+bool(true)
+string(8) "hi there"
+bool(true)
+NULL
+bool(true)
+NULL
+ meta a
+bool(false)
+NULL
+bool(true)
+NULL
+ meta b
+bool(false)
+NULL
+bool(true)
+NULL
+ meta c
+bool(true)
+array(2) {
+ [0]=>
+ string(2) "hi"
+ [1]=>
+ string(5) "there"
+}
+bool(true)
+NULL
+ meta d
+bool(true)
+array(2) {
+ ["hi"]=>
+ string(5) "there"
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+NULL
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/phar_metadata_readU.phpt b/ext/phar/tests/phar_metadata_readU.phpt
new file mode 100644
index 0000000..281e978
--- /dev/null
+++ b/ext/phar/tests/phar_metadata_readU.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Phar with metadata (read)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+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();
+$pmeta = 'hi there';
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+var_dump($phar->hasMetaData());
+var_dump($phar->getMetaData());
+var_dump($phar->delMetaData());
+var_dump($phar->getMetaData());
+var_dump($phar->delMetaData());
+var_dump($phar->getMetaData());
+foreach($files as $name => $cont) {
+ echo " meta $name\n";
+ var_dump($phar[$name]->hasMetadata());
+ var_dump($phar[$name]->getMetadata());
+ var_dump($phar[$name]->delMetadata());
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+bool(true)
+unicode(8) "hi there"
+bool(true)
+NULL
+bool(true)
+NULL
+ meta a
+bool(false)
+NULL
+bool(true)
+NULL
+ meta b
+bool(false)
+NULL
+bool(true)
+NULL
+ meta c
+bool(true)
+array(2) {
+ [0]=>
+ unicode(2) "hi"
+ [1]=>
+ unicode(5) "there"
+}
+bool(true)
+NULL
+ meta d
+bool(true)
+array(2) {
+ [u"hi"]=>
+ unicode(5) "there"
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+NULL
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/phar_metadata_write.phpt b/ext/phar/tests/phar_metadata_write.phpt
new file mode 100644
index 0000000..0a3b66d
--- /dev/null
+++ b/ext/phar/tests/phar_metadata_write.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Phar with metadata (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+var_dump($phar->getMetadata());
+$phar->setMetadata(array('my' => 'friend'));
+$phar->setMetadata(array('my' => 'friend'));
+var_dump($phar->getMetadata());
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+NULL
+array(1) {
+ ["my"]=>
+ string(6) "friend"
+}
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/phar_metadata_writeU.phpt b/ext/phar/tests/phar_metadata_writeU.phpt
new file mode 100644
index 0000000..21c42d7
--- /dev/null
+++ b/ext/phar/tests/phar_metadata_writeU.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Phar with metadata (write)
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+include 'files/phar_test.inc';
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+$phar = new Phar($fname);
+var_dump($phar->getMetadata());
+$phar->setMetadata(array('my' => 'friend'));
+$phar->setMetadata(array('my' => 'friend'));
+var_dump($phar->getMetadata());
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+
+unset($phar);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+NULL
+array(1) {
+ [u"my"]=>
+ unicode(6) "friend"
+}
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+===DONE===
diff --git a/ext/phar/tests/phar_mount.phpt b/ext/phar/tests/phar_mount.phpt
new file mode 100644
index 0000000..73bd489
--- /dev/null
+++ b/ext/phar/tests/phar_mount.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar: Phar::mount
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+Phar::mount("testit", "' . addslashes(__FILE__) . '");
+try {
+Phar::mount("testit", "' . addslashes(__FILE__) . '");
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+Phar::mount("' . addslashes($pname) . '/testit1", "' . addslashes(__FILE__) . '");
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+Phar::mount($pname . '/testit1', __FILE__);
+include $fname;
+// test copying of a phar with mounted entries
+$b = $a->convertToExecutable(Phar::TAR);
+$b->setStub('<?php
+set_include_path("phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+try {
+include $fname2;
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+Phar::mount($pname . '/oops', '/home/oops/../../etc/passwd:');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+Phar::mount($pname . '/testit2', $pname . '/testit1');
+echo substr($a['testit2']->getContent(),0, 50),"\n";
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.php failed
+Can only mount internal paths within a phar archive, use a relative path instead of "phar://%sphar_mount.phar.php/testit1"
+Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed
+Mounting of /oops to /home/oops/../../etc/passwd: within phar %sphar_mount.phar.php failed
+<?php
+$fname = dirname(__FILE__) . '/' . basename(
+===DONE===
diff --git a/ext/phar/tests/phar_offset_check.phpt b/ext/phar/tests/phar_offset_check.phpt
new file mode 100644
index 0000000..fe12534
--- /dev/null
+++ b/ext/phar/tests/phar_offset_check.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Phar: disallow stub and alias setting via offset*() methods
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://'.$fname;
+
+$phar = new Phar($fname);
+$phar->setDefaultStub();
+$phar->setAlias('susan');
+$phar['a.txt'] = "first file\n";
+$phar['b.txt'] = "second file\n";
+
+try {
+ $phar->offsetGet('.phar/stub.php');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $phar->offsetGet('.phar/alias.txt');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $phar->offsetSet('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+var_dump(strlen($phar->getStub()));
+
+try {
+ $phar->offsetUnset('.phar/stub.php');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+var_dump(strlen($phar->getStub()));
+
+try {
+ $phar->offsetSet('.phar/alias.txt', 'dolly');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+var_dump($phar->getAlias());
+
+try {
+ $phar->offsetUnset('.phar/alias.txt');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+var_dump($phar->getAlias());
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Entry .phar/stub.php does not exist
+Entry .phar/alias.txt does not exist
+Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
+int(6685)
+int(6685)
+Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
+string(5) "susan"
+string(5) "susan"
+===DONE===
diff --git a/ext/phar/tests/phar_offset_get_error.phpt b/ext/phar/tests/phar_offset_get_error.phpt
new file mode 100644
index 0000000..dade472
--- /dev/null
+++ b/ext/phar/tests/phar_offset_get_error.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar: ignore filenames starting with / on offsetSet
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://'.$fname;
+$iname = '/file.txt';
+$ename = '/error/..';
+
+$p = new Phar($fname);
+$p[$iname] = "foobar\n";
+
+try
+{
+ $p[$ename] = "foobar\n";
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+include($pname . $iname);
+
+// extra coverage
+try {
+$p['.phar/oops'] = 'hi';
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+$a = $p['.phar/stub.php'];
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+Entry /error/.. does not exist and cannot be created: phar error: invalid path "/error/.." contains upper directory reference
+foobar
+Cannot set any files or directories in magic ".phar" directory
+Entry .phar/stub.php does not exist
+===DONE===
diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt
new file mode 100644
index 0000000..7a81bbb
--- /dev/null
+++ b/ext/phar/tests/phar_oo_001.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar object: basics
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->getVersion());
+var_dump(count($phar));
+
+class MyPhar extends Phar
+{
+ function __construct()
+ {
+ }
+}
+
+try
+{
+ $phar = new MyPhar();
+ var_dump($phar->getVersion());
+}
+catch (LogicException $e)
+{
+ var_dump($e->getMessage());
+}
+try {
+ $phar = new Phar('test.phar');
+ $phar->__construct('oops');
+} catch (LogicException $e)
+{
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+string(5) "1.0.0"
+int(5)
+string(50) "Cannot call method on an uninitialized Phar object"
+string(29) "Cannot call constructor twice"
+===DONE===
diff --git a/ext/phar/tests/phar_oo_001U.phpt b/ext/phar/tests/phar_oo_001U.phpt
new file mode 100644
index 0000000..f13ddd4
--- /dev/null
+++ b/ext/phar/tests/phar_oo_001U.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar object: basics
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->getVersion());
+var_dump(count($phar));
+
+class MyPhar extends Phar
+{
+ function __construct()
+ {
+ }
+}
+
+try
+{
+ $phar = new MyPhar();
+ var_dump($phar->getVersion());
+}
+catch (BadMethodCallException $e)
+{
+ var_dump($e->getMessage());
+}
+try {
+ $phar = new Phar('test.phar');
+ $phar->__construct('oops');
+} catch (BadMethodCallException $e)
+{
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+string(5) "1.0.0"
+int(5)
+unicode(50) "Cannot call method on an uninitialized Phar object"
+unicode(29) "Cannot call constructor twice"
+===DONE===
diff --git a/ext/phar/tests/phar_oo_002.phpt b/ext/phar/tests/phar_oo_002.phpt
new file mode 100644
index 0000000..3754151
--- /dev/null
+++ b/ext/phar/tests/phar_oo_002.phpt
@@ -0,0 +1,140 @@
+--TEST--
+Phar object: iterator & entries
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileInfo');
+foreach($phar as $name => $ent)
+{
+ var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
+ var_dump($ent->getFilename());
+ var_dump($ent->getSize());
+ var_dump($ent->getType());
+ var_dump($ent->isWritable());
+ var_dump($ent->isReadable());
+ var_dump($ent->isExecutable());
+ var_dump($ent->isFile());
+ var_dump($ent->isDir());
+ var_dump($ent->isLink());
+ var_dump($ent->getCTime());
+ var_dump($ent->getMTime());
+ var_dump($ent->getATime());
+}
+
+echo "==RECURSIVE==\n";
+
+$phar = new Phar($fname);
+foreach(new RecursiveIteratorIterator($phar) as $name => $ent)
+{
+ var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
+ var_dump(str_replace('\\', '/', $ent->getFilename()));
+ var_dump($ent->getCompressedSize());
+ var_dump($ent->isCRCChecked());
+ var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
+ var_dump($ent->getPharFlags());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+string(42) "phar://*/files/phar_oo_test.phar.php%ca.php"
+string(5) "a.php"
+int(32)
+string(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+string(38) "phar://*/files/phar_oo_test.phar.php%cb"
+string(1) "b"
+int(0)
+string(3) "dir"
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+string(42) "phar://*/files/phar_oo_test.phar.php%cb.php"
+string(5) "b.php"
+int(32)
+string(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+string(42) "phar://*/files/phar_oo_test.phar.php%ce.php"
+string(5) "e.php"
+int(32)
+string(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+==RECURSIVE==
+string(42) "phar://*/files/phar_oo_test.phar.php%ca.php"
+string(5) "a.php"
+int(32)
+bool(false)
+NULL
+int(0)
+string(44) "phar://*/files/phar_oo_test.phar.php/b%cc.php"
+string(5) "c.php"
+int(34)
+bool(false)
+NULL
+int(0)
+string(44) "phar://*/files/phar_oo_test.phar.php/b%cd.php"
+string(5) "d.php"
+int(34)
+bool(false)
+NULL
+int(0)
+string(42) "phar://*/files/phar_oo_test.phar.php%cb.php"
+string(5) "b.php"
+int(32)
+bool(false)
+NULL
+int(0)
+string(42) "phar://*/files/phar_oo_test.phar.php%ce.php"
+string(5) "e.php"
+int(32)
+bool(false)
+NULL
+int(0)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_002U.phpt b/ext/phar/tests/phar_oo_002U.phpt
new file mode 100644
index 0000000..26d0d68
--- /dev/null
+++ b/ext/phar/tests/phar_oo_002U.phpt
@@ -0,0 +1,140 @@
+--TEST--
+Phar object: iterator & entries
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileInfo');
+foreach($phar as $name => $ent)
+{
+ var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
+ var_dump($ent->getFilename());
+ var_dump($ent->getSize());
+ var_dump($ent->getType());
+ var_dump($ent->isWritable());
+ var_dump($ent->isReadable());
+ var_dump($ent->isExecutable());
+ var_dump($ent->isFile());
+ var_dump($ent->isDir());
+ var_dump($ent->isLink());
+ var_dump($ent->getCTime());
+ var_dump($ent->getMTime());
+ var_dump($ent->getATime());
+}
+
+echo "==RECURSIVE==\n";
+
+$phar = new Phar($fname);
+foreach(new RecursiveIteratorIterator($phar) as $name => $ent)
+{
+ var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
+ var_dump(str_replace('\\', '/', $ent->getFilename()));
+ var_dump($ent->getCompressedSize());
+ var_dump($ent->isCRCChecked());
+ var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
+ var_dump($ent->getPharFlags());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+unicode(42) "phar://*/files/phar_oo_test.phar.php%ca.php"
+string(5) "a.php"
+int(32)
+unicode(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+unicode(38) "phar://*/files/phar_oo_test.phar.php%cb"
+string(1) "b"
+int(0)
+unicode(3) "dir"
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+unicode(42) "phar://*/files/phar_oo_test.phar.php%cb.php"
+string(5) "b.php"
+int(32)
+unicode(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+unicode(42) "phar://*/files/phar_oo_test.phar.php%ce.php"
+string(5) "e.php"
+int(32)
+unicode(4) "file"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+int(%d)
+int(%d)
+int(%d)
+==RECURSIVE==
+unicode(42) "phar://*/files/phar_oo_test.phar.php%ca.php"
+unicode(5) "a.php"
+int(32)
+bool(false)
+NULL
+int(0)
+unicode(44) "phar://*/files/phar_oo_test.phar.php/b%cc.php"
+unicode(5) "c.php"
+int(34)
+bool(false)
+NULL
+int(0)
+unicode(44) "phar://*/files/phar_oo_test.phar.php/b%cd.php"
+unicode(5) "d.php"
+int(34)
+bool(false)
+NULL
+int(0)
+unicode(42) "phar://*/files/phar_oo_test.phar.php%cb.php"
+unicode(5) "b.php"
+int(32)
+bool(false)
+NULL
+int(0)
+unicode(42) "phar://*/files/phar_oo_test.phar.php%ce.php"
+unicode(5) "e.php"
+int(32)
+bool(false)
+NULL
+int(0)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_003.phpt b/ext/phar/tests/phar_oo_003.phpt
new file mode 100644
index 0000000..ccaf7c6
--- /dev/null
+++ b/ext/phar/tests/phar_oo_003.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar object: entry & openFile()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass();
+foreach($phar as $name => $ent)
+{
+ var_dump($ent->getFilename());
+ if ($ent->isDir()) {
+ var_dump('DIR');
+ } else {
+ var_dump($ent->openFile()->fgets());
+ include $ent->getPathName();
+ }
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+string(5) "a.php"
+string(32) "<?php echo "This is a.php\n"; ?>"
+This is a.php
+string(1) "b"
+%s(3) "DIR"
+string(5) "b.php"
+string(32) "<?php echo "This is b.php\n"; ?>"
+This is b.php
+string(5) "e.php"
+string(32) "<?php echo "This is e.php\n"; ?>"
+This is e.php
+===DONE===
diff --git a/ext/phar/tests/phar_oo_004.phpt b/ext/phar/tests/phar_oo_004.phpt
new file mode 100644
index 0000000..ba67749
--- /dev/null
+++ b/ext/phar/tests/phar_oo_004.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Phar and DirectoryIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$it = new DirectoryIterator('phar://'.$fname);
+
+foreach($it as $name => $ent)
+{
+ var_dump($name);
+ var_dump($ent->getFilename());
+ var_dump($ent->isDir());
+ var_dump($ent->isDot());
+}
+
+?>
+===MANUAL===
+<?php
+
+class MyDirectoryIterator extends DirectoryIterator
+{
+ function __construct($dir)
+ {
+ echo __METHOD__ . "\n";
+ parent::__construct($dir);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+$it = new MyDirectoryIterator('phar://'.$fname);
+
+foreach($it as $name => $ent)
+{
+ var_dump($name);
+ var_dump($ent->getFilename());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+int(0)
+string(5) "a.php"
+bool(false)
+bool(false)
+int(1)
+string(1) "b"
+bool(true)
+bool(false)
+int(2)
+string(5) "b.php"
+bool(false)
+bool(false)
+int(3)
+string(5) "e.php"
+bool(false)
+bool(false)
+===MANUAL===
+MyDirectoryIterator::__construct
+MyDirectoryIterator::rewind
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(0)
+string(5) "a.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(1)
+string(1) "b"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(2)
+string(5) "b.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(3)
+string(5) "e.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+===DONE===
diff --git a/ext/phar/tests/phar_oo_004U.phpt b/ext/phar/tests/phar_oo_004U.phpt
new file mode 100644
index 0000000..2762ee3
--- /dev/null
+++ b/ext/phar/tests/phar_oo_004U.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Phar and DirectoryIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$it = new DirectoryIterator('phar://'.$fname);
+
+foreach($it as $name => $ent)
+{
+ var_dump($name);
+ var_dump($ent->getFilename());
+ var_dump($ent->isDir());
+ var_dump($ent->isDot());
+}
+
+?>
+===MANUAL===
+<?php
+
+class MyDirectoryIterator extends DirectoryIterator
+{
+ function __construct($dir)
+ {
+ echo __METHOD__ . "\n";
+ parent::__construct($dir);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+$it = new MyDirectoryIterator('phar://'.$fname);
+
+foreach($it as $name => $ent)
+{
+ var_dump($name);
+ var_dump($ent->getFilename());
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+int(0)
+unicode(5) "a.php"
+bool(false)
+bool(false)
+int(1)
+unicode(1) "b"
+bool(true)
+bool(false)
+int(2)
+unicode(5) "b.php"
+bool(false)
+bool(false)
+int(3)
+unicode(5) "e.php"
+bool(false)
+bool(false)
+===MANUAL===
+MyDirectoryIterator::__construct
+MyDirectoryIterator::rewind
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(0)
+unicode(5) "a.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(1)
+unicode(1) "b"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(2)
+unicode(5) "b.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+MyDirectoryIterator::current
+MyDirectoryIterator::key
+int(3)
+unicode(5) "e.php"
+MyDirectoryIterator::next
+MyDirectoryIterator::valid
+===DONE===
diff --git a/ext/phar/tests/phar_oo_005.phpt b/ext/phar/tests/phar_oo_005.phpt
new file mode 100644
index 0000000..cb3f298
--- /dev/null
+++ b/ext/phar/tests/phar_oo_005.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar and RecursiveDirectoryIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (version_compare(PHP_VERSION, "5.3", "<") or version_compare(PHP_VERSION, "5.4", ">="))
+ die("skip requires 5.3");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+$fname = str_replace('\\', '/', $fname);
+
+$it = new RecursiveDirectoryIterator('phar://'.$fname);
+$it = new RecursiveIteratorIterator($it);
+
+foreach($it as $name => $ent)
+{
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $name));
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $ent->getPathname()));
+ var_dump(str_replace('\\', '/', $it->getSubPath()));
+ var_dump(str_replace('\\', '/', $it->getSubPathName()));
+ $sub = $it->getPathInfo();
+ var_dump(str_replace('\\', '/', $sub->getFilename()));
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+string(14) "phar://*/a.php"
+string(14) "phar://*/a.php"
+string(0) ""
+string(5) "a.php"
+string(21) "phar_oo_test.phar.php"
+string(16) "phar://*/b/c.php"
+string(16) "phar://*/b/c.php"
+string(1) "b"
+string(7) "b/c.php"
+string(1) "b"
+string(16) "phar://*/b/d.php"
+string(16) "phar://*/b/d.php"
+string(1) "b"
+string(7) "b/d.php"
+string(1) "b"
+string(14) "phar://*/b.php"
+string(14) "phar://*/b.php"
+string(0) ""
+string(5) "b.php"
+string(21) "phar_oo_test.phar.php"
+string(14) "phar://*/e.php"
+string(14) "phar://*/e.php"
+string(0) ""
+string(5) "e.php"
+string(21) "phar_oo_test.phar.php"
+===DONE===
diff --git a/ext/phar/tests/phar_oo_005U.phpt b/ext/phar/tests/phar_oo_005U.phpt
new file mode 100644
index 0000000..bcdcb08
--- /dev/null
+++ b/ext/phar/tests/phar_oo_005U.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar and RecursiveDirectoryIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires Unicode support");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+$fname = str_replace('\\', '/', $fname);
+
+$it = new RecursiveDirectoryIterator('phar://'.$fname);
+$it = new RecursiveIteratorIterator($it);
+
+foreach($it as $name => $ent)
+{
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $name));
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $ent->getPathname()));
+ var_dump(str_replace('\\', '/', $it->getSubPath()));
+ var_dump(str_replace('\\', '/', $it->getSubPathName()));
+ $sub = $it->getPathInfo();
+ var_dump(str_replace('\\', '/', $sub->getFilename()));
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+unicode(14) "phar://*/a.php"
+unicode(14) "phar://*/a.php"
+unicode(0) ""
+unicode(5) "a.php"
+unicode(5) "a.php"
+unicode(16) "phar://*/b/c.php"
+unicode(16) "phar://*/b/c.php"
+unicode(1) "b"
+unicode(7) "b/c.php"
+unicode(5) "c.php"
+unicode(16) "phar://*/b/d.php"
+unicode(16) "phar://*/b/d.php"
+unicode(1) "b"
+unicode(7) "b/d.php"
+unicode(5) "d.php"
+unicode(14) "phar://*/b.php"
+unicode(14) "phar://*/b.php"
+unicode(0) ""
+unicode(5) "b.php"
+unicode(5) "b.php"
+unicode(14) "phar://*/e.php"
+unicode(14) "phar://*/e.php"
+unicode(0) ""
+unicode(5) "e.php"
+unicode(5) "e.php"
+===DONE===
diff --git a/ext/phar/tests/phar_oo_005_5.2.phpt b/ext/phar/tests/phar_oo_005_5.2.phpt
new file mode 100644
index 0000000..9e509d9
--- /dev/null
+++ b/ext/phar/tests/phar_oo_005_5.2.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar and RecursiveDirectoryIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+$fname = str_replace('\\', '/', $fname);
+
+$it = new RecursiveDirectoryIterator('phar://'.$fname);
+$it = new RecursiveIteratorIterator($it);
+
+foreach($it as $name => $ent)
+{
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $name));
+ var_dump(str_replace(array('\\', $fname), array('/', '*'), $ent->getPathname()));
+ var_dump(str_replace('\\', '/', $it->getSubPath()));
+ var_dump(str_replace('\\', '/', $it->getSubPathName()));
+ $sub = $it->getPathInfo();
+ var_dump(str_replace('\\', '/', $sub->getFilename()));
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+string(14) "phar://*/a.php"
+string(14) "phar://*/a.php"
+string(0) ""
+string(5) "a.php"
+string(21) "phar_oo_test.phar.php"
+string(16) "phar://*/b/c.php"
+string(16) "phar://*/b/c.php"
+string(1) "b"
+string(7) "b/c.php"
+string(1) "b"
+string(16) "phar://*/b/d.php"
+string(16) "phar://*/b/d.php"
+string(1) "b"
+string(7) "b/d.php"
+string(1) "b"
+string(14) "phar://*/b.php"
+string(14) "phar://*/b.php"
+string(0) ""
+string(5) "b.php"
+string(21) "phar_oo_test.phar.php"
+string(14) "phar://*/e.php"
+string(14) "phar://*/e.php"
+string(0) ""
+string(5) "e.php"
+string(21) "phar_oo_test.phar.php"
+===DONE===
diff --git a/ext/phar/tests/phar_oo_006.phpt b/ext/phar/tests/phar_oo_006.phpt
new file mode 100644
index 0000000..556c98c
--- /dev/null
+++ b/ext/phar/tests/phar_oo_006.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Phar object: array access
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+class MyFile extends SplFileObject
+{
+ function __construct($what)
+ {
+ echo __METHOD__ . "($what)\n";
+ parent::__construct($what);
+ }
+}
+
+$phar = new Phar($fname);
+try
+{
+ $phar->setFileClass('SplFileInfo');
+}
+catch (UnexpectedValueException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+$phar->setInfoClass('MyFile');
+
+echo $phar['a.php']->getFilename() . "\n";
+echo $phar['b/c.php']->getFilename() . "\n";
+echo $phar['b.php']->getFilename() . "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+SplFileInfo::setFileClass() expects parameter 1 to be a class name derived from SplFileObject, 'SplFileInfo' given
+MyFile::__construct(phar://%s/a.php)
+a.php
+MyFile::__construct(phar://%s/b/c.php)
+c.php
+MyFile::__construct(phar://%s/b.php)
+b.php
+===DONE===
diff --git a/ext/phar/tests/phar_oo_007.phpt b/ext/phar/tests/phar_oo_007.phpt
new file mode 100644
index 0000000..788b11f
--- /dev/null
+++ b/ext/phar/tests/phar_oo_007.phpt
@@ -0,0 +1,87 @@
+--TEST--
+Phar object: access through SplFileObject
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+class MyFile extends SplFileObject
+{
+ function __construct($name)
+ {
+ echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name) . ")\n";
+ parent::__construct($name);
+ }
+}
+
+$phar = new Phar($fname);
+$phar->setInfoClass('MyFile');
+
+$f = $phar['a.php'];
+
+$s = $f->fstat();
+
+var_dump($s['atime']);
+var_dump($s['ctime']);
+var_dump($s['mtime']);
+
+var_dump($f->ftell());
+var_dump($f->eof());
+var_dump($f->fgets());
+var_dump($f->eof());
+var_dump($f->fseek(20));
+var_dump($f->ftell());
+var_dump($f->fgets());
+var_dump($f->rewind());
+var_dump($f->ftell());
+var_dump($f->fgets());
+var_dump($f->ftell());
+
+?>
+===AGAIN===
+<?php
+
+$f = $phar['a.php'];
+
+var_dump($f->ftell());
+var_dump($f->eof());
+var_dump($f->fgets());
+var_dump($f->eof());
+
+//unset($f); without unset we check for working refcounting
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php)
+int(%d)
+int(%d)
+int(%d)
+int(0)
+bool(false)
+string(32) "<?php echo "This is a.php\n"; ?>"
+bool(true)
+int(0)
+int(20)
+string(12) "a.php\n"; ?>"
+NULL
+int(0)
+string(32) "<?php echo "This is a.php\n"; ?>"
+int(32)
+===AGAIN===
+MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php)
+int(0)
+bool(false)
+string(32) "<?php echo "This is a.php\n"; ?>"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_008.phpt b/ext/phar/tests/phar_oo_008.phpt
new file mode 100644
index 0000000..80d1ece
--- /dev/null
+++ b/ext/phar/tests/phar_oo_008.phpt
@@ -0,0 +1,119 @@
+--TEST--
+Phar object: iterating via SplFileObject
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 1;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileObject');
+
+$f = $phar['a.csv'];
+echo "===1===\n";
+foreach($f as $k => $v)
+{
+ echo "$k=>$v\n";
+}
+
+$f->setFlags(SplFileObject::DROP_NEW_LINE);
+
+echo "===2===\n";
+foreach($f as $k => $v)
+{
+ echo "$k=>$v\n";
+}
+
+class MyCSVFile extends SplFileObject
+{
+ function current()
+ {
+ return parent::fgetcsv(',', '"');
+ }
+}
+
+$phar->setInfoClass('MyCSVFile');
+$v = $phar['a.csv'];
+
+echo "===3===\n";
+while(!$v->eof())
+{
+ echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
+}
+
+echo "===4===\n";
+$v->rewind();
+while(!$v->eof())
+{
+ $l = $v->fgetcsv();
+ echo $v->key() . "=>" . join('|',$l) . "\n";
+}
+
+echo "===5===\n";
+foreach($v as $k => $d)
+{
+ echo "$k=>" . join('|',$d) . "\n";
+}
+
+class MyCSVFile2 extends SplFileObject
+{
+ function getCurrentLine()
+ {
+ echo __METHOD__ . "\n";
+ return parent::fgetcsv(',', '"');
+ }
+}
+
+$phar->setInfoClass('MyCSVFile2');
+$v = $phar['a.csv'];
+
+echo "===6===\n";
+foreach($v as $k => $d)
+{
+ echo "$k=>" . join('|',$d) . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+===1===
+0=>1,2,3
+
+1=>2,a,b
+
+2=>3,"c","'e'"
+===2===
+0=>1,2,3
+1=>2,a,b
+2=>3,"c","'e'"
+===3===
+0=>1|2|3
+0=>2|a|b
+1=>3|c|'e'
+===4===
+0=>1|2|3
+1=>2|a|b
+2=>3|c|'e'
+===5===
+0=>1|2|3
+1=>2|a|b
+2=>3|c|'e'
+===6===
+MyCSVFile2::getCurrentLine
+1=>1|2|3
+MyCSVFile2::getCurrentLine
+3=>2|a|b
+MyCSVFile2::getCurrentLine
+5=>3|c|'e'
+===DONE===
diff --git a/ext/phar/tests/phar_oo_009.phpt b/ext/phar/tests/phar_oo_009.phpt
new file mode 100644
index 0000000..6abd03e
--- /dev/null
+++ b/ext/phar/tests/phar_oo_009.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Phar object: iterating via SplFileObject and reading csv
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!defined('SplFileObject::READ_CSV') || !defined('SplFileObject::SKIP_EMPTY')) die('skip newer SPL version is required'); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 2;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileObject');
+
+$f = $phar['a.csv'];
+$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
+foreach($f as $k => $v)
+{
+ echo "$k=>$v\n";
+}
+
+?>
+===CSV===
+<?php
+
+$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
+foreach($f as $k => $v)
+{
+ echo "$k=>" . join('|', $v) . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+0=>1,2,3
+1=>2,a,b
+2=>3,"c","'e'"
+3=>4
+4=>5,5
+5=>7,777
+===CSV===
+0=>1|2|3
+1=>2|a|b
+2=>3|c|'e'
+3=>4
+4=>5|5
+6=>7|777
+===DONE===
diff --git a/ext/phar/tests/phar_oo_010.phpt b/ext/phar/tests/phar_oo_010.phpt
new file mode 100644
index 0000000..1d3ff73
--- /dev/null
+++ b/ext/phar/tests/phar_oo_010.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar object: ArrayAccess and isset
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 0;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(isset($phar['a.php']));
+var_dump(isset($phar['b.php']));
+var_dump(isset($phar['b/c.php']));
+var_dump(isset($phar['b/d.php']));
+var_dump(isset($phar['e.php']));
+
+?>
+===DIR===
+<?php
+var_dump(isset($phar['b']));
+?>
+===NA===
+<?php
+var_dump(isset($phar['a']));
+var_dump(isset($phar['b/c']));
+var_dump(isset($phar[12]));
+var_dump(isset($phar['b']));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===DIR===
+bool(true)
+===NA===
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_011.phpt b/ext/phar/tests/phar_oo_011.phpt
new file mode 100644
index 0000000..cfbab70
--- /dev/null
+++ b/ext/phar/tests/phar_oo_011.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar object: add file
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 0;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileObject');
+
+$phar['hi/f.php'] = 'hi';
+var_dump(isset($phar['hi']));
+var_dump(isset($phar['hi/f.php']));
+echo $phar['hi/f.php'];
+echo "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+bool(true)
+bool(true)
+hi
+===DONE===
diff --git a/ext/phar/tests/phar_oo_011b.phpt b/ext/phar/tests/phar_oo_011b.phpt
new file mode 100644
index 0000000..36d9963
--- /dev/null
+++ b/ext/phar/tests/phar_oo_011b.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar object: add file
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+
+try
+{
+ $pharconfig = 0;
+
+ require_once 'files/phar_oo_test.inc';
+
+ $phar = new Phar($fname);
+
+ $phar['f.php'] = 'hi';
+ var_dump(isset($phar['f.php']));
+ echo $phar['f.php'];
+ echo "\n";
+}
+catch (BadMethodCallException $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+Exception: Write operations disabled by the php.ini setting phar.readonly
+===DONE===
diff --git a/ext/phar/tests/phar_oo_012.phpt b/ext/phar/tests/phar_oo_012.phpt
new file mode 100644
index 0000000..e79ac09
--- /dev/null
+++ b/ext/phar/tests/phar_oo_012.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Phar object: unset file
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 0;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileObject');
+
+$phar['f.php'] = 'hi';
+var_dump(isset($phar['f.php']));
+echo $phar['f.php'];
+echo "\n";
+unset($phar['f.php']);
+var_dump(isset($phar['f.php']));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+bool(true)
+hi
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_012_confirm.phpt b/ext/phar/tests/phar_oo_012_confirm.phpt
new file mode 100644
index 0000000..58a3be8
--- /dev/null
+++ b/ext/phar/tests/phar_oo_012_confirm.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Phar object: unset file (confirm disk file is changed)
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$pharconfig = 0;
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+$phar->setInfoClass('SplFileObject');
+
+$phar['f.php'] = 'hi';
+var_dump(isset($phar['f.php']));
+echo $phar['f.php'];
+echo "\n";
+$md5 = md5_file($fname);
+unset($phar['f.php']);
+$md52 = md5_file($fname);
+if ($md5 == $md52) echo 'File on disk has not changed';
+var_dump(isset($phar['f.php']));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+bool(true)
+hi
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_012b.phpt b/ext/phar/tests/phar_oo_012b.phpt
new file mode 100644
index 0000000..80d8ed8
--- /dev/null
+++ b/ext/phar/tests/phar_oo_012b.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar object: unset file
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+
+try
+{
+ $pharconfig = 0;
+
+ require_once 'files/phar_oo_test.inc';
+
+ $phar = new Phar($fname);
+ $phar->setInfoClass('SplFileObject');
+
+ $phar['f.php'] = 'hi';
+ var_dump(isset($phar['f.php']));
+ echo $phar['f.php'];
+ echo "\n";
+ unset($phar['f.php']);
+ var_dump(isset($phar['f.php']));
+}
+catch (BadMethodCallException $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+Exception: Write operations disabled by the php.ini setting phar.readonly
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressallbz2.phpt b/ext/phar/tests/phar_oo_compressallbz2.phpt
new file mode 100644
index 0000000..3f52227
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressallbz2.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Phar::compressFiles(Phar::BZ2)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar = new Phar($fname);
+$phar->compressFiles(Phar::BZ2);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed(Phar::GZ));
+var_dump($phar['a']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(false)
+bool(true)
+string(1) "b"
+bool(false)
+bool(true)
+string(1) "c"
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressallgz.phpt b/ext/phar/tests/phar_oo_compressallgz.phpt
new file mode 100644
index 0000000..55e7435
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressallgz.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Phar::compressFiles(Phar::GZ)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar = new Phar($fname);
+$phar->compressFiles(Phar::GZ);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed(Phar::GZ));
+var_dump($phar['a']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+try {
+$phar->compressFiles(25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(true)
+bool(false)
+string(1) "b"
+bool(true)
+bool(false)
+string(1) "c"
+bool(true)
+bool(false)
+Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_001.phpt b/ext/phar/tests/phar_oo_compressed_001.phpt
new file mode 100644
index 0000000..af02012
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressed_001.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Phar: PharFileInfo::compress(Phar::GZ)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar['a'] = 'new a';
+$phar['a']->decompress();
+$phar['b'] = 'new b';
+$phar['b']->compress(Phar::GZ);
+$phar['d'] = 'new d';
+
+$phar = new Phar($fname);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+var_dump(file_get_contents($pname . '/d'));
+var_dump($phar['d']->isCompressed());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(5) "new a"
+bool(false)
+string(5) "new b"
+bool(true)
+string(1) "c"
+bool(false)
+string(5) "new d"
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_001b.phpt b/ext/phar/tests/phar_oo_compressed_001b.phpt
new file mode 100644
index 0000000..6d4c732
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressed_001b.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Phar: PharFileInfo::compress(Phar::BZ2)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar['a'] = 'new a';
+$phar['a']->decompress();
+$phar['b'] = 'new b';
+$phar['b']->compress(Phar::BZ2);
+$phar['d'] = 'new d';
+
+$phar = new Phar($fname);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+var_dump(file_get_contents($pname . '/d'));
+var_dump($phar['d']->isCompressed());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(5) "new a"
+bool(false)
+string(5) "new b"
+bool(true)
+string(1) "c"
+bool(false)
+string(5) "new d"
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_002.phpt b/ext/phar/tests/phar_oo_compressed_002.phpt
new file mode 100644
index 0000000..d4ec5cb
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressed_002.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Phar: context/compress=GZ
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+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'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$context = stream_context_create(array('phar'=>array('compress'=>Phar::GZ)));
+
+file_put_contents($pname . '/b', b'new b');
+file_put_contents($pname . '/c', b'new c', 0, $context);
+file_put_contents($pname . '/d', b'new d');
+file_put_contents($pname . '/e', b'new e', 0, $context);
+
+$phar = new Phar($fname);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+var_dump(file_get_contents($pname . '/d'));
+var_dump($phar['d']->isCompressed());
+var_dump(file_get_contents($pname . '/e'));
+var_dump($phar['e']->isCompressed());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(false)
+string(5) "new b"
+bool(false)
+string(5) "new c"
+bool(true)
+string(5) "new d"
+bool(false)
+string(5) "new e"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_002b.phpt b/ext/phar/tests/phar_oo_compressed_002b.phpt
new file mode 100644
index 0000000..d7213fd
--- /dev/null
+++ b/ext/phar/tests/phar_oo_compressed_002b.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Phar: context/compress=BZip2
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
+--INI--
+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'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$context = stream_context_create(array('phar'=>array('compress'=>Phar::BZ2)));
+
+file_put_contents($pname . '/b', b'new b');
+file_put_contents($pname . '/c', b'new c', 0, $context);
+file_put_contents($pname . '/d', b'new d');
+file_put_contents($pname . '/e', b'new e', 0, $context);
+
+$phar = new Phar($fname);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+var_dump(file_get_contents($pname . '/d'));
+var_dump($phar['d']->isCompressed());
+var_dump(file_get_contents($pname . '/e'));
+var_dump($phar['e']->isCompressed());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(false)
+string(5) "new b"
+bool(false)
+string(5) "new c"
+bool(true)
+string(5) "new d"
+bool(false)
+string(5) "new e"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_getcontents.phpt b/ext/phar/tests/phar_oo_getcontents.phpt
new file mode 100644
index 0000000..e42bca4
--- /dev/null
+++ b/ext/phar/tests/phar_oo_getcontents.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar object: getContent()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+
+$phar = new Phar($fname);
+$phar['a/b'] = 'file contents
+this works';
+$phar->addEmptyDir('hi');
+echo $phar['a/b']->getContent() . "\n";
+try {
+echo $phar['a']->getContent(), "\n";
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+echo $phar['hi']->getContent(), "\n";
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__halt_compiler();
+?>
+--EXPECTF--
+file contents
+this works
+Phar error: Cannot retrieve contents, "a" in phar "%sphar_oo_getcontents.phar.php" is a directory
+Phar error: Cannot retrieve contents, "hi" in phar "%sphar_oo_getcontents.phar.php" is a directory
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_oo_getcontentsgz.phpt b/ext/phar/tests/phar_oo_getcontentsgz.phpt
new file mode 100644
index 0000000..a480a69
--- /dev/null
+++ b/ext/phar/tests/phar_oo_getcontentsgz.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar object: getContent() (verify it works with compression)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+
+$phar = new Phar($fname);
+$phar['a'] = 'file contents
+this works';
+$phar['a']->compress(Phar::GZ);
+copy($fname, $fname2);
+$phar2 = new Phar($fname2);
+var_dump($phar2['a']->isCompressed());
+echo $phar2['a']->getContent() . "\n";
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+bool(true)
+file contents
+this works
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_oo_getmodified.phpt b/ext/phar/tests/phar_oo_getmodified.phpt
new file mode 100644
index 0000000..d531393
--- /dev/null
+++ b/ext/phar/tests/phar_oo_getmodified.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar::getModified()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->getModified());
+$phar->compressFiles(Phar::GZ);
+var_dump($phar->getModified());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_iswriteable.phpt b/ext/phar/tests/phar_oo_iswriteable.phpt
new file mode 100644
index 0000000..9fbca2c
--- /dev/null
+++ b/ext/phar/tests/phar_oo_iswriteable.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Phar::isWriteable
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$pname = 'phar://hio';
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
+$files['dir/'] = '';
+$hasdir = 1;
+include 'files/phar_test.inc';
+$a = new Phar($fname);
+$b = new PharData($fname2);
+$b['test'] = 'hi';
+
+var_dump($a['a.php']->isWritable());
+var_dump($a['a.php']->isReadable());
+$a['a.php']->chmod(000);
+var_dump($a['a.php']->isWritable());
+var_dump($a['a.php']->isReadable());
+$a['a.php']->chmod(0666);
+var_dump($a['a.php']->isWritable());
+var_dump($a['a.php']->isReadable());
+ini_set('phar.readonly',1);
+clearstatcache();
+var_dump($a['a.php']->isWritable());
+var_dump($a['a.php']->isReadable());
+ini_set('phar.readonly',0);
+clearstatcache();
+var_dump($a['a.php']->isWritable());
+var_dump($a['a.php']->isReadable());
+?>
+archive
+<?php
+ini_set('phar.readonly',0);
+$p = new Phar('doesnotexisthere.phar');
+var_dump($p->isWritable());
+clearstatcache();
+var_dump($a->isWritable());
+var_dump($b->isWritable());
+ini_set('phar.readonly',1);
+clearstatcache();
+var_dump($a->isWritable());
+var_dump($b->isWritable());
+chmod($fname2, 000);
+clearstatcache();
+var_dump($a->isWritable());
+var_dump($b->isWritable());
+chmod($fname2, 0666);
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+archive
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_nosig.phpt b/ext/phar/tests/phar_oo_nosig.phpt
new file mode 100644
index 0000000..d99222e
--- /dev/null
+++ b/ext/phar/tests/phar_oo_nosig.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar::getSignature() no signature
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+
+require_once 'files/phar_oo_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->getSignature());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
+__halt_compiler();
+?>
+--EXPECT--
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_oo_uncompressall.phpt b/ext/phar/tests/phar_oo_uncompressall.phpt
new file mode 100644
index 0000000..19cf953
--- /dev/null
+++ b/ext/phar/tests/phar_oo_uncompressall.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Phar::decompressFiles()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar = new Phar($fname);
+$phar->compressFiles(Phar::GZ);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed(Phar::GZ));
+var_dump($phar['a']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+
+$phar->decompressFiles();
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['a']->isCompressed());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(true)
+bool(false)
+string(1) "b"
+bool(true)
+bool(false)
+string(1) "c"
+bool(true)
+bool(false)
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+===DONE===
diff --git a/ext/phar/tests/phar_running.phpt b/ext/phar/tests/phar_running.phpt
new file mode 100644
index 0000000..2d132b9
--- /dev/null
+++ b/ext/phar/tests/phar_running.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: Phar::running()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['index.php'] = '<?php
+Phar::running(array());
+var_dump(Phar::running());
+var_dump(Phar::running(false));
+?>';
+include $pname . '/index.php';
+var_dump(Phar::running());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: Phar::running() expects parameter 1 to be boolean, array given in phar://%sphar_running.phar.php/index.php on line 2
+string(%d) "phar://%sphar_running.phar.php"
+string(%d) "%sphar_running.phar.php"
+string(0) ""
+===DONE===
diff --git a/ext/phar/tests/phar_setalias.phpt b/ext/phar/tests/phar_setalias.phpt
new file mode 100644
index 0000000..ef9fa28
--- /dev/null
+++ b/ext/phar/tests/phar_setalias.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar::setAlias()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+hio
+test
+===DONE===
diff --git a/ext/phar/tests/phar_setalias2.phpt b/ext/phar/tests/phar_setalias2.phpt
new file mode 100644
index 0000000..901e4d2
--- /dev/null
+++ b/ext/phar/tests/phar_setalias2.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar::setAlias() error
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+$b = $phar;
+$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
+try {
+ $phar->setAlias('test');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ $b = new Phar(dirname(__FILE__) . '/nope.phar', 0, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+unlink(dirname(__FILE__) . '/notphar.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+hio
+test
+alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
+alias "test" is already used for archive "%sphar_setalias2.phar.php" cannot be overloaded with "%snope.phar"
+===DONE===
diff --git a/ext/phar/tests/phar_setdefaultstub.phpt b/ext/phar/tests/phar_setdefaultstub.phpt
new file mode 100644
index 0000000..434e647
--- /dev/null
+++ b/ext/phar/tests/phar_setdefaultstub.phpt
@@ -0,0 +1,944 @@
+--TEST--
+Phar: Phar::setDefaultStub() with and without arg
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<php echo "this is a\n"; ?>';
+$phar['b.php'] = '<php echo "this is b\n"; ?>';
+$phar->setDefaultStub();
+$phar->stopBuffering();
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+$phar->setDefaultStub('my/custom/thingy.php');
+$phar->stopBuffering();
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+$phar->setDefaultStub('my/custom/thingy.php', 'the/web.php');
+$phar->stopBuffering();
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub(str_repeat('a', 400));
+ $phar->stopBuffering();
+ var_dump(strlen($phar->getStub()));
+
+ $phar->setDefaultStub(str_repeat('a', 401));
+ $phar->stopBuffering();
+ var_dump(strlen($phar->getStub()));
+
+} catch(Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECT--
+string(6685) "<?php
+
+$web = 'index.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'index.php';
+const LEN = 6685;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>
+"
+============================================================================
+============================================================================
+string(6696) "<?php
+
+$web = 'index.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'my/custom/thingy.php';
+const LEN = 6696;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>
+"
+============================================================================
+============================================================================
+string(6698) "<?php
+
+$web = 'the/web.php';
+
+if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
+Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web);
+include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
+return;
+}
+
+if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
+Extract_Phar::go(true);
+$mimes = array(
+'phps' => 2,
+'c' => 'text/plain',
+'cc' => 'text/plain',
+'cpp' => 'text/plain',
+'c++' => 'text/plain',
+'dtd' => 'text/plain',
+'h' => 'text/plain',
+'log' => 'text/plain',
+'rng' => 'text/plain',
+'txt' => 'text/plain',
+'xsd' => 'text/plain',
+'php' => 1,
+'inc' => 1,
+'avi' => 'video/avi',
+'bmp' => 'image/bmp',
+'css' => 'text/css',
+'gif' => 'image/gif',
+'htm' => 'text/html',
+'html' => 'text/html',
+'htmls' => 'text/html',
+'ico' => 'image/x-ico',
+'jpe' => 'image/jpeg',
+'jpg' => 'image/jpeg',
+'jpeg' => 'image/jpeg',
+'js' => 'application/x-javascript',
+'midi' => 'audio/midi',
+'mid' => 'audio/midi',
+'mod' => 'audio/mod',
+'mov' => 'movie/quicktime',
+'mp3' => 'audio/mp3',
+'mpg' => 'video/mpeg',
+'mpeg' => 'video/mpeg',
+'pdf' => 'application/pdf',
+'png' => 'image/png',
+'swf' => 'application/shockwave-flash',
+'tif' => 'image/tiff',
+'tiff' => 'image/tiff',
+'wav' => 'audio/wav',
+'xbm' => 'image/xbm',
+'xml' => 'text/xml',
+);
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$basename = basename(__FILE__);
+if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
+chdir(Extract_Phar::$temp);
+include $web;
+return;
+}
+$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
+if (!$pt || $pt == '/') {
+$pt = $web;
+header('HTTP/1.1 301 Moved Permanently');
+header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
+exit;
+}
+$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
+if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
+header('HTTP/1.0 404 Not Found');
+echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
+exit;
+}
+$b = pathinfo($a);
+if (!isset($b['extension'])) {
+header('Content-Type: text/plain');
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+if (isset($mimes[$b['extension']])) {
+if ($mimes[$b['extension']] === 1) {
+include $a;
+exit;
+}
+if ($mimes[$b['extension']] === 2) {
+highlight_file($a);
+exit;
+}
+header('Content-Type: ' .$mimes[$b['extension']]);
+header('Content-Length: ' . filesize($a));
+readfile($a);
+exit;
+}
+}
+
+class Extract_Phar
+{
+static $temp;
+static $origdir;
+const GZ = 0x1000;
+const BZ2 = 0x2000;
+const MASK = 0x3000;
+const START = 'my/custom/thingy.php';
+const LEN = 6698;
+
+static function go($return = false)
+{
+$fp = fopen(__FILE__, 'rb');
+fseek($fp, self::LEN);
+$L = unpack('V', $a = (binary)fread($fp, 4));
+$m = (binary)'';
+
+do {
+$read = 8192;
+if ($L[1] - strlen($m) < 8192) {
+$read = $L[1] - strlen($m);
+}
+$last = (binary)fread($fp, $read);
+$m .= $last;
+} while (strlen($last) && strlen($m) < $L[1]);
+
+if (strlen($m) < $L[1]) {
+die('ERROR: manifest length read was "' .
+strlen($m) .'" should be "' .
+$L[1] . '"');
+}
+
+$info = self::_unpack($m);
+$f = $info['c'];
+
+if ($f & self::GZ) {
+if (!function_exists('gzinflate')) {
+die('Error: zlib extension is not enabled -' .
+' gzinflate() function needed for zlib-compressed .phars');
+}
+}
+
+if ($f & self::BZ2) {
+if (!function_exists('bzdecompress')) {
+die('Error: bzip2 extension is not enabled -' .
+' bzdecompress() function needed for bz2-compressed .phars');
+}
+}
+
+$temp = self::tmpdir();
+
+if (!$temp || !is_writable($temp)) {
+$sessionpath = session_save_path();
+if (strpos ($sessionpath, ";") !== false)
+$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
+if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
+die('Could not locate temporary directory to extract phar');
+}
+$temp = $sessionpath;
+}
+
+$temp .= '/pharextract/'.basename(__FILE__, '.phar');
+self::$temp = $temp;
+self::$origdir = getcwd();
+@mkdir($temp, 0777, true);
+$temp = realpath($temp);
+
+if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
+self::_removeTmpFiles($temp, getcwd());
+@mkdir($temp, 0777, true);
+@file_put_contents($temp . '/' . md5_file(__FILE__), '');
+
+foreach ($info['m'] as $path => $file) {
+$a = !file_exists(dirname($temp . '/' . $path));
+@mkdir(dirname($temp . '/' . $path), 0777, true);
+clearstatcache();
+
+if ($path[strlen($path) - 1] == '/') {
+@mkdir($temp . '/' . $path, 0777);
+} else {
+file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
+@chmod($temp . '/' . $path, 0666);
+}
+}
+}
+
+chdir($temp);
+
+if (!$return) {
+include self::START;
+}
+}
+
+static function tmpdir()
+{
+if (strpos(PHP_OS, 'WIN') !== false) {
+if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
+return $var;
+}
+if (is_dir('/temp') || mkdir('/temp')) {
+return realpath('/temp');
+}
+return false;
+}
+if ($var = getenv('TMPDIR')) {
+return $var;
+}
+return realpath('/tmp');
+}
+
+static function _unpack($m)
+{
+$info = unpack('V', substr($m, 0, 4));
+ $l = unpack('V', substr($m, 10, 4));
+$m = substr($m, 14 + $l[1]);
+$s = unpack('V', substr($m, 0, 4));
+$o = 0;
+$start = 4 + $s[1];
+$ret['c'] = 0;
+
+for ($i = 0; $i < $info[1]; $i++) {
+ $len = unpack('V', substr($m, $start, 4));
+$start += 4;
+ $savepath = substr($m, $start, $len[1]);
+$start += $len[1];
+ $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
+$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
+& 0xffffffff);
+$ret['m'][$savepath][7] = $o;
+$o += $ret['m'][$savepath][2];
+$start += 24 + $ret['m'][$savepath][5];
+$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
+}
+return $ret;
+}
+
+static function extractFile($path, $entry, $fp)
+{
+$data = '';
+$c = $entry[2];
+
+while ($c) {
+if ($c < 8192) {
+$data .= @fread($fp, $c);
+$c = 0;
+} else {
+$c -= 8192;
+$data .= @fread($fp, 8192);
+}
+}
+
+if ($entry[4] & self::GZ) {
+$data = gzinflate($data);
+} elseif ($entry[4] & self::BZ2) {
+$data = bzdecompress($data);
+}
+
+if (strlen($data) != $entry[0]) {
+die("Invalid internal .phar file (size error " . strlen($data) . " != " .
+$stat[7] . ")");
+}
+
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+die("Invalid internal .phar file (checksum error)");
+}
+
+return $data;
+}
+
+static function _removeTmpFiles($temp, $origdir)
+{
+chdir($temp);
+
+foreach (glob('*') as $f) {
+if (file_exists($f)) {
+is_dir($f) ? @rmdir($f) : @unlink($f);
+if (file_exists($f) && is_dir($f)) {
+self::_removeTmpFiles($f, getcwd());
+}
+}
+}
+
+@rmdir($temp);
+clearstatcache();
+chdir($origdir);
+}
+}
+
+Extract_Phar::go();
+__HALT_COMPILER(); ?>
+"
+============================================================================
+============================================================================
+int(7076)
+Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
+===DONE===
diff --git a/ext/phar/tests/phar_setsignaturealgo1.phpt b/ext/phar/tests/phar_setsignaturealgo1.phpt
new file mode 100644
index 0000000..eacee7b
--- /dev/null
+++ b/ext/phar/tests/phar_setsignaturealgo1.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Phar::setSignatureAlgorithm()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if ( extension_loaded("hash")) die("skip extension hash conflicts"); ?>
+<?php if (!defined("Phar::PGP")) die("skip PGP Signature algorithm not available"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
+$p['file1.txt'] = 'hi';
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::MD5);
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::SHA1);
+var_dump($p->getSignature());
+try {
+$p->setSignatureAlgorithm(Phar::SHA256);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::SHA512);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::PGP);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar');
+?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
+string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_setsignaturealgo2.phpt b/ext/phar/tests/phar_setsignaturealgo2.phpt
new file mode 100644
index 0000000..9f548d0
--- /dev/null
+++ b/ext/phar/tests/phar_setsignaturealgo2.phpt
@@ -0,0 +1,90 @@
+--TEST--
+Phar::setSupportedSignatures() with hash
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("hash")) die("skip hash extension required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$p = new Phar($fname);
+$p['file1.txt'] = 'hi';
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::MD5);
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::SHA1);
+var_dump($p->getSignature());
+try {
+$p->setSignatureAlgorithm(Phar::SHA256);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::SHA512);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$config = dirname(__FILE__) . '/files/openssl.cnf';
+$config_arg = array('config' => $config);
+$private = openssl_get_privatekey(file_get_contents(dirname(__FILE__) . '/files/private.pem'));
+$pkey = '';
+openssl_pkey_export($private, $pkey, NULL, $config_arg);
+$p->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-256"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-512"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/tests/phar_stub.phpt b/ext/phar/tests/phar_stub.phpt
new file mode 100644
index 0000000..832dc40
--- /dev/null
+++ b/ext/phar/tests/phar_stub.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Phar::setStub()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$fp = fopen($fname, 'rb');
+//// 1
+echo fread($fp, strlen($file)) . "\n";
+fclose($fp);
+$phar = new Phar($fname);
+$file = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
+
+//// 2
+$phar->setStub($file);
+$fp = fopen($fname, 'rb');
+echo fread($fp, strlen($file)) . "\n";
+fclose($fp);
+
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php';
+$file = b'<?php echo "third stub\n"; __HALT_COMPILER(); ?>';
+$fp = fopen($fname2, 'wb');
+fwrite($fp, $file);
+fclose($fp);
+$fp = fopen($fname2, 'rb');
+
+//// 3
+$phar->setStub($fp);
+fclose($fp);
+
+$fp = fopen($fname, 'rb');
+echo fread($fp, strlen($file)) . "\n";
+fclose($fp);
+
+$fp = fopen($fname2, 'ab');
+fwrite($fp, b'booya');
+fclose($fp);
+echo file_get_contents($fname2) . "\n";
+
+$fp = fopen($fname2, 'rb');
+
+//// 4
+$phar->setStub($fp, strlen($file));
+fclose($fp);
+
+$fp = fopen($fname, 'rb');
+echo fread($fp, strlen($file)) . "\n";
+if (fread($fp, strlen('booya')) == 'booya') {
+ echo 'failed - copied booya';
+}
+fclose($fp);
+$phar['testing'] = 'hi';
+
+// ensure stub is not overwritten
+$fp = fopen($fname, 'rb');
+echo fread($fp, strlen($file)) . "\n";
+if (fread($fp, strlen('booya')) == 'booya') {
+ echo 'failed - copied booya';
+}
+fclose($fp);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>booya
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+===DONE===
diff --git a/ext/phar/tests/phar_stub_error.phpt b/ext/phar/tests/phar_stub_error.phpt
new file mode 100644
index 0000000..bb5d63b
--- /dev/null
+++ b/ext/phar/tests/phar_stub_error.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Phar::setStub()/getStub()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$stub = b'<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($stub);
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
+try
+{
+ $phar->setStub($newstub);
+}
+catch(exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+$phar->stopBuffering();
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+Exception: illegal stub for phar "%sphar_stub_error.phar.php"
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_stub_write.phpt b/ext/phar/tests/phar_stub_write.phpt
new file mode 100644
index 0000000..ecdb3b9
--- /dev/null
+++ b/ext/phar/tests/phar_stub_write.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar::setStub()/getStub()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$stub = b'<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($stub);
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
+$sexp = $stub . "\r\n";
+
+$phar->setStub($stub);
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+$phar->stopBuffering();
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+
+$phar = new Phar($fname);
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+"
+bool(false)
+bool(true)
+string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_stub_write_file.phpt b/ext/phar/tests/phar_stub_write_file.phpt
new file mode 100644
index 0000000..e4c8676
--- /dev/null
+++ b/ext/phar/tests/phar_stub_write_file.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar::setStub()/getStub() from file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+allow_url_fopen=1
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$stub = b'<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($stub);
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
+$sexp = $stub . "\r\n";
+$stub = fopen('data://,'.$stub, 'r');
+$phar->setStub($stub);
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+$phar->stopBuffering();
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+
+$phar = new Phar($fname);
+var_dump($phar->getStub() == $stub);
+var_dump($phar->getStub() == $sexp);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+bool(true)
+string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+"
+bool(false)
+bool(true)
+string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/phar_unlinkarchive.phpt b/ext/phar/tests/phar_unlinkarchive.phpt
new file mode 100644
index 0000000..4800c52
--- /dev/null
+++ b/ext/phar/tests/phar_unlinkarchive.phpt
@@ -0,0 +1,108 @@
+--TEST--
+Phar::unlinkArchive()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+try {
+Phar::unlinkArchive("");
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pdname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+
+try {
+Phar::unlinkArchive($fname);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+file_put_contents($pdname, 'blahblah');
+try {
+Phar::unlinkArchive($pdname);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+Phar::unlinkArchive(array());
+
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
+$file = $stub;
+
+$files = array();
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+include 'files/phar_test.inc';
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+try {
+Phar::unlinkArchive($fname);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+$phar = $phar->convertToExecutable(Phar::ZIP);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+
+copy($fname2, $fname3);
+
+$phar = new Phar($fname3);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+
+Phar::unlinkArchive($fname);
+var_dump(file_exists($fname));
+$phar = new Phar($fname);
+var_dump(count($phar));
+$phar['evil.php'] = '<?php
+try {
+Phar::unlinkArchive(Phar::running(false));
+} catch (Exception $e) {echo $e->getMessage(),"\n";}
+var_dump(Phar::running(false));
+include Phar::running(true) . "/another.php";
+?>';
+$phar['another.php'] = "hi\n";
+unset($phar);
+include $pname . '/evil.php';
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Unknown phar archive ""
+Unknown phar archive "%sphar_unlinkarchive.phar"
+Unknown phar archive "%sphar_unlinkarchive.phar.tar": internal corruption of phar "%sphar_unlinkarchive.phar.tar" (truncated entry)
+
+Warning: Phar::unlinkArchive() expects parameter 1 to be %string, array given in %sphar_unlinkarchive.php on line %d
+bool(false)
+string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+phar archive "%sphar_unlinkarchive.phar" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+bool(false)
+int(0)
+phar archive "%sphar_unlinkarchive.phar" cannot be unlinked from within itself
+string(%d) "%sphar_unlinkarchive.phar"
+hi
+===DONE===
diff --git a/ext/phar/tests/pharfileinfo_chmod.phpt b/ext/phar/tests/pharfileinfo_chmod.phpt
new file mode 100644
index 0000000..e99be5d
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_chmod.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Phar: PharFileInfo::chmod extra code coverage
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+
+$phar['a/b'] = 'hi there';
+
+$b = $phar['a/b'];
+try {
+$phar['a']->chmod(066);
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+$b->chmod(array());
+lstat($pname . '/a/b'); // sets BG(CurrentLStatFile)
+$b->chmod(0666);
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+Phar entry "a" is a temporary directory (not an actual entry in the archive), cannot chmod
+
+Warning: PharFileInfo::chmod() expects parameter 1 to be long, array given in %spharfileinfo_chmod.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_compression.phpt b/ext/phar/tests/pharfileinfo_compression.phpt
new file mode 100644
index 0000000..fbac499
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_compression.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Phar: PharFileInfo compression-related methods
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+
+$phar['a/b'] = 'hi there';
+
+$b = $phar['a/b'];
+
+$b->isCompressed(array());
+try {
+$b->isCompressed(25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$b->compress(25);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$tar = $phar->convertToData(Phar::TAR);
+
+$c = $tar['a/b'];
+try {
+$c->compress(Phar::GZ);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+try {
+$phar['a']->compress(Phar::GZ);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 1);
+try {
+$b->compress(Phar::GZ);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 0);
+var_dump($b->compress(Phar::GZ));
+var_dump($b->compress(Phar::GZ));
+var_dump($b->compress(Phar::BZ2));
+var_dump($b->compress(Phar::BZ2));
+
+echo "decompress\n";
+
+ini_set('phar.readonly', 1);
+try {
+$phar['a/b']->decompress();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly', 0);
+try {
+$phar['a']->decompress();
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+var_dump($b->decompress());
+var_dump($b->decompress());
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
+--EXPECTF--
+Warning: PharFileInfo::isCompressed() expects parameter 1 to be long, array given in %spharfileinfo_compression.php on line 11
+Unknown compression type specified
+Unknown compression type specified
+Cannot compress with Gzip compression, not possible with tar-based phar archives
+Phar entry is a directory, cannot set compression
+Phar is readonly, cannot change compression
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+decompress
+Phar is readonly, cannot decompress
+Phar entry is a directory, cannot set compression
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_construct.phpt b/ext/phar/tests/pharfileinfo_construct.phpt
new file mode 100644
index 0000000..2610095
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_construct.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Phar: PharFileInfo::__construct
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+try {
+file_put_contents($fname, 'blah');
+$a = new PharFileInfo($pname . '/oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+unlink($fname);
+}
+
+$a = new PharFileInfo(array());
+
+$a = new Phar($fname);
+$a['a'] = 'hi';
+$b = $a['a'];
+
+try {
+$a = new PharFileInfo($pname . '/oops/I/do/not/exist');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+try {
+$b->__construct('oops');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+try {
+$a = new PharFileInfo(__FILE__);
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
+
+Warning: PharFileInfo::__construct() expects parameter 1 to be %string, array given in %spharfileinfo_construct.php on line %d
+Cannot access phar file entry '/oops/I/do/not/exist' in archive '%spharfileinfo_construct.phar'
+Cannot call constructor twice
+'%spharfileinfo_construct.php' is not a valid phar archive URL (must have at least phar://filename.phar)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_destruct.phpt b/ext/phar/tests/pharfileinfo_destruct.phpt
new file mode 100644
index 0000000..48a58c0
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_destruct.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar: PharFileInfo::__destruct
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+$a = new Phar($fname);
+$a['a/subdir/here'] = 'hi';
+
+$b = new PharFileInfo($pname . '/a/subdir');
+unset($b);
+
+$b = new PharFileInfo($pname . '/a/subdir/here');
+unset($b);
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_getcrc32.phpt b/ext/phar/tests/pharfileinfo_getcrc32.phpt
new file mode 100644
index 0000000..dfa12f4
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_getcrc32.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: PharFileInfo::getCRC32
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+$file = "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+// compressed file length does not match incompressed lentgh for an uncompressed file
+
+$files = array();
+$files['a/subdir/here'] = array('cont'=>'a','ulen'=>1,'clen'=>1);;
+include 'files/phar_test.inc';
+
+$b = new PharFileInfo($pname . '/a/subdir');
+try {
+var_dump($b->getCRC32());
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+
+$b = new PharFileInfo($pname . '/a/subdir/here');
+try {
+var_dump($b->getCRC32());
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+$a = file_get_contents($pname . '/a/subdir/here');
+try {
+var_dump($b->getCRC32());
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+Phar entry is a directory, does not have a CRC
+Phar entry was not CRC checked
+int(%s)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/pharfileinfo_setmetadata.phpt b/ext/phar/tests/pharfileinfo_setmetadata.phpt
new file mode 100644
index 0000000..8fb6935
--- /dev/null
+++ b/ext/phar/tests/pharfileinfo_setmetadata.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: PharFileInfo::setMetadata/delMetadata extra code coverage
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+
+$phar['a/b'] = 'hi there';
+$tar = $phar->convertToData(Phar::TAR);
+
+$b = $phar['a/b'];
+try {
+$phar['a']->setMetadata('hi');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+$phar['a']->delMetadata();
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+ini_set('phar.readonly', 1);
+try {
+$b->setMetadata('hi');
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+try {
+$b->delMetadata();
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+ini_set('phar.readonly', 0);
+$b->setMetadata(1,2,3);
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
+--EXPECTF--
+Phar entry is a temporary directory (not an actual entry in the archive), cannot set metadata
+Phar entry is a temporary directory (not an actual entry in the archive), cannot delete metadata
+Write operations disabled by the php.ini setting phar.readonly
+Write operations disabled by the php.ini setting phar.readonly
+
+Warning: PharFileInfo::setMetadata() expects exactly 1 parameter, 3 given in %spharfileinfo_setmetadata.php on line %d
+===DONE===
diff --git a/ext/phar/tests/phpinfo_001.phpt b/ext/phar/tests/phpinfo_001.phpt
new file mode 100644
index 0000000..5de74da
--- /dev/null
+++ b/ext/phar/tests/phpinfo_001.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Phar: phpinfo display 1
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip zlib not loaded");
+if (!extension_loaded("bz2")) die("skip bz2 not loaded");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+phar.cache_list=
+--FILE--
+<?php
+phpinfo(INFO_MODULES);
+ini_set('phar.readonly',1);
+ini_set('phar.require_hash',1);
+phpinfo(INFO_MODULES);
+?>
+===DONE===
+--EXPECTF--
+%aPhar
+
+Phar: PHP Archive support => enabled
+Phar EXT version => %s
+Phar API version => 1.1.1
+SVN revision => %sRevision: %s $
+Phar-based phar archives => enabled
+Tar-based phar archives => enabled
+ZIP-based phar archives => enabled
+gzip compression => enabled
+bzip2 compression => enabled
+OpenSSL support => disabled (install ext/openssl)
+
+
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.
+Phar fully realized by Gregory Beaver and Marcus Boerger.
+Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
+Directive => Local Value => Master Value
+phar.cache_list => no value => no value
+phar.readonly => Off => Off
+phar.require_hash => Off => Off
+%a
+Phar
+
+Phar: PHP Archive support => enabled
+Phar EXT version => %s
+Phar API version => 1.1.1
+SVN revision => %sRevision: %s $
+Phar-based phar archives => enabled
+Tar-based phar archives => enabled
+ZIP-based phar archives => enabled
+gzip compression => enabled
+bzip2 compression => enabled
+OpenSSL support => disabled (install ext/openssl)
+
+
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.
+Phar fully realized by Gregory Beaver and Marcus Boerger.
+Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
+Directive => Local Value => Master Value
+phar.cache_list => no value => no value
+phar.readonly => On => Off
+phar.require_hash => On => Off
+%a
+===DONE===
diff --git a/ext/phar/tests/phpinfo_002.phpt b/ext/phar/tests/phpinfo_002.phpt
new file mode 100644
index 0000000..da6db95
--- /dev/null
+++ b/ext/phar/tests/phpinfo_002.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: phpinfo display 2
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip zlib not loaded");
+if (!extension_loaded("bz2")) die("skip bz2 not loaded");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+phar.cache_list=
+--FILE--
+<?php
+phpinfo(INFO_MODULES);
+?>
+===DONE===
+--EXPECTF--
+%a
+Phar
+
+Phar: PHP Archive support => enabled
+Phar EXT version => %s
+Phar API version => 1.1.1
+SVN revision => %sRevision: %s $
+Phar-based phar archives => enabled
+Tar-based phar archives => enabled
+ZIP-based phar archives => enabled
+gzip compression => enabled
+bzip2 compression => enabled
+OpenSSL support => disabled (install ext/openssl)
+
+
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.
+Phar fully realized by Gregory Beaver and Marcus Boerger.
+Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
+Directive => Local Value => Master Value
+phar.cache_list => no value => no value
+phar.readonly => On => On
+phar.require_hash => On => On
+%a
+===DONE===
diff --git a/ext/phar/tests/phpinfo_003.phpt b/ext/phar/tests/phpinfo_003.phpt
new file mode 100644
index 0000000..045f1a0
--- /dev/null
+++ b/ext/phar/tests/phpinfo_003.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: phpinfo display 3
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (extension_loaded("zlib")) die("skip zlib loaded");
+if (extension_loaded("bz2")) die("skip bz2 loaded");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+phar.cache_list=
+--FILE--
+<?php
+phpinfo(INFO_MODULES);
+?>
+===DONE===
+--EXPECTF--
+%a
+Phar
+
+Phar: PHP Archive support => enabled
+Phar EXT version => %s
+Phar API version => 1.1.1
+SVN revision => %cId: %s $
+Phar-based phar archives => enabled
+Tar-based phar archives => enabled
+ZIP-based phar archives => enabled
+gzip compression => disabled (install ext/zlib)
+bzip2 compression => disabled (install pecl/bz2)
+OpenSSL support => disabled (install ext/openssl)
+
+
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.
+Phar fully realized by Gregory Beaver and Marcus Boerger.
+Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.
+Directive => Local Value => Master Value
+phar.cache_list => no value => no value
+phar.readonly => On => On
+phar.require_hash => On => On
+%a
+===DONE===
diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt
new file mode 100644
index 0000000..c49205c
--- /dev/null
+++ b/ext/phar/tests/phpinfo_004.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Phar: phpinfo display 4
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("zlib")) die("skip zlib not loaded");
+if (!extension_loaded("bz2")) die("skip bz2 not loaded");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+phar.cache_list=
+--POST--
+a=b
+--FILE--
+<?php
+phpinfo(INFO_MODULES);
+ini_set('phar.readonly',1);
+ini_set('phar.require_hash',1);
+phpinfo(INFO_MODULES);
+?>
+===DONE===
+--EXPECTF--
+%a<br />
+<h2><a name="module_Phar">Phar</a></h2>
+<table border="0" cellpadding="3" width="600">
+<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
+<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
+<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">gzip compression </td><td class="v">enabled </td></tr>
+<tr><td class="e">bzip2 compression </td><td class="v">enabled </td></tr>
+<tr><td class="e">OpenSSL support </td><td class="v">disabled (install ext/openssl) </td></tr>
+</table><br />
+<table border="0" cellpadding="3" width="600">
+<tr class="v"><td>
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
+</table><br />
+<table border="0" cellpadding="3" width="600">
+<tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr>
+<tr><td class="e">phar.cache_list</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>
+<tr><td class="e">phar.readonly</td><td class="v">Off</td><td class="v">Off</td></tr>
+<tr><td class="e">phar.require_hash</td><td class="v">Off</td><td class="v">Off</td></tr>
+</table><br />
+%a<br />
+<h2><a name="module_Phar">Phar</a></h2>
+<table border="0" cellpadding="3" width="600">
+<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
+<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
+<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
+<tr><td class="e">gzip compression </td><td class="v">enabled </td></tr>
+<tr><td class="e">bzip2 compression </td><td class="v">enabled </td></tr>
+<tr><td class="e">OpenSSL support </td><td class="v">disabled (install ext/openssl) </td></tr>
+</table><br />
+<table border="0" cellpadding="3" width="600">
+<tr class="v"><td>
+Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr>
+</table><br />
+<table border="0" cellpadding="3" width="600">
+<tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr>
+<tr><td class="e">phar.cache_list</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>
+<tr><td class="e">phar.readonly</td><td class="v">On</td><td class="v">Off</td></tr>
+<tr><td class="e">phar.require_hash</td><td class="v">On</td><td class="v">Off</td></tr>
+</table><br />
+%a<br />
+</div></body></html>===DONE===
diff --git a/ext/phar/tests/readfile.phpt b/ext/phar/tests/readfile.phpt
new file mode 100644
index 0000000..60fdad1
--- /dev/null
+++ b/ext/phar/tests/readfile.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar: test readfile() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+readfile("dir/file1.txt");
+readfile("file1.txt", true);
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+Phar::interceptFileFuncs();
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+hihi===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/readfile_edgecases.phpt b/ext/phar/tests/readfile_edgecases.phpt
new file mode 100644
index 0000000..3cf69ed
--- /dev/null
+++ b/ext/phar/tests/readfile_edgecases.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar: test edge cases of readfile() function interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+readfile(array());
+chdir(dirname(__FILE__));
+file_put_contents($fname, "blah\n");
+file_put_contents("foob", "test\n");
+readfile($fname);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', '<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("' . addslashes(dirname(__FILE__)) . '");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+Warning: readfile() expects parameter 1 to be a valid path, array given in %sreadfile_edgecases.php on line %d
+blah
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+test
+test
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+
+Warning: readfile(phar://%sreadfile_edgecases.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecases.phar.php/foo/hi on line %d
+===DONE===
diff --git a/ext/phar/tests/readfile_edgecasesU.phpt b/ext/phar/tests/readfile_edgecasesU.phpt
new file mode 100644
index 0000000..c26b45f
--- /dev/null
+++ b/ext/phar/tests/readfile_edgecasesU.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: test edge cases of readfile() function interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires php 6.0 or newer"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+chdir(dirname(__FILE__));
+file_put_contents($fname, "blah\n");
+file_put_contents("foob", "test\n");
+readfile($fname);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', '<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("' . addslashes(dirname(__FILE__)) . '");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+blah
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+test
+test
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+
+Warning: readfile(phar://%sreadfile_edgecasesU.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecasesU.phar.php/foo/hi on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/refcount1.phpt b/ext/phar/tests/refcount1.phpt
new file mode 100644
index 0000000..ddbb7f7
--- /dev/null
+++ b/ext/phar/tests/refcount1.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, b"extra");
+fclose($fp);
+echo "===CLOSE===\n";
+$p = new Phar($fname);
+$b = fopen($pname . '/b/c.php', 'rb');
+$a = $p['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($pname . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $pname . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.php/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%d) "c.php"
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.php", has open file pointers, cannot unlink in %srefcount1.php on line %d
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.php/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%s) "c.php"
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/refcount1_5_2.phpt b/ext/phar/tests/refcount1_5_2.phpt
new file mode 100644
index 0000000..bf2c2b7
--- /dev/null
+++ b/ext/phar/tests/refcount1_5_2.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
+
+$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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, "extra");
+fclose($fp);
+
+echo "===CLOSE===\n";
+
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($alias . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1_5_2.phar", has open file pointers, cannot unlink in %sefcount1_5_2.php on line %d
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/rename.phpt b/ext/phar/tests/rename.phpt
new file mode 100644
index 0000000..c73c98e
--- /dev/null
+++ b/ext/phar/tests/rename.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: rename test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+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';
+include 'files/phar_test.inc';
+include $fname;
+
+echo file_get_contents($pname . '/a') . "\n";
+rename($pname . '/a', $pname . '/b');
+echo file_get_contents($pname . '/b') . "\n";
+echo file_get_contents($pname . '/a') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/rename_dir.phpt b/ext/phar/tests/rename_dir.phpt
new file mode 100644
index 0000000..d19a37f
--- /dev/null
+++ b/ext/phar/tests/rename_dir.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Phar: rename_dir test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+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/x'] = 'a';
+include 'files/phar_test.inc';
+include $fname;
+
+echo file_get_contents($pname . '/a/x') . "\n";
+rename($pname . '/a', $pname . '/b');
+echo file_get_contents($pname . '/b/x') . "\n";
+echo file_get_contents($pname . '/a/x') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename_dir.phar.php/a/x): failed to open stream: phar error: "a/x" is not a file in phar "%srename_dir.phar.php" in %srename_dir.php on line %d
diff --git a/ext/phar/tests/rename_dir_and_mount.phpt b/ext/phar/tests/rename_dir_and_mount.phpt
new file mode 100644
index 0000000..b74f47b
--- /dev/null
+++ b/ext/phar/tests/rename_dir_and_mount.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar: rename_dir and mount test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+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/x'] = 'a';
+$files['a/b/x'] = 'a';
+include 'files/phar_test.inc';
+include $fname;
+
+Phar::mount("$pname/a/c", dirname(__FILE__));
+
+var_dump(file_exists($pname . '/a'));
+var_dump(file_exists($pname . '/a/x'));
+var_dump(file_exists($pname . '/a/b'));
+var_dump(file_exists($pname . '/a/b/x'));
+var_dump(file_exists($pname . '/a/c'));
+var_dump(file_exists($pname . '/a/c/'.basename(__FILE__)));
+rename($pname . '/a', $pname . '/b');
+clearstatcache();
+var_dump(file_exists($pname . '/a'));
+var_dump(file_exists($pname . '/a/x'));
+var_dump(file_exists($pname . '/a/b'));
+var_dump(file_exists($pname . '/a/b/x'));
+var_dump(file_exists($pname . '/a/c'));
+var_dump(file_exists($pname . '/a/c/'.basename(__FILE__)));
+var_dump(file_exists($pname . '/b'));
+var_dump(file_exists($pname . '/b/x'));
+var_dump(file_exists($pname . '/b/b'));
+var_dump(file_exists($pname . '/b/b/x'));
+var_dump(file_exists($pname . '/b/c'));
+var_dump(file_exists($pname . '/b/c/'.basename(__FILE__)));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/phar/tests/rmdir.phpt b/ext/phar/tests/rmdir.phpt
new file mode 100644
index 0000000..726e2cf
--- /dev/null
+++ b/ext/phar/tests/rmdir.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Phar: rmdir test
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$file = b"<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a/x'] = 'a';
+include 'files/phar_test.inc';
+include $fname;
+
+echo file_get_contents($pname . '/a/x') . "\n";
+var_dump(rmdir($pname . '/a'));
+echo file_get_contents($pname . '/a/x') . "\n";
+unlink($pname . '/a/x');
+var_dump(rmdir($pname . '/a'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+a
+
+Warning: rmdir(): phar error: Directory not empty in %srmdir.php on line 14
+bool(false)
+a
+bool(true)
diff --git a/ext/phar/tests/security.phpt b/ext/phar/tests/security.phpt
new file mode 100644
index 0000000..f2944da
--- /dev/null
+++ b/ext/phar/tests/security.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar: test to ensure phar.readonly cannot be circumvented
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.php';
+$a = new Phar($fname);
+$a->setStub('<?php
+Phar::mapPhar();
+$phar = new Phar(__FILE__);
+var_dump($phar->isWritable());
+try {
+$phar["b"] = "should not work!";
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+__HALT_COMPILER();
+?>');
+$a['hi'] = 'hi';
+unset($a);
+copy($fname, $fname2);
+Phar::unlinkArchive($fname);
+ini_set('phar.readonly', 1);
+include $fname2;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.php'); ?>
+--EXPECT--
+bool(false)
+Write operations disabled by the php.ini setting phar.readonly
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/stat.phpt b/ext/phar/tests/stat.phpt
new file mode 100644
index 0000000..184aa6d
--- /dev/null
+++ b/ext/phar/tests/stat.phpt
@@ -0,0 +1,225 @@
+--TEST--
+Phar: test stat function interceptions
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+var_dump(stat(""));
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$a = new Phar($fname);
+$a['my/index.php'] = '<?php
+echo "stat\n";
+var_dump(stat("dir/file1.txt"));
+echo "lstat\n";
+var_dump(lstat("dir/file1.txt"));
+echo "fileperms\n";
+var_dump(fileperms("dir/file1.txt"));
+echo "fileinode\n";
+var_dump(fileinode("dir/file1.txt"));
+echo "filesize\n";
+var_dump(filesize("dir/file1.txt"));
+echo "fileowner\n";
+var_dump(fileowner("dir/file1.txt"));
+echo "filegroup\n";
+var_dump(filegroup("dir/file1.txt"));
+echo "filemtime\n";
+var_dump(filemtime("dir/file1.txt"));
+echo "fileatime\n";
+var_dump(fileatime("dir/file1.txt"));
+echo "filectime\n";
+var_dump(filectime("dir/file1.txt"));
+echo "filetype\n";
+var_dump(filetype("dir/file1.txt"));
+echo "is_writable\n";
+var_dump(is_writable("dir/file1.txt"));
+echo "is_writeable\n";
+var_dump(is_writeable("dir/file1.txt"));
+echo "is_readable\n";
+var_dump(is_readable("dir/file1.txt"));
+echo "is_executable\n";
+var_dump(is_executable("dir/file1.txt"));
+echo "file_exists\n";
+var_dump(file_exists("dir/file1.txt"));
+echo "is_dir\n";
+var_dump(is_dir("dir/file1.txt"));
+echo "is_file\n";
+var_dump(is_file("dir/file1.txt"));
+echo "is_link\n";
+var_dump(is_link("dir/file1.txt"));
+echo "not found\n";
+var_dump(file_exists("not/found"));
+echo "not found 2\n";
+var_dump(fileperms("not/found"));
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "my/index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+bool(false)
+stat
+array(26) {
+ [0]=>
+ int(12)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(33206)
+ [3]=>
+ int(1)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(%s)
+ [7]=>
+ int(2)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%s)
+ [12]=>
+ int(%s)
+ ["dev"]=>
+ int(12)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(33206)
+ ["nlink"]=>
+ int(1)
+ ["uid"]=>
+ int(0)
+ ["gid"]=>
+ int(0)
+ ["rdev"]=>
+ int(%s)
+ ["size"]=>
+ int(2)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%s)
+ ["blocks"]=>
+ int(%s)
+}
+lstat
+array(26) {
+ [0]=>
+ int(12)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(33206)
+ [3]=>
+ int(1)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(%s)
+ [7]=>
+ int(2)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%s)
+ [12]=>
+ int(%s)
+ ["dev"]=>
+ int(12)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(33206)
+ ["nlink"]=>
+ int(1)
+ ["uid"]=>
+ int(0)
+ ["gid"]=>
+ int(0)
+ ["rdev"]=>
+ int(%s)
+ ["size"]=>
+ int(2)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%s)
+ ["blocks"]=>
+ int(%s)
+}
+fileperms
+int(33206)
+fileinode
+int(%d)
+filesize
+int(2)
+fileowner
+int(0)
+filegroup
+int(0)
+filemtime
+int(%d)
+fileatime
+int(%d)
+filectime
+int(%d)
+filetype
+string(4) "file"
+is_writable
+bool(true)
+is_writeable
+bool(false)
+is_readable
+bool(true)
+is_executable
+bool(false)
+file_exists
+bool(true)
+is_dir
+bool(false)
+is_file
+bool(true)
+is_link
+bool(false)
+not found
+bool(false)
+not found 2
+
+Warning: fileperms(): stat failed for not/found in phar://%sstat.phar.php/my/index.php on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/stat2.phpt b/ext/phar/tests/stat2.phpt
new file mode 100644
index 0000000..defda71
--- /dev/null
+++ b/ext/phar/tests/stat2.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: test stat function interceptions and is_file/is_link edge cases (PHP 5.2)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) != '5.2') die("skip PHP 5.2 required for this test");?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+is_file();
+is_link();
+var_dump(is_file(__FILE__));
+
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+copy(dirname(__FILE__) . '/tar/files/links.tar', $fname2);
+$a = new PharData($fname2);
+$b = $a->convertToExecutable();
+unset($a);
+Phar::unlinkArchive($fname2);
+$b['foo/stat.php'] = '<?php
+echo "is_link\n";
+var_dump(is_link("./stat.php"),is_file("./stat.php"), is_link("./oops"), is_file("./oops"));
+var_dump(is_link("testit/link"), filetype("testit/link"), filetype("testit"), is_file("testit/link"));
+echo "not found\n";
+var_dump(is_link("notfound"));
+echo "dir\n";
+var_dump(is_dir("./bar"), is_file("foo/bar/blah"));
+?>';
+$b->addEmptyDir('foo/bar/blah');
+$b->setStub('<?php
+include "phar://" . __FILE__ . "/foo/stat.php";
+__HALT_COMPILER();');
+include $fname3;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
+--EXPECTF--
+Warning: Wrong parameter count for is_file() in %sstat2.php on line %d
+
+Warning: Wrong parameter count for is_link() in %sstat2.php on line %d
+bool(true)
+is_link
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+string(4) "link"
+string(3) "dir"
+bool(true)
+not found
+bool(false)
+dir
+bool(true)
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/stat2_5.3.phpt b/ext/phar/tests/stat2_5.3.phpt
new file mode 100644
index 0000000..aba2a64
--- /dev/null
+++ b/ext/phar/tests/stat2_5.3.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: test stat function interceptions and is_file/is_link edge cases (PHP 5.3+)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) == '5.2') die("skip PHP 5.3+ required for this test");?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+is_file();
+is_link();
+var_dump(is_file(__FILE__));
+
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+copy(dirname(__FILE__) . '/tar/files/links.tar', $fname2);
+$a = new PharData($fname2);
+$b = $a->convertToExecutable(Phar::TAR, Phar::NONE, '.3.phar.tar');
+unset($a);
+Phar::unlinkArchive($fname2);
+$b['foo/stat.php'] = '<?php
+echo "is_link\n";
+var_dump(is_link("./stat.php"),is_file("./stat.php"), is_link("./oops"), is_file("./oops"));
+var_dump(is_link("testit/link"), filetype("testit/link"), filetype("testit"), is_file("testit/link"));
+echo "not found\n";
+var_dump(is_link("notfound"));
+echo "dir\n";
+var_dump(is_dir("./bar"), is_file("foo/bar/blah"));
+?>';
+$b->addEmptyDir('foo/bar/blah');
+$b->setStub('<?php
+include "phar://" . __FILE__ . "/foo/stat.php";
+__HALT_COMPILER();');
+include $fname3;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
+--EXPECTF--
+Warning: is_file() expects exactly 1 parameter, 0 given in %sstat2_5.3.php on line %d
+
+Warning: is_link() expects exactly 1 parameter, 0 given in %sstat2_5.3.php on line %d
+bool(true)
+is_link
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+string(4) "link"
+string(3) "dir"
+bool(true)
+not found
+bool(false)
+dir
+bool(true)
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/033.phpt b/ext/phar/tests/tar/033.phpt
new file mode 100644
index 0000000..29223e4
--- /dev/null
+++ b/ext/phar/tests/tar/033.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Phar::chmod tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+
+try {
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
+ echo "test dir\n";
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0000);
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isReadable());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+bool(false)
+test dir
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/033a.phpt b/ext/phar/tests/tar/033a.phpt
new file mode 100644
index 0000000..09b5446
--- /dev/null
+++ b/ext/phar/tests/tar/033a.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar::chmod tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+try {
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
+ echo "test dir\n";
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0000);
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isReadable());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+?>
+--EXPECTF--
+bool(false)
+Cannot modify permissions for file "a.php" in phar "%s033a.phar.tar", write operations are prohibited
+===DONE===
diff --git a/ext/phar/tests/tar/alias_acrobatics.phpt b/ext/phar/tests/tar/alias_acrobatics.phpt
new file mode 100644
index 0000000..d08dc04
--- /dev/null
+++ b/ext/phar/tests/tar/alias_acrobatics.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: alias edge cases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar';
+
+$p = new Phar($fname);
+
+$p->setAlias('foo');
+$p['unused'] = 'hi';
+try {
+$a = new Phar($fname2, 0, 'foo');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+copy($fname, $fname2);
+echo "2\n";
+try {
+$a = new Phar($fname2);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+$b = new Phar($fname, 0, 'another');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar');
+?>
+--EXPECTF--
+alias "foo" is already used for archive "%salias_acrobatics.phar.tar" cannot be overloaded with "%salias_acrobatics.2.phar.tar"
+2
+phar error: Unable to add tar-based phar "%salias_acrobatics.2.phar.tar", alias is already in use
+alias "another" is already used for archive "%salias_acrobatics.phar.tar" cannot be overloaded with "%salias_acrobatics.phar.tar"
+===DONE===
diff --git a/ext/phar/tests/tar/all.phpt b/ext/phar/tests/tar/all.phpt
new file mode 100644
index 0000000..4dfb654
--- /dev/null
+++ b/ext/phar/tests/tar/all.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar: test that creation of tar-based phar generates valid tar with all bells/whistles
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php';
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+
+$phar->setMetadata('hi there');
+$phar['a'] = 'hi';
+$phar['a']->setMetadata('a meta');
+$phar['b'] = 'hi2';
+$phar['c'] = 'hi3';
+$phar['b']->chmod(0444);
+$phar->setStub("<?php ok __HALT_COMPILER();");
+$phar->setAlias("hime");
+unset($phar);
+copy($fname, $fname2);
+Phar::unlinkArchive($fname);
+var_dump(file_exists($fname), file_exists($pname . '/a'));
+
+$phar = new Phar($fname2);
+var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
+var_dump((string) decoct(fileperms($pname2 . '/b')));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+var_dump($phar->getMetadata());
+var_dump($phar['a']->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php'); ?>
+--EXPECT--
+bool(false)
+bool(false)
+string(2) "hi"
+string(3) "hi2"
+string(3) "hi3"
+string(6) "100444"
+string(32) "<?php ok __HALT_COMPILER(); ?>
+"
+string(4) "hime"
+string(8) "hi there"
+string(6) "a meta"
+===DONE===
diff --git a/ext/phar/tests/tar/allU.phpt b/ext/phar/tests/tar/allU.phpt
new file mode 100644
index 0000000..50c7fc7
--- /dev/null
+++ b/ext/phar/tests/tar/allU.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar: test that creation of tar-based phar generates valid tar with all bells/whistles
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php';
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+
+$phar->setMetadata('hi there');
+$phar['a'] = 'hi';
+$phar['a']->setMetadata('a meta');
+$phar['b'] = 'hi2';
+$phar['c'] = 'hi3';
+$phar['b']->chmod(0444);
+$phar->setStub("<?php ok __HALT_COMPILER();");
+$phar->setAlias("hime");
+unset($phar);
+copy($fname, $fname2);
+Phar::unlinkArchive($fname);
+var_dump(file_exists($fname), file_exists($pname . '/a'));
+
+$phar = new Phar($fname2);
+var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
+var_dump((string) decoct(fileperms($pname2 . '/b')));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+var_dump($phar->getMetadata());
+var_dump($phar['a']->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php'); ?>
+--EXPECT--
+bool(false)
+bool(false)
+string(2) "hi"
+string(3) "hi2"
+string(3) "hi3"
+unicode(6) "100444"
+string(32) "<?php ok __HALT_COMPILER(); ?>
+"
+string(4) "hime"
+unicode(8) "hi there"
+unicode(6) "a meta"
+===DONE===
diff --git a/ext/phar/tests/tar/badalias.phpt b/ext/phar/tests/tar/badalias.phpt
new file mode 100644
index 0000000..441fc03
--- /dev/null
+++ b/ext/phar/tests/tar/badalias.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar: invalid aliases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--FILE--
+<?php
+$e = dirname(__FILE__) . '/files/';
+for ($i = 1; $i <= 5; $i++) {
+try {
+new Phar($e . "badalias$i.phar.tar");
+} catch (Exception $ee) {
+echo $ee->getMessage(), "\n";
+}
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: invalid alias "hi/thereaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." in tar-based phar "%sbadalias1.phar.tar"
+phar error: invalid alias "hi\there" in tar-based phar "%sbadalias2.phar.tar"
+phar error: invalid alias "hi;there" in tar-based phar "%sbadalias3.phar.tar"
+phar error: invalid alias "hi:there" in tar-based phar "%sbadalias4.phar.tar"
+phar error: tar-based phar "%sbadalias5.phar.tar" has alias that is larger than 511 bytes, cannot process
+===DONE===
diff --git a/ext/phar/tests/tar/badchecksum.phpt b/ext/phar/tests/tar/badchecksum.phpt
new file mode 100644
index 0000000..fae19b1
--- /dev/null
+++ b/ext/phar/tests/tar/badchecksum.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Phar: tar with bad checksum
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$pname = 'phar://' . $fname;
+
+include dirname(__FILE__) . '/files/corrupt_tarmaker.php.inc';
+$a = new corrupt_tarmaker($fname, 'none');
+$a->init();
+$a->addFile('hithere', 'contents', null, 'checksum');
+$a->close();
+
+try {
+ $p = new PharData($fname);
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+?>
+--EXPECTF--
+phar error: "%sbadchecksum.tar" is a corrupted tar file (checksum mismatch of file "hithere")
+===DONE===
diff --git a/ext/phar/tests/tar/bignames.phpt b/ext/phar/tests/tar/bignames.phpt
new file mode 100644
index 0000000..c10b1ce
--- /dev/null
+++ b/ext/phar/tests/tar/bignames.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: tar with huge filenames
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.tar';
+$fname4 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.4.tar';
+$pname = 'phar://' . $fname;
+
+$p1 = new PharData($fname);
+$p1[str_repeat('a', 100) . '/b'] = 'hi';
+$p1[str_repeat('a', 155) . '/' . str_repeat('b', 100)] = 'hi2';
+copy($fname, $fname2);
+$p2 = new PharData($fname2);
+echo $p2[str_repeat('a', 100) . '/b']->getContent() . "\n";
+echo $p2[str_repeat('a', 155) . '/' . str_repeat('b', 100)]->getContent() . "\n";
+
+try {
+ $p2[str_repeat('a', 400)] = 'yuck';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $p2 = new PharData($fname3);
+ $p2[str_repeat('a', 101)] = 'yuck';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $p2 = new PharData($fname4);
+ $p2[str_repeat('b', 160) . '/' . str_repeat('a', 90)] = 'yuck';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
+@unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.tar');
+@unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.4.tar');
+?>
+--EXPECTF--
+hi
+hi2
+tar-based phar "%sbignames.2.tar" cannot be created, filename "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
+tar-based phar "%sbignames.3.tar" cannot be created, filename "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
+tar-based phar "%sbignames.4.tar" cannot be created, filename "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
+===DONE===
diff --git a/ext/phar/tests/tar/bignames_overflow.phpt b/ext/phar/tests/tar/bignames_overflow.phpt
new file mode 100644
index 0000000..359e9c6
--- /dev/null
+++ b/ext/phar/tests/tar/bignames_overflow.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Phar: tar with huge filenames, buffer overflow
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
+$pname = 'phar://' . $fname;
+
+include dirname(__FILE__) . '/files/make.dangerous.tar.php.inc';
+
+$tar = new danger_tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile(str_repeat('a', 101), 'hi');
+$tar->addFile(str_repeat('a', 255), 'hi2');
+$tar->close();
+
+$p1 = new PharData($fname);
+foreach ($p1 as $file) {
+ echo $file->getFileName(), "\n";
+}
+echo $p1['a/' . str_repeat('a', 100)]->getContent() . "\n";
+echo $p1[str_repeat('a', 155) . '/' . str_repeat('a', 100)]->getContent() . "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
+?>
+--EXPECT--
+a
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+hi
+hi2
+===DONE===
diff --git a/ext/phar/tests/tar/bug49910.phpt b/ext/phar/tests/tar/bug49910.phpt
new file mode 100644
index 0000000..6fb66a5
--- /dev/null
+++ b/ext/phar/tests/tar/bug49910.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug #49910: no support for ././@LongLink for long filenames in phar tar support
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip"); ?>
+--FILE--
+<?php
+$fname = str_replace('\\', '/', dirname(__FILE__) . '/files/Structures_Graph-1.0.3.tgz');
+$tar = new PharData($fname);
+$files = array();
+foreach (new RecursiveIteratorIterator($tar) as $file) {
+ $files[] = str_replace($fname, '*', $file->getPathName());
+}
+print_r($files);
+?>
+===DONE===
+--EXPECT--
+Array
+(
+ [0] => phar://*/Structures_Graph-1.0.3/LICENSE
+ [1] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/AcyclicTest.php
+ [2] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/TopologicalSorter.php
+ [3] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Node.php
+ [4] => phar://*/Structures_Graph-1.0.3/Structures/Graph.php
+ [5] => phar://*/Structures_Graph-1.0.3/docs/generate.sh
+ [6] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph.html
+ [7] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_AcyclicTest.html
+ [8] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_TopologicalSorter.html
+ [9] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Node.html
+ [10] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_AcyclicTest_php.html
+ [11] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_TopologicalSorter_php.html
+ [12] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Node_php.html
+ [13] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_php.html
+ [14] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/tutorial_Structures_Graph.pkg.html
+ [15] => phar://*/Structures_Graph-1.0.3/docs/html/classtrees_Structures_Graph.html
+ [16] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex.html
+ [17] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex_Structures_Graph.html
+ [18] => phar://*/Structures_Graph-1.0.3/docs/html/errors.html
+ [19] => phar://*/Structures_Graph-1.0.3/docs/html/index.html
+ [20] => phar://*/Structures_Graph-1.0.3/docs/html/li_Structures_Graph.html
+ [21] => phar://*/Structures_Graph-1.0.3/docs/html/media/banner.css
+ [22] => phar://*/Structures_Graph-1.0.3/docs/html/media/stylesheet.css
+ [23] => phar://*/Structures_Graph-1.0.3/docs/html/packages.html
+ [24] => phar://*/Structures_Graph-1.0.3/docs/html/todolist.html
+ [25] => phar://*/Structures_Graph-1.0.3/docs/tutorials/Structures_Graph/Structures_Graph.pkg
+ [26] => phar://*/Structures_Graph-1.0.3/tests/AllTests.php
+ [27] => phar://*/Structures_Graph-1.0.3/tests/testCase/BasicGraph.php
+ [28] => phar://*/package.xml
+)
+===DONE===
diff --git a/ext/phar/tests/tar/create_new_and_modify.phpt b/ext/phar/tests/tar/create_new_and_modify.phpt
new file mode 100644
index 0000000..8062fda
--- /dev/null
+++ b/ext/phar/tests/tar/create_new_and_modify.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: create and modify tar-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$pname = 'phar://' . $fname;
+
+@unlink($fname);
+
+file_put_contents($pname . '/a.php', "brand new!\n");
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::TAR));
+$sig1 = md5_file($fname);
+
+include $pname . '/a.php';
+
+file_put_contents($pname .'/a.php', "modified!\n");
+file_put_contents($pname .'/b.php', "another!\n");
+
+$phar = new Phar($fname);
+$sig2 = md5_file($fname);
+
+var_dump($sig1 != $sig2);
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php'); ?>
+--EXPECTF--
+bool(true)
+brand new!
+bool(true)
+modified!
+another!
+===DONE===
diff --git a/ext/phar/tests/tar/create_new_phar_b.phpt b/ext/phar/tests/tar/create_new_phar_b.phpt
new file mode 100644
index 0000000..371e47d
--- /dev/null
+++ b/ext/phar/tests/tar/create_new_phar_b.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Phar: create a completely new tar-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+
+file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/a.php',
+ 'brand new!');
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/a.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: file_put_contents(phar://%screate_new_phar_b.phar.tar/a.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %screate_new_phar_b.php on line %d
+
+Warning: include(phar://%screate_new_phar_b.phar.tar/a.php): failed to open stream: %s in %screate_new_phar_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%screate_new_phar_b.phar.tar/a.php' for inclusion (include_path='%s') in %screate_new_phar_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/delete.phpt b/ext/phar/tests/tar/delete.phpt
new file mode 100644
index 0000000..32b2b1e
--- /dev/null
+++ b/ext/phar/tests/tar/delete.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Phar: delete test, tar-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+$stub = "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar->setStub($stub);
+$phar->stopBuffering();
+
+echo file_get_contents($alias . '/a') . "\n";
+$phar->delete('a');
+echo file_get_contents($alias . '/a') . "\n";
+
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+a
+
+Warning: file_get_contents(phar://%sdelete.phar.tar/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.tar" in %sdelete.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/tar/delete_in_phar.phpt b/ext/phar/tests/tar/delete_in_phar.phpt
new file mode 100644
index 0000000..91ef4a2
--- /dev/null
+++ b/ext/phar/tests/tar/delete_in_phar.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: delete a file within a tar-based .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
+
+?>
+===AFTER===
+<?php
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar.phar.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.tar" in %sdelete_in_phar.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/delete_in_phar_b.phpt b/ext/phar/tests/tar/delete_in_phar_b.phpt
new file mode 100644
index 0000000..a67bf7a
--- /dev/null
+++ b/ext/phar/tests/tar/delete_in_phar_b.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: delete a file within a tar-based .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
+
+?>
+===AFTER===
+<?php
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+
+Warning: unlink(): phar error: write operations disabled by the php.ini setting phar.readonly in %sdelete_in_phar_b.php on line %d
+===AFTER===
+This is a
+This is b
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/tar/delete_in_phar_confirm.phpt b/ext/phar/tests/tar/delete_in_phar_confirm.phpt
new file mode 100644
index 0000000..707bcbd
--- /dev/null
+++ b/ext/phar/tests/tar/delete_in_phar_confirm.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Phar: delete a file within a tar-based .phar (confirm disk file is changed)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+$md5 = md5_file($fname);
+unlink($alias . '/b/c.php');
+clearstatcache();
+$md52 = md5_file($fname);
+if ($md5 == $md52) echo 'file was not modified';
+?>
+===AFTER===
+<?php
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/a.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar_confirm.phar.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.tar" in %sdelete_in_phar_confirm.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/dir.phpt b/ext/phar/tests/tar/dir.phpt
new file mode 100644
index 0000000..64d5d12
--- /dev/null
+++ b/ext/phar/tests/tar/dir.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: mkdir/rmdir test tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$pname2 = 'phar://' . $fname2;
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$pname3 = 'phar://' . $fname3;
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::TAR));
+
+$phar->addEmptyDir('test');
+var_dump(isset($phar['.phar/stub.php']));
+var_dump($phar['test']->isDir());
+var_dump($phar['test/']->isDir());
+copy($fname, $fname2);
+mkdir($pname . '/another/dir/');
+var_dump($phar['another/dir']->isDir());
+rmdir($pname . '/another/dir/');
+copy($fname, $fname3);
+clearstatcache();
+var_dump(file_exists($pname . '/another/dir/'));
+var_dump(file_exists($pname2 . '/test/'));
+var_dump(file_exists($pname3 . '/another/dir/'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/phar/tests/tar/exists_as_phar.phpt b/ext/phar/tests/tar/exists_as_phar.phpt
new file mode 100644
index 0000000..9a8cfc8
--- /dev/null
+++ b/ext/phar/tests/tar/exists_as_phar.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Phar: phar-based phar named with ".tar" fails
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$tname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+copy($fname, $tname);
+$phar->setAlias('hio2');
+
+try {
+ $p = new Phar($tname);
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECTF--
+phar tar error: "%sexists_as_phar.phar.tar" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar
+===DONE===
diff --git a/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz b/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz
new file mode 100644
index 0000000..976603d
--- /dev/null
+++ b/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz b/ext/phar/tests/tar/files/P1-1.0.0.tgz
new file mode 100644
index 0000000..1d9cae4
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
new file mode 100644
index 0000000..eb59bdd
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4drcwddPs6LmIbdT1ifT
+Ev8HXh1Fk1yNusCDoCX6mYkgqvCmx02F/9k5q7n6CPblTcF5mdDI8kcRrUHmyXtD
+9X0d7RN7BakZMPH5KPaNkXiXsI9YGSb39AnZgYw01n6u0W6Ohha+KwOsrxkKCF4u
+LjPLQAlM+3uD8y9Tz2fF+pAE901kHrd3ue7a5i5EtW0bzl5QfxnwFZXAO0StQ9dF
+slzibRH+1pFjMRxDnlgYmLQF6jMWm9Ty6x9UH9HZ3E3F9QZEQVXWT9y/pe30HcAX
+YxAGZjPIx19UNPF5C+Nps6MjxNRht0pGXTL9sptYoiNjRiXAS0y4FM+8K6xvBIOF
+ZQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
new file mode 100644
index 0000000..fa14f0c
--- /dev/null
+++ b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias1.phar.tar b/ext/phar/tests/tar/files/badalias1.phar.tar
new file mode 100644
index 0000000..6cd4716
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias1.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias2.phar.tar b/ext/phar/tests/tar/files/badalias2.phar.tar
new file mode 100644
index 0000000..5face85
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias2.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias3.phar.tar b/ext/phar/tests/tar/files/badalias3.phar.tar
new file mode 100644
index 0000000..ab36e1f
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias3.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias4.phar.tar b/ext/phar/tests/tar/files/badalias4.phar.tar
new file mode 100644
index 0000000..c54e31d
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias4.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias5.phar.tar b/ext/phar/tests/tar/files/badalias5.phar.tar
new file mode 100644
index 0000000..dd52b6a
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias5.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/biglink.tar b/ext/phar/tests/tar/files/biglink.tar
new file mode 100644
index 0000000..43bbf58
--- /dev/null
+++ b/ext/phar/tests/tar/files/biglink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc
new file mode 100644
index 0000000..b0eba6c
--- /dev/null
+++ b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc
@@ -0,0 +1,177 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+class corrupt_tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null, $corrupt = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0xA000 && $corrupt === 'symlink') {
+ $type = 2; // Symbolic Link
+ $link = $fileOrStream;
+ $stat['size'] = 0;
+ $fileOrStream = '';
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = $fileOrStream;
+ $stat['size'] = 0;
+ $fileOrStream = '';
+ } else if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ decoct($stat['mode']),
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '');
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ if ($corrupt === 'checksum') $checksum++;
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, $block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, $fileOrStream);
+ if (strlen($fileOrStream) && !isset($link) && strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/frontcontroller.phar.inc b/ext/phar/tests/tar/files/frontcontroller.phar.inc
new file mode 100644
index 0000000..6f426e8
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a['index.php'] = 'here is my index';
+$a->setStub('<?php
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller.phar.tar b/ext/phar/tests/tar/files/frontcontroller.phar.tar
new file mode 100644
index 0000000..02d8766
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller10.phar.inc b/ext/phar/tests/tar/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000..5b132fa
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.tar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller10.phar.tar b/ext/phar/tests/tar/files/frontcontroller10.phar.tar
new file mode 100644
index 0000000..574d7cd
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller10.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller11.phar.inc b/ext/phar/tests/tar/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000..2fa15f0
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.tar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller11.phar.tar b/ext/phar/tests/tar/files/frontcontroller11.phar.tar
new file mode 100644
index 0000000..08cbdc1
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller11.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.inc b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000..0a9422a
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.tar');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.tar b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
new file mode 100644
index 0000000..e945e49
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller2.phar.inc b/ext/phar/tests/tar/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000..8ae1171
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "a.php");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller2.phar.tar b/ext/phar/tests/tar/files/frontcontroller2.phar.tar
new file mode 100644
index 0000000..231e15a
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller2.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.inc b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000..800f65e
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => b"a.phps");
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.tar b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
new file mode 100644
index 0000000..16853bd
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.inc b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000..bfb9b41
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => false);
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.tar b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
new file mode 100644
index 0000000..5a1d4ee
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller5.phar.inc b/ext/phar/tests/tar/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000..d6204c7
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller5.phar.tar b/ext/phar/tests/tar/files/frontcontroller5.phar.tar
new file mode 100644
index 0000000..6053eb2
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller5.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller6.phar.inc b/ext/phar/tests/tar/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000..a5a6e30
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => 100));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller6.phar.tar b/ext/phar/tests/tar/files/frontcontroller6.phar.tar
new file mode 100644
index 0000000..eb3e44c
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller6.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller7.phar.inc b/ext/phar/tests/tar/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000..88121f5
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.tar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => null));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller7.phar.tar b/ext/phar/tests/tar/files/frontcontroller7.phar.tar
new file mode 100644
index 0000000..b59d052
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller7.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller8.phar.inc b/ext/phar/tests/tar/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000..f51a762
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller8.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.tar');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller8.phar.tar b/ext/phar/tests/tar/files/frontcontroller8.phar.tar
new file mode 100644
index 0000000..3440a7f
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller8.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller9.phar.inc b/ext/phar/tests/tar/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000..758ce4f
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.tar');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::mungServer(array());
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/tar/files/frontcontroller9.phar.tar b/ext/phar/tests/tar/files/frontcontroller9.phar.tar
new file mode 100644
index 0000000..15e95b1
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller9.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/links.phar.tar b/ext/phar/tests/tar/files/links.phar.tar
new file mode 100644
index 0000000..4646100
--- /dev/null
+++ b/ext/phar/tests/tar/files/links.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/links.tar b/ext/phar/tests/tar/files/links.tar
new file mode 100644
index 0000000..6cd22df
--- /dev/null
+++ b/ext/phar/tests/tar/files/links.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/make.dangerous.tar.php.inc b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc
new file mode 100644
index 0000000..deeaa41
--- /dev/null
+++ b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc
@@ -0,0 +1,170 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+// this tarmaker makes a malicious tar with a header designed to overflow the buffer
+class danger_tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = @readlink($current);
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ '12345678', // have a mode that allows the name to overflow
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '123456789abc'); // malicious block
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, (binary)$fileOrStream);
+ if (strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/make_invalid_tar.php.inc b/ext/phar/tests/tar/files/make_invalid_tar.php.inc
new file mode 100644
index 0000000..413dd7b
--- /dev/null
+++ b/ext/phar/tests/tar/files/make_invalid_tar.php.inc
@@ -0,0 +1,9 @@
+<?php
+include dirname(__FILE__) . '/tarmaker.php.inc';
+class corrupter extends tarmaker {
+function close()
+{
+ fwrite($this->tmp, (binary)'oopsie');
+ fclose($this->tmp);
+}
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/subdirlink.tar b/ext/phar/tests/tar/files/subdirlink.tar
new file mode 100644
index 0000000..5463a49
--- /dev/null
+++ b/ext/phar/tests/tar/files/subdirlink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/tarmaker.php.inc b/ext/phar/tests/tar/files/tarmaker.php.inc
new file mode 100644
index 0000000..9b8d348
--- /dev/null
+++ b/ext/phar/tests/tar/files/tarmaker.php.inc
@@ -0,0 +1,169 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+class tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = @readlink($current);
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ decoct($stat['mode']),
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '');
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, (binary)$fileOrStream);
+ if (strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/tinylink.tar b/ext/phar/tests/tar/files/tinylink.tar
new file mode 100644
index 0000000..741b56c
--- /dev/null
+++ b/ext/phar/tests/tar/files/tinylink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/trunc.tar b/ext/phar/tests/tar/files/trunc.tar
new file mode 100644
index 0000000..2156b5c
--- /dev/null
+++ b/ext/phar/tests/tar/files/trunc.tar
Binary files differ
diff --git a/ext/phar/tests/tar/frontcontroller1.phar.phpt b/ext/phar/tests/tar/frontcontroller1.phar.phpt
new file mode 100644
index 0000000..7715816
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller1.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller other tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller1.phar.php
+REQUEST_URI=/frontcontroller1.phar.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Content-type: image/jpeg
+Content-length: 3
+--EXPECT--
+hio
diff --git a/ext/phar/tests/tar/frontcontroller10.phar.phpt b/ext/phar/tests/tar/frontcontroller10.phar.phpt
new file mode 100644
index 0000000..f1fc6e3
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller10.phar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar front controller rewrite array invalid tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller10.phar.php
+REQUEST_URI=/frontcontroller10.phar.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller4.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+Status: 403 Access Denied
+--EXPECT--
+<html>
+ <head>
+ <title>Access Denied</title>
+ </head>
+ <body>
+ <h1>403 - File /hi Access Denied</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller11.phar.phpt b/ext/phar/tests/tar/frontcontroller11.phar.phpt
new file mode 100644
index 0000000..2b0d15b
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller11.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type extension is not a string tar-based
+--INI--
+default_charset=
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller11.phar.php
+REQUEST_URI=/frontcontroller11.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller5.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.phar.php:2
+Stack trace:
+#0 %sfrontcontroller11.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller11.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller12.phar.phpt b/ext/phar/tests/tar/frontcontroller12.phar.phpt
new file mode 100644
index 0000000..2086856
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller12.phar.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type unknown int tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller12.phar.php
+REQUEST_URI=/frontcontroller12.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller6.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.phar.php:2
+Stack trace:
+#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller12.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller13.phar.phpt b/ext/phar/tests/tar/frontcontroller13.phar.phpt
new file mode 100644
index 0000000..ce7620a
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller13.phar.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type not string/int tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller13.phar.php
+REQUEST_URI=/frontcontroller13.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller7.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.phar.php:2
+Stack trace:
+#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller13.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller14.phar.phpt b/ext/phar/tests/tar/frontcontroller14.phar.phpt
new file mode 100644
index 0000000..c40f9b6
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller14.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller mime type override, other tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller14.phar.php
+REQUEST_URI=/frontcontroller14.phar.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.tar
+--EXPECTHEADERS--
+Content-type: foo/bar
+Content-length: 4
+--EXPECT--
+hio2
diff --git a/ext/phar/tests/tar/frontcontroller15.phar.phpt b/ext/phar/tests/tar/frontcontroller15.phar.phpt
new file mode 100644
index 0000000..2147121
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller15.phar.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller mime type override, Phar::PHPS tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller15.phar.php
+REQUEST_URI=/frontcontroller15.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
+
diff --git a/ext/phar/tests/tar/frontcontroller16.phar.phpt b/ext/phar/tests/tar/frontcontroller16.phar.phpt
new file mode 100644
index 0000000..caa0c31
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller16.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller mime type override, Phar::PHP tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller16.phar.php
+REQUEST_URI=/frontcontroller16.phar.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio1
+
diff --git a/ext/phar/tests/tar/frontcontroller17.phar.phpt b/ext/phar/tests/tar/frontcontroller17.phar.phpt
new file mode 100644
index 0000000..17d04ba
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller17.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller mime type unknown tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller17.phar.php
+REQUEST_URI=/frontcontroller17.phar.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.tar
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+Content-length: 4
+--EXPECT--
+hio3
+
diff --git a/ext/phar/tests/tar/frontcontroller18.phar.phpt b/ext/phar/tests/tar/frontcontroller18.phar.phpt
new file mode 100644
index 0000000..c52ce29
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller18.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller18.phar.php
+REQUEST_URI=/frontcontroller18.phar.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller9.phar.tar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2
+Stack trace:
+#0 %sfrontcontroller18.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller18.phar.php on line 2
diff --git a/ext/phar/tests/tar/frontcontroller19.phar.phpt b/ext/phar/tests/tar/frontcontroller19.phar.phpt
new file mode 100644
index 0000000..6b07438
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller19.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure 2 tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller19.phar.php
+REQUEST_URI=/frontcontroller19.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller10.phar.tar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2
+Stack trace:
+#0 %sfrontcontroller19.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller19.phar.php on line 2
diff --git a/ext/phar/tests/tar/frontcontroller2.phar.phpt b/ext/phar/tests/tar/frontcontroller2.phar.phpt
new file mode 100644
index 0000000..82070e3
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller2.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller PHP test tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller2.phar.php
+REQUEST_URI=/frontcontroller2.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio
diff --git a/ext/phar/tests/tar/frontcontroller20.phar.phpt b/ext/phar/tests/tar/frontcontroller20.phar.phpt
new file mode 100644
index 0000000..3cc470d
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller20.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller $_SERVER munging failure 3 tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller20.phar.php
+REQUEST_URI=/frontcontroller20.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller11.phar.tar
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2
+Stack trace:
+#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller20.phar.php on line 2
diff --git a/ext/phar/tests/tar/frontcontroller21.phar.phpt b/ext/phar/tests/tar/frontcontroller21.phar.phpt
new file mode 100644
index 0000000..bb93996
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller21.phar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar front controller $_SERVER munging success tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller21.phar.php
+REQUEST_URI=/frontcontroller21.phar.php/index.php?test=hi
+PATH_INFO=/index.php
+QUERY_STRING=test=hi
+--FILE_EXTERNAL--
+files/frontcontroller12.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%unicode|string%(10) "/index.php"
+string(10) "/index.php"
+string(%d) "phar://%sfrontcontroller21.phar.php/index.php"
+string(18) "/index.php?test=hi"
+string(37) "/frontcontroller21.phar.php/index.php"
+string(27) "/frontcontroller21.phar.php"
+string(%d) "%sfrontcontroller21.phar.php"
+string(45) "/frontcontroller21.phar.php/index.php?test=hi" \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller3.phar.phpt b/ext/phar/tests/tar/frontcontroller3.phar.phpt
new file mode 100644
index 0000000..06a4948
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller3.phar.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller phps tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller3.phar.php
+REQUEST_URI=/frontcontroller3.phar.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
diff --git a/ext/phar/tests/tar/frontcontroller4.phar.phpt b/ext/phar/tests/tar/frontcontroller4.phar.phpt
new file mode 100644
index 0000000..db4846c
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller4.phar.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Phar front controller index.php relocate (no /) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller4.phar.php
+REQUEST_URI=/frontcontroller4.phar.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller4.phar.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/tar/frontcontroller5.phar.phpt b/ext/phar/tests/tar/frontcontroller5.phar.phpt
new file mode 100644
index 0000000..534e66a
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller5.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller index.php relocate tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller5.phar.php
+REQUEST_URI=/frontcontroller5.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller5.phar.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/tar/frontcontroller6.phar.phpt b/ext/phar/tests/tar/frontcontroller6.phar.phpt
new file mode 100644
index 0000000..5375bee
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller6.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller 404 tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller6.phar.php
+REQUEST_URI=/frontcontroller6.phar.php/notfound.php
+PATH_INFO=/notfound.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.tar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /notfound.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller7.phar.phpt b/ext/phar/tests/tar/frontcontroller7.phar.phpt
new file mode 100644
index 0000000..3b73f20
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller7.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller alternate index file tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller7.phar.php
+REQUEST_URI=/frontcontroller7.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller2.phar.tar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller7.phar.php/a.php
+--EXPECT--
diff --git a/ext/phar/tests/tar/frontcontroller8.phar.phpt b/ext/phar/tests/tar/frontcontroller8.phar.phpt
new file mode 100644
index 0000000..19844cb
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller8.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller no index file 404 tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller8.phar.php
+REQUEST_URI=/frontcontroller8.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller3.phar.tar
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /index.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/tar/frontcontroller9.phar.phpt b/ext/phar/tests/tar/frontcontroller9.phar.phpt
new file mode 100644
index 0000000..48e655c
--- /dev/null
+++ b/ext/phar/tests/tar/frontcontroller9.phar.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller rewrite array tar-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller9.phar.php
+REQUEST_URI=/frontcontroller9.phar.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller3.phar.tar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
diff --git a/ext/phar/tests/tar/links.phpt b/ext/phar/tests/tar/links.phpt
new file mode 100644
index 0000000..d702cac
--- /dev/null
+++ b/ext/phar/tests/tar/links.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Phar: tar with hard link and symbolic link
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+copy(dirname(__FILE__) . '/files/links.tar', $fname);
+try {
+ $p = new PharData($fname);
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+var_dump($p['testit/link']->getContent());
+var_dump($p['testit/hard']->getContent());
+var_dump($p['testit/file']->getContent());
+$p['testit/link'] = 'overwriting';
+var_dump($p['testit/link']->getContent());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+?>
+--EXPECT--
+string(3) "hi
+"
+string(3) "hi
+"
+string(3) "hi
+"
+string(11) "overwriting"
+===DONE===
diff --git a/ext/phar/tests/tar/links2.phpt b/ext/phar/tests/tar/links2.phpt
new file mode 100644
index 0000000..1939e00
--- /dev/null
+++ b/ext/phar/tests/tar/links2.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Phar: tar with hard link to nowhere
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
+$pname = 'phar://' . $fname;
+
+include dirname(__FILE__) . '/files/corrupt_tarmaker.php.inc';
+$a = new corrupt_tarmaker($fname, 'none');
+$a->init();
+$a->addFile('hardlink', 'internal/file.txt', array(
+ 'mode' => 0xA000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+$a->close();
+
+try {
+ $p = new PharData($fname);
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+?>
+--EXPECTF--
+phar error: "%slinks2.tar" is a corrupted tar file - hard link to non-existent file "internal/file.txt"
+===DONE===
diff --git a/ext/phar/tests/tar/links3.phpt b/ext/phar/tests/tar/links3.phpt
new file mode 100644
index 0000000..def399e
--- /dev/null
+++ b/ext/phar/tests/tar/links3.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar: tar with link to absolute path
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+try {
+ $p = new PharData(dirname(__FILE__) . '/files/biglink.tar');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+echo $p['file.txt']->getContent();
+echo $p['my/file']->getContent();
+?>
+===DONE===
+--EXPECT--
+my file
+my file
+===DONE===
diff --git a/ext/phar/tests/tar/links4.phpt b/ext/phar/tests/tar/links4.phpt
new file mode 100644
index 0000000..1d658a7
--- /dev/null
+++ b/ext/phar/tests/tar/links4.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar: tar with link to root directory file from root directory file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+try {
+ $p = new PharData(dirname(__FILE__) . '/files/tinylink.tar');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+echo $p['file.txt']->getContent();
+echo $p['link.txt']->getContent();
+?>
+===DONE===
+--EXPECT--
+hi
+hi
+===DONE===
diff --git a/ext/phar/tests/tar/links5.phpt b/ext/phar/tests/tar/links5.phpt
new file mode 100644
index 0000000..6d11d3e
--- /dev/null
+++ b/ext/phar/tests/tar/links5.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar: tar with relative link to subdirectory file from subdirectory file
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+try {
+ $p = new PharData(dirname(__FILE__) . '/files/subdirlink.tar');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+echo $p['hi/test.txt']->getContent();
+echo $p['hi/link.txt']->getContent();
+?>
+===DONE===
+--EXPECT--
+hi
+hi
+===DONE===
diff --git a/ext/phar/tests/tar/links6.phpt b/ext/phar/tests/tar/links6.phpt
new file mode 100644
index 0000000..95fd8fb
--- /dev/null
+++ b/ext/phar/tests/tar/links6.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: test nested linked files
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+?>
+--INI--
+phar.require_hash=0
+--FILE--
+<?php
+echo file_get_contents('phar://' . dirname(__FILE__) . '/files/links.phar.tar/link2');
+echo file_get_contents('phar://' . dirname(__FILE__) . '/files/links.phar.tar/link1');
+echo file_get_contents('phar://' . dirname(__FILE__) . '/files/links.phar.tar/testit.txt');
+
+$a = fopen('phar://' . dirname(__FILE__) . '/files/links.phar.tar/link2', 'r');
+fseek($a, 3);
+echo fread($a, 10);
+?>
+===DONE===
+--EXPECT--
+hi there
+
+hi there
+
+hi there
+
+there
+
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/open_for_write_existing.phpt b/ext/phar/tests/tar/open_for_write_existing.phpt
new file mode 100644
index 0000000..a034b8f
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_existing.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECT--
+extra
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_b.phpt b/ext/phar/tests/tar/open_for_write_existing_b.phpt
new file mode 100644
index 0000000..fa631e6
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_existing_b.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt
new file mode 100644
index 0000000..a6fea06
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b_5_2.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_c.phpt b/ext/phar/tests/tar/open_for_write_existing_c.phpt
new file mode 100644
index 0000000..aeb28b0
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_existing_c.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt
new file mode 100644
index 0000000..091b7df
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c_5_2.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_newfile.phpt b/ext/phar/tests/tar/open_for_write_newfile.phpt
new file mode 100644
index 0000000..e2efb34
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_newfile.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECT--
+This is b/c
+extra
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_newfile_b.phpt b/ext/phar/tests/tar/open_for_write_newfile_b.phpt
new file mode 100644
index 0000000..2ea557b
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_newfile_b.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.tar" in %sopen_for_write_newfile_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt
new file mode 100644
index 0000000..1bb02a0
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b_5_2.phar.tar" in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b_5_2.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_newfile_c.phpt b/ext/phar/tests/tar/open_for_write_newfile_c.phpt
new file mode 100644
index 0000000..f7cbb3a
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_newfile_c.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt
new file mode 100644
index 0000000..8a7d873
--- /dev/null
+++ b/ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c_5_2.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c_5_2.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c_5_2.phar.tar" in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c_5_2.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
new file mode 100644
index 0000000..d18f32e
--- /dev/null
+++ b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering() tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.tar', 0, 'brandnewphar.phar');
+var_dump($p->isFileFormat(Phar::TAR));
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+string(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+string(5) "Hello"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
new file mode 100644
index 0000000..d058b36
--- /dev/null
+++ b/ext/phar/tests/tar/phar_begin_setstub_commitU.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering() tar-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.tar', 0, 'brandnewphar.phar');
+var_dump($p->isFileFormat(Phar::TAR));
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+unicode(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+unicode(5) "Hello"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator4.phpt b/ext/phar/tests/tar/phar_buildfromiterator4.phpt
new file mode 100644
index 0000000..b7d6d56
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator4.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file passed in tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt'))));
+ var_dump($phar->isFileFormat(Phar::TAR));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "%sphar_buildfromiterator4.phpt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt
new file mode 100644
index 0000000..54972cb
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar::buildFromIterator() iterator, iterator returns non-string tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid value (must return a string)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator6.phpt b/ext/phar/tests/tar/phar_buildfromiterator6.phpt
new file mode 100644
index 0000000..408775c
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator6.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, key is int tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid key (must return a string)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator7.phpt b/ext/phar/tests/tar/phar_buildfromiterator7.phpt
new file mode 100644
index 0000000..65084f3
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator7.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, file can't be opened tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned a file that could not be opened "phar_buildfromiterator7./oopsie/there.phpt"
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator8.phpt b/ext/phar/tests/tar/phar_buildfromiterator8.phpt
new file mode 100644
index 0000000..f42640f
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator8.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Phar::buildFromIterator() iterator, SplFileInfo as current tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), dirname(__FILE__) . DIRECTORY_SEPARATOR);
+ asort($a);
+ var_dump($a);
+ var_dump($phar->isFileFormat(Phar::TAR));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+array(21) {
+ ["frontcontroller1.phar.phpt"]=>
+ string(%d) "%sfrontcontroller1.phar.phpt"
+ ["frontcontroller10.phar.phpt"]=>
+ string(%d) "%sfrontcontroller10.phar.phpt"
+ ["frontcontroller11.phar.phpt"]=>
+ string(%d) "%sfrontcontroller11.phar.phpt"
+ ["frontcontroller12.phar.phpt"]=>
+ string(%d) "%sfrontcontroller12.phar.phpt"
+ ["frontcontroller13.phar.phpt"]=>
+ string(%d) "%sfrontcontroller13.phar.phpt"
+ ["frontcontroller14.phar.phpt"]=>
+ string(%d) "%sfrontcontroller14.phar.phpt"
+ ["frontcontroller15.phar.phpt"]=>
+ string(%d) "%sfrontcontroller15.phar.phpt"
+ ["frontcontroller16.phar.phpt"]=>
+ string(%d) "%sfrontcontroller16.phar.phpt"
+ ["frontcontroller17.phar.phpt"]=>
+ string(%d) "%sfrontcontroller17.phar.phpt"
+ ["frontcontroller18.phar.phpt"]=>
+ string(%d) "%sfrontcontroller18.phar.phpt"
+ ["frontcontroller19.phar.phpt"]=>
+ string(%d) "%sfrontcontroller19.phar.phpt"
+ ["frontcontroller2.phar.phpt"]=>
+ string(%d) "%sfrontcontroller2.phar.phpt"
+ ["frontcontroller20.phar.phpt"]=>
+ string(%d) "%sfrontcontroller20.phar.phpt"
+ ["frontcontroller21.phar.phpt"]=>
+ string(%d) "%sfrontcontroller21.phar.phpt"
+ ["frontcontroller3.phar.phpt"]=>
+ string(%d) "%sfrontcontroller3.phar.phpt"
+ ["frontcontroller4.phar.phpt"]=>
+ string(%d) "%sfrontcontroller4.phar.phpt"
+ ["frontcontroller5.phar.phpt"]=>
+ string(%d) "%sfrontcontroller5.phar.phpt"
+ ["frontcontroller6.phar.phpt"]=>
+ string(%d) "%sfrontcontroller6.phar.phpt"
+ ["frontcontroller7.phar.phpt"]=>
+ string(%d) "%sfrontcontroller7.phar.phpt"
+ ["frontcontroller8.phar.phpt"]=>
+ string(%d) "%sfrontcontroller8.phar.phpt"
+ ["frontcontroller9.phar.phpt"]=>
+ string(%d) "%sfrontcontroller9.phar.phpt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_buildfromiterator9.phpt b/ext/phar/tests/tar/phar_buildfromiterator9.phpt
new file mode 100644
index 0000000..f9deef4
--- /dev/null
+++ b/ext/phar/tests/tar/phar_buildfromiterator9.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file resource passed in tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r')))));
+ fclose($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "[stream]"
+}
+===DONE===
diff --git a/ext/phar/tests/tar/phar_commitwrite.phpt b/ext/phar/tests/tar/phar_commitwrite.phpt
new file mode 100644
index 0000000..262ea1d
--- /dev/null
+++ b/ext/phar/tests/tar/phar_commitwrite.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar::setStub()/stopBuffering() tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--ENV--
+TEMP=.
+TMP=.
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.tar', 0, 'brandnewphar.phar');
+$p['file1.txt'] = 'hi';
+$p->stopBuffering();
+var_dump($p->getStub());
+$p->setStub("<?php
+function __autoload(\$class)
+{
+ include 'phar://' . str_replace('_', '/', \$class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER();
+?>");
+var_dump($p->getStub());
+var_dump($p->isFileFormat(Phar::TAR));
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
+?>
+--EXPECT--
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+string(200) "<?php
+function __autoload($class)
+{
+ include 'phar://' . str_replace('_', '/', $class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER(); ?>
+"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar.phpt b/ext/phar/tests/tar/phar_convert_phar.phpt
new file mode 100644
index 0000000..d754ac1
--- /dev/null
+++ b/ext/phar/tests/tar/phar_convert_phar.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Phar::convertToPhar() from tar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar';
+
+$phar = new Phar($fname);
+$phar['a.txt'] = 'some text';
+$phar->stopBuffering();
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump(strlen($phar->getStub()));
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+$phar['a'] = 'hi there';
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.3.phar');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump(strlen($phar->getStub()));
+
+copy($fname3, $fname2);
+
+$phar = new Phar($fname2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump(strlen($phar->getStub()));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+int(6683)
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+int(6683)
+bool(true)
+int(6683)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar2.phpt b/ext/phar/tests/tar/phar_convert_phar2.phpt
new file mode 100644
index 0000000..58901ca
--- /dev/null
+++ b/ext/phar/tests/tar/phar_convert_phar2.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar::convertToPhar() gzipped
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
+
+$phar = new Phar($fname);
+$phar['a.txt'] = 'some text';
+$phar->stopBuffering();
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump(strlen($phar->getStub()));
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+$phar['a'] = 'hi there';
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::GZ);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed());
+var_dump(strlen($phar->getStub()));
+
+copy($fname . '.gz', $fname2);
+
+$phar = new Phar($fname2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed() == Phar::GZ);
+var_dump(strlen($phar->getStub()));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+int(6683)
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+int(4096)
+int(6683)
+bool(true)
+bool(true)
+int(6683)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar3.phpt b/ext/phar/tests/tar/phar_convert_phar3.phpt
new file mode 100644
index 0000000..543c89b
--- /dev/null
+++ b/ext/phar/tests/tar/phar_convert_phar3.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar::convertToPhar() bzipped
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
+
+$phar = new Phar($fname);
+$phar['a.txt'] = 'some text';
+$phar->stopBuffering();
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump(strlen($phar->getStub()));
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+
+$phar['a'] = 'hi there';
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::BZ2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed());
+var_dump(strlen($phar->getStub()));
+
+copy($fname . '.bz2', $fname2);
+
+$phar = new Phar($fname2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed() == Phar::BZ2);
+var_dump(strlen($phar->getStub()));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.bz2');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.bz2');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+int(6683)
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+int(8192)
+int(6683)
+bool(true)
+bool(true)
+int(6683)
+===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar4.phpt b/ext/phar/tests/tar/phar_convert_phar4.phpt
new file mode 100644
index 0000000..9b095f1
--- /dev/null
+++ b/ext/phar/tests/tar/phar_convert_phar4.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Phar::convertToPhar() with global metadata
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
+
+$phar = new Phar($fname);
+$phar['a.txt'] = 'some text';
+$phar->setMetadata(b'hi');
+$phar->stopBuffering();
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump(strlen($phar->getStub()));
+var_dump($phar->getMetadata());
+
+$phar = $phar->convertToExecutable(Phar::TAR);
+var_dump($phar->isFileFormat(Phar::TAR));
+var_dump($phar->getStub());
+var_dump($phar->getMetadata());
+
+$phar['a'] = 'hi there';
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::GZ);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed());
+var_dump(strlen($phar->getStub()));
+var_dump($phar->getMetadata());
+
+copy($fname . '.gz', $fname2);
+
+$phar = new Phar($fname2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump($phar->isCompressed() == Phar::GZ);
+var_dump(strlen($phar->getStub()));
+var_dump($phar->getMetadata());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+int(6683)
+string(2) "hi"
+bool(true)
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+string(2) "hi"
+bool(true)
+int(4096)
+int(6683)
+string(2) "hi"
+bool(true)
+bool(true)
+int(6683)
+string(2) "hi"
+===DONE===
diff --git a/ext/phar/tests/tar/phar_copy.phpt b/ext/phar/tests/tar/phar_copy.phpt
new file mode 100644
index 0000000..ed5cdac
--- /dev/null
+++ b/ext/phar/tests/tar/phar_copy.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Phar: copy() tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.php';
+
+$pname = 'phar://'.$fname;
+$iname = '/file.txt';
+$ename = '/error/..';
+
+$p = new Phar($fname);
+
+try
+{
+ $p['a'] = 'hi';
+ $p->startBuffering();
+ $p->copy('a', 'b');
+ echo file_get_contents($p['b']->getPathName());
+ $p->copy('b', 'c');
+ $p->stopBuffering();
+ echo file_get_contents($p['c']->getPathName());
+ copy($fname, $fname2);
+ var_dump($p->isFileFormat(Phar::TAR));
+ $p->copy('a', $ename);
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly',1);
+$p2 = new Phar($fname2);
+var_dump($p2->isFileFormat(Phar::TAR));
+echo "\n";
+echo 'a: ' , file_get_contents($p2['a']->getPathName());
+echo 'b: ' ,file_get_contents($p2['b']->getPathName());
+echo 'c: ' ,file_get_contents($p2['c']->getPathName());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?>
+--EXPECTF--
+hihibool(true)
+file "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s
+bool(true)
+
+a: hib: hic: hi===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/phar_magic.phpt b/ext/phar/tests/tar/phar_magic.phpt
new file mode 100644
index 0000000..ed0a462
--- /dev/null
+++ b/ext/phar/tests/tar/phar_magic.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Phar: include/fopen magic tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$p = new Phar($fname);
+var_dump($p->isFileFormat(Phar::TAR));
+$p['a'] = '<?php include "b/c.php";' . "\n";
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub('<?php
+set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
+include "phar://" . __FILE__ . "/a";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+bool(true)
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/tar/phar_setalias.phpt b/ext/phar/tests/tar/phar_setalias.phpt
new file mode 100644
index 0000000..a1bc511
--- /dev/null
+++ b/ext/phar/tests/tar/phar_setalias.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar::setAlias() tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.tar';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+
+$files = array();
+
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+
+copy($fname, $fname2);
+$phar->setAlias('unused');
+$a = new Phar($fname2);
+echo $a->getAlias() . "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+hio
+test
+test
+===DONE===
diff --git a/ext/phar/tests/tar/phar_setalias2.phpt b/ext/phar/tests/tar/phar_setalias2.phpt
new file mode 100644
index 0000000..a44cc39
--- /dev/null
+++ b/ext/phar/tests/tar/phar_setalias2.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar::setAlias() error tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+
+$files = array();
+
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+$b = $phar;
+$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
+
+try {
+ $phar->setAlias('test');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+hio
+test
+alias "test" is already used for archive "%sphar_setalias2.phar.tar" and cannot be used for other archives
+===DONE===
diff --git a/ext/phar/tests/tar/phar_setdefaultstub.phpt b/ext/phar/tests/tar/phar_setdefaultstub.phpt
new file mode 100644
index 0000000..c1e6642
--- /dev/null
+++ b/ext/phar/tests/tar/phar_setdefaultstub.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Phar: Phar::setDefaultStub() with and without arg, tar-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<php echo "this is a\n"; ?>';
+$phar['b.php'] = '<php echo "this is b\n"; ?>';
+$phar->setStub('<?php echo "Hello World\n"; __HALT_COMPILER(); ?>');
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub();
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub('my/custom/thingy.php');
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php');
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+?>
+--EXPECTF--
+string(51) "<?php echo "Hello World\n"; __HALT_COMPILER(); ?>
+"
+============================================================================
+============================================================================
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+============================================================================
+============================================================================
+
+Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 1 given in %sphar_setdefaultstub.php on line %d
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+============================================================================
+============================================================================
+
+Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 2 given in %sphar_setdefaultstub.php on line %d
+string(60) "<?php // tar-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/tar/phar_setsignaturealgo2.phpt b/ext/phar/tests/tar/phar_setsignaturealgo2.phpt
new file mode 100644
index 0000000..b68bbf6
--- /dev/null
+++ b/ext/phar/tests/tar/phar_setsignaturealgo2.phpt
@@ -0,0 +1,91 @@
+--TEST--
+Phar::setSupportedSignatures() with hash, tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--ENV--
+TEMP=.
+TMP=.
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$p = new Phar($fname);
+$p['file1.txt'] = 'hi';
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::MD5);
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::SHA1);
+var_dump($p->getSignature());
+try {
+$p->setSignatureAlgorithm(Phar::SHA256);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::SHA512);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$config = dirname(__FILE__) . '/../files/openssl.cnf';
+$config_arg = array('config' => $config);
+$private = openssl_get_privatekey(file_get_contents(dirname(dirname(__FILE__)) . '/files/private.pem'));
+$pkey = '';
+openssl_pkey_export($private, $pkey, NULL, $config_arg);
+$p->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-256"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-512"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/tests/tar/phar_stub.phpt b/ext/phar/tests/tar/phar_stub.phpt
new file mode 100644
index 0000000..5a61eae
--- /dev/null
+++ b/ext/phar/tests/tar/phar_stub.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Phar::setStub() (tar-based)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
+$pname = 'phar://' . $fname;
+$pname2 = 'phar://' . $fname2;
+
+$p = new Phar($pname2);
+$p->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$p['a'] = 'a';
+$p['b'] = 'b';
+$p['c'] = 'c';
+copy($fname2, $fname);
+
+$phar = new Phar($fname);
+echo $phar->getStub();
+
+$file = b'<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
+
+//// 2
+$phar->setStub($file);
+echo $phar->getStub();
+
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php';
+$file = b'<?php echo "third stub\n"; __HALT_COMPILER(); ?>';
+$fp = fopen($fname3, 'wb');
+fwrite($fp, $file);
+fclose($fp);
+$fp = fopen($fname3, 'rb');
+
+//// 3
+$phar->setStub($fp);
+fclose($fp);
+
+echo $phar->getStub();
+
+$fp = fopen($fname3, 'ab');
+fwrite($fp, b'booya');
+fclose($fp);
+echo file_get_contents($fname3) . "\n";
+
+$fp = fopen($fname3, 'rb');
+
+//// 4
+$phar->setStub($fp, strlen($file));
+fclose($fp);
+echo $phar->getStub();
+
+$phar['testing'] = 'hi';
+
+echo $phar->getStub();
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>booya
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+===DONE===
diff --git a/ext/phar/tests/tar/phar_stub_error.phpt b/ext/phar/tests/tar/phar_stub_error.phpt
new file mode 100644
index 0000000..61532b9
--- /dev/null
+++ b/ext/phar/tests/tar/phar_stub_error.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar::setStub()/getStub() tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+
+$phar = new Phar($fname);
+$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' ."\r\n";
+$phar->setStub($stub);
+$phar->setAlias('hio');
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
+
+try {
+ $phar->setStub($newstub);
+} catch(exception $e) {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+$phar->stopBuffering();
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.tar"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/refcount1.phpt b/ext/phar/tests/tar/refcount1.phpt
new file mode 100644
index 0000000..b26c47d
--- /dev/null
+++ b/ext/phar/tests/tar/refcount1.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?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"; ?>';
+$files['.phar/alias.txt'] = 'hio';
+
+foreach ($files as $n => $file) {
+ $tar->addFile($n, $file);
+}
+
+$tar->close();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b"extra");
+fclose($fp);
+echo "===CLOSE===\n";
+$phar = new Phar($fname);
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($alias . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.tar/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%d) "c.php"
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.tar", has open file pointers, cannot unlink in %srefcount1.php on line %d
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.tar/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%s) "c.php"
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/tar/refcount1_5_2.phpt b/ext/phar/tests/tar/refcount1_5_2.phpt
new file mode 100644
index 0000000..18587d9
--- /dev/null
+++ b/ext/phar/tests/tar/refcount1_5_2.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
+
+$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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, "extra");
+fclose($fp);
+
+echo "===CLOSE===\n";
+
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($alias . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1_5_2.phar.tar", has open file pointers, cannot unlink in %sefcount1_5_2.php on line %d
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/tar/rename.phpt b/ext/phar/tests/tar/rename.phpt
new file mode 100644
index 0000000..96588a6
--- /dev/null
+++ b/ext/phar/tests/tar/rename.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: rename test tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+
+$files = array();
+$files['a'] = 'a';
+
+foreach ($files as $n => $file) {
+ $tar->addFile($n, $file);
+}
+
+$tar->close();
+
+include $fname;
+
+echo file_get_contents($alias . '/a') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename.phar.tar/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d
diff --git a/ext/phar/tests/tar/rename_dir.phpt b/ext/phar/tests/tar/rename_dir.phpt
new file mode 100644
index 0000000..0b95789
--- /dev/null
+++ b/ext/phar/tests/tar/rename_dir.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: rename_dir test tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+
+$files = array();
+$files['a/x'] = 'a';
+
+foreach ($files as $n => $file) {
+ $tar->addFile($n, $file);
+}
+
+$tar->close();
+
+include $fname;
+
+echo file_get_contents($alias . '/a/x') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b/x') . "\n";
+echo file_get_contents($alias . '/a/x') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename_dir.phar.tar/a/x): failed to open stream: phar error: "a/x" is not a file in phar "%srename_dir.phar.tar" in %srename_dir.php on line %d
diff --git a/ext/phar/tests/tar/require_hash.phpt b/ext/phar/tests/tar/require_hash.phpt
new file mode 100644
index 0000000..638534b
--- /dev/null
+++ b/ext/phar/tests/tar/require_hash.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: tar-based phar, require_hash=1, no signature
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+ini_set('phar.require_hash', 1);
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/tar_004.phar.tar';
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_004.tar';
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->addFile('.phar/stub.php', "__HALT_COMPILER();");
+$tar->close();
+
+try {
+ $phar = new Phar($fname);
+ var_dump($phar->getStub());
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+ini_set('phar.require_hash', 0);
+try {
+ $phar = new PharData($fname2);
+ $phar['file'] = 'hi';
+ var_dump($phar->getSignature());
+ $phar->setSignatureAlgorithm(Phar::MD5);
+ var_dump($phar->getSignature());
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_004.tar');
+?>
+--EXPECTF--
+tar-based phar "%star_004.phar.tar" does not have a signature
+bool(false)
+array(2) {
+ ["hash"]=>
+ string(32) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+===DONE===
diff --git a/ext/phar/tests/tar/rmdir.phpt b/ext/phar/tests/tar/rmdir.phpt
new file mode 100644
index 0000000..be03782
--- /dev/null
+++ b/ext/phar/tests/tar/rmdir.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: rmdir test tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+
+$files = array();
+$files['a/x'] = 'a';
+
+foreach ($files as $n => $file) {
+ $tar->addFile($n, $file);
+}
+$tar->mkdir('a');
+
+$tar->close();
+
+include $fname;
+
+echo file_get_contents($alias . '/a/x') . "\n";
+var_dump(rmdir($alias . '/a'));
+echo file_get_contents($alias . '/a/x') . "\n";
+unlink($alias . '/a/x');
+var_dump(rmdir($alias . '/a'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+a
+
+Warning: rmdir(): phar error: Directory not empty in %srmdir.php on line %d
+bool(false)
+a
+bool(true)
diff --git a/ext/phar/tests/tar/tar_001.phpt b/ext/phar/tests/tar/tar_001.phpt
new file mode 100644
index 0000000..500058b
--- /dev/null
+++ b/ext/phar/tests/tar/tar_001.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar: tar-based phar corrupted
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
+
+$tar = new corrupter(dirname(__FILE__) . '/tar_001.phar.tar', 'none');
+$tar->init();
+$tar->addFile('tar_001.phpt', __FILE__);
+$tar->close();
+
+$tar = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar.tar/tar_001.phpt', 'rb');
+try {
+ $phar = new Phar(dirname(__FILE__) . '/tar_001.phar.tar');
+ echo "should not execute\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_001.phar.tar');
+?>
+--EXPECTF--
+Warning: fopen(phar://%star_001.phar.tar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar.tar" is a corrupted tar file (truncated) in %star_001.php on line 9
+phar error: "%star_001.phar.tar" is a corrupted tar file (truncated)
+===DONE===
diff --git a/ext/phar/tests/tar/tar_002.phpt b/ext/phar/tests/tar/tar_002.phpt
new file mode 100644
index 0000000..75fc220
--- /dev/null
+++ b/ext/phar/tests/tar/tar_002.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: tar-based phar corrupted 2
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
+
+$tar = new corrupter(dirname(__FILE__) . '/tar_002.phar.tar', 'none');
+$tar->init();
+$tar->addFile('tar_002.phpt', __FILE__);
+$tar->close();
+
+$tar = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar.tar/tar_002.phpt', 'rb');
+
+try {
+ $phar = new Phar(dirname(__FILE__) . '/tar_002.phar.tar');
+ echo "should not execute\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_002.phar.tar');
+?>
+--EXPECTF--
+Warning: fopen(phar://%star_002.phar.tar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar.tar" is a corrupted tar file (truncated) in %star_002.php on line 9
+phar error: "%star_002.phar.tar" is a corrupted tar file (truncated)
+===DONE===
diff --git a/ext/phar/tests/tar/tar_003.phpt b/ext/phar/tests/tar/tar_003.phpt
new file mode 100644
index 0000000..3dec341
--- /dev/null
+++ b/ext/phar/tests/tar/tar_003.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Phar: tar-based phar, valid 1
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_003.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?php // tar-based phar archive stub file\n__HALT_COMPILER();");
+$tar->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r'));
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->close();
+
+fclose($g);
+
+echo file_get_contents($alias . '/internal/file/here');
+
+try {
+$tar = opendir($alias . '/');
+} catch (Exception $e) {
+echo $e->getMessage()."\n";
+}
+
+while (false !== ($v = readdir($tar))) {
+ echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
+ echo $v . "\n";
+}
+closedir($tar);
+
+/* ensure none of the dir tar files were freed */
+echo "second round\n";
+$tar = opendir($alias . '/');
+while (false !== ($v = readdir($tar))) {
+ echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
+ echo $v . "\n";
+}
+closedir($tar);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_003.phar.tar');
+?>
+--EXPECT--
+hi there!
+dir
+dir
+dir
+internal
+file
+tar_003.phpt
+second round
+dir
+dir
+dir
+internal
+file
+tar_003.phpt
+===DONE===
diff --git a/ext/phar/tests/tar/tar_004.phpt b/ext/phar/tests/tar/tar_004.phpt
new file mode 100644
index 0000000..bb1d3bf
--- /dev/null
+++ b/ext/phar/tests/tar/tar_004.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: tar-based phar, tar phar with stub, mapPhar()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_004.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+');
+$tar->close();
+
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
+?>
+--EXPECTF--
+string(9) "it worked"
+string(%d) "phar://%star_004.phar.tar/tar_004.php"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_004U.phpt b/ext/phar/tests/tar/tar_004U.phpt
new file mode 100644
index 0000000..45c77a9
--- /dev/null
+++ b/ext/phar/tests/tar/tar_004U.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: tar-based phar, tar phar with stub, mapPhar()
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_004U.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('tar_004U.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004U.php";
+');
+$tar->close();
+
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_004U.phar.tar');
+?>
+--EXPECTF--
+unicode(9) "it worked"
+unicode(%d) "phar://%star_004U.phar.tar/tar_004U.php"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_bz2.phpt b/ext/phar/tests/tar/tar_bz2.phpt
new file mode 100644
index 0000000..6093bb9
--- /dev/null
+++ b/ext/phar/tests/tar/tar_bz2.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar: tar-based phar, bzipped tar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_bz2.phar';
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_bz2.phar.tar';
+$alias2 = 'phar://' . $fname2;
+
+$tar = new tarmaker($fname, 'bz2');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != "phar");
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+__HALT_COMPILER();
+');
+$tar->close();
+
+include $alias;
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+
+copy($fname, $fname2);
+
+$phar2 = new Phar($fname2);
+var_dump($phar2->isFileFormat(Phar::TAR));
+var_dump($phar2->isCompressed() == Phar::BZ2);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_bz2.phar');
+@unlink(dirname(__FILE__) . '/tar_bz2.phar.tar');
+?>
+--EXPECTF--
+string(%d) "%star_bz2.phar"
+bool(true)
+string(9) "it worked"
+string(%d) "phar://%star_bz2.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_bz2U.phpt b/ext/phar/tests/tar/tar_bz2U.phpt
new file mode 100644
index 0000000..2f92976
--- /dev/null
+++ b/ext/phar/tests/tar/tar_bz2U.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar: tar-based phar, bzipped tar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_bz2U.phar';
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_bz2U.phar.tar';
+$alias2 = 'phar://' . $fname2;
+
+$tar = new tarmaker($fname, 'bz2');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != "phar");
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+__HALT_COMPILER();
+');
+$tar->close();
+
+include $alias;
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+
+copy($fname, $fname2);
+
+$phar2 = new Phar($fname2);
+var_dump($phar2->isFileFormat(Phar::TAR));
+var_dump($phar2->isCompressed() == Phar::BZ2);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_bz2U.phar');
+@unlink(dirname(__FILE__) . '/tar_bz2U.phar.tar');
+?>
+--EXPECTF--
+unicode(%d) "%star_bz2U.phar"
+bool(true)
+unicode(9) "it worked"
+unicode(%d) "phar://%star_bz2U.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/tar_gzip.phpt b/ext/phar/tests/tar/tar_gzip.phpt
new file mode 100644
index 0000000..d44e1b1
--- /dev/null
+++ b/ext/phar/tests/tar/tar_gzip.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: tar-based phar, gzipped tar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/tar_gzip.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_gzip.phar.tar';
+$pname2 = 'phar://' . $fname2;
+
+$a = new tarmaker($fname, 'zlib');
+$a->init();
+$a->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$a->addFile('internal/file/here', "hi there!\n");
+$a->mkDir('internal/dir');
+$a->mkDir('dir');
+$a->addFile('.phar/stub.php', '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+');
+$a->close();
+
+include $fname;
+
+$a = new Phar($fname);
+$a['test'] = 'hi';
+copy($fname, $fname2);
+$b = new Phar($fname2);
+var_dump($b->isFileFormat(Phar::TAR));
+var_dump($b->isCompressed() == Phar::GZ);
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_gzip.phar');
+@unlink(dirname(__FILE__) . '/tar_gzip.phar.tar');
+?>
+--EXPECTF--
+string(9) "it worked"
+string(%d) "phar://%star_gzip.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_gzipU.phpt b/ext/phar/tests/tar/tar_gzipU.phpt
new file mode 100644
index 0000000..4aa348e
--- /dev/null
+++ b/ext/phar/tests/tar/tar_gzipU.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: tar-based phar, gzipped tar
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/tar_gzip.phar';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_gzip.phar.tar';
+$pname2 = 'phar://' . $fname2;
+
+$a = new tarmaker($fname, 'zlib');
+$a->init();
+$a->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$a->addFile('internal/file/here', "hi there!\n");
+$a->mkDir('internal/dir');
+$a->mkDir('dir');
+$a->addFile('.phar/stub.php', '<?php
+Phar::mapPhar();
+var_dump("it worked");
+include "phar://" . __FILE__ . "/tar_004.php";
+');
+$a->close();
+
+include $fname;
+
+$a = new Phar($fname);
+$a['test'] = 'hi';
+copy($fname, $fname2);
+$b = new Phar($fname2);
+var_dump($b->isFileFormat(Phar::TAR));
+var_dump($b->isCompressed() == Phar::GZ);
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_gzip.phar');
+@unlink(dirname(__FILE__) . '/tar_gzip.phar.tar');
+?>
+--EXPECTF--
+unicode(9) "it worked"
+unicode(%d) "phar://%star_gzip.phar/tar_004.php"
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_makebz2.phpt b/ext/phar/tests/tar/tar_makebz2.phpt
new file mode 100644
index 0000000..f703b46
--- /dev/null
+++ b/ext/phar/tests/tar/tar_makebz2.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Phar: tar-based phar, make new bzipped tar
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/tar_makebz2.phar.tar';
+$fname2 = dirname(__FILE__) . '/tar_makebz2.phar.tar.bz2';
+$fname3 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar.bz2';
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+var_dump($phar->isFileFormat(Phar::TAR));
+$phar = $phar->compress(Phar::BZ2);
+
+copy($fname2, $fname3);
+
+$phar2 = new Phar($fname3);
+var_dump($phar2->isFileFormat(Phar::TAR));
+var_dump($phar2->isCompressed() == Phar::BZ2);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_makebz2.phar.bz2');
+@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar.bz2');
+@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar.bz2');
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/tar/tar_makegz.phpt b/ext/phar/tests/tar/tar_makegz.phpt
new file mode 100644
index 0000000..46fe177
--- /dev/null
+++ b/ext/phar/tests/tar/tar_makegz.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Phar: tar-based phar, make new gzipped tar
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/tar_makegz.phar.tar';
+$fname2 = dirname(__FILE__) . '/tar_makegz.phar.tar.gz';
+$fname3 = dirname(__FILE__) . '/tar_makegz_b.phar.tar.gz';
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+var_dump($phar->isFileFormat(Phar::TAR));
+$phar = $phar->compress(Phar::GZ);
+
+
+copy($fname2, $fname3);
+
+$phar2 = new Phar($fname3);
+var_dump($phar2->isFileFormat(Phar::TAR));
+var_dump($phar2->isCompressed() == Phar::GZ);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_makegz.phar.gz');
+@unlink(dirname(__FILE__) . '/tar_makegz.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_makegz.phar.tar.gz');
+@unlink(dirname(__FILE__) . '/tar_makegz_b.phar.tar.gz');
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/tar_nohash.phpt b/ext/phar/tests/tar/tar_nohash.phpt
new file mode 100644
index 0000000..dae2bb9
--- /dev/null
+++ b/ext/phar/tests/tar/tar_nohash.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar: tar archive, require_hash=1, should not error out
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+try {
+ $phar = new PharData(dirname(__FILE__) . '/files/Net_URL-1.0.15.tgz');
+ var_dump($phar->getStub());
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+string(0) ""
+===DONE===
diff --git a/ext/phar/tests/tar/tar_nostub.phpt b/ext/phar/tests/tar/tar_nostub.phpt
new file mode 100644
index 0000000..0036662
--- /dev/null
+++ b/ext/phar/tests/tar/tar_nostub.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: tar-based phar, third-party tar with no stub, Phar->getStub()
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/tar_004.phar.tar';
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_004.tar';
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->close();
+
+try {
+ $phar = new Phar($fname);
+ var_dump($phar->getStub());
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+copy($fname, $fname2);
+
+try {
+ $phar = new PharData($fname2);
+ var_dump($phar->getStub());
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_004.tar');
+?>
+--EXPECTF--
+RecursiveDirectoryIterator::__construct(phar://%star_004.phar.tar/): failed to open dir: '%star_004.phar.tar' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive
+phar url "phar://%star_004.phar.tar/" is unknown
+string(0) ""
+===DONE===
diff --git a/ext/phar/tests/tar/tar_openssl_hash.phpt b/ext/phar/tests/tar/tar_openssl_hash.phpt
new file mode 100644
index 0000000..49ef77a
--- /dev/null
+++ b/ext/phar/tests/tar/tar_openssl_hash.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar: tar archive, require_hash=1, OpenSSL hash
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+<?php if (!extension_loaded("openssl")) die("skip openssl not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+try {
+ $phar = new PharData(dirname(__FILE__) . '/files/P1-1.0.0.tgz');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/phar/tests/tar/truncated.phpt b/ext/phar/tests/tar/truncated.phpt
new file mode 100644
index 0000000..fbcabb7
--- /dev/null
+++ b/ext/phar/tests/tar/truncated.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar: truncated tar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+ $p = new PharData(dirname(__FILE__) . '/files/trunc.tar');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECTF--
+phar error: "%strunc.tar" is a corrupted tar file (truncated)
+===DONE===
diff --git a/ext/phar/tests/test_alias_unset.phpt b/ext/phar/tests/test_alias_unset.phpt
new file mode 100644
index 0000000..0127d8b
--- /dev/null
+++ b/ext/phar/tests/test_alias_unset.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: test for the odd case where we intend to remove an archive from memory
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+$phar->setAlias('first');
+$phar['file1.txt'] = 'hi';
+unset($phar);
+
+$phar2 = new Phar($fname2);
+$phar2->setAlias('first'); // this works because there are no references to $fname open
+$phar2['file1.txt'] = 'hi';
+unset($phar2);
+
+$a = fopen($pname . '/file1.txt', 'r'); // this works because there are no references to $fname2 open
+try {
+$phar2 = new Phar($fname2); // fails because references open to $fname
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+fclose($a);
+$phar2 = new Phar($fname2); // succeeds because all refs are closed
+var_dump($phar2->getAlias());
+
+$a = file_get_contents($pname . '/file1.txt'); // this fails because $fname2 ref exists
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+--EXPECTF--
+Cannot open archive "%stest_alias_unset.2.phar.php", alias is already in use by existing archive
+string(5) "first"
+
+Warning: file_get_contents(phar://%sfile1.txt): failed to open stream: Cannot open archive "%stest_alias_unset.phar.php", alias is already in use by existing archive in %stest_alias_unset.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/test_signaturealgos.phpt b/ext/phar/tests/test_signaturealgos.phpt
new file mode 100644
index 0000000..7cbf6c0
--- /dev/null
+++ b/ext/phar/tests/test_signaturealgos.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar: verify signature parsing works
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("hash")) die("skip extension hash conflicts");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$a = new Phar(dirname(__FILE__) . '/files/sha1.phar');
+$r = $a->getSignature();
+var_dump($r['hash_type']);
+$a = new Phar(dirname(__FILE__) . '/files/sha512.phar');
+$r = $a->getSignature();
+var_dump($r['hash_type']);
+$a = new Phar(dirname(__FILE__) . '/files/sha256.phar');
+$r = $a->getSignature();
+var_dump($r['hash_type']);
+$a = new Phar(dirname(__FILE__) . '/files/md5.phar');
+$r = $a->getSignature();
+var_dump($r['hash_type']);
+$a = new Phar(dirname(__FILE__) . '/files/openssl.phar');
+$r = $a->getSignature();
+var_dump($r['hash_type']);
+?>
+===DONE===
+--EXPECT--
+string(5) "SHA-1"
+string(7) "SHA-512"
+string(7) "SHA-256"
+string(3) "MD5"
+string(7) "OpenSSL"
+===DONE===
diff --git a/ext/phar/tests/test_unset.phpt b/ext/phar/tests/test_unset.phpt
new file mode 100644
index 0000000..3da537c
--- /dev/null
+++ b/ext/phar/tests/test_unset.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: ensure unset() works properly on a non-flushed phar archive
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+
+if (file_exists($fname)) unlink($fname);
+if (file_exists($fname2)) unlink($fname2);
+
+$phar = new Phar($fname); // no entries, never flushed
+$phar->setAlias('first');
+$phar->setMetadata('hi');
+unset($phar);
+
+$phar = new Phar($fname2);
+$phar['b'] = 'whatever'; // flushed
+try {
+ $phar->setAlias('first');
+} catch(Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+$phar = new Phar($fname);
+var_dump($phar->getMetadata());
+var_dump($phar->getAlias());
+var_dump(file_exists($fname));
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+--EXPECTF--
+NULL
+string(%d) "%stest_unset.phar.php"
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/webphar_compilefail.phpt b/ext/phar/tests/webphar_compilefail.phpt
new file mode 100644
index 0000000..ab5532d
--- /dev/null
+++ b/ext/phar/tests/webphar_compilefail.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: Phar::webPhar, open compiled file fails
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.readonly=1
+--FILE--
+<?php
+try {
+Phar::webPhar('oopsiedaisy.phar', '/index.php');
+} catch (Exception $e) {
+echo $e->getMessage() . "\n";
+}
+__HALT_COMPILER();
+?>
+--EXPECTF--
+internal corruption of phar "%swebphar_compilefail.php" (truncated manifest at manifest length) \ No newline at end of file
diff --git a/ext/phar/tests/withphar.phpt b/ext/phar/tests/withphar.phpt
new file mode 100644
index 0000000..c422fa9
--- /dev/null
+++ b/ext/phar/tests/withphar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar: phar run with pecl/phar with default stub
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+include dirname(__FILE__) . '/files/nophar.phar';
+?>
+===DONE===
+--EXPECT--
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/withphar_web.phpt b/ext/phar/tests/withphar_web.phpt
new file mode 100644
index 0000000..487873a
--- /dev/null
+++ b/ext/phar/tests/withphar_web.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar: default web stub, with phar extension
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--ENV--
+SCRIPT_NAME=/withphar_web.php
+REQUEST_URI=/withphar_web.php/web.php
+PATH_INFO=/web.php
+--FILE_EXTERNAL--
+files/nophar.phar
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+web
diff --git a/ext/phar/tests/zf_test.phpt b/ext/phar/tests/zf_test.phpt
new file mode 100644
index 0000000..c5d587d
--- /dev/null
+++ b/ext/phar/tests/zf_test.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Phar: test broken app
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$file = "zfapp";
+$orig_file = dirname(__FILE__) . "/files/$file.tgz";
+$tgz_file = dirname(__FILE__) . "/$file.tgz";
+$phar_file = dirname(__FILE__) . "/$file.phar.tar.gz";
+copy($orig_file, $tgz_file);
+
+$phar = new PharData($tgz_file);
+$phar = $phar->convertToExecutable();
+
+$phar = new Phar($phar_file);
+$phar->startBuffering();
+$phar->setStub("<?php
+Phar::interceptFileFuncs();
+Phar::webPhar('$file.phar', 'html/index.php');
+echo 'BlogApp is intended to be executed from a web browser\n';
+exit -1;
+__HALT_COMPILER();
+");
+$phar->stopBuffering();
+
+foreach(new RecursiveIteratorIterator($phar) as $path) {
+ echo str_replace('\\', '/', $path->getPathName()) . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/zfapp.tgz');
+unlink(dirname(__FILE__) . '/zfapp.phar.tar.gz');
+?>
+--EXPECTF--
+phar://%szfapp.phar.tar.gz/application/default/controllers/ErrorController.php
+phar://%szfapp.phar.tar.gz/application/default/controllers/IndexController.php
+phar://%szfapp.phar.tar.gz/application/default/views/scripts/error/error.phtml
+phar://%szfapp.phar.tar.gz/application/default/views/scripts/index/index.phtml
+phar://%szfapp.phar.tar.gz/html/.htaccess
+phar://%szfapp.phar.tar.gz/html/index.php
+===DONE===
diff --git a/ext/phar/tests/zip/033.phpt b/ext/phar/tests/zip/033.phpt
new file mode 100644
index 0000000..c980758
--- /dev/null
+++ b/ext/phar/tests/zip/033.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Phar::chmod zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+
+try {
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ copy($fname, $fname2);
+ $phar->setAlias('unused');
+ $phar2 = new Phar($fname2);
+ var_dump($phar2['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
+ echo "test dir\n";
+ var_dump($phar['test']->isDir());
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0000);
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isReadable());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(false)
+test dir
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/033a.phpt b/ext/phar/tests/zip/033a.phpt
new file mode 100644
index 0000000..429d3bd
--- /dev/null
+++ b/ext/phar/tests/zip/033a.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar::chmod zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+try {
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
+ echo "test dir\n";
+ var_dump($phar['test']->isExecutable());
+ $phar['test']->chmod(0777);
+ var_dump($phar['test']->isExecutable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isExecutable());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+?>
+--EXPECTF--
+bool(false)
+Cannot modify permissions for file "a.php" in phar "%sa.phar.zip", write operations are prohibited
+===DONE===
diff --git a/ext/phar/tests/zip/alias_acrobatics.phpt b/ext/phar/tests/zip/alias_acrobatics.phpt
new file mode 100644
index 0000000..2a58e39
--- /dev/null
+++ b/ext/phar/tests/zip/alias_acrobatics.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: alias edge cases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+
+$p = new Phar($fname);
+
+$p->setAlias('foo');
+$p['unused'] = 'hi';
+try {
+$a = new Phar($fname2, 0, 'foo');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+copy($fname, $fname2);
+echo "2\n";
+try {
+$a = new Phar($fname2);
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+try {
+$b = new Phar($fname, 0, 'another');
+} catch (Exception $e) {
+echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+?>
+--EXPECTF--
+alias "foo" is already used for archive "%salias_acrobatics.phar.zip" cannot be overloaded with "%salias_acrobatics.2.phar.zip"
+2
+phar error: Unable to add zip-based phar "%salias_acrobatics.2.phar.zip" with implicit alias, alias is already in use
+alias "another" is already used for archive "%salias_acrobatics.phar.zip" cannot be overloaded with "%salias_acrobatics.phar.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/all.phpt b/ext/phar/tests/zip/all.phpt
new file mode 100644
index 0000000..49d79a4
--- /dev/null
+++ b/ext/phar/tests/zip/all.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Phar: test that creation of zip-based phar generates valid zip with all bells/whistles
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php';
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+
+$phar->setMetadata('hi there');
+$phar['a'] = 'hi';
+$phar['a']->setMetadata('a meta');
+$phar['b'] = 'hi2';
+$phar['b']->compress(Phar::GZ);
+$phar['c'] = 'hi3';
+$phar['c']->compress(Phar::BZ2);
+$phar['b']->chmod(0444);
+$phar->setStub("<?php ok __HALT_COMPILER();");
+$phar->setAlias("hime");
+unset($phar);
+copy($fname, $fname2);
+Phar::unlinkArchive($fname);
+var_dump(file_exists($fname), file_exists($pname . '/a'));
+
+$phar = new Phar($fname2);
+var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
+var_dump($phar['a']->isCompressed(), $phar['b']->isCompressed() == Phar::GZ, $phar['c']->isCompressed() == Phar::BZ2);
+var_dump((string) decoct(fileperms($pname2 . '/b')));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+var_dump($phar->getMetadata());
+var_dump($phar['a']->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?>
+--EXPECT--
+bool(false)
+bool(false)
+string(2) "hi"
+string(3) "hi2"
+string(3) "hi3"
+bool(false)
+bool(true)
+bool(true)
+string(6) "100444"
+string(32) "<?php ok __HALT_COMPILER(); ?>
+"
+string(4) "hime"
+string(8) "hi there"
+string(6) "a meta"
+===DONE===
diff --git a/ext/phar/tests/zip/allU.phpt b/ext/phar/tests/zip/allU.phpt
new file mode 100644
index 0000000..93fe5da
--- /dev/null
+++ b/ext/phar/tests/zip/allU.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar: test that creation of zip-based phar generates valid zip with all bells/whistles
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+if (!extension_loaded("spl")) die("skip SPL not available");
+if (!extension_loaded("zlib")) die("skip zlib not available");
+if (!extension_loaded("bz2")) die("skip bz2 not available");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php';
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+
+$phar->setMetadata('hi there');
+$phar['a'] = 'hi';
+$phar['a']->setMetadata('a meta');
+$phar['b'] = 'hi2';
+$phar['b']->compress(Phar::GZ);
+$phar['c'] = 'hi3';
+$phar['c']->compress(Phar::BZ2);
+$phar['b']->chmod(0444);
+$phar->setStub("<?php ok __HALT_COMPILER();");
+$phar->setAlias("hime");
+unset($phar);
+copy($fname, $fname2);
+Phar::unlinkArchive($fname);
+var_dump(file_exists($fname), file_exists($pname . '/a'));
+
+$phar = new Phar($fname2);
+var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
+var_dump($phar['a']->isCompressed(), $phar['b']->isCompressed() == Phar::GZ, $phar['c']->isCompressed() == Phar::BZ2);
+var_dump((string) decoct(fileperms($pname2 . '/b')));
+var_dump($phar->getStub());
+var_dump($phar->getAlias());
+var_dump($phar->getMetadata());
+var_dump($phar['a']->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?>
+--EXPECT--
+bool(false)
+bool(false)
+string(2) "hi"
+string(3) "hi2"
+string(3) "hi3"
+bool(false)
+bool(true)
+bool(true)
+unicode(6) "100444"
+string(32) "<?php ok __HALT_COMPILER(); ?>
+"
+string(4) "hime"
+unicode(8) "hi there"
+unicode(6) "a meta"
+===DONE===
diff --git a/ext/phar/tests/zip/badalias.phpt b/ext/phar/tests/zip/badalias.phpt
new file mode 100644
index 0000000..0291c4b
--- /dev/null
+++ b/ext/phar/tests/zip/badalias.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar: invalid aliases
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--FILE--
+<?php
+$e = dirname(__FILE__) . '/files/';
+for ($i = 1; $i <= 5; $i++) {
+try {
+new Phar($e . "badalias$i.phar.zip");
+} catch (Exception $ee) {
+echo $ee->getMessage(), "\n";
+}
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: invalid alias "hi/there" in zip-based phar "%sbadalias1.phar.zip"
+phar error: invalid alias "hi\there" in zip-based phar "%sbadalias2.phar.zip"
+phar error: invalid alias "hi\there" in zip-based phar "%sbadalias3.phar.zip"
+phar error: invalid alias "hi;there" in zip-based phar "%sbadalias4.phar.zip"
+phar error: invalid alias "hi:there" in zip-based phar "%sbadalias5.phar.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/bug48791.phpt b/ext/phar/tests/zip/bug48791.phpt
new file mode 100644
index 0000000..45c5271
--- /dev/null
+++ b/ext/phar/tests/zip/bug48791.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: Bug #48791: open office documents always reported as corrupted by phar extension
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--FILE--
+<?php
+echo file_get_contents('phar://' . dirname(__FILE__) . '/files/test.odt/content.xml'), "\n";
+?>
+===DONE===
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/><style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/><style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="MS Mincho" svg:font-family="&apos;MS Mincho&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L1"/><style:style style:name="T1" style:family="text"><style:text-properties style:font-name="Arial"/></style:style><text:list-style style:name="L1"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:h text:style-name="Heading_20_1" text:outline-level="1">Überschrift</text:h><text:list xml:id="list38593008" text:style-name="L1"><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Name:<text:tab/><text:tab/>$$n_fn$$</text:span></text:p></text:list-item><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Firma:<text:tab/><text:tab/>$$org_name$$</text:span></text:p></text:list-item><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Menge:<text:tab/>$$#menge$$</text:span></text:p></text:list-item></text:list></office:text></office:body></office:document-content>
+===DONE===
diff --git a/ext/phar/tests/zip/bzip2.phpt b/ext/phar/tests/zip/bzip2.phpt
new file mode 100644
index 0000000..a703ce6
--- /dev/null
+++ b/ext/phar/tests/zip/bzip2.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Phar: process bzip2-compressed zip entry
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not available"); ?>
+--FILE--
+<?php
+try {
+ $a = new PharData(dirname(__FILE__) . '/files/bzip2.zip');
+ foreach ($a as $entry => $file) {
+ echo $file->getContent();
+ }
+ $a = new Phar(dirname(__FILE__) . '/files/bz2_alias.phar.zip');
+ var_dump($a->getAlias());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECT--
+<?php
+include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('hi2', null, 'hii2', null, null, 'encrypt', 'encrypt');
+$a->writeZip(dirname(__FILE__) . '/encrypted.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('', null, 'stdin');
+$a->writeZip(dirname(__FILE__) . '/stdin.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hii', null, 'hii', null, null, 'filename_len', 'filename_len');
+$a->addFile('hi', null, 'hii');
+$a->writeZip(dirname(__FILE__) . '/truncfilename.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress');
+$a->writeZip(dirname(__FILE__) . '/compress_unsup1.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 2);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup2.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 3);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup3.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 4);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup4.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 5);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup5.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 6);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup6.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 7);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup7.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 9);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup9.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 10);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup10.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 14);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup14.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 18);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup18.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 19);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup19.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 97);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup97.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 98);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup98.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11);
+$a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip');
+?>
+string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_001.phpt b/ext/phar/tests/zip/corrupt_001.phpt
new file mode 100644
index 0000000..0b019c6
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar: corrupted zip (count mismatch)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/count1.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/count2.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount1.zip"
+phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount2.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_002.phpt b/ext/phar/tests/zip/corrupt_002.phpt
new file mode 100644
index 0000000..86a2712
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (no end of zip record)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/nozipend.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: end of central directory not found in zip-based phar "%snozipend.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_003.phpt b/ext/phar/tests/zip/corrupt_003.phpt
new file mode 100644
index 0000000..c41e015
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_003.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (truncated file comment)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/filecomment.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupt zip archive, zip file comment truncated in zip-based phar "%sfilecomment.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_004.phpt b/ext/phar/tests/zip/corrupt_004.phpt
new file mode 100644
index 0000000..3760e8f
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_004.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (central directory offset incorrect)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/cdir_offset.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupted central directory entry, no magic signature in zip-based phar "%scdir_offset.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_005.phpt b/ext/phar/tests/zip/corrupt_005.phpt
new file mode 100644
index 0000000..6b5d31d
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_005.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: encrypted zip
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/encrypted.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: Cannot process encrypted zip files in zip-based phar "%sencrypted.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_006.phpt b/ext/phar/tests/zip/corrupt_006.phpt
new file mode 100644
index 0000000..9c83617
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_006.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: zip with file created from stdin
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/stdin.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: Cannot process zips created from stdin (zero-length filename) in zip-based phar "%sstdin.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_007.phpt b/ext/phar/tests/zip/corrupt_007.phpt
new file mode 100644
index 0000000..80c9139
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_007.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (truncated filename record)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/truncfilename.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupted central directory entry, no magic signature in zip-based phar "%struncfilename.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_008.phpt b/ext/phar/tests/zip/corrupt_008.phpt
new file mode 100644
index 0000000..5a20f4d
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_008.phpt
@@ -0,0 +1,101 @@
+--TEST--
+Phar: unsupported compression methods
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup1.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup2.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup3.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup4.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup5.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup6.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup7.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup9.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup10.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup14.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup18.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup19.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup97.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsup98.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ new PharData(dirname(__FILE__) . '/files/compress_unsupunknown.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: unsupported compression method (Shrunk) used in this zip in zip-based phar "%scompress_unsup1.zip"
+phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup2.zip"
+phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup3.zip"
+phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup4.zip"
+phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup5.zip"
+phar error: unsupported compression method (Implode) used in this zip in zip-based phar "%scompress_unsup6.zip"
+phar error: unsupported compression method (Tokenize) used in this zip in zip-based phar "%scompress_unsup7.zip"
+phar error: unsupported compression method (Deflate64) used in this zip in zip-based phar "%scompress_unsup9.zip"
+phar error: unsupported compression method (PKWare Implode/old IBM TERSE) used in this zip in zip-based phar "%scompress_unsup10.zip"
+phar error: unsupported compression method (LZMA) used in this zip in zip-based phar "%scompress_unsup14.zip"
+phar error: unsupported compression method (IBM TERSE) used in this zip in zip-based phar "%scompress_unsup18.zip"
+phar error: unsupported compression method (IBM LZ77) used in this zip in zip-based phar "%scompress_unsup19.zip"
+phar error: unsupported compression method (WavPack) used in this zip in zip-based phar "%scompress_unsup97.zip"
+phar error: unsupported compression method (PPMd) used in this zip in zip-based phar "%scompress_unsup98.zip"
+phar error: unsupported compression method (unknown) used in this zip in zip-based phar "%scompress_unsupunknown.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_009.phpt b/ext/phar/tests/zip/corrupt_009.phpt
new file mode 100644
index 0000000..91f142d
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_009.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (extra field way too long)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/extralen_toolong.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: Unable to process extra field header for file in central directory in zip-based phar "%sextralen_toolong.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/corrupt_010.phpt b/ext/phar/tests/zip/corrupt_010.phpt
new file mode 100644
index 0000000..ead723c
--- /dev/null
+++ b/ext/phar/tests/zip/corrupt_010.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar: unable to process zip (zip spanning multiple archives)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+ new PharData(dirname(__FILE__) . '/files/disknumber.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: split archives spanning multiple zips cannot be processed in zip-based phar "%sdisknumber.zip"
+===DONE===
diff --git a/ext/phar/tests/zip/create_new_and_modify.phpt b/ext/phar/tests/zip/create_new_and_modify.phpt
new file mode 100644
index 0000000..5a3ec33
--- /dev/null
+++ b/ext/phar/tests/zip/create_new_and_modify.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Phar: create and modify zip-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+
+@unlink($fname);
+
+file_put_contents($pname . '/a.php', "brand new!\n");
+
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::ZIP));
+$sig1 = md5_file($fname);
+
+include $pname . '/a.php';
+
+file_put_contents($pname .'/a.php', "modified!\n");
+file_put_contents($pname .'/b.php', "another!\n");
+
+$phar = new Phar($fname);
+$sig2 = md5_file($fname);
+
+var_dump($sig1 != $sig2);
+
+include $pname . '/a.php';
+include $pname . '/b.php';
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+--EXPECTF--
+bool(true)
+brand new!
+bool(true)
+modified!
+another!
+===DONE===
diff --git a/ext/phar/tests/zip/create_new_phar_b.phpt b/ext/phar/tests/zip/create_new_phar_b.phpt
new file mode 100644
index 0000000..5fda5b4
--- /dev/null
+++ b/ext/phar/tests/zip/create_new_phar_b.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Phar: create a completely new zip-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+
+file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php',
+ 'brand new!');
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: file_put_contents(phar://%screate_new_phar_b.phar.zip/a.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %screate_new_phar_b.php on line %d
+
+Warning: include(phar://%screate_new_phar_b.phar.zip/a.php): failed to open stream: %s in %screate_new_phar_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%screate_new_phar_b.phar.zip/a.php' for inclusion (include_path='%s') in %screate_new_phar_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/zip/delete.phpt b/ext/phar/tests/zip/delete.phpt
new file mode 100644
index 0000000..06078b3
--- /dev/null
+++ b/ext/phar/tests/zip/delete.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Phar: delete test, zip-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+$file = "<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>";
+
+$phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar->setStub($file);
+$phar->stopBuffering();
+
+echo file_get_contents($alias . '/a') . "\n";
+$phar->delete('a');
+echo file_get_contents($alias . '/a') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+a
+
+Warning: file_get_contents(phar://%sdelete.phar.zip/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.zip" in %sdelete.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/zip/delete_in_phar.phpt b/ext/phar/tests/zip/delete_in_phar.phpt
new file mode 100644
index 0000000..b7bda7c
--- /dev/null
+++ b/ext/phar/tests/zip/delete_in_phar.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: delete a file within a zip-based .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
+?>
+===AFTER===
+<?php
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.zip" in %sdelete_in_phar.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
+
+===DONE===
+ \ No newline at end of file
diff --git a/ext/phar/tests/zip/delete_in_phar_b.phpt b/ext/phar/tests/zip/delete_in_phar_b.phpt
new file mode 100644
index 0000000..eb1a6cc
--- /dev/null
+++ b/ext/phar/tests/zip/delete_in_phar_b.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Phar: delete a file within a zip-based .phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
+?>
+===AFTER===
+<?php
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+
+Warning: unlink(): phar error: write operations disabled by the php.ini setting phar.readonly in %sdelete_in_phar_b.php on line %d
+===AFTER===
+This is a
+This is b
+This is b/c
+
+===DONE===
diff --git a/ext/phar/tests/zip/delete_in_phar_confirm.phpt b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
new file mode 100644
index 0000000..fdd0b42
--- /dev/null
+++ b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: delete a file within a zip-based .phar (confirm disk file is changed)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+
+$md5 = md5_file($fname);
+unlink($alias . '/b/c.php');
+clearstatcache();
+$md52 = md5_file($fname);
+if ($md5 == $md52) echo 'file was not modified';
+?>
+===AFTER===
+<?php
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+This is a
+This is b
+This is b/c
+===AFTER===
+This is a
+This is b
+
+Warning: include(%sdelete_in_phar_confirm.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.zip" in %sdelete_in_phar_confirm.php on line %d
+
+Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/zip/dir.phpt b/ext/phar/tests/zip/dir.phpt
new file mode 100644
index 0000000..3cbeacd
--- /dev/null
+++ b/ext/phar/tests/zip/dir.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Phar: mkdir/rmdir test zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
+$pname2 = 'phar://' . $fname2;
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
+$pname3 = 'phar://' . $fname3;
+$phar = new Phar($fname);
+var_dump($phar->isFileFormat(Phar::ZIP));
+
+$phar->addEmptyDir('test');
+var_dump($phar['test']->isDir());
+var_dump($phar['test/']->isDir());
+copy($fname, $fname2);
+mkdir($pname . '/another/dir/');
+var_dump($phar['another/dir']->isDir());
+rmdir($pname . '/another/dir/');
+copy($fname, $fname3);
+clearstatcache();
+var_dump(file_exists($pname . '/another/dir/'));
+var_dump(file_exists($pname2 . '/test/'));
+var_dump(file_exists($pname3 . '/another/dir/'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/phar/tests/zip/exists_as_phar.phpt b/ext/phar/tests/zip/exists_as_phar.phpt
new file mode 100644
index 0000000..ccb37e8
--- /dev/null
+++ b/ext/phar/tests/zip/exists_as_phar.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Phar: phar-based phar named with ".zip" fails
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$tname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar->addEmptyDir('test');
+$phar->stopBuffering();
+copy($fname, $tname);
+$phar->setAlias('hio2');
+
+try {
+ $p = new Phar($tname);
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+?>
+--EXPECTF--
+phar zip error: phar "%sexists_as_phar.phar.zip" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar
+===DONE===
diff --git a/ext/phar/tests/zip/files/badalias1.phar.zip b/ext/phar/tests/zip/files/badalias1.phar.zip
new file mode 100644
index 0000000..0e3adfc
--- /dev/null
+++ b/ext/phar/tests/zip/files/badalias1.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/badalias2.phar.zip b/ext/phar/tests/zip/files/badalias2.phar.zip
new file mode 100644
index 0000000..7b5baaa
--- /dev/null
+++ b/ext/phar/tests/zip/files/badalias2.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/badalias3.phar.zip b/ext/phar/tests/zip/files/badalias3.phar.zip
new file mode 100644
index 0000000..7b5baaa
--- /dev/null
+++ b/ext/phar/tests/zip/files/badalias3.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/badalias4.phar.zip b/ext/phar/tests/zip/files/badalias4.phar.zip
new file mode 100644
index 0000000..49b7be0
--- /dev/null
+++ b/ext/phar/tests/zip/files/badalias4.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/badalias5.phar.zip b/ext/phar/tests/zip/files/badalias5.phar.zip
new file mode 100644
index 0000000..9f2b0e8
--- /dev/null
+++ b/ext/phar/tests/zip/files/badalias5.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/bz2_alias.phar.zip b/ext/phar/tests/zip/files/bz2_alias.phar.zip
new file mode 100644
index 0000000..8d3082a
--- /dev/null
+++ b/ext/phar/tests/zip/files/bz2_alias.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/bzip2.zip b/ext/phar/tests/zip/files/bzip2.zip
new file mode 100644
index 0000000..2f27f02
--- /dev/null
+++ b/ext/phar/tests/zip/files/bzip2.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/cdir_offset.zip b/ext/phar/tests/zip/files/cdir_offset.zip
new file mode 100644
index 0000000..9172554
--- /dev/null
+++ b/ext/phar/tests/zip/files/cdir_offset.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup1.zip b/ext/phar/tests/zip/files/compress_unsup1.zip
new file mode 100644
index 0000000..bd1f72b
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup1.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup10.zip b/ext/phar/tests/zip/files/compress_unsup10.zip
new file mode 100644
index 0000000..2a7f221
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup10.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup14.zip b/ext/phar/tests/zip/files/compress_unsup14.zip
new file mode 100644
index 0000000..d494143
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup14.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup18.zip b/ext/phar/tests/zip/files/compress_unsup18.zip
new file mode 100644
index 0000000..7ef2217
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup18.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup19.zip b/ext/phar/tests/zip/files/compress_unsup19.zip
new file mode 100644
index 0000000..8086d45
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup19.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup2.zip b/ext/phar/tests/zip/files/compress_unsup2.zip
new file mode 100644
index 0000000..d827d2d
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup2.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup3.zip b/ext/phar/tests/zip/files/compress_unsup3.zip
new file mode 100644
index 0000000..d4acc60
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup3.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup4.zip b/ext/phar/tests/zip/files/compress_unsup4.zip
new file mode 100644
index 0000000..76a4dc1
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup4.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup5.zip b/ext/phar/tests/zip/files/compress_unsup5.zip
new file mode 100644
index 0000000..d42155d
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup5.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup6.zip b/ext/phar/tests/zip/files/compress_unsup6.zip
new file mode 100644
index 0000000..5084640
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup6.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup7.zip b/ext/phar/tests/zip/files/compress_unsup7.zip
new file mode 100644
index 0000000..65c2e23
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup7.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup9.zip b/ext/phar/tests/zip/files/compress_unsup9.zip
new file mode 100644
index 0000000..df0c767
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup9.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup97.zip b/ext/phar/tests/zip/files/compress_unsup97.zip
new file mode 100644
index 0000000..907f365
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup97.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsup98.zip b/ext/phar/tests/zip/files/compress_unsup98.zip
new file mode 100644
index 0000000..54f19fb
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsup98.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/compress_unsupunknown.zip b/ext/phar/tests/zip/files/compress_unsupunknown.zip
new file mode 100644
index 0000000..1706954
--- /dev/null
+++ b/ext/phar/tests/zip/files/compress_unsupunknown.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/corrupt2.php.inc b/ext/phar/tests/zip/files/corrupt2.php.inc
new file mode 100644
index 0000000..3edf620
--- /dev/null
+++ b/ext/phar/tests/zip/files/corrupt2.php.inc
@@ -0,0 +1,60 @@
+<?php
+include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('hi2', null, 'hii2', null, null, 'encrypt', 'encrypt');
+$a->writeZip(dirname(__FILE__) . '/encrypted.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('', null, 'stdin');
+$a->writeZip(dirname(__FILE__) . '/stdin.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hii', null, 'hii', null, null, 'filename_len', 'filename_len');
+$a->addFile('hi', null, 'hii');
+$a->writeZip(dirname(__FILE__) . '/truncfilename.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress');
+$a->writeZip(dirname(__FILE__) . '/compress_unsup1.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 2);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup2.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 3);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup3.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 4);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup4.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 5);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup5.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 6);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup6.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 7);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup7.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 9);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup9.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 10);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup10.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 14);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup14.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 18);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup18.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 19);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup19.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 97);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup97.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 98);
+$a->writeZip(dirname(__FILE__) . '/compress_unsup98.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11);
+$a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip');
+?>
diff --git a/ext/phar/tests/zip/files/corrupt3.php.inc b/ext/phar/tests/zip/files/corrupt3.php.inc
new file mode 100644
index 0000000..05ba70b
--- /dev/null
+++ b/ext/phar/tests/zip/files/corrupt3.php.inc
@@ -0,0 +1,9 @@
+<?php
+include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii', null, null, null, 'extralen1');
+$a->writeZip(dirname(__FILE__) . '/extralen_toolong.zip');
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->writeZip(dirname(__FILE__) . '/disknumber.zip', 'disknumber');
+?>
diff --git a/ext/phar/tests/zip/files/corrupt_count1.php.inc b/ext/phar/tests/zip/files/corrupt_count1.php.inc
new file mode 100644
index 0000000..314fdef
--- /dev/null
+++ b/ext/phar/tests/zip/files/corrupt_count1.php.inc
@@ -0,0 +1,11 @@
+<?php
+include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('hi2', null, 'hii2');
+$a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1');
+$a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2');
+$a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none');
+$a->writeZip(dirname(__FILE__) . '/filecomment.zip', 'comment');
+$a->writeZip(dirname(__FILE__) . '/cdir_offset.zip', 'cdir_offset');
+?>
diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
new file mode 100644
index 0000000..9fbfe34
--- /dev/null
+++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
@@ -0,0 +1,332 @@
+<?php
+// this corrupt zip maker uses portions of Vincent Lascaux's File_Archive to create
+// specifically corrupted zip archives for unit-testing zip support in the phar extension
+// and was modified by Greg Beaver
+/**
+ * ZIP archive writer
+ *
+ * PHP versions 4 and 5
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
+ *
+ * @category File Formats
+ * @package File_Archive
+ * @author Vincent Lascaux <vincentlascaux@php.net>
+ * @copyright 1997-2005 The PHP Group
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ * @version CVS: $Id$
+ * @link http://pear.php.net/package/File_Archive
+ */
+
+/**
+ * ZIP archive writer
+ */
+class corrupt_zipmaker
+{
+ /**
+ * @var int Current position in the writer
+ * @access private
+ */
+ var $offset = 0;
+
+ /**
+ * @var string Optionnal comment to add to the zip
+ * @access private
+ */
+ var $comment = "";
+
+ /**
+ * @var string Data written at the end of the ZIP file
+ * @access private
+ */
+ var $central = "";
+
+ /**
+ * @var string Data written at the start of the ZIP file
+ * @access private
+ */
+ var $start = "";
+
+ /**
+ * Set a comment on the ZIP file
+ */
+ function setComment($comment) { $this->comment = $comment; }
+
+ /**
+ * @param int $time Unix timestamp of the date to convert
+ * @return the date formated as a ZIP date
+ */
+ function getMTime($time)
+ {
+ $mtime = ($time !== null ? getdate($time) : getdate());
+ $mtime = preg_replace(
+ "/(..){1}(..){1}(..){1}(..){1}/",
+ "\\x\\4\\x\\3\\x\\2\\x\\1",
+ dechex(($mtime['year']-1980<<25)|
+ ($mtime['mon' ]<<21)|
+ ($mtime['mday' ]<<16)|
+ ($mtime['hours' ]<<11)|
+ ($mtime['minutes']<<5)|
+ ($mtime['seconds']>>1)));
+ eval('$mtime = "'.$mtime.'";');
+ return $mtime;
+ }
+
+ private function getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $corrupt, $fakecomp)
+ {
+ switch ($corrupt) {
+ case null :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'compress' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $fakecomp) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'encrypt' :
+ $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'crc32' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'complength' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength + 1, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'uncomplength' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'filename_len' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00) .
+ $filename .
+ $data;
+ break;
+ case 'extra_len' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 1) .
+ $filename .
+ $data;
+ break;
+ case 'filename' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
+ substr($filename, 1) .
+ $data;
+ break;
+ case 'data' :
+ $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
+ $filename .
+ substr($data, 1);
+ break;
+ }
+ return $file;
+ }
+
+ private function getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $corrupt, &$offset, $fakecomp)
+ {
+ settype($comment, 'string');
+ switch ($corrupt) {
+ case null :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'encrypt' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'compress' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $fakecomp) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'crc32' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'complength' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength - 1, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'uncomplength' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'filename_len' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'offset' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
+ 0x0000, $this->offset - 1).
+ $filename . $comment;
+ $offset = strlen($central) - 1;
+ break;
+ case 'comment' :
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment) + 1,0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $comment;
+ $offset = strlen($central);
+ break;
+ case 'extralen1' :
+ $extra = 'nu' . 0xffff; // way huge size
+ $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
+ $mtime .
+ pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00,
+ 0x0000, $this->offset).
+ $filename . $extra . $comment;
+ $offset = strlen($central);
+ break;
+ }
+ return $central;
+ }
+
+ function addFile($filename, $mtime, $data, $comment = null, $compress = null, $filecorrupt = null, $centralcorrupt = null, $fakecomp = 1)
+ {
+ $mtime = $this->getMTime($mtime ? $mtime : null);
+
+ $uncomplength = strlen($data);
+ $crc32 = crc32($data) & 0xFFFFFFFF;
+ $compmethod = 0;
+ switch ($compress) {
+ case 'gz' :
+ $data = gzcompress($data);
+ $compmethod = 8;
+ break;
+ case 'bz2' :
+ $data = bzcompress($data);
+ $compmethod = 12;
+ break;
+ }
+ $complength = strlen($data);
+
+ $this->start .= ($file = $this->getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $filecorrupt, $fakecomp));
+
+ $offset = 0;
+ $this->central .= $this->getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $centralcorrupt, $offset, $fakecomp);
+
+ $this->offset += $offset;
+ $this->count++;
+ }
+
+ function writeZip($zipfile, $corrupt = null)
+ {
+ $write = $this->start . $this->central;
+ switch ($corrupt) {
+ case null :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count, $this->count,
+ $this->offset, strlen($this->start),
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'disknumber' :
+ $write .= "PK\x05\x06\x01\x00\x01\x00" .
+ pack("vvVVv", $this->count, $this->count,
+ $this->offset, strlen($this->start),
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'count1' :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count + 1, $this->count,
+ $this->offset, strlen($this->start),
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'count2' :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count, $this->count + 1,
+ $this->offset, strlen($this->start),
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'cdir_offset' :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count, $this->count,
+ $this->offset, strlen($this->start) - 3,
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'cdir_len' :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count, $this->count,
+ $this->offset - 5, strlen($this->start),
+ strlen($this->comment)) . $this->comment;
+ break;
+ case 'comment' :
+ $write .= "PK\x05\x06\x00\x00\x00\x00" .
+ pack("vvVVv", $this->count, $this->count,
+ strlen($this->start), $this->offset + 1,
+ strlen($this->comment) + 1) . $this->comment;
+ break;
+ case 'none' :
+ }
+ file_put_contents($zipfile, $write);
+ }
+}
+?> \ No newline at end of file
diff --git a/ext/phar/tests/zip/files/count1.zip b/ext/phar/tests/zip/files/count1.zip
new file mode 100644
index 0000000..73b5561
--- /dev/null
+++ b/ext/phar/tests/zip/files/count1.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/count2.zip b/ext/phar/tests/zip/files/count2.zip
new file mode 100644
index 0000000..6aa2619
--- /dev/null
+++ b/ext/phar/tests/zip/files/count2.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/disknumber.zip b/ext/phar/tests/zip/files/disknumber.zip
new file mode 100644
index 0000000..f20db05
--- /dev/null
+++ b/ext/phar/tests/zip/files/disknumber.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/encrypted.zip b/ext/phar/tests/zip/files/encrypted.zip
new file mode 100644
index 0000000..dee73ca
--- /dev/null
+++ b/ext/phar/tests/zip/files/encrypted.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/extralen_toolong.zip b/ext/phar/tests/zip/files/extralen_toolong.zip
new file mode 100644
index 0000000..a03a403
--- /dev/null
+++ b/ext/phar/tests/zip/files/extralen_toolong.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/filecomment.zip b/ext/phar/tests/zip/files/filecomment.zip
new file mode 100644
index 0000000..414b121
--- /dev/null
+++ b/ext/phar/tests/zip/files/filecomment.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.inc b/ext/phar/tests/zip/files/frontcontroller.phar.inc
new file mode 100644
index 0000000..241dceb
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a['index.php'] = 'here is my index';
+$a->setStub('<?php
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.zip b/ext/phar/tests/zip/files/frontcontroller.phar.zip
new file mode 100644
index 0000000..28992ff
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.inc b/ext/phar/tests/zip/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000..c973cc1
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.zip');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.zip b/ext/phar/tests/zip/files/frontcontroller10.phar.zip
new file mode 100644
index 0000000..d206c89
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller10.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.inc b/ext/phar/tests/zip/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000..c24a6f1
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.zip');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER["SCRIPT_NAME"]);
+var_dump($_SERVER["SCRIPT_FILENAME"]);
+var_dump($_SERVER["REQUEST_URI"]);
+var_dump($_SERVER["PHAR_PHP_SELF"]);
+var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER["PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.zip b/ext/phar/tests/zip/files/frontcontroller11.phar.zip
new file mode 100644
index 0000000..9942183
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller11.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000..c5f38ff
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.zip');
+$a['index.php'] = '<?php
+var_dump($_SERVER["PHP_SELF"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
+';
+$a->setStub('<?php
+Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.zip b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
new file mode 100644
index 0000000..ed9be3d
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.inc b/ext/phar/tests/zip/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000..6cfa052
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "a.php");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.zip b/ext/phar/tests/zip/files/frontcontroller2.phar.zip
new file mode 100644
index 0000000..3d7c0bb
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller2.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000..ccd55b7
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => b"a.phps");
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.zip b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
new file mode 100644
index 0000000..6f35a80
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000..9f664cf
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array(b"/hi" => false);
+ if (isset($b[$a])) return $b[$a];
+ return $a;
+}
+Phar::webPhar("whatever", "index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.zip b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
new file mode 100644
index 0000000..fb27ccb
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.inc b/ext/phar/tests/zip/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000..931fa97
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.zip b/ext/phar/tests/zip/files/frontcontroller5.phar.zip
new file mode 100644
index 0000000..7fa7ab6
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller5.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.inc b/ext/phar/tests/zip/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000..da178fe
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => 100));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.zip b/ext/phar/tests/zip/files/frontcontroller6.phar.zip
new file mode 100644
index 0000000..eac313c
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller6.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.inc b/ext/phar/tests/zip/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000..a186491
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.zip');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("php" => null));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.zip b/ext/phar/tests/zip/files/frontcontroller7.phar.zip
new file mode 100644
index 0000000..be72052
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller7.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller8.phar.inc b/ext/phar/tests/zip/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000..e04ac41
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller8.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.zip');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller8.phar.zip b/ext/phar/tests/zip/files/frontcontroller8.phar.zip
new file mode 100644
index 0000000..d065cd5
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller8.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller9.phar.inc b/ext/phar/tests/zip/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000..5044045
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.zip');
+$a['a.phps'] = 'hio1';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a->setStub('<?php
+Phar::mungServer(array());
+Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/zip/files/frontcontroller9.phar.zip b/ext/phar/tests/zip/files/frontcontroller9.phar.zip
new file mode 100644
index 0000000..82c4eb7
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller9.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc
new file mode 100644
index 0000000..cec8ef7
--- /dev/null
+++ b/ext/phar/tests/zip/files/make_invalid_tar.php.inc
@@ -0,0 +1,12 @@
+<?php
+include dirname(__FILE__) . '/tarmaker.php.inc';
+class corrupter extends tarmaker {
+function close()
+{
+ parent::close();
+ $fp = fopen($this->path, 'r+b');
+ fseek($fp, 20);
+ fwrite($fp, 'oopsie');
+ fclose($fp);
+}
+} \ No newline at end of file
diff --git a/ext/phar/tests/zip/files/metadata.phar.inc b/ext/phar/tests/zip/files/metadata.phar.inc
new file mode 100644
index 0000000..932fc96
--- /dev/null
+++ b/ext/phar/tests/zip/files/metadata.phar.inc
@@ -0,0 +1,11 @@
+<?php
+@unlink(dirname(__FILE__) . '/metadata.phar.zip');
+$a = new Phar(dirname(__FILE__) . '/metadata.phar.zip');
+$a['a'] = 'a';
+$a['b'] = 'b';
+$a['b']->setMetadata('hi there');
+$a['c'] = 'c';
+$a['c']->setMetadata(array('hi', 'there'));
+$a['d'] = 'd';
+$a['d']->setMetadata(array('hi'=>'there','foo'=>'bar'));
+?>
diff --git a/ext/phar/tests/zip/files/metadata.phar.zip b/ext/phar/tests/zip/files/metadata.phar.zip
new file mode 100644
index 0000000..3c5cf00
--- /dev/null
+++ b/ext/phar/tests/zip/files/metadata.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/nozipend.zip b/ext/phar/tests/zip/files/nozipend.zip
new file mode 100644
index 0000000..f976072
--- /dev/null
+++ b/ext/phar/tests/zip/files/nozipend.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/odt.odt b/ext/phar/tests/zip/files/odt.odt
new file mode 100644
index 0000000..527e09f
--- /dev/null
+++ b/ext/phar/tests/zip/files/odt.odt
Binary files differ
diff --git a/ext/phar/tests/zip/files/stdin.zip b/ext/phar/tests/zip/files/stdin.zip
new file mode 100644
index 0000000..4376eb6
--- /dev/null
+++ b/ext/phar/tests/zip/files/stdin.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/test.odt b/ext/phar/tests/zip/files/test.odt
new file mode 100644
index 0000000..c5cefe5
--- /dev/null
+++ b/ext/phar/tests/zip/files/test.odt
Binary files differ
diff --git a/ext/phar/tests/zip/files/truncfilename.zip b/ext/phar/tests/zip/files/truncfilename.zip
new file mode 100644
index 0000000..d8a526a
--- /dev/null
+++ b/ext/phar/tests/zip/files/truncfilename.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/zip.zip b/ext/phar/tests/zip/files/zip.zip
new file mode 100644
index 0000000..5ee9cae
--- /dev/null
+++ b/ext/phar/tests/zip/files/zip.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/zipmaker.php.inc b/ext/phar/tests/zip/files/zipmaker.php.inc
new file mode 100644
index 0000000..aceab0d
--- /dev/null
+++ b/ext/phar/tests/zip/files/zipmaker.php.inc
@@ -0,0 +1,70 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests
+class zipmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * @var ZIPArchive
+ */
+ protected $zip;
+ protected $path;
+ function __construct($path)
+ {
+ if (!class_exists('ZIPArchive')) {
+ throw new Exception(
+ 'Zip extension is not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream)
+ {
+ if (is_resource($fileOrStream)) {
+ $this->zip->addFromString($path, stream_get_contents($fileOrStream));
+ } else {
+ $this->zip->addFromString($path, $fileOrStream);
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ $this->zip = new ZipArchive;
+ if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) {
+ throw new Exception(
+ 'Cannot open ZIP archive ' . $this->path
+ );
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * This is a no-op for the tar creator
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->zip->addEmptyDir($dir);
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ $this->zip->close();
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/zip/files/zlib_alias.phar.zip b/ext/phar/tests/zip/files/zlib_alias.phar.zip
new file mode 100644
index 0000000..d6f98e8
--- /dev/null
+++ b/ext/phar/tests/zip/files/zlib_alias.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller1.phar.phpt b/ext/phar/tests/zip/frontcontroller1.phar.phpt
new file mode 100644
index 0000000..b4ace60
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller1.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller other zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller1.phar.php
+REQUEST_URI=/frontcontroller1.phar.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Content-type: image/jpeg
+Content-length: 3
+--EXPECT--
+hio
diff --git a/ext/phar/tests/zip/frontcontroller10.phar.phpt b/ext/phar/tests/zip/frontcontroller10.phar.phpt
new file mode 100644
index 0000000..56d16c2
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller10.phar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar front controller rewrite array invalid zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller10.phar.php
+REQUEST_URI=/frontcontroller10.phar.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller4.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+Status: 403 Access Denied
+--EXPECT--
+<html>
+ <head>
+ <title>Access Denied</title>
+ </head>
+ <body>
+ <h1>403 - File /hi Access Denied</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller11.phar.phpt b/ext/phar/tests/zip/frontcontroller11.phar.phpt
new file mode 100644
index 0000000..e4900cd
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller11.phar.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar front controller mime type extension is not a string zip-based
+--INI--
+default_charset=
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+<?php die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller11.phar.php
+REQUEST_URI=/frontcontroller11.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller5.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.phar.php:2
+Stack trace:
+#0 %sfrontcontroller11.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller11.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller12.phar.phpt b/ext/phar/tests/zip/frontcontroller12.phar.phpt
new file mode 100644
index 0000000..504d037
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller12.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type unknown int zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller12.phar.php
+REQUEST_URI=/frontcontroller12.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller6.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller12.phar.php:2
+Stack trace:
+#0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller12.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller13.phar.phpt b/ext/phar/tests/zip/frontcontroller13.phar.phpt
new file mode 100644
index 0000000..4b9e910
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller13.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type not string/int zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller13.phar.php
+REQUEST_URI=/frontcontroller13.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller7.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed' in %sfrontcontroller13.phar.php:2
+Stack trace:
+#0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller13.phar.php on line 2 \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller14.phar.phpt b/ext/phar/tests/zip/frontcontroller14.phar.phpt
new file mode 100644
index 0000000..496160b
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller14.phar.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Phar front controller mime type override, other zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller14.phar.php
+REQUEST_URI=/frontcontroller14.phar.php/a.jpg
+PATH_INFO=/a.jpg
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.zip
+--EXPECTHEADERS--
+Content-type: foo/bar
+Content-length: 4
+--EXPECT--
+hio2
diff --git a/ext/phar/tests/zip/frontcontroller15.phar.phpt b/ext/phar/tests/zip/frontcontroller15.phar.phpt
new file mode 100644
index 0000000..f6cd29a
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller15.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller mime type override, Phar::PHPS zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller15.phar.php
+REQUEST_URI=/frontcontroller15.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
+
diff --git a/ext/phar/tests/zip/frontcontroller16.phar.phpt b/ext/phar/tests/zip/frontcontroller16.phar.phpt
new file mode 100644
index 0000000..d3f457b
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller16.phar.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Phar front controller mime type override, Phar::PHP zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller16.phar.php
+REQUEST_URI=/frontcontroller16.phar.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio1
+
diff --git a/ext/phar/tests/zip/frontcontroller17.phar.phpt b/ext/phar/tests/zip/frontcontroller17.phar.phpt
new file mode 100644
index 0000000..5d52653
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller17.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller mime type unknown zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller17.phar.php
+REQUEST_URI=/frontcontroller17.phar.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller8.phar.zip
+--EXPECTHEADERS--
+Content-type: application/octet-stream
+Content-length: 4
+--EXPECT--
+hio3
+
diff --git a/ext/phar/tests/zip/frontcontroller18.phar.phpt b/ext/phar/tests/zip/frontcontroller18.phar.phpt
new file mode 100644
index 0000000..dbd09ca
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller18.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller $_SERVER munging failure zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller18.phar.php
+REQUEST_URI=/frontcontroller18.phar.php/fronk.gronk
+PATH_INFO=/fronk.gronk
+--FILE_EXTERNAL--
+files/frontcontroller9.phar.zip
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2
+Stack trace:
+#0 %sfrontcontroller18.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller18.phar.php on line 2
diff --git a/ext/phar/tests/zip/frontcontroller19.phar.phpt b/ext/phar/tests/zip/frontcontroller19.phar.phpt
new file mode 100644
index 0000000..0eb87bf
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller19.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller $_SERVER munging failure 2 zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller19.phar.php
+REQUEST_URI=/frontcontroller19.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller10.phar.zip
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2
+Stack trace:
+#0 %sfrontcontroller19.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller19.phar.php on line 2
diff --git a/ext/phar/tests/zip/frontcontroller2.phar.phpt b/ext/phar/tests/zip/frontcontroller2.phar.phpt
new file mode 100644
index 0000000..e143e79
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller2.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller PHP test zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller2.phar.php
+REQUEST_URI=/frontcontroller2.phar.php/a.php
+PATH_INFO=/a.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+hio
diff --git a/ext/phar/tests/zip/frontcontroller20.phar.phpt b/ext/phar/tests/zip/frontcontroller20.phar.phpt
new file mode 100644
index 0000000..b1caf52
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller20.phar.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Phar front controller $_SERVER munging failure 3 zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller20.phar.php
+REQUEST_URI=/frontcontroller20.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller11.phar.zip
+--EXPECTF--
+Fatal error: Uncaught exception 'PharException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2
+Stack trace:
+#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
+#1 {main}
+ thrown in %sfrontcontroller20.phar.php on line 2
diff --git a/ext/phar/tests/zip/frontcontroller21.phar.phpt b/ext/phar/tests/zip/frontcontroller21.phar.phpt
new file mode 100644
index 0000000..74caa2c
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller21.phar.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar front controller $_SERVER munging success zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller21.phar.php
+REQUEST_URI=/frontcontroller21.phar.php/index.php?test=hi
+PATH_INFO=/index.php
+QUERY_STRING=test=hi
+--FILE_EXTERNAL--
+files/frontcontroller12.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECTF--
+%unicode|string%(10) "/index.php"
+string(10) "/index.php"
+string(%d) "phar://%sfrontcontroller21.phar.php/index.php"
+string(18) "/index.php?test=hi"
+string(37) "/frontcontroller21.phar.php/index.php"
+string(27) "/frontcontroller21.phar.php"
+string(%d) "%sfrontcontroller21.phar.php"
+string(45) "/frontcontroller21.phar.php/index.php?test=hi" \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller3.phar.phpt b/ext/phar/tests/zip/frontcontroller3.phar.phpt
new file mode 100644
index 0000000..88a8a24
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller3.phar.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Phar front controller phps zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller3.phar.php
+REQUEST_URI=/frontcontroller3.phar.php/a.phps
+PATH_INFO=/a.phps
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code>
diff --git a/ext/phar/tests/zip/frontcontroller4.phar.phpt b/ext/phar/tests/zip/frontcontroller4.phar.phpt
new file mode 100644
index 0000000..ff85eb6
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller4.phar.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller index.php relocate (no /) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller4.phar.php
+REQUEST_URI=/frontcontroller4.phar.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller4.phar.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/zip/frontcontroller5.phar.phpt b/ext/phar/tests/zip/frontcontroller5.phar.phpt
new file mode 100644
index 0000000..1705fac
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller5.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller index.php relocate zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller5.phar.php
+REQUEST_URI=/frontcontroller5.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller5.phar.php/index.php
+--EXPECT--
diff --git a/ext/phar/tests/zip/frontcontroller6.phar.phpt b/ext/phar/tests/zip/frontcontroller6.phar.phpt
new file mode 100644
index 0000000..15489f6
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller6.phar.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar front controller 404 zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller6.phar.php
+REQUEST_URI=/frontcontroller6.phar.php/notfound.php
+PATH_INFO=/notfound.php
+--FILE_EXTERNAL--
+files/frontcontroller.phar.zip
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /notfound.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller7.phar.phpt b/ext/phar/tests/zip/frontcontroller7.phar.phpt
new file mode 100644
index 0000000..828da0a
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller7.phar.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar front controller alternate index file zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller7.phar.php
+REQUEST_URI=/frontcontroller7.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller2.phar.zip
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller7.phar.php/a.php
+--EXPECT--
diff --git a/ext/phar/tests/zip/frontcontroller8.phar.phpt b/ext/phar/tests/zip/frontcontroller8.phar.phpt
new file mode 100644
index 0000000..1b0d133
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller8.phar.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Phar front controller no index file 404 zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller8.phar.php
+REQUEST_URI=/frontcontroller8.phar.php/
+PATH_INFO=/
+--FILE_EXTERNAL--
+files/frontcontroller3.phar.zip
+--EXPECTHEADERS--
+Status: 404 Not Found
+--EXPECT--
+<html>
+ <head>
+ <title>File Not Found</title>
+ </head>
+ <body>
+ <h1>404 - File /index.php Not Found</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/ext/phar/tests/zip/frontcontroller9.phar.phpt b/ext/phar/tests/zip/frontcontroller9.phar.phpt
new file mode 100644
index 0000000..4f12c9c
--- /dev/null
+++ b/ext/phar/tests/zip/frontcontroller9.phar.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar front controller rewrite array zip-based
+--INI--
+default_charset=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller9.phar.php
+REQUEST_URI=/frontcontroller9.phar.php/hi
+PATH_INFO=/hi
+--FILE_EXTERNAL--
+files/frontcontroller3.phar.zip
+--EXPECTHEADERS--
+Content-type: text/html; charset=UTF-8
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">hio</span><span style="color: #007700">(){}</span>
+</span>
+</code> \ No newline at end of file
diff --git a/ext/phar/tests/zip/getalias.phpt b/ext/phar/tests/zip/getalias.phpt
new file mode 100644
index 0000000..9c91763
--- /dev/null
+++ b/ext/phar/tests/zip/getalias.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar: getAlias() with an existing phar.zip
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+// sanity check with a virgin phar.zip
+$phar = new Phar($fname);
+var_dump($phar->getAlias());
+unset($phar);
+
+copy(dirname(__FILE__) . '/files/metadata.phar.zip', $fname);
+
+// existing phar.zip, no alias set
+$phar = new Phar($fname);
+var_dump($phar->getAlias());
+
+// check that default alias can be overwritten
+$phar->setAlias('jiminycricket');
+var_dump($phar->getAlias());
+unset($phar);
+
+// existing phar.zip, alias set
+$phar = new Phar($fname);
+var_dump($phar->getAlias());
+
+// check that alias can't be set manually
+try {
+ $phar['.phar/alias.txt'] = 'pinocchio';
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+var_dump($phar->getAlias());
+
+// check that user-defined alias can be overwritten
+$phar->setAlias('pinocchio');
+var_dump($phar->getAlias());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+string(%d) "%sgetalias.phar.zip"
+string(%d) "%sgetalias.phar.zip"
+string(13) "jiminycricket"
+string(13) "jiminycricket"
+Cannot set alias ".phar/alias.txt" directly in phar "%sgetalias.phar.zip", use setAlias
+string(13) "jiminycricket"
+string(9) "pinocchio"
+===DONE===
diff --git a/ext/phar/tests/zip/largezip.phpt b/ext/phar/tests/zip/largezip.phpt
new file mode 100644
index 0000000..a8438eb
--- /dev/null
+++ b/ext/phar/tests/zip/largezip.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: large zip file (zip edge cases)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php';
+$pname = 'phar://' . $fname;
+$pname2 = 'phar://' . $fname2;
+
+$p = new Phar($fname);
+$p['big'] = str_repeat(str_repeat('hi', 100), 1000);
+$p['big2'] = str_repeat(str_repeat('hi', 100), 1000);
+
+copy($fname, $fname2);
+$p2 = new Phar($fname2);
+var_dump(strlen($p2['big']->getContent()));
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?>
+--EXPECT--
+int(200000)
+===DONE===
diff --git a/ext/phar/tests/zip/metadata_write_commit.phpt b/ext/phar/tests/zip/metadata_write_commit.phpt
new file mode 100644
index 0000000..1629636
--- /dev/null
+++ b/ext/phar/tests/zip/metadata_write_commit.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Phar with meta-data (write) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$f2name = dirname(__FILE__) . '/files/metadata.phar.zip';
+$pname = 'phar://' . $fname;
+$p2name = 'phar://' . $f2name;
+
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($p2name.'/'.$name));
+}
+
+copy($f2name, $fname);
+$phar = new Phar($fname);
+$phar->startBuffering();
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+$phar->setMetadata('hi');
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+$phar->stopBuffering();
+
+unset($phar);
+
+$phar = new Phar($fname);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+var_dump($phar->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ ["foo"]=>
+ string(3) "bar"
+}
+bool(true)
+string(2) "hi"
+===DONE===
diff --git a/ext/phar/tests/zip/metadata_write_commitU.phpt b/ext/phar/tests/zip/metadata_write_commitU.phpt
new file mode 100644
index 0000000..bc589af
--- /dev/null
+++ b/ext/phar/tests/zip/metadata_write_commitU.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Phar with meta-data (write) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$f2name = dirname(__FILE__) . '/files/metadata.phar.zip';
+$pname = 'phar://' . $fname;
+$p2name = 'phar://' . $f2name;
+
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a'] = array('cont' => 'a');
+$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
+$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
+$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($p2name.'/'.$name));
+}
+
+copy($f2name, $fname);
+$phar = new Phar($fname);
+$phar->startBuffering();
+$phar['a']->setMetadata(42);
+$phar['b']->setMetadata(NULL);
+$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
+$phar['d']->setMetadata(true);
+$phar->setMetadata('hi');
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+$phar->stopBuffering();
+
+unset($phar);
+
+$phar = new Phar($fname);
+
+foreach($files as $name => $cont) {
+ var_dump(file_get_contents($pname.'/'.$name));
+}
+
+foreach($files as $name => $cont) {
+ var_dump($phar[$name]->getMetadata());
+}
+var_dump($phar->getMetadata());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+--EXPECT--
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+int(42)
+NULL
+array(2) {
+ [0]=>
+ int(25)
+ [u"foo"]=>
+ unicode(3) "bar"
+}
+bool(true)
+unicode(2) "hi"
+===DONE===
diff --git a/ext/phar/tests/zip/notphar.phpt b/ext/phar/tests/zip/notphar.phpt
new file mode 100644
index 0000000..c0648c4
--- /dev/null
+++ b/ext/phar/tests/zip/notphar.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Phar: a non-executable zip with no stub named .phar.zip
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=1
+detect_unicode=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$pname = 'phar://' . $fname;
+
+copy(dirname(__FILE__) . '/files/zip.zip', $fname);
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+Warning: include(phar://%snotphar.phar.zip/.phar/stub.php): failed to open stream: '%snotphar.phar.zip' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive in %snotphar.php on line %d
+PK%a
diff --git a/ext/phar/tests/zip/odt.phpt b/ext/phar/tests/zip/odt.phpt
new file mode 100644
index 0000000..b007d44
--- /dev/null
+++ b/ext/phar/tests/zip/odt.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Phar: test a zip archive created by openoffice
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--FILE--
+<?php
+$a = new PharData(dirname(__FILE__) . '/files/odt.odt');
+foreach (new RecursiveIteratorIterator($a, RecursiveIteratorIterator::LEAVES_ONLY) as $b) {
+ if ($b->isDir()) {
+ echo "dir " . $b->getPathName() . "\n";
+ } else {
+ echo $b->getPathName() . "\n";
+ }
+}
+// this next line is for increased code coverage
+try {
+ $b = new Phar(dirname(__FILE__) . '/files/odt.odt');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar://%sodt.odt/Configurations2/accelerator%ccurrent.xml
+phar://%sodt.odt/META-INF%cmanifest.xml
+phar://%sodt.odt/Thumbnails%cthumbnail.png
+phar://%sodt.odt%ccontent.xml
+phar://%sodt.odt%cmeta.xml
+phar://%sodt.odt%cmimetype
+phar://%sodt.odt%csettings.xml
+phar://%sodt.odt%cstyles.xml
+Cannot create phar '%sodt.odt', file extension (or combination) not recognised or the directory does not exist
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing.phpt b/ext/phar/tests/zip/open_for_write_existing.phpt
new file mode 100644
index 0000000..bbf036c
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_existing.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECT--
+extra
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_b.phpt b/ext/phar/tests/zip/open_for_write_existing_b.phpt
new file mode 100644
index 0000000..b997c68
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_existing_b.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt
new file mode 100644
index 0000000..b88a496
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b_5_2.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_c.phpt b/ext/phar/tests/zip/open_for_write_existing_c.phpt
new file mode 100644
index 0000000..313ee4a
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_existing_c.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt
new file mode 100644
index 0000000..9e23fd5
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c_5_2.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
+This is b/c
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_newfile.phpt b/ext/phar/tests/zip/open_for_write_newfile.phpt
new file mode 100644
index 0000000..ffcae0f
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_newfile.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECT--
+This is b/c
+extra
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_newfile_b.phpt b/ext/phar/tests/zip/open_for_write_newfile_b.phpt
new file mode 100644
index 0000000..96fd2e4
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_newfile_b.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.zip" in %sopen_for_write_newfile_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt
new file mode 100644
index 0000000..3032427
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b_5_2.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b_5_2.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b_5_2.phar.zip" in %sopen_for_write_newfile_b_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b_5_2.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_newfile_c.phpt b/ext/phar/tests/zip/open_for_write_newfile_c.phpt
new file mode 100644
index 0000000..ef580cb
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_newfile_c.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, b'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt
new file mode 100644
index 0000000..9bf5af5
--- /dev/null
+++ b/ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c_5_2.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c_5_2.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c_5_2.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c_5_2.phar.zip" in %sopen_for_write_newfile_c_5_2.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c_5_2.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c_5_2.php on line %d
+
+===DONE===
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commit.phpt b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
new file mode 100644
index 0000000..dc59f2f
--- /dev/null
+++ b/ext/phar/tests/zip/phar_begin_setstub_commit.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering() zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar');
+var_dump($p->isFileFormat(Phar::ZIP));
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+
+// add portion to test setting stub from resource
+file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+$a = fopen(dirname(__FILE__) . '/myfakestub.php', 'rb');
+$p->setStub($a);
+var_dump($p->getStub());
+$c = strlen('<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>' . 'extra stuff');
+fseek($a, 0);
+$p->setStub($a, $c);
+var_dump($p->getStub());
+fclose($a);
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
+unlink(dirname(__FILE__) . '/myfakestub.php');
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+string(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+string(5) "Hello"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
new file mode 100644
index 0000000..2956fc6
--- /dev/null
+++ b/ext/phar/tests/zip/phar_begin_setstub_commitU.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering() zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar');
+var_dump($p->isFileFormat(Phar::ZIP));
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+
+// add portion to test setting stub from resource
+file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+$a = fopen(dirname(__FILE__) . '/myfakestub.php', 'rb');
+$p->setStub($a);
+var_dump($p->getStub());
+$c = strlen('<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>' . 'extra stuff');
+fseek($a, 0);
+$p->setStub($a, $c);
+var_dump($p->getStub());
+fclose($a);
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
+unlink(dirname(__FILE__) . '/myfakestub.php');
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+unicode(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(false)
+unicode(5) "Hello"
+unicode(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator4.phpt b/ext/phar/tests/zip/phar_buildfromiterator4.phpt
new file mode 100644
index 0000000..cc11fe5
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator4.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file passed in zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt'))));
+ var_dump($phar->isFileFormat(Phar::ZIP));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "%sphar_buildfromiterator4.phpt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt
new file mode 100644
index 0000000..1d14686
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Phar::buildFromIterator() iterator, iterator returns non-string zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid value (must return a string)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator6.phpt b/ext/phar/tests/zip/phar_buildfromiterator6.phpt
new file mode 100644
index 0000000..936dda9
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator6.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, key is int zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+ var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned an invalid key (must return a string)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator7.phpt b/ext/phar/tests/zip/phar_buildfromiterator7.phpt
new file mode 100644
index 0000000..777dbf8
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator7.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Phar::buildFromIterator() iterator, file can't be opened zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt'))));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+%s(24) "UnexpectedValueException"
+Iterator myIterator returned a file that could not be opened "phar_buildfromiterator7./oopsie/there.phpt"
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator8.phpt b/ext/phar/tests/zip/phar_buildfromiterator8.phpt
new file mode 100644
index 0000000..d2b1be2
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator8.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Phar::buildFromIterator() iterator, SplFileInfo as current zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+ $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), dirname(__FILE__) . DIRECTORY_SEPARATOR);
+ asort($a);
+ var_dump($a);
+ var_dump($phar->isFileFormat(Phar::ZIP));
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+array(21) {
+ ["frontcontroller1.phar.phpt"]=>
+ string(%d) "%sfrontcontroller1.phar.phpt"
+ ["frontcontroller10.phar.phpt"]=>
+ string(%d) "%sfrontcontroller10.phar.phpt"
+ ["frontcontroller11.phar.phpt"]=>
+ string(%d) "%sfrontcontroller11.phar.phpt"
+ ["frontcontroller12.phar.phpt"]=>
+ string(%d) "%sfrontcontroller12.phar.phpt"
+ ["frontcontroller13.phar.phpt"]=>
+ string(%d) "%sfrontcontroller13.phar.phpt"
+ ["frontcontroller14.phar.phpt"]=>
+ string(%d) "%sfrontcontroller14.phar.phpt"
+ ["frontcontroller15.phar.phpt"]=>
+ string(%d) "%sfrontcontroller15.phar.phpt"
+ ["frontcontroller16.phar.phpt"]=>
+ string(%d) "%sfrontcontroller16.phar.phpt"
+ ["frontcontroller17.phar.phpt"]=>
+ string(%d) "%sfrontcontroller17.phar.phpt"
+ ["frontcontroller18.phar.phpt"]=>
+ string(%d) "%sfrontcontroller18.phar.phpt"
+ ["frontcontroller19.phar.phpt"]=>
+ string(%d) "%sfrontcontroller19.phar.phpt"
+ ["frontcontroller2.phar.phpt"]=>
+ string(%d) "%sfrontcontroller2.phar.phpt"
+ ["frontcontroller20.phar.phpt"]=>
+ string(%d) "%sfrontcontroller20.phar.phpt"
+ ["frontcontroller21.phar.phpt"]=>
+ string(%d) "%sfrontcontroller21.phar.phpt"
+ ["frontcontroller3.phar.phpt"]=>
+ string(%d) "%sfrontcontroller3.phar.phpt"
+ ["frontcontroller4.phar.phpt"]=>
+ string(%d) "%sfrontcontroller4.phar.phpt"
+ ["frontcontroller5.phar.phpt"]=>
+ string(%d) "%sfrontcontroller5.phar.phpt"
+ ["frontcontroller6.phar.phpt"]=>
+ string(%d) "%sfrontcontroller6.phar.phpt"
+ ["frontcontroller7.phar.phpt"]=>
+ string(%d) "%sfrontcontroller7.phar.phpt"
+ ["frontcontroller8.phar.phpt"]=>
+ string(%d) "%sfrontcontroller8.phar.phpt"
+ ["frontcontroller9.phar.phpt"]=>
+ string(%d) "%sfrontcontroller9.phar.phpt"
+}
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_buildfromiterator9.phpt b/ext/phar/tests/zip/phar_buildfromiterator9.phpt
new file mode 100644
index 0000000..0b56307
--- /dev/null
+++ b/ext/phar/tests/zip/phar_buildfromiterator9.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Phar::buildFromIterator() iterator, 1 file resource passed in
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+class myIterator implements Iterator
+{
+ var $a;
+ function __construct(array $a)
+ {
+ $this->a = $a;
+ }
+ function next() {
+ echo "next\n";
+ return next($this->a);
+ }
+ function current() {
+ echo "current\n";
+ return current($this->a);
+ }
+ function key() {
+ echo "key\n";
+ return key($this->a);
+ }
+ function valid() {
+ echo "valid\n";
+ return current($this->a);
+ }
+ function rewind() {
+ echo "rewind\n";
+ return reset($this->a);
+ }
+}
+try {
+ chdir(dirname(__FILE__));
+ $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
+ var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r')))));
+ fclose($a);
+} catch (Exception $e) {
+ var_dump(get_class($e));
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/buildfromiterator.phar');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+rewind
+valid
+current
+key
+next
+valid
+array(1) {
+ ["a"]=>
+ string(%d) "[stream]"
+}
+===DONE===
diff --git a/ext/phar/tests/zip/phar_commitwrite.phpt b/ext/phar/tests/zip/phar_commitwrite.phpt
new file mode 100644
index 0000000..4e18a6b
--- /dev/null
+++ b/ext/phar/tests/zip/phar_commitwrite.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Phar::setStub()/stopBuffering() zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--ENV--
+TEMP=.
+TMP=.
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar');
+$p['file1.txt'] = 'hi';
+$p->stopBuffering();
+var_dump($p->getStub());
+$p->setStub("<?php
+function __autoload(\$class)
+{
+ include 'phar://' . str_replace('_', '/', \$class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER();
+?>");
+var_dump($p->getStub());
+var_dump($p->isFileFormat(Phar::ZIP));
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
+?>
+--EXPECT--
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+string(200) "<?php
+function __autoload($class)
+{
+ include 'phar://' . str_replace('_', '/', $class);
+}
+Phar::mapPhar('brandnewphar.phar');
+include 'phar://brandnewphar.phar/startup.php';
+__HALT_COMPILER(); ?>
+"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_convert_phar.phpt b/ext/phar/tests/zip/phar_convert_phar.phpt
new file mode 100644
index 0000000..cad6d9f
--- /dev/null
+++ b/ext/phar/tests/zip/phar_convert_phar.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Phar::convertToPhar() from zip
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar';
+
+$phar = new Phar($fname);
+$phar['a.txt'] = 'some text';
+$phar->stopBuffering();
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump(strlen($phar->getStub()));
+
+$phar = $phar->convertToExecutable(Phar::ZIP);
+var_dump($phar->isFileFormat(Phar::ZIP));
+var_dump($phar->getStub());
+
+$phar['a'] = 'hi there';
+
+$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.3.phar');
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump(strlen($phar->getStub()));
+
+copy($fname3, $fname2);
+
+$phar = new Phar($fname2);
+var_dump($phar->isFileFormat(Phar::PHAR));
+var_dump(strlen($phar->getStub()));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar');
+__HALT_COMPILER();
+?>
+--EXPECT--
+bool(false)
+int(6683)
+bool(true)
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+bool(true)
+int(6683)
+bool(true)
+int(6683)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_copy.phpt b/ext/phar/tests/zip/phar_copy.phpt
new file mode 100644
index 0000000..14034c9
--- /dev/null
+++ b/ext/phar/tests/zip/phar_copy.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar: copy() zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=1
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.php';
+
+$pname = 'phar://'.$fname;
+$iname = '/file.txt';
+$ename = '/error/..';
+
+$p = new Phar($fname);
+
+try
+{
+ $p['a'] = 'hi';
+ $p->startBuffering();
+ $p->copy('a', 'b');
+ echo file_get_contents($p['b']->getPathName());
+ $p->copy('b', 'c');
+ $p->stopBuffering();
+ echo file_get_contents($p['c']->getPathName());
+ copy($fname, $fname2);
+ var_dump($p->isFileFormat(Phar::ZIP));
+ $p->copy('a', $ename);
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+ini_set('phar.readonly',1);
+$p2 = new Phar($fname2);
+var_dump($p2->isFileFormat(Phar::ZIP));
+echo "\n";
+echo 'a: ' , file_get_contents($p2['a']->getPathName());
+echo 'b: ' ,file_get_contents($p2['b']->getPathName());
+echo 'c: ' ,file_get_contents($p2['c']->getPathName());
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?>
+--EXPECTF--
+hihibool(true)
+file "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s
+bool(true)
+
+a: hib: hic: hi===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/zip/phar_magic.phpt b/ext/phar/tests/zip/phar_magic.phpt
new file mode 100644
index 0000000..694f927
--- /dev/null
+++ b/ext/phar/tests/zip/phar_magic.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Phar: include/fopen magic zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$p = new Phar($fname);
+var_dump($p->isFileFormat(Phar::ZIP));
+$p['a'] = '<?php include "b/c.php";' . "\n";
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub('<?php
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != "phar");
+set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
+include "phar://" . __FILE__ . "/a";
+__HALT_COMPILER();');
+include $pname;
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+bool(true)
+string(%d) "%sphar_magic.phar.zip.php"
+bool(true)
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/zip/phar_magicU.phpt b/ext/phar/tests/zip/phar_magicU.phpt
new file mode 100644
index 0000000..f034e4e
--- /dev/null
+++ b/ext/phar/tests/zip/phar_magicU.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Phar: include/fopen magic zip-based
+--SKIPIF--
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
+?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$p = new Phar($fname);
+var_dump($p->isFileFormat(Phar::ZIP));
+$p['a'] = '<?php include "b/c.php";' . "\n";
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub('<?php
+var_dump(__FILE__);
+var_dump(substr(__FILE__, 0, 4) != "phar");
+set_include_path("phar://" . __FILE__);
+include "phar://" . __FILE__ . "/a";
+__HALT_COMPILER();');
+include $pname;
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+bool(true)
+unicode(%d) "%sphar_magicU.phar.zip.php"
+bool(true)
+in b
+<?php include "b/c.php";
+in d
+===DONE===
diff --git a/ext/phar/tests/zip/phar_oo_compressallbz2.phpt b/ext/phar/tests/zip/phar_oo_compressallbz2.phpt
new file mode 100644
index 0000000..d6b0a8f
--- /dev/null
+++ b/ext/phar/tests/zip/phar_oo_compressallbz2.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Phar::compressFiles(Phar::BZ2) zip format
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$pname = 'phar://' . $fname;
+$pname2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar['b'] = 'b';
+$phar['c'] = 'c';
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar->compressFiles(Phar::BZ2);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed(Phar::GZ));
+var_dump($phar['a']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed(Phar::GZ));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+$phar['d'] = 'hi'; // increases code coverage by having ufp open
+copy($fname, $fname2);
+$c = new Phar($fname2);
+var_dump(file_get_contents($pname2 . '/a'));
+var_dump($c['a']->isCompressed(Phar::GZ));
+var_dump($c['a']->isCompressed(Phar::BZ2));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(false)
+bool(true)
+string(1) "b"
+bool(false)
+bool(true)
+string(1) "c"
+bool(false)
+bool(true)
+string(1) "a"
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_oo_compressallgz.phpt b/ext/phar/tests/zip/phar_oo_compressallgz.phpt
new file mode 100644
index 0000000..47dddac
--- /dev/null
+++ b/ext/phar/tests/zip/phar_oo_compressallgz.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Phar::compressFiles(Phar::GZ) zip format
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar['b'] = 'b';
+$phar['c'] = 'c';
+
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed());
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed());
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['c']->isCompressed());
+
+$phar->compressFiles(Phar::GZ);
+var_dump(file_get_contents($pname . '/a'));
+var_dump($phar['a']->isCompressed(Phar::BZ2));
+var_dump($phar['a']->isCompressed(Phar::GZ));
+var_dump(file_get_contents($pname . '/b'));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump($phar['b']->isCompressed(Phar::GZ));
+var_dump(file_get_contents($pname . '/c'));
+var_dump($phar['b']->isCompressed(Phar::BZ2));
+var_dump($phar['c']->isCompressed(Phar::GZ));
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
+?>
+--EXPECTF--
+string(1) "a"
+bool(false)
+string(1) "b"
+bool(false)
+string(1) "c"
+bool(false)
+string(1) "a"
+bool(false)
+bool(true)
+string(1) "b"
+bool(false)
+bool(true)
+string(1) "c"
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/phar_setalias.phpt b/ext/phar/tests/zip/phar_setalias.phpt
new file mode 100644
index 0000000..1a39633
--- /dev/null
+++ b/ext/phar/tests/zip/phar_setalias.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Phar::setAlias() zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '3.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+
+$files = array();
+
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+
+// test compression
+
+$phar->compressFiles(Phar::GZ);
+copy($fname, $fname2);
+$phar->setAlias('unused');
+$p2 = new Phar($fname2);
+echo $p2->getAlias(), "\n";
+$p2->compressFiles(Phar::BZ2);
+copy($fname2, $fname3);
+$p2->setAlias('unused2');
+$p3 = new Phar($fname3);
+echo $p3->getAlias(), "\n";
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '3.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECT--
+hio
+test
+test
+test
+===DONE===
diff --git a/ext/phar/tests/zip/phar_setalias2.phpt b/ext/phar/tests/zip/phar_setalias2.phpt
new file mode 100644
index 0000000..c89f4c7
--- /dev/null
+++ b/ext/phar/tests/zip/phar_setalias2.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Phar::setAlias() error zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+
+$files = array();
+
+$files['a'] = 'a';
+$files['b'] = 'b';
+$files['c'] = 'c';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+echo $phar->getAlias() . "\n";
+$phar->setAlias('test');
+echo $phar->getAlias() . "\n";
+$b = $phar;
+$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
+try {
+ $phar->setAlias('test');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+hio
+test
+alias "test" is already used for archive "%sphar_setalias2.phar.zip" and cannot be used for other archives
+===DONE===
diff --git a/ext/phar/tests/zip/phar_setdefaultstub.phpt b/ext/phar/tests/zip/phar_setdefaultstub.phpt
new file mode 100644
index 0000000..e21d764
--- /dev/null
+++ b/ext/phar/tests/zip/phar_setdefaultstub.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Phar: Phar::setDefaultStub() with and without arg, zip-based phar
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<php echo "this is a\n"; ?>';
+$phar['b.php'] = '<php echo "this is b\n"; ?>';
+$phar->setStub('<?php echo "Hello World\n"; __HALT_COMPILER(); ?>');
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub();
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub('my/custom/thingy.php');
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+echo "============================================================================\n";
+echo "============================================================================\n";
+
+try {
+ $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php');
+ $phar->stopBuffering();
+} catch(Exception $e) {
+ echo $e->getMessage(). "\n";
+}
+
+var_dump($phar->getStub());
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+?>
+--EXPECTF--
+string(51) "<?php echo "Hello World\n"; __HALT_COMPILER(); ?>
+"
+============================================================================
+============================================================================
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+============================================================================
+============================================================================
+
+Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 1 given in %sphar_setdefaultstub.php on line %d
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+============================================================================
+============================================================================
+
+Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 2 given in %sphar_setdefaultstub.php on line %d
+string(60) "<?php // zip-based phar archive stub file
+__HALT_COMPILER();"
+===DONE===
diff --git a/ext/phar/tests/zip/phar_setsignaturealgo2.phpt b/ext/phar/tests/zip/phar_setsignaturealgo2.phpt
new file mode 100644
index 0000000..7d3730c
--- /dev/null
+++ b/ext/phar/tests/zip/phar_setsignaturealgo2.phpt
@@ -0,0 +1,115 @@
+--TEST--
+Phar::setSupportedSignatures() with hash, zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar.zip';
+$fname4 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.4.phar.zip';
+$fname5 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.5.phar.zip';
+$fname6 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.6.phar.zip';
+$p = new Phar($fname);
+$p['file1.txt'] = 'hi';
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::MD5);
+
+copy($fname, $fname2);
+$p = new Phar($fname2);
+var_dump($p->getSignature());
+
+$p->setSignatureAlgorithm(Phar::SHA1);
+
+copy($fname2, $fname3);
+$p = new Phar($fname3);
+var_dump($p->getSignature());
+
+try {
+$p->setSignatureAlgorithm(Phar::SHA256);
+copy($fname3, $fname4);
+$p = new Phar($fname4);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::SHA512);
+copy($fname4, $fname5);
+$p = new Phar($fname5);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$config = dirname(__FILE__) . '/../files/openssl.cnf';
+$config_arg = array('config' => $config);
+$keys=openssl_pkey_new($config_arg);
+openssl_pkey_export($keys, $privkey, NULL, $config_arg);
+$pubkey=openssl_pkey_get_details($keys);
+$p->setSignatureAlgorithm(Phar::OPENSSL, $privkey);
+
+copy($fname5, $fname6);
+file_put_contents($fname6 . '.pubkey', $pubkey['key']);
+$p = new Phar($fname6);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.4.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.5.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip.pubkey');
+?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-256"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-512"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/tests/zip/phar_stub.phpt b/ext/phar/tests/zip/phar_stub.phpt
new file mode 100644
index 0000000..72c1f17
--- /dev/null
+++ b/ext/phar/tests/zip/phar_stub.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Phar::setStub() (zip-based)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
+$pname = 'phar://' . $fname;
+$pname2 = 'phar://' . $fname2;
+
+$p = new Phar($pname2);
+$p->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$p['a'] = 'a';
+$p['b'] = 'b';
+$p['c'] = 'c';
+copy($fname2, $fname);
+
+$phar = new Phar($fname);
+echo $phar->getStub();
+
+$file = b'<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
+
+//// 2
+$phar->setStub($file);
+echo $phar->getStub();
+
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php';
+$file = b'<?php echo "third stub\n"; __HALT_COMPILER(); ?>';
+$fp = fopen($fname3, 'wb');
+fwrite($fp, $file);
+fclose($fp);
+$fp = fopen($fname3, 'rb');
+
+//// 3
+$phar->setStub($fp);
+fclose($fp);
+
+echo $phar->getStub();
+
+$fp = fopen($fname3, 'ab');
+fwrite($fp, b'booya');
+fclose($fp);
+echo file_get_contents($fname3) . "\n";
+
+$fp = fopen($fname3, 'rb');
+
+//// 4
+$phar->setStub($fp, strlen($file));
+fclose($fp);
+echo $phar->getStub();
+
+$phar['testing'] = 'hi';
+
+echo $phar->getStub();
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+__HALT_COMPILER();
+?>
+--EXPECT--
+<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+<?php echo "second stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>booya
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+<?php echo "third stub\n"; __HALT_COMPILER(); ?>
+===DONE===
diff --git a/ext/phar/tests/zip/phar_stub_error.phpt b/ext/phar/tests/zip/phar_stub_error.phpt
new file mode 100644
index 0000000..dafb312
--- /dev/null
+++ b/ext/phar/tests/zip/phar_stub_error.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Phar::setStub()/getStub() zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' . "\r\n");
+$phar->setAlias('hio');
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
+try
+{
+ $phar->setStub($newstub);
+}
+catch(exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+$phar->stopBuffering();
+var_dump($phar->getStub());
+var_dump($phar->getStub() == $stub);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+__HALT_COMPILER();
+?>
+--EXPECTF--
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+bool(true)
+===DONE===
diff --git a/ext/phar/tests/zip/refcount1.phpt b/ext/phar/tests/zip/refcount1.phpt
new file mode 100644
index 0000000..618e7fe
--- /dev/null
+++ b/ext/phar/tests/zip/refcount1.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
+
+$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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, b"extra");
+fclose($fp);
+echo "===CLOSE===\n";
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($alias . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.zip/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%d) "c.php"
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.zip", has open file pointers, cannot unlink in %srefcount1.php on line %d
+object(PharFileInfo)#%d (2) {
+ [%spathName":%sSplFileInfo":private]=>
+ string(%d) "phar://%srefcount1.phar.zip/b/c.php"
+ [%sfileName":%sSplFileInfo":private]=>
+ string(%s) "c.php"
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/zip/refcount1_5_2.phpt b/ext/phar/tests/zip/refcount1_5_2.phpt
new file mode 100644
index 0000000..f3b2771
--- /dev/null
+++ b/ext/phar/tests/zip/refcount1_5_2.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Phar: test that refcounting avoids problems with deleting a file zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
+
+$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"; ?>';
+
+foreach ($files as $n => $file) {
+ $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, "extra");
+fclose($fp);
+
+echo "===CLOSE===\n";
+
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
+var_dump($a);
+var_dump(fread($b, 20));
+rewind($b);
+echo "===UNLINK===\n";
+unlink($alias . '/b/c.php');
+var_dump($a);
+var_dump(fread($b, 20));
+include $alias . '/b/c.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+===CLOSE===
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+===UNLINK===
+
+Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1_5_2.phar.zip", has open file pointers, cannot unlink in %sefcount1_5_2.php on line %d
+object(PharFileInfo)#%d (0) {
+}
+string(5) "extra"
+extra
+===DONE===
diff --git a/ext/phar/tests/zip/rename.phpt b/ext/phar/tests/zip/rename.phpt
new file mode 100644
index 0000000..9b1f5c9
--- /dev/null
+++ b/ext/phar/tests/zip/rename.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: rename test zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
+include $fname;
+
+echo file_get_contents($alias . '/a') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename.phar.zip/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/zip/rename_dir.phpt b/ext/phar/tests/zip/rename_dir.phpt
new file mode 100644
index 0000000..bb03c7f
--- /dev/null
+++ b/ext/phar/tests/zip/rename_dir.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: rename_dir test zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+$phar['a/x'] = 'a';
+$phar->stopBuffering();
+
+include $fname;
+
+echo file_get_contents($alias . '/a/x') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b/x') . "\n";
+echo file_get_contents($alias . '/a/x') . "\n";
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+a
+a
+
+Warning: file_get_contents(phar://%srename_dir.phar.zip/a/x): failed to open stream: phar error: "a/x" is not a file in phar "%srename_dir.phar.zip" in %srename_dir.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/zip/rmdir.phpt b/ext/phar/tests/zip/rmdir.phpt
new file mode 100644
index 0000000..c7ef9da
--- /dev/null
+++ b/ext/phar/tests/zip/rmdir.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Phar: rmdir test zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php
+Phar::mapPhar('hio');
+__HALT_COMPILER(); ?>");
+$phar->addEmptyDir('a');
+$phar['a/x'] = 'a';
+$phar->stopBuffering();
+
+include $fname;
+
+echo file_get_contents($alias . '/a/x') . "\n";
+var_dump(rmdir($alias . '/a'));
+echo file_get_contents($alias . '/a/x') . "\n";
+unlink($alias . '/a/x');
+var_dump(rmdir($alias . '/a'));
+?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+a
+
+Warning: rmdir(): phar error: Directory not empty in %srmdir.php on line %d
+bool(false)
+a
+bool(true)
diff --git a/ext/phar/tests/zip/unixzip.phpt b/ext/phar/tests/zip/unixzip.phpt
new file mode 100644
index 0000000..e2b95be
--- /dev/null
+++ b/ext/phar/tests/zip/unixzip.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: test a zip archive created by unix "zip" command
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+$a = new PharData(dirname(__FILE__) . '/files/zip.zip');
+foreach ($a as $b) {
+ if ($b->isDir()) {
+ echo "dir " . $b->getPathName() . "\n";
+ } else {
+ echo $b->getPathName(), "\n";
+ echo file_get_contents($b->getPathName()), "\n";
+ }
+}
+if (isset($a['notempty/hi.txt'])) {
+ echo $a['notempty/hi.txt']->getPathName() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+dir phar://%s/zip.zip%cempty
+phar://%s/zip.zip%chi.txt
+hi there
+
+dir phar://%s/zip.zip%cnotempty
+phar://%s/zip.zip/notempty%chi.txt
+===DONE===
diff --git a/ext/phar/tests/zip/zlib.phpt b/ext/phar/tests/zip/zlib.phpt
new file mode 100644
index 0000000..c7494e2
--- /dev/null
+++ b/ext/phar/tests/zip/zlib.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Phar: process zlib-compressed zip alias
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--FILE--
+<?php
+try {
+ $a = new Phar(dirname(__FILE__) . '/files/zlib_alias.phar.zip');
+ var_dump($a->getAlias());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECT--
+string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
+===DONE===
diff --git a/ext/phar/util.c b/ext/phar/util.c
new file mode 100644
index 0000000..05c90cd
--- /dev/null
+++ b/ext/phar/util.c
@@ -0,0 +1,2385 @@
+/*
+ +----------------------------------------------------------------------+
+ | phar php single-file executable PHP extension |
+ | utility functions |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2005-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ | Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "phar_internal.h"
+#ifdef PHAR_HASH_OK
+#include "ext/hash/php_hash_sha.h"
+#endif
+
+#ifdef PHAR_HAVE_OPENSSL
+/* OpenSSL includes */
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include <openssl/crypto.h>
+#include <openssl/pem.h>
+#include <openssl/err.h>
+#include <openssl/conf.h>
+#include <openssl/rand.h>
+#include <openssl/ssl.h>
+#include <openssl/pkcs12.h>
+#else
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
+#endif
+
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
+extern php_stream_wrapper php_stream_phar_wrapper;
+#endif
+
+/* for links to relative location, prepend cwd of the entry */
+static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+{
+ char *p, *ret = NULL;
+ if (!entry->link) {
+ return NULL;
+ }
+ if (entry->link[0] == '/') {
+ return estrdup(entry->link + 1);
+ }
+ p = strrchr(entry->filename, '/');
+ if (p) {
+ *p = '\0';
+ spprintf(&ret, 0, "%s/%s", entry->filename, entry->link);
+ return ret;
+ }
+ return entry->link;
+}
+/* }}} */
+
+phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *link_entry;
+ char *link;
+
+ if (!entry->link) {
+ return entry;
+ }
+
+ link = phar_get_link_location(entry TSRMLS_CC);
+ if (SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->link, strlen(entry->link), (void **)&link_entry) ||
+ SUCCESS == zend_hash_find(&(entry->phar->manifest), link, strlen(link), (void **)&link_entry)) {
+ if (link != entry->link) {
+ efree(link);
+ }
+ return phar_get_link_source(link_entry TSRMLS_CC);
+ } else {
+ if (link != entry->link) {
+ efree(link);
+ }
+ return NULL;
+ }
+}
+/* }}} */
+
+/* retrieve a phar_entry_info's current file pointer for reading contents */
+php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /* {{{ */
+{
+ if (follow_links && entry->link) {
+ phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC);
+
+ if (link_entry && link_entry != entry) {
+ return phar_get_efp(link_entry, 1 TSRMLS_CC);
+ }
+ }
+
+ if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_FP) {
+ if (!phar_get_entrypfp(entry TSRMLS_CC)) {
+ /* re-open just in time for cases where our refcount reached 0 on the phar archive */
+ phar_open_archive_fp(entry->phar TSRMLS_CC);
+ }
+ return phar_get_entrypfp(entry TSRMLS_CC);
+ } else if (phar_get_fp_type(entry TSRMLS_CC) == PHAR_UFP) {
+ return phar_get_entrypufp(entry TSRMLS_CC);
+ } else if (entry->fp_type == PHAR_MOD) {
+ return entry->fp;
+ } else {
+ /* temporary manifest entry */
+ if (!entry->fp) {
+ entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL);
+ }
+ return entry->fp;
+ }
+}
+/* }}} */
+
+int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC) /* {{{ */
+{
+ php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC);
+ off_t temp, eoffset;
+
+ if (!fp) {
+ return -1;
+ }
+
+ if (follow_links) {
+ phar_entry_info *t;
+ t = phar_get_link_source(entry TSRMLS_CC);
+ if (t) {
+ entry = t;
+ }
+ }
+
+ if (entry->is_dir) {
+ return 0;
+ }
+
+ eoffset = phar_get_fp_offset(entry TSRMLS_CC);
+
+ switch (whence) {
+ case SEEK_END:
+ temp = eoffset + entry->uncompressed_filesize + offset;
+ break;
+ case SEEK_CUR:
+ temp = eoffset + position + offset;
+ break;
+ case SEEK_SET:
+ temp = eoffset + offset;
+ break;
+ default:
+ temp = 0;
+ }
+
+ if (temp > eoffset + (off_t) entry->uncompressed_filesize) {
+ return -1;
+ }
+
+ if (temp < eoffset) {
+ return -1;
+ }
+
+ return php_stream_seek(fp, temp, SEEK_SET);
+}
+/* }}} */
+
+/* mount an absolute path or uri to a path internal to the phar archive */
+int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info entry = {0};
+ php_stream_statbuf ssb;
+ int is_phar;
+ const char *err;
+
+ if (phar_path_check(&path, &path_len, &err) > pcr_is_ok) {
+ return FAILURE;
+ }
+
+ if (path_len >= sizeof(".phar")-1 && !memcmp(path, ".phar", sizeof(".phar")-1)) {
+ /* no creating magic phar files by mounting them */
+ return FAILURE;
+ }
+
+ is_phar = (filename_len > 7 && !memcmp(filename, "phar://", 7));
+
+ entry.phar = phar;
+ entry.filename = estrndup(path, path_len);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(entry.filename, path_len);
+#endif
+ entry.filename_len = path_len;
+ if (is_phar) {
+ entry.tmp = estrndup(filename, filename_len);
+ } else {
+ entry.tmp = expand_filepath(filename, NULL TSRMLS_CC);
+ if (!entry.tmp) {
+ entry.tmp = estrndup(filename, filename_len);
+ }
+ }
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && !is_phar && (!php_checkuid(entry.tmp, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+ efree(entry.tmp);
+ efree(entry.filename);
+ return FAILURE;
+ }
+#endif
+ filename = entry.tmp;
+
+ /* only check openbasedir for files, not for phar streams */
+ if (!is_phar && php_check_open_basedir(filename TSRMLS_CC)) {
+ efree(entry.tmp);
+ efree(entry.filename);
+ return FAILURE;
+ }
+
+ entry.is_mounted = 1;
+ entry.is_crc_checked = 1;
+ entry.fp_type = PHAR_TMP;
+
+ if (SUCCESS != php_stream_stat_path(filename, &ssb)) {
+ efree(entry.tmp);
+ efree(entry.filename);
+ return FAILURE;
+ }
+
+ if (ssb.sb.st_mode & S_IFDIR) {
+ entry.is_dir = 1;
+ if (SUCCESS != zend_hash_add(&phar->mounted_dirs, entry.filename, path_len, (void *)&(entry.filename), sizeof(char *), NULL)) {
+ /* directory already mounted */
+ efree(entry.tmp);
+ efree(entry.filename);
+ return FAILURE;
+ }
+ } else {
+ entry.is_dir = 0;
+ entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size;
+ }
+
+ entry.flags = ssb.sb.st_mode;
+
+ if (SUCCESS == zend_hash_add(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ return SUCCESS;
+ }
+
+ efree(entry.tmp);
+ efree(entry.filename);
+ return FAILURE;
+}
+/* }}} */
+
+char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+{
+#if PHP_VERSION_ID >= 50300
+ char *path, *fname, *arch, *entry, *ret, *test;
+ int arch_len, entry_len, fname_len, ret_len;
+ phar_archive_data *phar;
+
+ if (pphar) {
+ *pphar = NULL;
+ } else {
+ pphar = &phar;
+ }
+
+ if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) {
+ return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ }
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ fname_len = strlen(fname);
+
+ if (PHAR_G(last_phar) && !memcmp(fname, "phar://", 7) && fname_len - 7 >= PHAR_G(last_phar_name_len) && !memcmp(fname + 7, PHAR_G(last_phar_name), PHAR_G(last_phar_name_len))) {
+ arch = estrndup(PHAR_G(last_phar_name), PHAR_G(last_phar_name_len));
+ arch_len = PHAR_G(last_phar_name_len);
+ phar = PHAR_G(last_phar);
+ goto splitted;
+ }
+
+ if (fname_len < 7 || memcmp(fname, "phar://", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ }
+
+ efree(entry);
+
+ if (*filename == '.') {
+ int try_len;
+
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ return phar_save_resolve_path(filename, filename_len TSRMLS_CC);
+ }
+splitted:
+ if (pphar) {
+ *pphar = phar;
+ }
+
+ try_len = filename_len;
+ test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC);
+
+ if (*test == '/') {
+ if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) {
+ spprintf(&ret, 0, "phar://%s%s", arch, test);
+ efree(arch);
+ efree(test);
+ return ret;
+ }
+ } else {
+ if (zend_hash_exists(&(phar->manifest), test, try_len)) {
+ spprintf(&ret, 0, "phar://%s/%s", arch, test);
+ efree(arch);
+ efree(test);
+ return ret;
+ }
+ }
+ efree(test);
+ }
+
+ spprintf(&path, MAXPATHLEN, "phar://%s/%s%c%s", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path));
+ efree(arch);
+ ret = php_resolve_path(filename, filename_len, path TSRMLS_CC);
+ efree(path);
+
+ if (ret && strlen(ret) > 8 && !strncmp(ret, "phar://", 7)) {
+ ret_len = strlen(ret);
+ /* found phar:// */
+
+ if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ return ret;
+ }
+
+ zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
+
+ if (!pphar && PHAR_G(manifest_cached)) {
+ zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
+ }
+
+ efree(arch);
+ efree(entry);
+ }
+
+ return ret;
+#else /* PHP 5.2 */
+ char resolved_path[MAXPATHLEN];
+ char trypath[MAXPATHLEN];
+ char *ptr, *end, *path = PG(include_path);
+ php_stream_wrapper *wrapper;
+ const char *p;
+ int n = 0;
+ char *fname, *arch, *entry, *ret, *test;
+ int arch_len, entry_len;
+ phar_archive_data *phar = NULL;
+
+ if (!filename) {
+ return NULL;
+ }
+
+ if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) {
+ goto doit;
+ }
+
+ fname = (char*)zend_get_executed_filename(TSRMLS_C);
+
+ if (SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ goto doit;
+ }
+
+ efree(entry);
+
+ if (*filename == '.') {
+ int try_len;
+
+ if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
+ efree(arch);
+ goto doit;
+ }
+
+ try_len = filename_len;
+ test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC);
+
+ if (*test == '/') {
+ if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) {
+ spprintf(&ret, 0, "phar://%s%s", arch, test);
+ efree(arch);
+ efree(test);
+ return ret;
+ }
+ } else {
+ if (zend_hash_exists(&(phar->manifest), test, try_len)) {
+ spprintf(&ret, 0, "phar://%s/%s", arch, test);
+ efree(arch);
+ efree(test);
+ return ret;
+ }
+ }
+
+ efree(test);
+ }
+
+ efree(arch);
+doit:
+ if (*filename == '.' || IS_ABSOLUTE_PATH(filename, filename_len) || !path || !*path) {
+ if (tsrm_realpath(filename, resolved_path TSRMLS_CC)) {
+ return estrdup(resolved_path);
+ } else {
+ return NULL;
+ }
+ }
+
+ /* test for stream wrappers and return */
+ for (p = filename; p - filename < filename_len && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n);
+
+ if (n < filename_len - 3 && (*p == ':') && (!strncmp("//", p+1, 2) || ( filename_len > 4 && !memcmp("data", filename, 4)))) {
+ /* found stream wrapper, this is an absolute path until stream wrappers implement realpath */
+ return estrndup(filename, filename_len);
+ }
+
+ ptr = (char *) path;
+ while (ptr && *ptr) {
+ int len, is_stream_wrapper = 0, maybe_stream = 1;
+
+ end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
+#ifndef PHP_WIN32
+ /* search for stream wrapper */
+ if (end - ptr <= 1) {
+ maybe_stream = 0;
+ goto not_stream;
+ }
+
+ for (p = ptr, n = 0; p < end && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n);
+
+ if (n == end - ptr && *p && !strncmp("//", p+1, 2)) {
+ is_stream_wrapper = 1;
+ /* seek to real end of include_path portion */
+ end = strchr(end + 1, DEFAULT_DIR_SEPARATOR);
+ } else {
+ maybe_stream = 0;
+ }
+not_stream:
+#endif
+ if (end) {
+ if ((end-ptr) + 1 + filename_len + 1 >= MAXPATHLEN) {
+ ptr = end + 1;
+ continue;
+ }
+
+ memcpy(trypath, ptr, end-ptr);
+ len = end-ptr;
+ trypath[end-ptr] = '/';
+ memcpy(trypath+(end-ptr)+1, filename, filename_len+1);
+ ptr = end+1;
+ } else {
+ len = strlen(ptr);
+
+ if (len + 1 + filename_len + 1 >= MAXPATHLEN) {
+ break;
+ }
+
+ memcpy(trypath, ptr, len);
+ trypath[len] = '/';
+ memcpy(trypath+len+1, filename, filename_len+1);
+ ptr = NULL;
+ }
+
+ if (!is_stream_wrapper && maybe_stream) {
+ /* search for stream wrapper */
+ for (p = trypath, n = 0; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n);
+ }
+
+ if (is_stream_wrapper || (n < len - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4)))) {
+ char *actual;
+
+ wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
+ if (wrapper == &php_plain_files_wrapper) {
+ strlcpy(trypath, actual, sizeof(trypath));
+ } else if (!wrapper) {
+ /* if wrapper is NULL, there was a mal-formed include_path stream wrapper, so skip this ptr */
+ continue;
+ } else {
+ if (wrapper->wops->url_stat) {
+ php_stream_statbuf ssb;
+
+ if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, 0, &ssb, NULL TSRMLS_CC)) {
+ if (wrapper == &php_stream_phar_wrapper) {
+ char *arch, *entry;
+ int arch_len, entry_len, ret_len;
+
+ ret_len = strlen(trypath);
+ /* found phar:// */
+
+ if (SUCCESS != phar_split_fname(trypath, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
+ return estrndup(trypath, ret_len);
+ }
+
+ zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
+
+ if (!pphar && PHAR_G(manifest_cached)) {
+ zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
+ }
+
+ efree(arch);
+ efree(entry);
+
+ return estrndup(trypath, ret_len);
+ }
+ return estrdup(trypath);
+ }
+ }
+ continue;
+ }
+ }
+
+ if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) {
+ return estrdup(resolved_path);
+ }
+ } /* end provided path */
+
+ /* check in calling scripts' current working directory as a fall back case */
+ if (zend_is_executing(TSRMLS_C)) {
+ char *exec_fname = (char*)zend_get_executed_filename(TSRMLS_C);
+ int exec_fname_length = strlen(exec_fname);
+ const char *p;
+ int n = 0;
+
+ while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length]));
+ if (exec_fname && exec_fname[0] != '[' &&
+ exec_fname_length > 0 &&
+ exec_fname_length + 1 + filename_len + 1 < MAXPATHLEN) {
+ memcpy(trypath, exec_fname, exec_fname_length + 1);
+ memcpy(trypath+exec_fname_length + 1, filename, filename_len+1);
+
+ /* search for stream wrapper */
+ for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n);
+
+ if (n < exec_fname_length - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4))) {
+ char *actual;
+
+ wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
+
+ if (wrapper == &php_plain_files_wrapper) {
+ /* this should never technically happen, but we'll leave it here for completeness */
+ strlcpy(trypath, actual, sizeof(trypath));
+ } else if (!wrapper) {
+ /* if wrapper is NULL, there was a malformed include_path stream wrapper
+ this also should be impossible */
+ return NULL;
+ } else {
+ return estrdup(trypath);
+ }
+ }
+
+ if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) {
+ return estrdup(resolved_path);
+ }
+ }
+ }
+
+ return NULL;
+#endif /* PHP 5.2 */
+}
+/* }}} */
+
+/**
+ * Retrieve a copy of the file information on a single file within a phar, or null.
+ * This also transfers the open file pointer, if any, to the entry.
+ *
+ * If the file does not already exist, this will fail. Pre-existing files can be
+ * appended, truncated, or read. For read, if the entry is marked unmodified, it is
+ * assumed that the file pointer, if present, is opened for reading
+ */
+int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ phar_entry_info *entry;
+ int for_write = mode[0] != 'r' || mode[1] == '+';
+ int for_append = mode[0] == 'a';
+ int for_create = mode[0] != 'r';
+ int for_trunc = mode[0] == 'w';
+
+ if (!ret) {
+ return FAILURE;
+ }
+
+ *ret = NULL;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ if (for_write && PHAR_G(readonly) && !phar->is_data) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, disabled by ini setting", path, fname);
+ }
+ return FAILURE;
+ }
+
+ if (!path_len) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"\" in phar \"%s\" cannot be empty", fname);
+ }
+ return FAILURE;
+ }
+really_get_entry:
+ if (allow_dir) {
+ if ((entry = phar_get_entry_info_dir(phar, path, path_len, allow_dir, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security TSRMLS_CC)) == NULL) {
+ if (for_create && (!PHAR_G(readonly) || phar->is_data)) {
+ return SUCCESS;
+ }
+ return FAILURE;
+ }
+ } else {
+ if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error, security TSRMLS_CC)) == NULL) {
+ if (for_create && (!PHAR_G(readonly) || phar->is_data)) {
+ return SUCCESS;
+ }
+ return FAILURE;
+ }
+ }
+
+ if (for_write && phar->is_persistent) {
+ if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, could not make cached phar writeable", path, fname);
+ }
+ return FAILURE;
+ } else {
+ goto really_get_entry;
+ }
+ }
+
+ if (entry->is_modified && !for_write) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for reading, writable file pointers are open", path, fname);
+ }
+ return FAILURE;
+ }
+
+ if (entry->fp_refcount && for_write) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, readable file pointers are open", path, fname);
+ }
+ return FAILURE;
+ }
+
+ if (entry->is_deleted) {
+ if (!for_create) {
+ return FAILURE;
+ }
+ entry->is_deleted = 0;
+ }
+
+ if (entry->is_dir) {
+ *ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
+ (*ret)->position = 0;
+ (*ret)->fp = NULL;
+ (*ret)->phar = phar;
+ (*ret)->for_write = for_write;
+ (*ret)->internal_file = entry;
+ (*ret)->is_zip = entry->is_zip;
+ (*ret)->is_tar = entry->is_tar;
+
+ if (!phar->is_persistent) {
+ ++(entry->phar->refcount);
+ ++(entry->fp_refcount);
+ }
+
+ return SUCCESS;
+ }
+
+ if (entry->fp_type == PHAR_MOD) {
+ if (for_trunc) {
+ if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) {
+ return FAILURE;
+ }
+ } else if (for_append) {
+ phar_seek_efp(entry, 0, SEEK_END, 0, 0 TSRMLS_CC);
+ }
+ } else {
+ if (for_write) {
+ if (entry->link) {
+ efree(entry->link);
+ entry->link = NULL;
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
+ }
+
+ if (for_trunc) {
+ if (FAILURE == phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) {
+ return FAILURE;
+ }
+ } else {
+ if (FAILURE == phar_separate_entry_fp(entry, error TSRMLS_CC)) {
+ return FAILURE;
+ }
+ }
+ } else {
+ if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+ }
+ }
+
+ *ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
+ (*ret)->position = 0;
+ (*ret)->phar = phar;
+ (*ret)->for_write = for_write;
+ (*ret)->internal_file = entry;
+ (*ret)->is_zip = entry->is_zip;
+ (*ret)->is_tar = entry->is_tar;
+ (*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC);
+ if (entry->link) {
+ (*ret)->zero = phar_get_fp_offset(phar_get_link_source(entry TSRMLS_CC) TSRMLS_CC);
+ } else {
+ (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC);
+ }
+
+ if (!phar->is_persistent) {
+ ++(entry->fp_refcount);
+ ++(entry->phar->refcount);
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * Create a new dummy file slot within a writeable phar for a newly created file
+ */
+phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ phar_entry_info *entry, etemp;
+ phar_entry_data *ret;
+ const char *pcr_error;
+ char is_dir;
+
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(path, path_len);
+#endif
+
+ is_dir = (path_len && path[path_len - 1] == '/') ? 1 : 0;
+
+ if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
+ return NULL;
+ }
+
+ if (FAILURE == phar_get_entry_data(&ret, fname, fname_len, path, path_len, mode, allow_dir, error, security TSRMLS_CC)) {
+ return NULL;
+ } else if (ret) {
+ return ret;
+ }
+
+ if (phar_path_check(&path, &path_len, &pcr_error) > pcr_is_ok) {
+ if (error) {
+ spprintf(error, 0, "phar error: invalid path \"%s\" contains %s", path, pcr_error);
+ }
+ return NULL;
+ }
+
+ if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be created, could not make cached phar writeable", path, fname);
+ }
+ return NULL;
+ }
+
+ /* create a new phar data holder */
+ ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
+
+ /* create an entry, this is a new file */
+ memset(&etemp, 0, sizeof(phar_entry_info));
+ etemp.filename_len = path_len;
+ etemp.fp_type = PHAR_MOD;
+ etemp.fp = php_stream_fopen_tmpfile();
+
+ if (!etemp.fp) {
+ if (error) {
+ spprintf(error, 0, "phar error: unable to create temporary file");
+ }
+ efree(ret);
+ return NULL;
+ }
+
+ etemp.fp_refcount = 1;
+
+ if (allow_dir == 2) {
+ etemp.is_dir = 1;
+ etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_DIR;
+ } else {
+ etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_FILE;
+ }
+ if (is_dir) {
+ etemp.filename_len--; /* strip trailing / */
+ path_len--;
+ }
+
+ phar_add_virtual_dirs(phar, path, path_len TSRMLS_CC);
+ etemp.is_modified = 1;
+ etemp.timestamp = time(0);
+ etemp.is_crc_checked = 1;
+ etemp.phar = phar;
+ etemp.filename = estrndup(path, path_len);
+ etemp.is_zip = phar->is_zip;
+
+ if (phar->is_tar) {
+ etemp.is_tar = phar->is_tar;
+ etemp.tar_type = etemp.is_dir ? TAR_DIR : TAR_FILE;
+ }
+
+ if (FAILURE == zend_hash_add(&phar->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), (void **) &entry)) {
+ php_stream_close(etemp.fp);
+ if (error) {
+ spprintf(error, 0, "phar error: unable to add new entry \"%s\" to phar \"%s\"", etemp.filename, phar->fname);
+ }
+ efree(ret);
+ efree(etemp.filename);
+ return NULL;
+ }
+
+ if (!entry) {
+ php_stream_close(etemp.fp);
+ efree(etemp.filename);
+ efree(ret);
+ return NULL;
+ }
+
+ ++(phar->refcount);
+ ret->phar = phar;
+ ret->fp = entry->fp;
+ ret->position = ret->zero = 0;
+ ret->for_write = 1;
+ ret->is_zip = entry->is_zip;
+ ret->is_tar = entry->is_tar;
+ ret->internal_file = entry;
+
+ return ret;
+}
+/* }}} */
+
+/* initialize a phar_archive_data's read-only fp for existing phar data */
+int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+{
+ if (phar_get_pharfp(phar TSRMLS_CC)) {
+ return SUCCESS;
+ }
+#if PHP_API_VERSION < 20100412
+ if (PG(safe_mode) && (!php_checkuid(phar->fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
+ return FAILURE;
+ }
+#endif
+
+ if (php_check_open_basedir(phar->fname TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ phar_set_pharfp(phar, php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, NULL) TSRMLS_CC);
+
+ if (!phar_get_pharfp(phar TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* copy file data from an existing to a new phar_entry_info that is not in the manifest */
+int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *link;
+
+ if (FAILURE == phar_open_entry_fp(source, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ if (dest->link) {
+ efree(dest->link);
+ dest->link = NULL;
+ dest->tar_type = (dest->is_tar ? TAR_FILE : '\0');
+ }
+
+ dest->fp_type = PHAR_MOD;
+ dest->offset = 0;
+ dest->is_modified = 1;
+ dest->fp = php_stream_fopen_tmpfile();
+ phar_seek_efp(source, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+ link = phar_get_link_source(source TSRMLS_CC);
+
+ if (!link) {
+ link = source;
+ }
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) {
+ php_stream_close(dest->fp);
+ dest->fp_type = PHAR_FP;
+ if (error) {
+ spprintf(error, 4096, "phar error: unable to copy contents of file \"%s\" to \"%s\" in phar archive \"%s\"", source->filename, dest->filename, source->phar->fname);
+ }
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* open and decompress a compressed phar entry
+ */
+int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC) /* {{{ */
+{
+ php_stream_filter *filter;
+ phar_archive_data *phar = entry->phar;
+ char *filtername;
+ off_t loc;
+ php_stream *ufp;
+ phar_entry_data dummy;
+
+ if (follow_links && entry->link) {
+ phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC);
+ if (link_entry && link_entry != entry) {
+ return phar_open_entry_fp(link_entry, error, 1 TSRMLS_CC);
+ }
+ }
+
+ if (entry->is_modified) {
+ return SUCCESS;
+ }
+
+ if (entry->fp_type == PHAR_TMP) {
+ if (!entry->fp) {
+ entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL);
+ }
+ return SUCCESS;
+ }
+
+ if (entry->fp_type != PHAR_FP) {
+ /* either newly created or already modified */
+ return SUCCESS;
+ }
+
+ if (!phar_get_pharfp(phar TSRMLS_CC)) {
+ if (FAILURE == phar_open_archive_fp(phar TSRMLS_CC)) {
+ spprintf(error, 4096, "phar error: Cannot open phar archive \"%s\" for reading", phar->fname);
+ return FAILURE;
+ }
+ }
+
+ if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ dummy.internal_file = entry;
+ dummy.phar = phar;
+ dummy.zero = entry->offset;
+ dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+ return SUCCESS;
+ }
+
+ if (!phar_get_entrypufp(entry TSRMLS_CC)) {
+ phar_set_entrypufp(entry, php_stream_fopen_tmpfile() TSRMLS_CC);
+ if (!phar_get_entrypufp(entry TSRMLS_CC)) {
+ spprintf(error, 4096, "phar error: Cannot open temporary file for decompressing phar archive \"%s\" file \"%s\"", phar->fname, entry->filename);
+ return FAILURE;
+ }
+ }
+
+ dummy.internal_file = entry;
+ dummy.phar = phar;
+ dummy.zero = entry->offset;
+ dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ ufp = phar_get_entrypufp(entry TSRMLS_CC);
+
+ if ((filtername = phar_decompress_filter(entry, 0)) != NULL) {
+ filter = php_stream_filter_create(filtername, NULL, 0 TSRMLS_CC);
+ } else {
+ filter = NULL;
+ }
+
+ if (!filter) {
+ spprintf(error, 4096, "phar error: unable to read phar \"%s\" (cannot create %s filter while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), entry->filename);
+ return FAILURE;
+ }
+
+ /* now we can safely use proper decompression */
+ /* save the new offset location within ufp */
+ php_stream_seek(ufp, 0, SEEK_END);
+ loc = php_stream_tell(ufp);
+ php_stream_filter_append(&ufp->writefilters, filter);
+ php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
+
+ if (entry->uncompressed_filesize) {
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
+ spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ return FAILURE;
+ }
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_flush(ufp);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+
+ if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) {
+ spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
+ return FAILURE;
+ }
+
+ entry->old_flags = entry->flags;
+
+ /* this is now the new location of the file contents within this fp */
+ phar_set_fp_type(entry, PHAR_UFP, loc TSRMLS_CC);
+ dummy.zero = entry->offset;
+ dummy.fp = ufp;
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0 TSRMLS_CC)) {
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+/* }}} */
+
+#if defined(PHP_VERSION_ID) && PHP_VERSION_ID < 50202
+typedef struct {
+ char *data;
+ size_t fpos;
+ size_t fsize;
+ size_t smax;
+ int mode;
+ php_stream **owner_ptr;
+} php_stream_memory_data;
+#endif
+
+int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+{
+ if (entry->fp_type == PHAR_MOD) {
+ /* already newly created, truncate */
+#if PHP_VERSION_ID >= 50202
+ php_stream_truncate_set_size(entry->fp, 0);
+#else
+ if (php_stream_is(entry->fp, PHP_STREAM_IS_TEMP)) {
+ if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_MEMORY)) {
+ php_stream *inner = *(php_stream**)entry->fp->abstract;
+ php_stream_memory_data *memfp = (php_stream_memory_data*)inner->abstract;
+ memfp->fpos = 0;
+ memfp->fsize = 0;
+ } else if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_STDIO)) {
+ php_stream_truncate_set_size(*(php_stream**)entry->fp->abstract, 0);
+ } else {
+ if (error) {
+ spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname);
+ }
+ return FAILURE;
+ }
+ } else if (php_stream_is(entry->fp, PHP_STREAM_IS_STDIO)) {
+ php_stream_truncate_set_size(entry->fp, 0);
+ } else {
+ if (error) {
+ spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname);
+ }
+ return FAILURE;
+ }
+#endif
+ entry->old_flags = entry->flags;
+ entry->is_modified = 1;
+ phar->is_modified = 1;
+ /* reset file size */
+ entry->uncompressed_filesize = 0;
+ entry->compressed_filesize = 0;
+ entry->crc32 = 0;
+ entry->flags = PHAR_ENT_PERM_DEF_FILE;
+ entry->fp_type = PHAR_MOD;
+ entry->offset = 0;
+ return SUCCESS;
+ }
+
+ if (error) {
+ *error = NULL;
+ }
+
+ /* open a new temp file for writing */
+ if (entry->link) {
+ efree(entry->link);
+ entry->link = NULL;
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
+ }
+
+ entry->fp = php_stream_fopen_tmpfile();
+
+ if (!entry->fp) {
+ if (error) {
+ spprintf(error, 0, "phar error: unable to create temporary file");
+ }
+ return FAILURE;
+ }
+
+ entry->old_flags = entry->flags;
+ entry->is_modified = 1;
+ phar->is_modified = 1;
+ /* reset file size */
+ entry->uncompressed_filesize = 0;
+ entry->compressed_filesize = 0;
+ entry->crc32 = 0;
+ entry->flags = PHAR_ENT_PERM_DEF_FILE;
+ entry->fp_type = PHAR_MOD;
+ entry->offset = 0;
+ return SUCCESS;
+}
+/* }}} */
+
+int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+{
+ php_stream *fp;
+ phar_entry_info *link;
+
+ if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ if (entry->fp_type == PHAR_MOD) {
+ return SUCCESS;
+ }
+
+ fp = php_stream_fopen_tmpfile();
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC);
+ link = phar_get_link_source(entry TSRMLS_CC);
+
+ if (!link) {
+ link = entry;
+ }
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: cannot separate entry file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fname);
+ }
+ return FAILURE;
+ }
+
+ if (entry->link) {
+ efree(entry->link);
+ entry->link = NULL;
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
+ }
+
+ entry->offset = 0;
+ entry->fp = fp;
+ entry->fp_type = PHAR_MOD;
+ entry->is_modified = 1;
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * helper function to open an internal file's fp just-in-time
+ */
+phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
+{
+ if (error) {
+ *error = NULL;
+ }
+ /* seek to start of internal file and read it */
+ if (FAILURE == phar_open_entry_fp(entry, error, 1 TSRMLS_CC)) {
+ return NULL;
+ }
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1 TSRMLS_CC)) {
+ spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", entry->filename, phar->fname);
+ return NULL;
+ }
+ return entry;
+}
+/* }}} */
+
+int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_DC) /* {{{ */
+{
+ if (phar->refcount || phar->is_persistent) {
+ return FAILURE;
+ }
+
+ /* this archive has no open references, so emit an E_STRICT and remove it */
+ if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
+ return FAILURE;
+ }
+
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * Looks up a phar archive in the filename map, connecting it to the alias
+ * (if any) or returns null
+ */
+int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *fd, **fd_ptr;
+ char *my_realpath, *save;
+ int save_len;
+ ulong fhash, ahash = 0;
+
+ phar_request_initialize(TSRMLS_C);
+
+ if (error) {
+ *error = NULL;
+ }
+
+ *archive = NULL;
+
+ if (PHAR_G(last_phar) && fname_len == PHAR_G(last_phar_name_len) && !memcmp(fname, PHAR_G(last_phar_name), fname_len)) {
+ *archive = PHAR_G(last_phar);
+ if (alias && alias_len) {
+
+ if (!PHAR_G(last_phar)->is_temporary_alias && (alias_len != PHAR_G(last_phar)->alias_len || memcmp(PHAR_G(last_phar)->alias, alias, alias_len))) {
+ if (error) {
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, PHAR_G(last_phar)->fname, fname);
+ }
+ *archive = NULL;
+ return FAILURE;
+ }
+
+ if (PHAR_G(last_phar)->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len, (void**)&fd_ptr)) {
+ zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), PHAR_G(last_phar)->alias, PHAR_G(last_phar)->alias_len);
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&(*archive), sizeof(phar_archive_data*), NULL);
+ PHAR_G(last_alias) = alias;
+ PHAR_G(last_alias_len) = alias_len;
+ }
+
+ return SUCCESS;
+ }
+
+ if (alias && alias_len && PHAR_G(last_phar) && alias_len == PHAR_G(last_alias_len) && !memcmp(alias, PHAR_G(last_alias), alias_len)) {
+ fd = PHAR_G(last_phar);
+ fd_ptr = &fd;
+ goto alias_success;
+ }
+
+ if (alias && alias_len) {
+ ahash = zend_inline_hash_func(alias, alias_len);
+ if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void**)&fd_ptr)) {
+alias_success:
+ if (fname && (fname_len != (*fd_ptr)->fname_len || strncmp(fname, (*fd_ptr)->fname, fname_len))) {
+ if (error) {
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ }
+ if (SUCCESS == phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ efree(*error);
+ *error = NULL;
+ }
+ return FAILURE;
+ }
+
+ *archive = *fd_ptr;
+ fd = *fd_ptr;
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = alias;
+ PHAR_G(last_alias_len) = alias_len;
+
+ return SUCCESS;
+ }
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_alias, alias, alias_len, ahash, (void **)&fd_ptr)) {
+ goto alias_success;
+ }
+ }
+
+ fhash = zend_inline_hash_func(fname, fname_len);
+ my_realpath = NULL;
+ save = fname;
+ save_len = fname_len;
+
+ if (fname && fname_len) {
+ if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, fhash, (void**)&fd_ptr)) {
+ *archive = *fd_ptr;
+ fd = *fd_ptr;
+
+ if (alias && alias_len) {
+ if (!fd->is_temporary_alias && (alias_len != fd->alias_len || memcmp(fd->alias, alias, alias_len))) {
+ if (error) {
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ }
+ return FAILURE;
+ }
+
+ if (fd->alias_len && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), fd->alias, fd->alias_len, (void**)&fd_ptr)) {
+ zend_hash_del(&(PHAR_GLOBALS->phar_alias_map), fd->alias, fd->alias_len);
+ }
+
+ zend_hash_quick_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void*)&fd, sizeof(phar_archive_data*), NULL);
+ }
+
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = fd->alias;
+ PHAR_G(last_alias_len) = fd->alias_len;
+
+ return SUCCESS;
+ }
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_phars, fname, fname_len, fhash, (void**)&fd_ptr)) {
+ *archive = *fd_ptr;
+ fd = *fd_ptr;
+
+ /* this could be problematic - alias should never be different from manifest alias
+ for cached phars */
+ if (!fd->is_temporary_alias && alias && alias_len) {
+ if (alias_len != fd->alias_len || memcmp(fd->alias, alias, alias_len)) {
+ if (error) {
+ spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
+ }
+ return FAILURE;
+ }
+ }
+
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = fd->alias;
+ PHAR_G(last_alias_len) = fd->alias_len;
+
+ return SUCCESS;
+ }
+
+ if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_alias_map), save, save_len, fhash, (void**)&fd_ptr)) {
+ fd = *archive = *fd_ptr;
+
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = fd->alias;
+ PHAR_G(last_alias_len) = fd->alias_len;
+
+ return SUCCESS;
+ }
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_alias, save, save_len, fhash, (void**)&fd_ptr)) {
+ fd = *archive = *fd_ptr;
+
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = fd->alias;
+ PHAR_G(last_alias_len) = fd->alias_len;
+
+ return SUCCESS;
+ }
+
+ /* not found, try converting \ to / */
+ my_realpath = expand_filepath(fname, my_realpath TSRMLS_CC);
+
+ if (my_realpath) {
+ fname_len = strlen(my_realpath);
+ fname = my_realpath;
+ } else {
+ return FAILURE;
+ }
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(fname, fname_len);
+#endif
+ fhash = zend_inline_hash_func(fname, fname_len);
+
+ if (SUCCESS == zend_hash_quick_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, fhash, (void**)&fd_ptr)) {
+realpath_success:
+ *archive = *fd_ptr;
+ fd = *fd_ptr;
+
+ if (alias && alias_len) {
+ zend_hash_quick_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, ahash, (void*)&fd, sizeof(phar_archive_data*), NULL);
+ }
+
+ efree(my_realpath);
+
+ PHAR_G(last_phar) = fd;
+ PHAR_G(last_phar_name) = fd->fname;
+ PHAR_G(last_phar_name_len) = fd->fname_len;
+ PHAR_G(last_alias) = fd->alias;
+ PHAR_G(last_alias_len) = fd->alias_len;
+
+ return SUCCESS;
+ }
+
+ if (PHAR_G(manifest_cached) && SUCCESS == zend_hash_quick_find(&cached_phars, fname, fname_len, fhash, (void**)&fd_ptr)) {
+ goto realpath_success;
+ }
+
+ efree(my_realpath);
+ }
+
+ return FAILURE;
+}
+/* }}} */
+
+/**
+ * Determine which stream compression filter (if any) we need to read this file
+ */
+char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */
+{
+ switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ return "zlib.deflate";
+ case PHAR_ENT_COMPRESSED_BZ2:
+ return "bzip2.compress";
+ default:
+ return return_unknown ? "unknown" : NULL;
+ }
+}
+/* }}} */
+
+/**
+ * Determine which stream decompression filter (if any) we need to read this file
+ */
+char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */
+{
+ php_uint32 flags;
+
+ if (entry->is_modified) {
+ flags = entry->old_flags;
+ } else {
+ flags = entry->flags;
+ }
+
+ switch (flags & PHAR_ENT_COMPRESSION_MASK) {
+ case PHAR_ENT_COMPRESSED_GZ:
+ return "zlib.inflate";
+ case PHAR_ENT_COMPRESSED_BZ2:
+ return "bzip2.decompress";
+ default:
+ return return_unknown ? "unknown" : NULL;
+ }
+}
+/* }}} */
+
+/**
+ * retrieve information on a file contained within a phar, or null if it ain't there
+ */
+phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC) /* {{{ */
+{
+ return phar_get_entry_info_dir(phar, path, path_len, 0, error, security TSRMLS_CC);
+}
+/* }}} */
+/**
+ * retrieve information on a file or directory contained within a phar, or null if none found
+ * allow_dir is 0 for none, 1 for both empty directories in the phar and temp directories, and 2 for only
+ * valid pre-existing empty directory entries
+ */
+phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC) /* {{{ */
+{
+ const char *pcr_error;
+ phar_entry_info *entry;
+ int is_dir;
+
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(path, path_len);
+#endif
+
+ is_dir = (path_len && (path[path_len - 1] == '/')) ? 1 : 0;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ if (security && path_len >= sizeof(".phar")-1 && !memcmp(path, ".phar", sizeof(".phar")-1)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: cannot directly access magic \".phar\" directory or files within it");
+ }
+ return NULL;
+ }
+
+ if (!path_len && !dir) {
+ if (error) {
+ spprintf(error, 4096, "phar error: invalid path \"%s\" must not be empty", path);
+ }
+ return NULL;
+ }
+
+ if (phar_path_check(&path, &path_len, &pcr_error) > pcr_is_ok) {
+ if (error) {
+ spprintf(error, 4096, "phar error: invalid path \"%s\" contains %s", path, pcr_error);
+ }
+ return NULL;
+ }
+
+ if (!phar->manifest.arBuckets) {
+ return NULL;
+ }
+
+ if (is_dir) {
+ if (!path_len || path_len == 1) {
+ return NULL;
+ }
+ path_len--;
+ }
+
+ if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
+ if (entry->is_deleted) {
+ /* entry is deleted, but has not been flushed to disk yet */
+ return NULL;
+ }
+ if (entry->is_dir && !dir) {
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" is a directory", path);
+ }
+ return NULL;
+ }
+ if (!entry->is_dir && dir == 2) {
+ /* user requested a directory, we must return one */
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" exists and is a not a directory", path);
+ }
+ return NULL;
+ }
+ return entry;
+ }
+
+ if (dir) {
+ if (zend_hash_exists(&phar->virtual_dirs, path, path_len)) {
+ /* a file or directory exists in a sub-directory of this path */
+ entry = (phar_entry_info *) ecalloc(1, sizeof(phar_entry_info));
+ /* this next line tells PharFileInfo->__destruct() to efree the filename */
+ entry->is_temp_dir = entry->is_dir = 1;
+ entry->filename = (char *) estrndup(path, path_len + 1);
+ entry->filename_len = path_len;
+ entry->phar = phar;
+ return entry;
+ }
+ }
+
+ if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
+ phar_zstr key;
+ char *str_key;
+ ulong unused;
+ uint keylen;
+
+ zend_hash_internal_pointer_reset(&phar->mounted_dirs);
+ while (FAILURE != zend_hash_has_more_elements(&phar->mounted_dirs)) {
+ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) {
+ break;
+ }
+
+ PHAR_STR(key, str_key);
+
+ if ((int)keylen >= path_len || strncmp(str_key, path, keylen)) {
+ PHAR_STR_FREE(str_key);
+ continue;
+ } else {
+ char *test;
+ int test_len;
+ php_stream_statbuf ssb;
+
+ if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
+ if (error) {
+ spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", str_key);
+ }
+ PHAR_STR_FREE(str_key);
+ return NULL;
+ }
+
+ if (!entry->tmp || !entry->is_mounted) {
+ if (error) {
+ spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", str_key);
+ }
+ PHAR_STR_FREE(str_key);
+ return NULL;
+ }
+ PHAR_STR_FREE(str_key);
+
+ test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen);
+
+ if (SUCCESS != php_stream_stat_path(test, &ssb)) {
+ efree(test);
+ return NULL;
+ }
+
+ if (ssb.sb.st_mode & S_IFDIR && !dir) {
+ efree(test);
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" is a directory", path);
+ }
+ return NULL;
+ }
+
+ if ((ssb.sb.st_mode & S_IFDIR) == 0 && dir) {
+ efree(test);
+ /* user requested a directory, we must return one */
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" exists and is a not a directory", path);
+ }
+ return NULL;
+ }
+
+ /* mount the file just in time */
+ if (SUCCESS != phar_mount_entry(phar, test, test_len, path, path_len TSRMLS_CC)) {
+ efree(test);
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" exists as file \"%s\" and could not be mounted", path, test);
+ }
+ return NULL;
+ }
+
+ efree(test);
+
+ if (SUCCESS != zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: path \"%s\" exists as file \"%s\" and could not be retrieved after being mounted", path, test);
+ }
+ return NULL;
+ }
+ return entry;
+ }
+ }
+ }
+
+ return NULL;
+}
+/* }}} */
+
+static const char hexChars[] = "0123456789ABCDEF";
+
+static int phar_hex_str(const char *digest, size_t digest_len, char **signature TSRMLS_DC) /* {{{ */
+{
+ int pos = -1;
+ size_t len = 0;
+
+ *signature = (char*)safe_pemalloc(digest_len, 2, 1, PHAR_G(persist));
+
+ for (; len < digest_len; ++len) {
+ (*signature)[++pos] = hexChars[((const unsigned char *)digest)[len] >> 4];
+ (*signature)[++pos] = hexChars[((const unsigned char *)digest)[len] & 0x0F];
+ }
+ (*signature)[++pos] = '\0';
+ return pos;
+}
+/* }}} */
+
+#ifndef PHAR_HAVE_OPENSSL
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
+{
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
+ zval *zdata, *zsig, *zkey, *retval_ptr, **zp[3], *openssl;
+
+ MAKE_STD_ZVAL(zdata);
+ MAKE_STD_ZVAL(openssl);
+ ZVAL_STRINGL(openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1, 1);
+ MAKE_STD_ZVAL(zsig);
+ ZVAL_STRINGL(zsig, *signature, *signature_len, 1);
+ MAKE_STD_ZVAL(zkey);
+ ZVAL_STRINGL(zkey, key, key_len, 1);
+ zp[0] = &zdata;
+ zp[1] = &zsig;
+ zp[2] = &zkey;
+
+ php_stream_rewind(fp);
+ Z_TYPE_P(zdata) = IS_STRING;
+ Z_STRLEN_P(zdata) = end;
+
+#if PHP_MAJOR_VERSION > 5
+ if (end != (off_t) php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
+#else
+ if (end != (off_t) php_stream_copy_to_mem(fp, &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
+#endif
+ zval_dtor(zdata);
+ zval_dtor(zsig);
+ zval_dtor(zkey);
+ zval_dtor(openssl);
+ efree(openssl);
+ efree(zdata);
+ efree(zkey);
+ efree(zsig);
+ return FAILURE;
+ }
+
+#if PHP_VERSION_ID < 50300
+ if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) {
+#else
+ if (FAILURE == zend_fcall_info_init(openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
+#endif
+ zval_dtor(zdata);
+ zval_dtor(zsig);
+ zval_dtor(zkey);
+ zval_dtor(openssl);
+ efree(openssl);
+ efree(zdata);
+ efree(zkey);
+ efree(zsig);
+ return FAILURE;
+ }
+
+ fci.param_count = 3;
+ fci.params = zp;
+#if PHP_VERSION_ID < 50300
+ ++(zdata->refcount);
+ if (!is_sign) {
+ ++(zsig->refcount);
+ }
+ ++(zkey->refcount);
+#else
+ Z_ADDREF_P(zdata);
+ if (is_sign) {
+ Z_SET_ISREF_P(zsig);
+ } else {
+ Z_ADDREF_P(zsig);
+ }
+ Z_ADDREF_P(zkey);
+#endif
+ fci.retval_ptr_ptr = &retval_ptr;
+
+ if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
+ zval_dtor(zdata);
+ zval_dtor(zsig);
+ zval_dtor(zkey);
+ zval_dtor(openssl);
+ efree(openssl);
+ efree(zdata);
+ efree(zkey);
+ efree(zsig);
+ return FAILURE;
+ }
+
+ zval_dtor(openssl);
+ efree(openssl);
+#if PHP_VERSION_ID < 50300
+ --(zdata->refcount);
+ if (!is_sign) {
+ --(zsig->refcount);
+ }
+ --(zkey->refcount);
+#else
+ Z_DELREF_P(zdata);
+ if (is_sign) {
+ Z_UNSET_ISREF_P(zsig);
+ } else {
+ Z_DELREF_P(zsig);
+ }
+ Z_DELREF_P(zkey);
+#endif
+ zval_dtor(zdata);
+ efree(zdata);
+ zval_dtor(zkey);
+ efree(zkey);
+
+ switch (Z_TYPE_P(retval_ptr)) {
+ default:
+ case IS_LONG:
+ zval_dtor(zsig);
+ efree(zsig);
+ if (1 == Z_LVAL_P(retval_ptr)) {
+ efree(retval_ptr);
+ return SUCCESS;
+ }
+ efree(retval_ptr);
+ return FAILURE;
+ case IS_BOOL:
+ efree(retval_ptr);
+ if (Z_BVAL_P(retval_ptr)) {
+ *signature = estrndup(Z_STRVAL_P(zsig), Z_STRLEN_P(zsig));
+ *signature_len = Z_STRLEN_P(zsig);
+ zval_dtor(zsig);
+ efree(zsig);
+ return SUCCESS;
+ }
+ zval_dtor(zsig);
+ efree(zsig);
+ return FAILURE;
+ }
+}
+/* }}} */
+#endif /* #ifndef PHAR_HAVE_OPENSSL */
+
+int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC) /* {{{ */
+{
+ int read_size, len;
+ off_t read_len;
+ unsigned char buf[1024];
+
+ php_stream_rewind(fp);
+
+ switch (sig_type) {
+ case PHAR_SIG_OPENSSL: {
+#ifdef PHAR_HAVE_OPENSSL
+ BIO *in;
+ EVP_PKEY *key;
+ EVP_MD *mdtype = (EVP_MD *) EVP_sha1();
+ EVP_MD_CTX md_ctx;
+#else
+ int tempsig;
+#endif
+ php_uint32 pubkey_len;
+ char *pubkey = NULL, *pfile;
+ php_stream *pfp;
+#ifndef PHAR_HAVE_OPENSSL
+ if (!zend_hash_exists(&module_registry, "openssl", sizeof("openssl"))) {
+ if (error) {
+ spprintf(error, 0, "openssl not loaded");
+ }
+ return FAILURE;
+ }
+#endif
+ /* use __FILE__ . '.pubkey' for public key file */
+ spprintf(&pfile, 0, "%s.pubkey", fname);
+ pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL);
+ efree(pfile);
+
+#if PHP_MAJOR_VERSION > 5
+ if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, (void **) &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
+#else
+ if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
+#endif
+ if (pfp) {
+ php_stream_close(pfp);
+ }
+ if (error) {
+ spprintf(error, 0, "openssl public key could not be read");
+ }
+ return FAILURE;
+ }
+
+ php_stream_close(pfp);
+#ifndef PHAR_HAVE_OPENSSL
+ tempsig = sig_len;
+
+ if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey, pubkey_len, &sig, &tempsig TSRMLS_CC)) {
+ if (pubkey) {
+ efree(pubkey);
+ }
+
+ if (error) {
+ spprintf(error, 0, "openssl signature could not be verified");
+ }
+
+ return FAILURE;
+ }
+
+ if (pubkey) {
+ efree(pubkey);
+ }
+
+ sig_len = tempsig;
+#else
+ in = BIO_new_mem_buf(pubkey, pubkey_len);
+
+ if (NULL == in) {
+ efree(pubkey);
+ if (error) {
+ spprintf(error, 0, "openssl signature could not be processed");
+ }
+ return FAILURE;
+ }
+
+ key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL);
+ BIO_free(in);
+ efree(pubkey);
+
+ if (NULL == key) {
+ if (error) {
+ spprintf(error, 0, "openssl signature could not be processed");
+ }
+ return FAILURE;
+ }
+
+ EVP_VerifyInit(&md_ctx, mdtype);
+ read_len = end_of_phar;
+
+ if (read_len > sizeof(buf)) {
+ read_size = sizeof(buf);
+ } else {
+ read_size = (int)read_len;
+ }
+
+ php_stream_seek(fp, 0, SEEK_SET);
+
+ while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
+ EVP_VerifyUpdate (&md_ctx, buf, len);
+ read_len -= (off_t)len;
+
+ if (read_len < read_size) {
+ read_size = (int)read_len;
+ }
+ }
+
+ if (EVP_VerifyFinal(&md_ctx, (unsigned char *)sig, sig_len, key) != 1) {
+ /* 1: signature verified, 0: signature does not match, -1: failed signature operation */
+ EVP_MD_CTX_cleanup(&md_ctx);
+
+ if (error) {
+ spprintf(error, 0, "broken openssl signature");
+ }
+
+ return FAILURE;
+ }
+
+ EVP_MD_CTX_cleanup(&md_ctx);
+#endif
+
+ *signature_len = phar_hex_str((const char*)sig, sig_len, signature TSRMLS_CC);
+ }
+ break;
+#ifdef PHAR_HASH_OK
+ case PHAR_SIG_SHA512: {
+ unsigned char digest[64];
+ PHP_SHA512_CTX context;
+
+ PHP_SHA512Init(&context);
+ read_len = end_of_phar;
+
+ if (read_len > sizeof(buf)) {
+ read_size = sizeof(buf);
+ } else {
+ read_size = (int)read_len;
+ }
+
+ while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
+ PHP_SHA512Update(&context, buf, len);
+ read_len -= (off_t)len;
+ if (read_len < read_size) {
+ read_size = (int)read_len;
+ }
+ }
+
+ PHP_SHA512Final(digest, &context);
+
+ if (memcmp(digest, sig, sizeof(digest))) {
+ if (error) {
+ spprintf(error, 0, "broken signature");
+ }
+ return FAILURE;
+ }
+
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ break;
+ }
+ case PHAR_SIG_SHA256: {
+ unsigned char digest[32];
+ PHP_SHA256_CTX context;
+
+ PHP_SHA256Init(&context);
+ read_len = end_of_phar;
+
+ if (read_len > sizeof(buf)) {
+ read_size = sizeof(buf);
+ } else {
+ read_size = (int)read_len;
+ }
+
+ while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
+ PHP_SHA256Update(&context, buf, len);
+ read_len -= (off_t)len;
+ if (read_len < read_size) {
+ read_size = (int)read_len;
+ }
+ }
+
+ PHP_SHA256Final(digest, &context);
+
+ if (memcmp(digest, sig, sizeof(digest))) {
+ if (error) {
+ spprintf(error, 0, "broken signature");
+ }
+ return FAILURE;
+ }
+
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ break;
+ }
+#else
+ case PHAR_SIG_SHA512:
+ case PHAR_SIG_SHA256:
+ if (error) {
+ spprintf(error, 0, "unsupported signature");
+ }
+ return FAILURE;
+#endif
+ case PHAR_SIG_SHA1: {
+ unsigned char digest[20];
+ PHP_SHA1_CTX context;
+
+ PHP_SHA1Init(&context);
+ read_len = end_of_phar;
+
+ if (read_len > sizeof(buf)) {
+ read_size = sizeof(buf);
+ } else {
+ read_size = (int)read_len;
+ }
+
+ while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
+ PHP_SHA1Update(&context, buf, len);
+ read_len -= (off_t)len;
+ if (read_len < read_size) {
+ read_size = (int)read_len;
+ }
+ }
+
+ PHP_SHA1Final(digest, &context);
+
+ if (memcmp(digest, sig, sizeof(digest))) {
+ if (error) {
+ spprintf(error, 0, "broken signature");
+ }
+ return FAILURE;
+ }
+
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ break;
+ }
+ case PHAR_SIG_MD5: {
+ unsigned char digest[16];
+ PHP_MD5_CTX context;
+
+ PHP_MD5Init(&context);
+ read_len = end_of_phar;
+
+ if (read_len > sizeof(buf)) {
+ read_size = sizeof(buf);
+ } else {
+ read_size = (int)read_len;
+ }
+
+ while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
+ PHP_MD5Update(&context, buf, len);
+ read_len -= (off_t)len;
+ if (read_len < read_size) {
+ read_size = (int)read_len;
+ }
+ }
+
+ PHP_MD5Final(digest, &context);
+
+ if (memcmp(digest, sig, sizeof(digest))) {
+ if (error) {
+ spprintf(error, 0, "broken signature");
+ }
+ return FAILURE;
+ }
+
+ *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature TSRMLS_CC);
+ break;
+ }
+ default:
+ if (error) {
+ spprintf(error, 0, "broken or unsupported signature");
+ }
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+/* }}} */
+
+int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error TSRMLS_DC) /* {{{ */
+{
+ unsigned char buf[1024];
+ int sig_len;
+
+ php_stream_rewind(fp);
+
+ if (phar->signature) {
+ efree(phar->signature);
+ phar->signature = NULL;
+ }
+
+ switch(phar->sig_flags) {
+#ifdef PHAR_HASH_OK
+ case PHAR_SIG_SHA512: {
+ unsigned char digest[64];
+ PHP_SHA512_CTX context;
+
+ PHP_SHA512Init(&context);
+
+ while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
+ PHP_SHA512Update(&context, buf, sig_len);
+ }
+
+ PHP_SHA512Final(digest, &context);
+ *signature = estrndup((char *) digest, 64);
+ *signature_length = 64;
+ break;
+ }
+ case PHAR_SIG_SHA256: {
+ unsigned char digest[32];
+ PHP_SHA256_CTX context;
+
+ PHP_SHA256Init(&context);
+
+ while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
+ PHP_SHA256Update(&context, buf, sig_len);
+ }
+
+ PHP_SHA256Final(digest, &context);
+ *signature = estrndup((char *) digest, 32);
+ *signature_length = 32;
+ break;
+ }
+#else
+ case PHAR_SIG_SHA512:
+ case PHAR_SIG_SHA256:
+ if (error) {
+ spprintf(error, 0, "unable to write to phar \"%s\" with requested hash type", phar->fname);
+ }
+
+ return FAILURE;
+#endif
+ case PHAR_SIG_OPENSSL: {
+ int siglen;
+ unsigned char *sigbuf;
+#ifdef PHAR_HAVE_OPENSSL
+ BIO *in;
+ EVP_PKEY *key;
+ EVP_MD_CTX *md_ctx;
+
+ in = BIO_new_mem_buf(PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len));
+
+ if (in == NULL) {
+ if (error) {
+ spprintf(error, 0, "unable to write to phar \"%s\" with requested openssl signature", phar->fname);
+ }
+ return FAILURE;
+ }
+
+ key = PEM_read_bio_PrivateKey(in, NULL,NULL, "");
+ BIO_free(in);
+
+ if (!key) {
+ if (error) {
+ spprintf(error, 0, "unable to process private key");
+ }
+ return FAILURE;
+ }
+
+ md_ctx = EVP_MD_CTX_create();
+
+ siglen = EVP_PKEY_size(key);
+ sigbuf = emalloc(siglen + 1);
+
+ if (!EVP_SignInit(md_ctx, EVP_sha1())) {
+ efree(sigbuf);
+ if (error) {
+ spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname);
+ }
+ return FAILURE;
+ }
+
+ while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
+ if (!EVP_SignUpdate(md_ctx, buf, sig_len)) {
+ efree(sigbuf);
+ if (error) {
+ spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname);
+ }
+ return FAILURE;
+ }
+ }
+
+ if (!EVP_SignFinal (md_ctx, sigbuf,(unsigned int *)&siglen, key)) {
+ efree(sigbuf);
+ if (error) {
+ spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
+ }
+ return FAILURE;
+ }
+
+ sigbuf[siglen] = '\0';
+ EVP_MD_CTX_destroy(md_ctx);
+#else
+ sigbuf = NULL;
+ siglen = 0;
+ php_stream_seek(fp, 0, SEEK_END);
+
+ if (FAILURE == phar_call_openssl_signverify(1, fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname);
+ }
+ return FAILURE;
+ }
+#endif
+ *signature = (char *) sigbuf;
+ *signature_length = siglen;
+ }
+ break;
+ default:
+ phar->sig_flags = PHAR_SIG_SHA1;
+ case PHAR_SIG_SHA1: {
+ unsigned char digest[20];
+ PHP_SHA1_CTX context;
+
+ PHP_SHA1Init(&context);
+
+ while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
+ PHP_SHA1Update(&context, buf, sig_len);
+ }
+
+ PHP_SHA1Final(digest, &context);
+ *signature = estrndup((char *) digest, 20);
+ *signature_length = 20;
+ break;
+ }
+ case PHAR_SIG_MD5: {
+ unsigned char digest[16];
+ PHP_MD5_CTX context;
+
+ PHP_MD5Init(&context);
+
+ while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
+ PHP_MD5Update(&context, buf, sig_len);
+ }
+
+ PHP_MD5Final(digest, &context);
+ *signature = estrndup((char *) digest, 16);
+ *signature_length = 16;
+ break;
+ }
+ }
+
+ phar->sig_len = phar_hex_str((const char *)*signature, *signature_length, &phar->signature TSRMLS_CC);
+ return SUCCESS;
+}
+/* }}} */
+
+void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len TSRMLS_DC) /* {{{ */
+{
+ const char *s;
+
+ while ((s = zend_memrchr(filename, '/', filename_len))) {
+ filename_len = s - filename;
+ if (FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
+ break;
+ }
+ }
+}
+/* }}} */
+
+static int phar_update_cached_entry(void *data, void *argument) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)data;
+ TSRMLS_FETCH();
+
+ entry->phar = (phar_archive_data *)argument;
+
+ if (entry->link) {
+ entry->link = estrdup(entry->link);
+ }
+
+ if (entry->tmp) {
+ entry->tmp = estrdup(entry->tmp);
+ }
+
+ entry->metadata_str.c = 0;
+ entry->filename = estrndup(entry->filename, entry->filename_len);
+ entry->is_persistent = 0;
+
+ if (entry->metadata) {
+ if (entry->metadata_len) {
+ char *buf = estrndup((char *) entry->metadata, entry->metadata_len);
+ /* assume success, we would have failed before */
+ phar_parse_metadata((char **) &buf, &entry->metadata, entry->metadata_len TSRMLS_CC);
+ efree(buf);
+ } else {
+ zval *t;
+
+ t = entry->metadata;
+ ALLOC_ZVAL(entry->metadata);
+ *entry->metadata = *t;
+ zval_copy_ctor(entry->metadata);
+#if PHP_VERSION_ID < 50300
+ entry->metadata->refcount = 1;
+#else
+ Z_SET_REFCOUNT_P(entry->metadata, 1);
+#endif
+ entry->metadata_str.c = NULL;
+ entry->metadata_str.len = 0;
+ }
+ }
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+static void phar_copy_cached_phar(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ HashTable newmanifest;
+ char *fname;
+ phar_archive_object **objphar;
+
+ phar = (phar_archive_data *) emalloc(sizeof(phar_archive_data));
+ *phar = **pphar;
+ phar->is_persistent = 0;
+ fname = phar->fname;
+ phar->fname = estrndup(phar->fname, phar->fname_len);
+ phar->ext = phar->fname + (phar->ext - fname);
+
+ if (phar->alias) {
+ phar->alias = estrndup(phar->alias, phar->alias_len);
+ }
+
+ if (phar->signature) {
+ phar->signature = estrdup(phar->signature);
+ }
+
+ if (phar->metadata) {
+ /* assume success, we would have failed before */
+ if (phar->metadata_len) {
+ char *buf = estrndup((char *) phar->metadata, phar->metadata_len);
+ phar_parse_metadata(&buf, &phar->metadata, phar->metadata_len TSRMLS_CC);
+ efree(buf);
+ } else {
+ zval *t;
+
+ t = phar->metadata;
+ ALLOC_ZVAL(phar->metadata);
+ *phar->metadata = *t;
+ zval_copy_ctor(phar->metadata);
+#if PHP_VERSION_ID < 50300
+ phar->metadata->refcount = 1;
+#else
+ Z_SET_REFCOUNT_P(phar->metadata, 1);
+#endif
+ }
+ }
+
+ zend_hash_init(&newmanifest, sizeof(phar_entry_info),
+ zend_get_hash_value, destroy_phar_manifest_entry, 0);
+ zend_hash_copy(&newmanifest, &(*pphar)->manifest, NULL, NULL, sizeof(phar_entry_info));
+ zend_hash_apply_with_argument(&newmanifest, (apply_func_arg_t) phar_update_cached_entry, (void *)phar TSRMLS_CC);
+ phar->manifest = newmanifest;
+ zend_hash_init(&phar->mounted_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, 0);
+ zend_hash_init(&phar->virtual_dirs, sizeof(char *),
+ zend_get_hash_value, NULL, 0);
+ zend_hash_copy(&phar->virtual_dirs, &(*pphar)->virtual_dirs, NULL, NULL, sizeof(void *));
+ *pphar = phar;
+
+ /* now, scan the list of persistent Phar objects referencing this phar and update the pointers */
+ for (zend_hash_internal_pointer_reset(&PHAR_GLOBALS->phar_persist_map);
+ SUCCESS == zend_hash_get_current_data(&PHAR_GLOBALS->phar_persist_map, (void **) &objphar);
+ zend_hash_move_forward(&PHAR_GLOBALS->phar_persist_map)) {
+ if (objphar[0]->arc.archive->fname_len == phar->fname_len && !memcmp(objphar[0]->arc.archive->fname, phar->fname, phar->fname_len)) {
+ objphar[0]->arc.archive = phar;
+ }
+ }
+}
+/* }}} */
+
+int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data **newpphar, *newphar = NULL;
+
+ if (SUCCESS != zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), (*pphar)->fname, (*pphar)->fname_len, (void *)&newphar, sizeof(phar_archive_data *), (void **)&newpphar)) {
+ return FAILURE;
+ }
+
+ *newpphar = *pphar;
+ phar_copy_cached_phar(newpphar TSRMLS_CC);
+ /* invalidate phar cache */
+ PHAR_G(last_phar) = NULL;
+ PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
+
+ if (newpphar[0]->alias_len && FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), newpphar[0]->alias, newpphar[0]->alias_len, (void*)newpphar, sizeof(phar_archive_data*), NULL)) {
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), (*pphar)->fname, (*pphar)->fname_len);
+ return FAILURE;
+ }
+
+ *pphar = *newpphar;
+ return SUCCESS;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
new file mode 100644
index 0000000..33732fb
--- /dev/null
+++ b/ext/phar/zip.c
@@ -0,0 +1,1514 @@
+/*
+ +----------------------------------------------------------------------+
+ | ZIP archive support for Phar |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2007-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gregory Beaver <cellog@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "phar_internal.h"
+
+#define PHAR_GET_16(var) ((php_uint16)((((php_uint16)var[0]) & 0xff) | \
+ (((php_uint16)var[1]) & 0xff) << 8))
+#define PHAR_GET_32(var) ((php_uint32)((((php_uint32)var[0]) & 0xff) | \
+ (((php_uint32)var[1]) & 0xff) << 8 | \
+ (((php_uint32)var[2]) & 0xff) << 16 | \
+ (((php_uint32)var[3]) & 0xff) << 24))
+static inline void phar_write_32(char buffer[4], php_uint32 value)
+{
+ buffer[3] = (unsigned char) ((value & 0xff000000) >> 24);
+ buffer[2] = (unsigned char) ((value & 0xff0000) >> 16);
+ buffer[1] = (unsigned char) ((value & 0xff00) >> 8);
+ buffer[0] = (unsigned char) (value & 0xff);
+}
+static inline void phar_write_16(char buffer[2], php_uint32 value)
+{
+ buffer[1] = (unsigned char) ((value & 0xff00) >> 8);
+ buffer[0] = (unsigned char) (value & 0xff);
+}
+# define PHAR_SET_32(var, value) phar_write_32(var, (php_uint32) (value));
+# define PHAR_SET_16(var, value) phar_write_16(var, (php_uint16) (value));
+
+static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, php_uint16 len TSRMLS_DC) /* {{{ */
+{
+ union {
+ phar_zip_extra_field_header header;
+ phar_zip_unix3 unix3;
+ } h;
+ int read;
+
+ do {
+ if (sizeof(h.header) != php_stream_read(fp, (char *) &h.header, sizeof(h.header))) {
+ return FAILURE;
+ }
+
+ if (h.header.tag[0] != 'n' || h.header.tag[1] != 'u') {
+ /* skip to next header */
+ php_stream_seek(fp, PHAR_GET_16(h.header.size), SEEK_CUR);
+ len -= PHAR_GET_16(h.header.size) + 4;
+ continue;
+ }
+
+ /* unix3 header found */
+ read = php_stream_read(fp, (char *) &(h.unix3.crc32), sizeof(h.unix3) - sizeof(h.header));
+ len -= read + 4;
+
+ if (sizeof(h.unix3) - sizeof(h.header) != read) {
+ return FAILURE;
+ }
+
+ if (PHAR_GET_16(h.unix3.size) > sizeof(h.unix3) - 4) {
+ /* skip symlink filename - we may add this support in later */
+ php_stream_seek(fp, PHAR_GET_16(h.unix3.size) - sizeof(h.unix3.size), SEEK_CUR);
+ }
+
+ /* set permissions */
+ entry->flags &= PHAR_ENT_COMPRESSION_MASK;
+
+ if (entry->is_dir) {
+ entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_MASK;
+ } else {
+ entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_MASK;
+ }
+
+ } while (len);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/*
+ extracted from libzip
+ zip_dirent.c -- read directory entry (local or central), clean dirent
+ Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
+
+ This function is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <nih@giga.or.at>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+static time_t phar_zip_d2u_time(char *cdtime, char *cddate) /* {{{ */
+{
+ int dtime = PHAR_GET_16(cdtime), ddate = PHAR_GET_16(cddate);
+ struct tm *tm, tmbuf;
+ time_t now;
+
+ now = time(NULL);
+ tm = php_localtime_r(&now, &tmbuf);
+
+ tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
+ tm->tm_mon = ((ddate>>5)&15) - 1;
+ tm->tm_mday = ddate&31;
+
+ tm->tm_hour = (dtime>>11)&31;
+ tm->tm_min = (dtime>>5)&63;
+ tm->tm_sec = (dtime<<1)&62;
+
+ return mktime(tm);
+}
+/* }}} */
+
+static void phar_zip_u2d_time(time_t time, char *dtime, char *ddate) /* {{{ */
+{
+ php_uint16 ctime, cdate;
+ struct tm *tm, tmbuf;
+
+ tm = php_localtime_r(&time, &tmbuf);
+ cdate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5) + tm->tm_mday;
+ ctime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5) + ((tm->tm_sec)>>1);
+ PHAR_SET_16(dtime, ctime);
+ PHAR_SET_16(ddate, cdate);
+}
+/* }}} */
+
+/**
+ * Does not check for a previously opened phar in the cache.
+ *
+ * Parse a new one and add it to the cache, returning either SUCCESS or
+ * FAILURE, and setting pphar to the pointer to the manifest entry
+ *
+ * This is used by phar_open_from_fp to process a zip-based phar, but can be called
+ * directly.
+ */
+int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_zip_dir_end locator;
+ char buf[sizeof(locator) + 65536];
+ long size;
+ php_uint16 i;
+ phar_archive_data *mydata = NULL;
+ phar_entry_info entry = {0};
+ char *p = buf, *ext, *actual_alias = NULL;
+ char *metadata = NULL;
+
+ size = php_stream_tell(fp);
+
+ if (size > sizeof(locator) + 65536) {
+ /* seek to max comment length + end of central directory record */
+ size = sizeof(locator) + 65536;
+ if (FAILURE == php_stream_seek(fp, -size, SEEK_END)) {
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: unable to search for end of central directory in zip-based phar \"%s\"", fname);
+ }
+ return FAILURE;
+ }
+ } else {
+ php_stream_seek(fp, 0, SEEK_SET);
+ }
+
+ if (!php_stream_read(fp, buf, size)) {
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: unable to read in data to search for end of central directory in zip-based phar \"%s\"", fname);
+ }
+ return FAILURE;
+ }
+
+ while ((p=(char *) memchr(p + 1, 'P', (size_t) (size - (p + 1 - buf)))) != NULL) {
+ if (!memcmp(p + 1, "K\5\6", 3)) {
+ memcpy((void *)&locator, (void *) p, sizeof(locator));
+ if (PHAR_GET_16(locator.centraldisk) != 0 || PHAR_GET_16(locator.disknumber) != 0) {
+ /* split archives not handled */
+ php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: split archives spanning multiple zips cannot be processed in zip-based phar \"%s\"", fname);
+ }
+ return FAILURE;
+ }
+
+ if (PHAR_GET_16(locator.counthere) != PHAR_GET_16(locator.count)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar \"%s\"", fname);
+ }
+ php_stream_close(fp);
+ return FAILURE;
+ }
+
+ mydata = pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist));
+ mydata->is_persistent = PHAR_G(persist);
+
+ /* read in archive comment, if any */
+ if (PHAR_GET_16(locator.comment_len)) {
+
+ metadata = p + sizeof(locator);
+
+ if (PHAR_GET_16(locator.comment_len) != size - (metadata - buf)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: corrupt zip archive, zip file comment truncated in zip-based phar \"%s\"", fname);
+ }
+ php_stream_close(fp);
+ pefree(mydata, mydata->is_persistent);
+ return FAILURE;
+ }
+
+ mydata->metadata_len = PHAR_GET_16(locator.comment_len);
+
+ if (phar_parse_metadata(&metadata, &mydata->metadata, PHAR_GET_16(locator.comment_len) TSRMLS_CC) == FAILURE) {
+ mydata->metadata_len = 0;
+ /* if not valid serialized data, it is a regular string */
+
+ if (entry.is_persistent) {
+ ALLOC_PERMANENT_ZVAL(mydata->metadata);
+ } else {
+ ALLOC_ZVAL(mydata->metadata);
+ }
+
+ INIT_ZVAL(*mydata->metadata);
+ metadata = pestrndup(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent);
+ ZVAL_STRINGL(mydata->metadata, metadata, PHAR_GET_16(locator.comment_len), 0);
+ }
+ } else {
+ mydata->metadata = NULL;
+ }
+
+ goto foundit;
+ }
+ }
+
+ php_stream_close(fp);
+
+ if (error) {
+ spprintf(error, 4096, "phar error: end of central directory not found in zip-based phar \"%s\"", fname);
+ }
+
+ return FAILURE;
+foundit:
+ mydata->fname = pestrndup(fname, fname_len, mydata->is_persistent);
+#ifdef PHP_WIN32
+ phar_unixify_path_separators(mydata->fname, fname_len);
+#endif
+ mydata->is_zip = 1;
+ mydata->fname_len = fname_len;
+ ext = strrchr(mydata->fname, '/');
+
+ if (ext) {
+ mydata->ext = memchr(ext, '.', (mydata->fname + fname_len) - ext);
+ if (mydata->ext == ext) {
+ mydata->ext = memchr(ext + 1, '.', (mydata->fname + fname_len) - ext - 1);
+ }
+ if (mydata->ext) {
+ mydata->ext_len = (mydata->fname + fname_len) - mydata->ext;
+ }
+ }
+
+ /* clean up on big-endian systems */
+ /* seek to central directory */
+ php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET);
+ /* read in central directory */
+ zend_hash_init(&mydata->manifest, PHAR_GET_16(locator.count),
+ zend_get_hash_value, destroy_phar_manifest_entry, (zend_bool)mydata->is_persistent);
+ zend_hash_init(&mydata->mounted_dirs, 5,
+ zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);
+ zend_hash_init(&mydata->virtual_dirs, PHAR_GET_16(locator.count) * 2,
+ zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);
+ entry.phar = mydata;
+ entry.is_zip = 1;
+ entry.fp_type = PHAR_FP;
+ entry.is_persistent = mydata->is_persistent;
+#define PHAR_ZIP_FAIL_FREE(errmsg, save) \
+ zend_hash_destroy(&mydata->manifest); \
+ mydata->manifest.arBuckets = 0; \
+ zend_hash_destroy(&mydata->mounted_dirs); \
+ mydata->mounted_dirs.arBuckets = 0; \
+ zend_hash_destroy(&mydata->virtual_dirs); \
+ mydata->virtual_dirs.arBuckets = 0; \
+ php_stream_close(fp); \
+ if (mydata->metadata) { \
+ zval_dtor(mydata->metadata); \
+ } \
+ if (mydata->signature) { \
+ efree(mydata->signature); \
+ } \
+ if (error) { \
+ spprintf(error, 4096, "phar error: %s in zip-based phar \"%s\"", errmsg, mydata->fname); \
+ } \
+ pefree(mydata->fname, mydata->is_persistent); \
+ if (mydata->alias) { \
+ pefree(mydata->alias, mydata->is_persistent); \
+ } \
+ pefree(mydata, mydata->is_persistent); \
+ efree(save); \
+ return FAILURE;
+#define PHAR_ZIP_FAIL(errmsg) \
+ zend_hash_destroy(&mydata->manifest); \
+ mydata->manifest.arBuckets = 0; \
+ zend_hash_destroy(&mydata->mounted_dirs); \
+ mydata->mounted_dirs.arBuckets = 0; \
+ zend_hash_destroy(&mydata->virtual_dirs); \
+ mydata->virtual_dirs.arBuckets = 0; \
+ php_stream_close(fp); \
+ if (mydata->metadata) { \
+ zval_dtor(mydata->metadata); \
+ } \
+ if (mydata->signature) { \
+ efree(mydata->signature); \
+ } \
+ if (error) { \
+ spprintf(error, 4096, "phar error: %s in zip-based phar \"%s\"", errmsg, mydata->fname); \
+ } \
+ pefree(mydata->fname, mydata->is_persistent); \
+ if (mydata->alias) { \
+ pefree(mydata->alias, mydata->is_persistent); \
+ } \
+ pefree(mydata, mydata->is_persistent); \
+ return FAILURE;
+
+ /* add each central directory item to the manifest */
+ for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
+ phar_zip_central_dir_file zipentry;
+ off_t beforeus = php_stream_tell(fp);
+
+ if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
+ PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
+ }
+
+ /* clean up for bigendian systems */
+ if (memcmp("PK\1\2", zipentry.signature, 4)) {
+ /* corrupted entry */
+ PHAR_ZIP_FAIL("corrupted central directory entry, no magic signature");
+ }
+
+ if (entry.is_persistent) {
+ entry.manifest_pos = i;
+ }
+
+ entry.compressed_filesize = PHAR_GET_32(zipentry.compsize);
+ entry.uncompressed_filesize = PHAR_GET_32(zipentry.uncompsize);
+ entry.crc32 = PHAR_GET_32(zipentry.crc32);
+ /* do not PHAR_GET_16 either on the next line */
+ entry.timestamp = phar_zip_d2u_time(zipentry.timestamp, zipentry.datestamp);
+ entry.flags = PHAR_ENT_PERM_DEF_FILE;
+ entry.header_offset = PHAR_GET_32(zipentry.offset);
+ entry.offset = entry.offset_abs = PHAR_GET_32(zipentry.offset) + sizeof(phar_zip_file_header) + PHAR_GET_16(zipentry.filename_len) +
+ PHAR_GET_16(zipentry.extra_len);
+
+ if (PHAR_GET_16(zipentry.flags) & PHAR_ZIP_FLAG_ENCRYPTED) {
+ PHAR_ZIP_FAIL("Cannot process encrypted zip files");
+ }
+
+ if (!PHAR_GET_16(zipentry.filename_len)) {
+ PHAR_ZIP_FAIL("Cannot process zips created from stdin (zero-length filename)");
+ }
+
+ entry.filename_len = PHAR_GET_16(zipentry.filename_len);
+ entry.filename = (char *) pemalloc(entry.filename_len + 1, entry.is_persistent);
+
+ if (entry.filename_len != php_stream_read(fp, entry.filename, entry.filename_len)) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unable to read in filename from central directory, truncated");
+ }
+
+ entry.filename[entry.filename_len] = '\0';
+
+ if (entry.filename[entry.filename_len - 1] == '/') {
+ entry.is_dir = 1;
+ entry.filename_len--;
+ entry.flags |= PHAR_ENT_PERM_DEF_DIR;
+ } else {
+ entry.is_dir = 0;
+ }
+
+ if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
+ size_t read;
+ php_stream *sigfile;
+ off_t now;
+ char *sig;
+
+ now = php_stream_tell(fp);
+ pefree(entry.filename, entry.is_persistent);
+ sigfile = php_stream_fopen_tmpfile();
+ if (!sigfile) {
+ PHAR_ZIP_FAIL("couldn't open temporary file");
+ }
+
+ php_stream_seek(fp, 0, SEEK_SET);
+ /* copy file contents + local headers and zip comment, if any, to be hashed for signature */
+ phar_stream_copy_to_stream(fp, sigfile, entry.header_offset, NULL);
+ /* seek to central directory */
+ php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET);
+ /* copy central directory header */
+ phar_stream_copy_to_stream(fp, sigfile, beforeus - PHAR_GET_32(locator.cdir_offset), NULL);
+ if (metadata) {
+ php_stream_write(sigfile, metadata, PHAR_GET_16(locator.comment_len));
+ }
+ php_stream_seek(fp, sizeof(phar_zip_file_header) + entry.header_offset + entry.filename_len + PHAR_GET_16(zipentry.extra_len), SEEK_SET);
+ sig = (char *) emalloc(entry.uncompressed_filesize);
+ read = php_stream_read(fp, sig, entry.uncompressed_filesize);
+ if (read != entry.uncompressed_filesize) {
+ php_stream_close(sigfile);
+ efree(sig);
+ PHAR_ZIP_FAIL("signature cannot be read");
+ }
+ mydata->sig_flags = PHAR_GET_32(sig);
+ if (FAILURE == phar_verify_signature(sigfile, php_stream_tell(sigfile), mydata->sig_flags, sig + 8, entry.uncompressed_filesize - 8, fname, &mydata->signature, &mydata->sig_len, error TSRMLS_CC)) {
+ efree(sig);
+ if (error) {
+ char *save;
+ php_stream_close(sigfile);
+ spprintf(&save, 4096, "signature cannot be verified: %s", *error);
+ efree(*error);
+ PHAR_ZIP_FAIL_FREE(save, save);
+ } else {
+ php_stream_close(sigfile);
+ PHAR_ZIP_FAIL("signature cannot be verified");
+ }
+ }
+ php_stream_close(sigfile);
+ efree(sig);
+ /* signature checked out, let's ensure this is the last file in the phar */
+ if (i != PHAR_GET_16(locator.count) - 1) {
+ PHAR_ZIP_FAIL("entries exist after signature, invalid phar");
+ }
+
+ continue;
+ }
+
+ phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
+
+ if (PHAR_GET_16(zipentry.extra_len)) {
+ off_t loc = php_stream_tell(fp);
+ if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("Unable to process extra field header for file in central directory");
+ }
+ php_stream_seek(fp, loc + PHAR_GET_16(zipentry.extra_len), SEEK_SET);
+ }
+
+ switch (PHAR_GET_16(zipentry.compressed)) {
+ case PHAR_ZIP_COMP_NONE :
+ /* compression flag already set */
+ break;
+ case PHAR_ZIP_COMP_DEFLATE :
+ entry.flags |= PHAR_ENT_COMPRESSED_GZ;
+ if (!PHAR_G(has_zlib)) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("zlib extension is required");
+ }
+ break;
+ case PHAR_ZIP_COMP_BZIP2 :
+ entry.flags |= PHAR_ENT_COMPRESSED_BZ2;
+ if (!PHAR_G(has_bz2)) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("bzip2 extension is required");
+ }
+ break;
+ case 1 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (Shrunk) used in this zip");
+ case 2 :
+ case 3 :
+ case 4 :
+ case 5 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (Reduce) used in this zip");
+ case 6 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (Implode) used in this zip");
+ case 7 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (Tokenize) used in this zip");
+ case 9 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (Deflate64) used in this zip");
+ case 10 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (PKWare Implode/old IBM TERSE) used in this zip");
+ case 14 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (LZMA) used in this zip");
+ case 18 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (IBM TERSE) used in this zip");
+ case 19 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (IBM LZ77) used in this zip");
+ case 97 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (WavPack) used in this zip");
+ case 98 :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (PPMd) used in this zip");
+ default :
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unsupported compression method (unknown) used in this zip");
+ }
+
+ /* get file metadata */
+ if (PHAR_GET_16(zipentry.comment_len)) {
+ if (PHAR_GET_16(zipentry.comment_len) != php_stream_read(fp, buf, PHAR_GET_16(zipentry.comment_len))) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unable to read in file comment, truncated");
+ }
+
+ p = buf;
+ entry.metadata_len = PHAR_GET_16(zipentry.comment_len);
+
+ if (phar_parse_metadata(&p, &(entry.metadata), PHAR_GET_16(zipentry.comment_len) TSRMLS_CC) == FAILURE) {
+ entry.metadata_len = 0;
+ /* if not valid serialized data, it is a regular string */
+
+ if (entry.is_persistent) {
+ ALLOC_PERMANENT_ZVAL(entry.metadata);
+ } else {
+ ALLOC_ZVAL(entry.metadata);
+ }
+
+ INIT_ZVAL(*entry.metadata);
+ ZVAL_STRINGL(entry.metadata, pestrndup(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent), PHAR_GET_16(zipentry.comment_len), 0);
+ }
+ } else {
+ entry.metadata = NULL;
+ }
+
+ if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
+ php_stream_filter *filter;
+ off_t saveloc;
+ /* verify local file header */
+ phar_zip_file_header local;
+
+ /* archive alias found */
+ saveloc = php_stream_tell(fp);
+ php_stream_seek(fp, PHAR_GET_32(zipentry.offset), SEEK_SET);
+
+ if (sizeof(local) != php_stream_read(fp, (char *) &local, sizeof(local))) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("phar error: internal corruption of zip-based phar (cannot read local file header for alias)");
+ }
+
+ /* verify local header */
+ if (entry.filename_len != PHAR_GET_16(local.filename_len) || entry.crc32 != PHAR_GET_32(local.crc32) || entry.uncompressed_filesize != PHAR_GET_32(local.uncompsize) || entry.compressed_filesize != PHAR_GET_32(local.compsize)) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("phar error: internal corruption of zip-based phar (local header of alias does not match central directory)");
+ }
+
+ /* construct actual offset to file start - local extra_len can be different from central extra_len */
+ entry.offset = entry.offset_abs =
+ sizeof(local) + entry.header_offset + PHAR_GET_16(local.filename_len) + PHAR_GET_16(local.extra_len);
+#if PHP_VERSION_ID < 50207
+ /* work around Bug #46147 */
+ fp->writepos = fp->readpos = 0;
+#endif
+ php_stream_seek(fp, entry.offset, SEEK_SET);
+ /* these next lines should be for php < 5.2.6 after 5.3 filters are fixed */
+ fp->writepos = 0;
+ fp->readpos = 0;
+ php_stream_seek(fp, entry.offset, SEEK_SET);
+ fp->writepos = 0;
+ fp->readpos = 0;
+ /* the above lines should be for php < 5.2.6 after 5.3 filters are fixed */
+
+ mydata->alias_len = entry.uncompressed_filesize;
+
+ if (entry.flags & PHAR_ENT_COMPRESSED_GZ) {
+ filter = php_stream_filter_create("zlib.inflate", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+
+ if (!filter) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unable to decompress alias, zlib filter creation failed");
+ }
+
+ php_stream_filter_append(&fp->readfilters, filter);
+
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ pefree(entry.filename, entry.is_persistent);
+#if PHP_VERSION_ID < 50207
+ PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
+#endif
+ PHAR_ZIP_FAIL("unable to read in alias, truncated");
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+
+ } else if (entry.flags & PHAR_ENT_COMPRESSED_BZ2) {
+ filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
+
+ if (!filter) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unable to read in alias, bzip2 filter creation failed");
+ }
+
+ php_stream_filter_append(&fp->readfilters, filter);
+
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ pefree(entry.filename, entry.is_persistent);
+#if PHP_VERSION_ID < 50207
+ PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
+#endif
+ PHAR_ZIP_FAIL("unable to read in alias, truncated");
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ } else {
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+ pefree(entry.filename, entry.is_persistent);
+ PHAR_ZIP_FAIL("unable to read in alias, truncated");
+ }
+ }
+
+ /* return to central directory parsing */
+ php_stream_seek(fp, saveloc, SEEK_SET);
+ }
+
+ phar_set_inode(&entry TSRMLS_CC);
+ zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void *)&entry,sizeof(phar_entry_info), NULL);
+ }
+
+ mydata->fp = fp;
+
+ if (zend_hash_exists(&(mydata->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ mydata->is_data = 0;
+ } else {
+ mydata->is_data = 1;
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+
+ if (actual_alias) {
+ phar_archive_data **fd_ptr;
+
+ if (!phar_validate_alias(actual_alias, mydata->alias_len)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: invalid alias \"%s\" in zip-based phar \"%s\"", actual_alias, fname);
+ }
+ efree(actual_alias);
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ return FAILURE;
+ }
+
+ mydata->is_temporary_alias = 0;
+
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, actual_alias, mydata->alias_len TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to add zip-based phar \"%s\" with implicit alias, alias is already in use", fname);
+ }
+ efree(actual_alias);
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ return FAILURE;
+ }
+ }
+
+ mydata->alias = entry.is_persistent ? pestrndup(actual_alias, mydata->alias_len, 1) : actual_alias;
+
+ if (entry.is_persistent) {
+ efree(actual_alias);
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ } else {
+ phar_archive_data **fd_ptr;
+
+ if (alias_len) {
+ if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {
+ if (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {
+ if (error) {
+ spprintf(error, 4096, "phar error: Unable to add zip-based phar \"%s\" with explicit alias, alias is already in use", fname);
+ }
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);
+ return FAILURE;
+ }
+ }
+
+ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ mydata->alias = pestrndup(alias, alias_len, mydata->is_persistent);
+ mydata->alias_len = alias_len;
+ } else {
+ mydata->alias = pestrndup(mydata->fname, fname_len, mydata->is_persistent);
+ mydata->alias_len = fname_len;
+ }
+
+ mydata->is_temporary_alias = 1;
+ }
+
+ if (pphar) {
+ *pphar = mydata;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
+/**
+ * Create or open a zip-based phar for writing
+ */
+int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
+{
+ phar_archive_data *phar;
+ int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC);
+
+ if (FAILURE == ret) {
+ return FAILURE;
+ }
+
+ if (pphar) {
+ *pphar = phar;
+ }
+
+ phar->is_data = is_data;
+
+ if (phar->is_zip) {
+ return ret;
+ }
+
+ if (phar->is_brandnew) {
+ phar->internal_file_start = 0;
+ phar->is_zip = 1;
+ phar->is_tar = 0;
+ return SUCCESS;
+ }
+
+ /* we've reached here - the phar exists and is a regular phar */
+ if (error) {
+ spprintf(error, 4096, "phar zip error: phar \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar", fname);
+ }
+
+ return FAILURE;
+}
+/* }}} */
+
+struct _phar_zip_pass {
+ php_stream *filefp;
+ php_stream *centralfp;
+ php_stream *old;
+ int free_fp;
+ int free_ufp;
+ char **error;
+};
+/* perform final modification of zip contents for each file in the manifest before saving */
+static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry;
+ phar_zip_file_header local;
+ phar_zip_unix3 perms;
+ phar_zip_central_dir_file central;
+ struct _phar_zip_pass *p;
+ php_uint32 newcrc32;
+ off_t offset;
+ int not_really_modified = 0;
+ entry = (phar_entry_info *)data;
+ p = (struct _phar_zip_pass*) arg;
+
+ if (entry->is_mounted) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ if (entry->is_deleted) {
+ if (entry->fp_refcount <= 0) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ /* we can't delete this in-memory until it is closed */
+ return ZEND_HASH_APPLY_KEEP;
+ }
+ }
+
+ phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC);
+ memset(&local, 0, sizeof(local));
+ memset(&central, 0, sizeof(central));
+ memset(&perms, 0, sizeof(perms));
+ strncpy(local.signature, "PK\3\4", 4);
+ strncpy(central.signature, "PK\1\2", 4);
+ PHAR_SET_16(central.extra_len, sizeof(perms));
+ PHAR_SET_16(local.extra_len, sizeof(perms));
+ perms.tag[0] = 'n';
+ perms.tag[1] = 'u';
+ PHAR_SET_16(perms.size, sizeof(perms) - 4);
+ PHAR_SET_16(perms.perms, entry->flags & PHAR_ENT_PERM_MASK);
+ {
+ php_uint32 crc = (php_uint32) ~0;
+ CRC32(crc, perms.perms[0]);
+ CRC32(crc, perms.perms[1]);
+ PHAR_SET_32(perms.crc32, ~crc);
+ }
+
+ if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_DEFLATE);
+ PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_DEFLATE);
+ }
+
+ if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
+ PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_BZIP2);
+ PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_BZIP2);
+ }
+
+ /* do not use PHAR_GET_16 on either field of the next line */
+ phar_zip_u2d_time(entry->timestamp, local.timestamp, local.datestamp);
+ memcpy(central.timestamp, local.timestamp, sizeof(local.timestamp));
+ memcpy(central.datestamp, local.datestamp, sizeof(local.datestamp));
+ PHAR_SET_16(central.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0));
+ PHAR_SET_16(local.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0));
+ PHAR_SET_32(central.offset, php_stream_tell(p->filefp));
+
+ /* do extra field for perms later */
+ if (entry->is_modified) {
+ php_uint32 loc;
+ php_stream_filter *filter;
+ php_stream *efp;
+
+ if (entry->is_dir) {
+ entry->is_modified = 0;
+ if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) {
+ php_stream_close(entry->fp);
+ entry->fp = NULL;
+ entry->fp_type = PHAR_FP;
+ }
+ goto continue_dir;
+ }
+
+ if (FAILURE == phar_open_entry_fp(entry, p->error, 0 TSRMLS_CC)) {
+ spprintf(p->error, 0, "unable to open file contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ /* we can be modified and already be compressed, such as when chmod() is executed */
+ if (entry->flags & PHAR_ENT_COMPRESSION_MASK && (entry->old_flags == entry->flags || !entry->old_flags)) {
+ not_really_modified = 1;
+ goto is_compressed;
+ }
+
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ efp = phar_get_efp(entry, 0 TSRMLS_CC);
+ newcrc32 = ~0;
+
+ for (loc = 0;loc < entry->uncompressed_filesize; ++loc) {
+ CRC32(newcrc32, php_stream_getc(efp));
+ }
+
+ entry->crc32 = ~newcrc32;
+ PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize);
+ PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize);
+
+ if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ /* not compressed */
+ entry->compressed_filesize = entry->uncompressed_filesize;
+ PHAR_SET_32(central.compsize, entry->uncompressed_filesize);
+ PHAR_SET_32(local.compsize, entry->uncompressed_filesize);
+ goto not_compressed;
+ }
+
+ filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
+
+ if (!filter) {
+ if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
+ spprintf(p->error, 0, "unable to gzip compress file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ } else {
+ spprintf(p->error, 0, "unable to bzip2 compress file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ /* create new file that holds the compressed version */
+ /* work around inability to specify freedom in write and strictness
+ in read count */
+ entry->cfp = php_stream_fopen_tmpfile();
+
+ if (!entry->cfp) {
+ spprintf(p->error, 0, "unable to create temporary file for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ php_stream_flush(efp);
+
+ if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
+ spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ php_stream_filter_append((&entry->cfp->writefilters), filter);
+
+ if (SUCCESS != phar_stream_copy_to_stream(efp, entry->cfp, entry->uncompressed_filesize, NULL)) {
+ spprintf(p->error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ php_stream_filter_flush(filter, 1);
+ php_stream_flush(entry->cfp);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ php_stream_seek(entry->cfp, 0, SEEK_END);
+ entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp);
+ PHAR_SET_32(central.compsize, entry->compressed_filesize);
+ PHAR_SET_32(local.compsize, entry->compressed_filesize);
+ /* generate crc on compressed file */
+ php_stream_rewind(entry->cfp);
+ entry->old_flags = entry->flags;
+ entry->is_modified = 1;
+ } else {
+is_compressed:
+ PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize);
+ PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize);
+ PHAR_SET_32(central.compsize, entry->compressed_filesize);
+ PHAR_SET_32(local.compsize, entry->compressed_filesize);
+
+ if (-1 == php_stream_seek(p->old, entry->offset_abs, SEEK_SET)) {
+ spprintf(p->error, 0, "unable to seek to start of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ }
+not_compressed:
+ PHAR_SET_32(central.crc32, entry->crc32);
+ PHAR_SET_32(local.crc32, entry->crc32);
+continue_dir:
+ /* set file metadata */
+ if (entry->metadata) {
+ php_serialize_data_t metadata_hash;
+
+ if (entry->metadata_str.c) {
+ smart_str_free(&entry->metadata_str);
+ }
+ entry->metadata_str.c = 0;
+ entry->metadata_str.len = 0;
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ PHAR_SET_16(central.comment_len, entry->metadata_str.len);
+ }
+
+ entry->header_offset = php_stream_tell(p->filefp);
+ offset = entry->header_offset + sizeof(local) + entry->filename_len + (entry->is_dir ? 1 : 0) + sizeof(perms);
+
+ if (sizeof(local) != php_stream_write(p->filefp, (char *)&local, sizeof(local))) {
+ spprintf(p->error, 0, "unable to write local file header of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (sizeof(central) != php_stream_write(p->centralfp, (char *)&central, sizeof(central))) {
+ spprintf(p->error, 0, "unable to write central directory entry for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (entry->is_dir) {
+ if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) {
+ spprintf(p->error, 0, "unable to write filename to local directory entry for directory \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (1 != php_stream_write(p->filefp, "/", 1)) {
+ spprintf(p->error, 0, "unable to write filename to local directory entry for directory \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) {
+ spprintf(p->error, 0, "unable to write filename to central directory entry for directory \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (1 != php_stream_write(p->centralfp, "/", 1)) {
+ spprintf(p->error, 0, "unable to write filename to central directory entry for directory \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ } else {
+ if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) {
+ spprintf(p->error, 0, "unable to write filename to local directory entry for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) {
+ spprintf(p->error, 0, "unable to write filename to central directory entry for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ }
+
+ if (sizeof(perms) != php_stream_write(p->filefp, (char *)&perms, sizeof(perms))) {
+ spprintf(p->error, 0, "unable to write local extra permissions file header of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (sizeof(perms) != php_stream_write(p->centralfp, (char *)&perms, sizeof(perms))) {
+ spprintf(p->error, 0, "unable to write central extra permissions file header of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ if (!not_really_modified && entry->is_modified) {
+ if (entry->cfp) {
+ if (SUCCESS != phar_stream_copy_to_stream(entry->cfp, p->filefp, entry->compressed_filesize, NULL)) {
+ spprintf(p->error, 0, "unable to write compressed contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ php_stream_close(entry->cfp);
+ entry->cfp = NULL;
+ } else {
+ if (FAILURE == phar_open_entry_fp(entry, p->error, 0 TSRMLS_CC)) {
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC);
+
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp, entry->uncompressed_filesize, NULL)) {
+ spprintf(p->error, 0, "unable to write contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ }
+
+ if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp && entry->fp_refcount == 0) {
+ php_stream_close(entry->fp);
+ }
+
+ entry->is_modified = 0;
+ } else {
+ entry->is_modified = 0;
+ if (entry->fp_refcount) {
+ /* open file pointers refer to this fp, do not free the stream */
+ switch (entry->fp_type) {
+ case PHAR_FP:
+ p->free_fp = 0;
+ break;
+ case PHAR_UFP:
+ p->free_ufp = 0;
+ default:
+ break;
+ }
+ }
+
+ if (!entry->is_dir && entry->compressed_filesize && SUCCESS != phar_stream_copy_to_stream(p->old, p->filefp, entry->compressed_filesize, NULL)) {
+ spprintf(p->error, 0, "unable to copy contents of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ return ZEND_HASH_APPLY_STOP;
+ }
+ }
+
+ entry->fp = NULL;
+ entry->offset = entry->offset_abs = offset;
+ entry->fp_type = PHAR_FP;
+
+ if (entry->metadata_str.c) {
+ if (entry->metadata_str.len != php_stream_write(p->centralfp, entry->metadata_str.c, entry->metadata_str.len)) {
+ spprintf(p->error, 0, "unable to write metadata as file comment for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ smart_str_free(&entry->metadata_str);
+ return ZEND_HASH_APPLY_STOP;
+ }
+
+ smart_str_free(&entry->metadata_str);
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pass *pass,
+ smart_str *metadata TSRMLS_DC) /* {{{ */
+{
+ /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
+ if (!phar->is_data || phar->sig_flags) {
+ int signature_length;
+ char *signature, sigbuf[8];
+ phar_entry_info entry = {0};
+ php_stream *newfile;
+ off_t tell, st;
+
+ newfile = php_stream_fopen_tmpfile();
+ st = tell = php_stream_tell(pass->filefp);
+ /* copy the local files, central directory, and the zip comment to generate the hash */
+ php_stream_seek(pass->filefp, 0, SEEK_SET);
+ phar_stream_copy_to_stream(pass->filefp, newfile, tell, NULL);
+ tell = php_stream_tell(pass->centralfp);
+ php_stream_seek(pass->centralfp, 0, SEEK_SET);
+ phar_stream_copy_to_stream(pass->centralfp, newfile, tell, NULL);
+ if (metadata->c) {
+ php_stream_write(newfile, metadata->c, metadata->len);
+ }
+
+ if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error TSRMLS_CC)) {
+ if (pass->error) {
+ char *save = *(pass->error);
+ spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar: %s", save);
+ efree(save);
+ }
+
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+
+ entry.filename = ".phar/signature.bin";
+ entry.filename_len = sizeof(".phar/signature.bin")-1;
+ entry.fp = php_stream_fopen_tmpfile();
+ entry.fp_type = PHAR_MOD;
+ entry.is_modified = 1;
+
+ PHAR_SET_32(sigbuf, phar->sig_flags);
+ PHAR_SET_32(sigbuf + 4, signature_length);
+
+ if (8 != (int)php_stream_write(entry.fp, sigbuf, 8) || signature_length != (int)php_stream_write(entry.fp, signature, signature_length)) {
+ efree(signature);
+ if (pass->error) {
+ spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar %s", phar->fname);
+ }
+
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+
+ efree(signature);
+ entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8;
+ entry.phar = phar;
+ /* throw out return value and write the signature */
+ phar_zip_changed_apply((void *)&entry, (void *)pass TSRMLS_CC);
+ php_stream_close(newfile);
+
+ if (pass->error && *(pass->error)) {
+ /* error is set by writeheaders */
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+ } /* signature */
+ return SUCCESS;
+}
+/* }}} */
+
+int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+{
+ char *pos;
+ smart_str main_metadata_str = {0};
+ static const char newstub[] = "<?php // zip-based phar archive stub file\n__HALT_COMPILER();";
+ char halt_stub[] = "__HALT_COMPILER();";
+ char *tmp;
+
+ php_stream *stubfile, *oldfile;
+ php_serialize_data_t metadata_hash;
+ int free_user_stub, closeoldfile = 0;
+ phar_entry_info entry = {0};
+ char *temperr = NULL;
+ struct _phar_zip_pass pass;
+ phar_zip_dir_end eocd;
+ php_uint32 cdir_size, cdir_offset;
+
+ pass.error = &temperr;
+ entry.flags = PHAR_ENT_PERM_DEF_FILE;
+ entry.timestamp = time(NULL);
+ entry.is_modified = 1;
+ entry.is_zip = 1;
+ entry.phar = phar;
+ entry.fp_type = PHAR_MOD;
+
+ if (phar->is_persistent) {
+ if (error) {
+ spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (phar->is_data) {
+ goto nostub;
+ }
+
+ /* set alias */
+ if (!phar->is_temporary_alias && phar->alias_len) {
+ entry.fp = php_stream_fopen_tmpfile();
+
+ if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
+ if (error) {
+ spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ entry.uncompressed_filesize = entry.compressed_filesize = phar->alias_len;
+ entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ entry.filename_len = sizeof(".phar/alias.txt")-1;
+
+ if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (error) {
+ spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ } else {
+ zend_hash_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
+ }
+
+ /* register alias */
+ if (phar->alias_len) {
+ if (FAILURE == phar_get_archive(&phar, phar->fname, phar->fname_len, phar->alias, phar->alias_len, error TSRMLS_CC)) {
+ return EOF;
+ }
+ }
+
+ /* set stub */
+ if (user_stub && !defaultstub) {
+ if (len < 0) {
+ /* resource passed in */
+ if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
+ if (error) {
+ spprintf(error, 0, "unable to access resource to copy stub to new zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (len == -1) {
+ len = PHP_STREAM_COPY_ALL;
+ } else {
+ len = -len;
+ }
+
+ user_stub = 0;
+
+ if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+ if (error) {
+ spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ free_user_stub = 1;
+ } else {
+ free_user_stub = 0;
+ }
+
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
+ if (error) {
+ spprintf(error, 0, "illegal stub for zip-based phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ return EOF;
+ }
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
+
+ len = pos - user_stub + 18;
+ entry.fp = php_stream_fopen_tmpfile();
+ entry.uncompressed_filesize = len + 5;
+
+ if ((size_t)len != php_stream_write(entry.fp, user_stub, len)
+ || 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) {
+ if (error) {
+ spprintf(error, 0, "unable to create stub from string in new zip-based phar \"%s\"", phar->fname);
+ }
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ php_stream_close(entry.fp);
+ return EOF;
+ }
+
+ entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
+ entry.filename_len = sizeof(".phar/stub.php")-1;
+
+ if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ if (error) {
+ spprintf(error, 0, "unable to set stub in zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+
+ if (free_user_stub) {
+ efree(user_stub);
+ }
+ } else {
+ /* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */
+ entry.fp = php_stream_fopen_tmpfile();
+
+ if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) {
+ php_stream_close(entry.fp);
+ if (error) {
+ spprintf(error, 0, "unable to %s stub in%szip-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname);
+ }
+ return EOF;
+ }
+
+ entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1;
+ entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
+ entry.filename_len = sizeof(".phar/stub.php")-1;
+
+ if (!defaultstub) {
+ if (!zend_hash_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
+ if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 0, "unable to create stub in zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ } else {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ }
+ } else {
+ if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
+ php_stream_close(entry.fp);
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 0, "unable to overwrite stub in zip-based phar \"%s\"", phar->fname);
+ }
+ return EOF;
+ }
+ }
+ }
+nostub:
+ if (phar->fp && !phar->is_brandnew) {
+ oldfile = phar->fp;
+ closeoldfile = 0;
+ php_stream_rewind(oldfile);
+ } else {
+ oldfile = php_stream_open_wrapper(phar->fname, "rb", 0, NULL);
+ closeoldfile = oldfile != NULL;
+ }
+
+ /* save modified files to the zip */
+ pass.old = oldfile;
+ pass.filefp = php_stream_fopen_tmpfile();
+
+ if (!pass.filefp) {
+fperror:
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to open temporary file", phar->fname);
+ }
+ return EOF;
+ }
+
+ pass.centralfp = php_stream_fopen_tmpfile();
+
+ if (!pass.centralfp) {
+ goto fperror;
+ }
+
+ pass.free_fp = pass.free_ufp = 1;
+ memset(&eocd, 0, sizeof(eocd));
+
+ strncpy(eocd.signature, "PK\5\6", 4);
+ if (!phar->is_data && !phar->sig_flags) {
+ phar->sig_flags = PHAR_SIG_SHA1;
+ }
+ if (phar->sig_flags) {
+ PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest) + 1);
+ PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest) + 1);
+ } else {
+ PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest));
+ PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest));
+ }
+ zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass TSRMLS_CC);
+
+ if (phar->metadata) {
+ /* set phar metadata */
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ }
+ if (temperr) {
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
+ }
+ efree(temperr);
+temperror:
+ php_stream_close(pass.centralfp);
+nocentralerror:
+ if (phar->metadata) {
+ smart_str_free(&main_metadata_str);
+ }
+ php_stream_close(pass.filefp);
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+ }
+
+ if (FAILURE == phar_zip_applysignature(phar, &pass, &main_metadata_str TSRMLS_CC)) {
+ goto temperror;
+ }
+
+ /* save zip */
+ cdir_size = php_stream_tell(pass.centralfp);
+ cdir_offset = php_stream_tell(pass.filefp);
+ PHAR_SET_32(eocd.cdir_size, cdir_size);
+ PHAR_SET_32(eocd.cdir_offset, cdir_offset);
+ php_stream_seek(pass.centralfp, 0, SEEK_SET);
+
+ {
+ size_t clen;
+ int ret = phar_stream_copy_to_stream(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen);
+ if (SUCCESS != ret || clen != cdir_size) {
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname);
+ }
+ goto temperror;
+ }
+ }
+
+ php_stream_close(pass.centralfp);
+
+ if (phar->metadata) {
+ /* set phar metadata */
+ PHAR_SET_16(eocd.comment_len, main_metadata_str.len);
+
+ if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname);
+ }
+ goto nocentralerror;
+ }
+
+ if (main_metadata_str.len != php_stream_write(pass.filefp, main_metadata_str.c, main_metadata_str.len)) {
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname);
+ }
+ goto nocentralerror;
+ }
+
+ smart_str_free(&main_metadata_str);
+
+ } else {
+ if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
+ if (error) {
+ spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname);
+ }
+ goto nocentralerror;
+ }
+ }
+
+ if (phar->fp && pass.free_fp) {
+ php_stream_close(phar->fp);
+ }
+
+ if (phar->ufp) {
+ if (pass.free_ufp) {
+ php_stream_close(phar->ufp);
+ }
+ phar->ufp = NULL;
+ }
+
+ /* re-open */
+ phar->is_brandnew = 0;
+
+ if (phar->donotflush) {
+ /* deferred flush */
+ phar->fp = pass.filefp;
+ } else {
+ phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
+ if (!phar->fp) {
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ phar->fp = pass.filefp;
+ if (error) {
+ spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname);
+ }
+ return EOF;
+ }
+ php_stream_rewind(pass.filefp);
+ phar_stream_copy_to_stream(pass.filefp, phar->fp, PHP_STREAM_COPY_ALL, NULL);
+ /* we could also reopen the file in "rb" mode but there is no need for that */
+ php_stream_close(pass.filefp);
+ }
+
+ if (closeoldfile) {
+ php_stream_close(oldfile);
+ }
+ return EOF;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */