Index: phar.c =================================================================== RCS file: /repository/pecl/phar/phar.c,v retrieving revision 1.219 diff -u -r1.219 phar.c --- phar.c 25 Nov 2007 05:04:39 -0000 1.219 +++ phar.c 9 Dec 2007 21:43:11 -0000 @@ -3757,6 +3757,56 @@ } /* }}} */ +static zend_op_array *(*orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); + +static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */ +{ + phar_archive_data **fd_ptr; + zend_op_array *res; + char *fname = NULL; + int fname_len; + + zend_compile_file = orig_compile_file; + if (PHAR_G(phar_fname_map).arBuckets) { + char *arch, *entry; + int arch_len, entry_len; + fname = 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 TSRMLS_CC)) { + char *s; + static char name[4096]; + + efree(entry); + entry = file_handle->filename; + /* include within phar, if :// is not in the url, then prepend phar:/// */ + entry_len = strlen(entry); + for (s = entry; s < (entry + entry_len - 4); s++) { + if (*s == ':' && *(s + 1) == '/' && *(s + 2) == '/') { + efree(arch); + goto skip_phar; + } + } + /* auto-convert to phar:// */ + strcpy(name, "phar://"); + strcat(name, arch); + strcat(name, "/"); + efree(arch); + strcat(name, entry); + file_handle->type = ZEND_HANDLE_FILENAME; + file_handle->free_filename = 1; + file_handle->filename = name; + } + } +skip_phar: + res = orig_compile_file(file_handle, type TSRMLS_CC); + zend_compile_file = phar_compile_file; + return res; +} +/* }}} */ + PHP_MINIT_FUNCTION(phar) /* {{{ */ { ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL); @@ -3765,6 +3815,8 @@ PHAR_G(has_gnupg) = zend_hash_exists(&module_registry, "gnupg", sizeof("gnupg")); PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2")); PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib")); + orig_compile_file = zend_compile_file; + zend_compile_file = phar_compile_file; phar_object_init(TSRMLS_C); return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper TSRMLS_CC);