diff options
Diffstat (limited to 'request_hooks.c')
-rw-r--r-- | request_hooks.c | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/request_hooks.c b/request_hooks.c deleted file mode 100644 index c4f5f53..0000000 --- a/request_hooks.c +++ /dev/null @@ -1,101 +0,0 @@ -#include "request_hooks.h" -#include "compat_zend_string.h" - -#include <Zend/zend.h> -#include <Zend/zend_compile.h> -#include <php_main.h> - -#if PHP_VERSION_ID < 70000 -int dd_execute_php_file(const char *filename TSRMLS_DC) { - int filename_len = strlen(filename); - if (filename_len == 0) { - return FAILURE; - } - int dummy = 1; - zend_file_handle file_handle; - zend_op_array *new_op_array; - zval *result = NULL; - int ret; - - ret = php_stream_open_for_zend_ex(filename, &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); - - if (ret == SUCCESS) { - if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(filename, filename_len); - } - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path) + 1, - (void *)&dummy, sizeof(int), NULL) == SUCCESS) { - new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC); - zend_destroy_file_handle(&file_handle TSRMLS_CC); - } else { - new_op_array = NULL; - zend_file_handle_dtor(&file_handle TSRMLS_CC); - } - if (new_op_array) { - EG(return_value_ptr_ptr) = &result; - EG(active_op_array) = new_op_array; - if (!EG(active_symbol_table)) { - zend_rebuild_symbol_table(TSRMLS_C); - } - - zend_execute(new_op_array TSRMLS_CC); - - destroy_op_array(new_op_array TSRMLS_CC); - efree(new_op_array); - if (!EG(exception)) { - if (EG(return_value_ptr_ptr)) { - zval_ptr_dtor(EG(return_value_ptr_ptr)); - } - } - - return 1; - } - } - return 0; -} -#else - -int dd_execute_php_file(const char *filename TSRMLS_DC) { - int filename_len = strlen(filename); - if (filename_len == 0) { - return FAILURE; - } - zval dummy; - zend_file_handle file_handle; - zend_op_array *new_op_array; - zval result; - int ret; - - ret = php_stream_open_for_zend_ex(filename, &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE); - - if (ret == SUCCESS) { - zend_string *opened_path; - if (!file_handle.opened_path) { - file_handle.opened_path = zend_string_init(filename, filename_len, 0); - } - opened_path = zend_string_copy(file_handle.opened_path); - ZVAL_NULL(&dummy); - if (zend_hash_add(&EG(included_files), opened_path, &dummy)) { - new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE); - zend_destroy_file_handle(&file_handle); - } else { - new_op_array = NULL; - zend_file_handle_dtor(&file_handle); - } - zend_string_release(opened_path); - if (new_op_array) { - ZVAL_UNDEF(&result); - zend_execute(new_op_array, &result); - - destroy_op_array(new_op_array); - efree(new_op_array); - if (!EG(exception)) { - zval_ptr_dtor(&result); - } - - return 1; - } - } - return 0; -} -#endif |