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;
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;
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;
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 */
#define PharFileFunction(fname, funcnum, orig) \
void fname(INTERNAL_FUNCTION_PARAMETERS) { \
- char *filename; \
- int filename_len; \
- \
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { \
- return; \
+ 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, "s", &filename, &filename_len) == FAILURE) { \
+ return; \
+ } \
+ \
+ phar_file_stat(filename, (php_stat_len) filename_len, funcnum, PHAR_G(orig), INTERNAL_FUNCTION_PARAM_PASSTHRU); \
} \
- \
- phar_file_stat(filename, (php_stat_len) filename_len, funcnum, PHAR_G(orig), INTERNAL_FUNCTION_PARAM_PASSTHRU); \
}
/* }}} */
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;
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;
/* }}} */
/* {{{ void phar_intercept_functions(TSRMLS_D) */
+void phar_intercept_functions(TSRMLS_D)
+{
+ zend_function *orig;
+
+ 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)) { \
orig->internal_function.handler = phar_##func; \
}
-void phar_intercept_functions(TSRMLS_D)
+void phar_intercept_functions_init(TSRMLS_D)
{
zend_function *orig;
- if (!PHAR_G(request_init)) {
- PHAR_G(cwd) = NULL;
- PHAR_G(cwd_len) = 0;
- } else if (PHAR_G(orig_fopen)) {
- /* don't double-intercept */
- return;
- }
PHAR_INTERCEPT(fopen);
PHAR_INTERCEPT(file_get_contents);
PHAR_INTERCEPT(is_file);
PHAR_INTERCEPT(lstat);
PHAR_INTERCEPT(stat);
PHAR_INTERCEPT(readfile);
+ PHAR_G(intercepted) = 0;
}
/* }}} */
-/* {{{ void phar_release_functions(TSRMLS_D) */
+/* {{{ 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_release_functions(TSRMLS_D)
+void phar_intercept_functions_shutdown(TSRMLS_D)
{
zend_function *orig;
PHAR_RELEASE(lstat);
PHAR_RELEASE(stat);
PHAR_RELEASE(readfile);
+ PHAR_G(intercepted) = 0;
}
/* }}} */
phar_object_init(TSRMLS_C);
+ phar_intercept_functions_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);
+ 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;
}
zend_hash_destroy(&(cached_phars));
zend_hash_destroy(&(cached_alias));
}
+
+ return SUCCESS;
}
/* }}} */
PHAR_G(cwd) = NULL;
PHAR_G(cwd_len) = 0;
PHAR_G(cwd_init) = 0;
- if (!PHAR_G(orig_fopen)) {
- phar_intercept_functions(TSRMLS_C);
- }
+ phar_intercept_functions(TSRMLS_C);
}
}
/* }}} */
ZEND_MOD_OPTIONAL("bz2")
ZEND_MOD_OPTIONAL("openssl")
ZEND_MOD_OPTIONAL("zlib")
+ ZEND_MOD_OPTIONAL("standard")
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
#endif