}
/* }}} */
+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) /* {{{ */
+{
+ zend_op_array *res;
+ char *fname = NULL;
+ int fname_len;
+
+ zend_compile_file = orig_compile_file;
+ if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map))) {
+ 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, *name;
+
+ efree(entry);
+ entry = file_handle->filename;
+ /* include within phar, if :// is not in the url, then prepend phar://<archive>/ */
+ 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:// */
+ spprintf(&name, 4096, "phar://%s/%s", arch, entry);
+ efree(arch);
+ 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);
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);
PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
{
return php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
+ zend_compile_file = orig_compile_file;
}
/* }}} */