void php_com_object_free_storage(zend_object *object) { php_com_dotnet_object *obj = (php_com_dotnet_object*)object; if (obj->typeinfo) { ITypeInfo_Release(obj->typeinfo); obj->typeinfo = NULL; } if (obj->sink_dispatch) { php_com_object_enable_event_sink(obj, FALSE); IDispatch_Release(obj->sink_dispatch); obj->sink_dispatch = NULL; } VariantClear(&obj->v); if (obj->method_cache) { zend_hash_destroy(obj->method_cache); FREE_HASHTABLE(obj->method_cache); } if (obj->id_of_name_cache) { zend_hash_destroy(obj->id_of_name_cache); FREE_HASHTABLE(obj->id_of_name_cache); } }
/* {{{ xsl_objects_free_storage */ void xsl_objects_free_storage(zend_object *object) { xsl_object *intern = php_xsl_fetch_object(object); zend_object_std_dtor(&intern->std); zend_hash_destroy(intern->parameter); FREE_HASHTABLE(intern->parameter); zend_hash_destroy(intern->registered_phpfunctions); FREE_HASHTABLE(intern->registered_phpfunctions); if (intern->node_list) { zend_hash_destroy(intern->node_list); FREE_HASHTABLE(intern->node_list); } if (intern->doc) { php_libxml_decrement_doc_ref(intern->doc); efree(intern->doc); } if (intern->ptr) { /* free wrapper */ if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) { ((xsltStylesheetPtr) intern->ptr)->_private = NULL; } xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr); intern->ptr = NULL; } if (intern->profiling) { efree(intern->profiling); } }
static ZEND_GSHUTDOWN_FUNCTION(hprose) { if (hprose_globals->cache1) { zend_hash_destroy(hprose_globals->cache1); FREE_HASHTABLE(hprose_globals->cache1); hprose_globals->cache1 = NULL; } if (hprose_globals->cache2) { zend_hash_destroy(hprose_globals->cache2); FREE_HASHTABLE(hprose_globals->cache2); hprose_globals->cache2 = NULL; } }
static PHP_RSHUTDOWN_FUNCTION(protobuf) { zend_hash_destroy(upb_def_to_php_obj_map); FREE_HASHTABLE(upb_def_to_php_obj_map); zend_hash_destroy(ce_to_php_obj_map); FREE_HASHTABLE(ce_to_php_obj_map); if (generated_pool_php != NULL) { zval_dtor(generated_pool_php); FREE_ZVAL(generated_pool_php); } }
static void php_runkit_sandbox_parent_dtor(php_runkit_sandbox_parent_object *objval) { zend_hash_destroy(objval->obj.properties); FREE_HASHTABLE(objval->obj.properties); efree(objval); }
/** * Destroyes the prepared ASTs */ void phalcon_orm_destroy_cache(TSRMLS_D) { zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; if (phalcon_globals_ptr->orm.parser_cache != NULL) { zend_hash_destroy(phalcon_globals_ptr->orm.parser_cache); FREE_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); phalcon_globals_ptr->orm.parser_cache = NULL; } if (phalcon_globals_ptr->orm.ast_cache != NULL) { zend_hash_destroy(phalcon_globals_ptr->orm.ast_cache); FREE_HASHTABLE(phalcon_globals_ptr->orm.ast_cache); phalcon_globals_ptr->orm.ast_cache = NULL; } }
void ion_http_message_free(zend_object * object) { zend_object_std_dtor(object); ion_http_message * message = ION_ZOBJ_OBJECT(object, ion_http_message); zend_hash_clean(message->headers); zend_hash_destroy(message->headers); FREE_HASHTABLE(message->headers); if(message->uri) { ion_object_release(message->uri); } if(message->reason) { zend_string_release(message->reason); } if(message->version) { zend_string_release(message->version); } if(message->body) { zend_string_release(message->body); } if(message->method) { zend_string_release(message->method); } if(message->target) { zend_string_release(message->target); } }
int luasandbox_timer_enable_profiler(luasandbox_timer_set * lts, struct timespec * period) { if (lts->profiler_running) { luasandbox_timer_stop_one(lts->profiler_timer, NULL); lts->profiler_running = 0; } lts->profiler_period = *period; if (lts->function_counts) { zend_hash_destroy(lts->function_counts); FREE_HASHTABLE(lts->function_counts); lts->function_counts = NULL; } lts->total_count = 0; lts->overrun_count = 0; if (period->tv_sec || period->tv_nsec) { ALLOC_HASHTABLE(lts->function_counts); zend_hash_init(lts->function_counts, 0, NULL, NULL, 0); luasandbox_timer * timer = luasandbox_timer_create_one( lts->sandbox, LUASANDBOX_TIMER_PROFILER); if (!timer) { return 0; } lts->profiler_running = 1; lts->profiler_timer = timer; luasandbox_timer_set_periodic(timer, <s->profiler_period); } return 1; }
static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* {{{ */ { switch (Z_TYPE_P(expr)) { case IS_ARRAY: smart_str_appends(buf, "Array\n"); if (Z_REFCOUNTED_P(expr)) { if (Z_IS_RECURSIVE_P(expr)) { smart_str_appends(buf, " *RECURSION*"); return; } Z_PROTECT_RECURSION_P(expr); } print_hash(buf, Z_ARRVAL_P(expr), indent, 0); if (Z_REFCOUNTED_P(expr)) { Z_UNPROTECT_RECURSION_P(expr); } break; case IS_OBJECT: { HashTable *properties; int is_temp; zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr)); smart_str_appends(buf, ZSTR_VAL(class_name)); zend_string_release(class_name); smart_str_appends(buf, " Object\n"); if (Z_IS_RECURSIVE_P(expr)) { smart_str_appends(buf, " *RECURSION*"); return; } if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) { break; } Z_PROTECT_RECURSION_P(expr); print_hash(buf, properties, indent, 1); Z_UNPROTECT_RECURSION_P(expr); if (is_temp) { zend_hash_destroy(properties); FREE_HASHTABLE(properties); } break; } case IS_LONG: smart_str_append_long(buf, Z_LVAL_P(expr)); break; case IS_REFERENCE: zend_print_zval_r_to_buf(buf, Z_REFVAL_P(expr), indent); break; default: { zend_string *str = zval_get_string(expr); smart_str_append(buf, str); zend_string_release(str); } break; } }
static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* {{{ */ { ZVAL_DEREF(expr); switch (Z_TYPE_P(expr)) { case IS_ARRAY: smart_str_appends(buf, "Array\n"); if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) && ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) { smart_str_appends(buf, " *RECURSION*"); Z_ARRVAL_P(expr)->u.v.nApplyCount--; return; } print_hash(buf, Z_ARRVAL_P(expr), indent, 0); if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) { Z_ARRVAL_P(expr)->u.v.nApplyCount--; } break; case IS_OBJECT: { HashTable *properties; int is_temp; zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr)); smart_str_appends(buf, ZSTR_VAL(class_name)); zend_string_release(class_name); smart_str_appends(buf, " Object\n"); if (Z_OBJ_APPLY_COUNT_P(expr) > 0) { smart_str_appends(buf, " *RECURSION*"); return; } if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) { break; } Z_OBJ_INC_APPLY_COUNT_P(expr); print_hash(buf, properties, indent, 1); Z_OBJ_DEC_APPLY_COUNT_P(expr); if (is_temp) { zend_hash_destroy(properties); FREE_HASHTABLE(properties); } break; } case IS_LONG: smart_str_append_long(buf, Z_LVAL_P(expr)); break; default: { zend_string *str = zval_get_string(expr); smart_str_append(buf, str); zend_string_release(str); } break; } }
void msgpack_serialize_var_destroy(msgpack_serialize_data_t *var_hash) { HashTable **var_hash_ptr = (HashTable **)var_hash; TSRMLS_FETCH(); --MSGPACK_G(serialize).level; if (!MSGPACK_G(serialize).level) { zend_hash_destroy(*var_hash_ptr); FREE_HASHTABLE(*var_hash_ptr); } }
/** * Destroys the active session * *<code> * var_dump($session->destroy()); * var_dump($session->destroy(true)); *</code> */ PHP_METHOD(Phalcon_Session_Adapter, destroy) { HashTable *_2$$4; HashPosition _1$$4; int ZEPHIR_LAST_CALL_STATUS; zval *removeData_param = NULL, *_SESSION = NULL, *uniqueId = NULL, *key = NULL, *_0$$4 = NULL, **_3$$4, *_4$$5 = NULL; zend_bool removeData; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &removeData_param); if (!removeData_param) { removeData = 0; } else { removeData = zephir_get_boolval(removeData_param); } if (removeData) { ZEPHIR_OBS_VAR(uniqueId); zephir_read_property_this(&uniqueId, this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(_0$$4); zephir_is_iterable(_SESSION, &_2$$4, &_1$$4, 1, 0, "phalcon/session/adapter.zep", 262); for ( ; zephir_hash_get_current_data_ex(_2$$4, (void**) &_3$$4, &_1$$4) == SUCCESS ; zephir_hash_move_forward_ex(_2$$4, &_1$$4) ) { ZEPHIR_GET_HMKEY(key, _2$$4, _1$$4); ZEPHIR_GET_HVALUE(_0$$4, _3$$4); ZEPHIR_INIT_LNVAR(_4$$5); ZEPHIR_CONCAT_VS(_4$$5, uniqueId, "#"); if (zephir_start_with(key, _4$$5, NULL)) { zephir_array_unset(&_SESSION, key, PH_SEPARATE); } } zend_hash_destroy(_2$$4); FREE_HASHTABLE(_2$$4); } else { ZEPHIR_INIT_NVAR(_SESSION); array_init(_SESSION); } } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_RETURN_CALL_FUNCTION("session_destroy", NULL, 32); zephir_check_call_status(); RETURN_MM(); }
/** * {@inheritdoc} */ PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, destroy) { HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *sessionId_param = NULL, *_SESSION, *id = NULL, *key = NULL, *_0 = NULL, **_3, *_4 = NULL, *_5, *_6 = NULL, *_7; zval *sessionId = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &sessionId_param); if (!sessionId_param) { ZEPHIR_INIT_VAR(sessionId); ZVAL_EMPTY_STRING(sessionId); } else { zephir_get_strval(sessionId, sessionId_param); } if (ZEPHIR_IS_STRING_IDENTICAL(sessionId, "")) { ZEPHIR_CALL_METHOD(&id, this_ptr, "getid", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(id, sessionId); } ZEPHIR_INIT_VAR(_0); zephir_is_iterable(_SESSION, &_2, &_1, 1, 0, "phalcon/session/adapter/libmemcached.zep", 168); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); zephir_array_unset(&_SESSION, key, PH_SEPARATE); } zend_hash_destroy(_2); FREE_HASHTABLE(_2); ZEPHIR_INIT_VAR(_4); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _5, "exists", NULL, 0, id); zephir_check_call_status(); if (zephir_is_true(_6)) { _7 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_4, _7, "delete", NULL, 0, id); zephir_check_call_status(); } else { ZVAL_BOOL(_4, 1); } RETURN_CCTOR(_4); }
/** * Used for closedir($fp) where $fp is an opendir('phar://...') directory handle */ static int phar_dir_close(php_stream *stream, int close_handle) /* {{{ */ { HashTable *data = (HashTable *)stream->abstract; if (data && HT_FLAGS(data)) { zend_hash_destroy(data); HT_FLAGS(data) = 0; FREE_HASHTABLE(data); stream->abstract = NULL; } return 0; }
/** * 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; }
void luasandbox_timer_destroy(luasandbox_timer_set * lts) { luasandbox_timer_stop(lts); if (lts->profiler_running) { luasandbox_timer_stop_one(lts->profiler_timer, NULL); lts->profiler_running = 0; } if (lts->function_counts) { zend_hash_destroy(lts->function_counts); FREE_HASHTABLE(lts->function_counts); lts->function_counts = NULL; } }
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */ { ZVAL_DEREF(expr); switch (Z_TYPE_P(expr)) { case IS_ARRAY: ZEND_PUTS_EX("Array\n"); if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) && ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) { ZEND_PUTS_EX(" *RECURSION*"); Z_ARRVAL_P(expr)->u.v.nApplyCount--; return; } print_hash(write_func, Z_ARRVAL_P(expr), indent, 0); if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) { Z_ARRVAL_P(expr)->u.v.nApplyCount--; } break; case IS_OBJECT: { HashTable *properties; int is_temp; zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr)); ZEND_PUTS_EX(ZSTR_VAL(class_name)); zend_string_release(class_name); ZEND_PUTS_EX(" Object\n"); if (Z_OBJ_APPLY_COUNT_P(expr) > 0) { ZEND_PUTS_EX(" *RECURSION*"); return; } if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) { break; } Z_OBJ_INC_APPLY_COUNT_P(expr); print_hash(write_func, properties, indent, 1); Z_OBJ_DEC_APPLY_COUNT_P(expr); if (is_temp) { zend_hash_destroy(properties); FREE_HASHTABLE(properties); } break; } default: zend_print_zval_ex(write_func, expr, indent); break; } }
static void zend_accel_destroy_zend_function(zval *zv) { zend_function *function = Z_PTR_P(zv); TSRMLS_FETCH(); if (function->type == ZEND_USER_FUNCTION) { if (function->op_array.static_variables) { FREE_HASHTABLE(function->op_array.static_variables); function->op_array.static_variables = NULL; } } destroy_zend_function(function TSRMLS_CC); }
static PHP_RSHUTDOWN_FUNCTION(phalcon){ if (PHALCON_GLOBAL(start_memory) != NULL) { phalcon_clean_restore_stack(TSRMLS_C); } if (PHALCON_GLOBAL(function_cache) != NULL) { zend_hash_destroy(PHALCON_GLOBAL(function_cache)); FREE_HASHTABLE(PHALCON_GLOBAL(function_cache)); PHALCON_GLOBAL(function_cache) = NULL; } phalcon_orm_destroy_cache(TSRMLS_C); return SUCCESS; }
static void zend_accel_destroy_zend_function(zval *zv) { zend_function *function = Z_PTR_P(zv); if (function->type == ZEND_USER_FUNCTION) { if (function->op_array.static_variables) { if (!(GC_FLAGS(function->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) { if (--GC_REFCOUNT(function->op_array.static_variables) == 0) { FREE_HASHTABLE(function->op_array.static_variables); } } function->op_array.static_variables = NULL; } } destroy_zend_function(function); }
SharedStringList KPHPArrayObject::GetPropertyNames() { SharedStringList property_names = new StringList(); HashPosition pos; HashTable *ht = Z_ARRVAL_P(this->list); for (zend_hash_internal_pointer_reset_ex(ht, &pos); zend_hash_has_more_elements_ex(ht, &pos) == SUCCESS; zend_hash_move_forward_ex(ht, &pos)) { char *key; unsigned int keylen; unsigned long index; zend_hash_get_current_key_ex(ht, &key, &keylen, &index, 0, &pos); property_names->push_back(new std::string(key)); } zend_hash_destroy(ht); FREE_HASHTABLE(ht); return property_names; }
/** * We have to cast values manually because parse_ini_file() has a poor implementation. * * @param mixed ini The array casted by `parse_ini_file` */ PHP_METHOD(Phalcon_Config_Adapter_Ini, _cast) { zend_bool _5$$5, _6$$5, _8$$5, _9$$5; HashTable *_1$$3; HashPosition _0$$3; zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *ini, *key = NULL, *val = NULL, **_2$$3, *_3$$4 = NULL, *_7$$5, *_10$$5, *_11$$9, *_12$$9, _13$$9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &ini); ZEPHIR_SEPARATE_PARAM(ini); if (Z_TYPE_P(ini) == IS_ARRAY) { zephir_is_iterable(ini, &_1$$3, &_0$$3, 1, 0, "phalcon/config/adapter/ini.zep", 134); for ( ; zephir_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zephir_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HMKEY(key, _1$$3, _0$$3); ZEPHIR_GET_HVALUE(val, _2$$3); ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "_cast", &_4, 135, val); zephir_check_call_status(); zephir_array_update_zval(&ini, key, &_3$$4, PH_COPY | PH_SEPARATE); } zend_hash_destroy(_1$$3); FREE_HASHTABLE(_1$$3); } if (Z_TYPE_P(ini) == IS_STRING) { _5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "true"); if (!(_5$$5)) { _5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "yes"); } _6$$5 = _5$$5; if (!(_6$$5)) { ZEPHIR_INIT_VAR(_7$$5); zephir_fast_strtolower(_7$$5, ini); _6$$5 = ZEPHIR_IS_STRING_IDENTICAL(_7$$5, "on"); } if (_6$$5) { RETURN_MM_BOOL(1); } _8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "false"); if (!(_8$$5)) { _8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "no"); } _9$$5 = _8$$5; if (!(_9$$5)) { ZEPHIR_INIT_VAR(_10$$5); zephir_fast_strtolower(_10$$5, ini); _9$$5 = ZEPHIR_IS_STRING_IDENTICAL(_10$$5, "off"); } if (_9$$5) { RETURN_MM_BOOL(0); } if (ZEPHIR_IS_STRING_IDENTICAL(ini, "null")) { RETURN_MM_NULL(); } if (zephir_is_numeric(ini)) { ZEPHIR_INIT_VAR(_11$$9); ZEPHIR_INIT_VAR(_12$$9); ZEPHIR_SINIT_VAR(_13$$9); ZVAL_STRING(&_13$$9, "/[.]+/", 0); zephir_preg_match(_12$$9, &_13$$9, ini, _11$$9, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_12$$9)) { RETURN_MM_DOUBLE(zephir_get_doubleval(ini)); } else { RETURN_MM_LONG(zephir_get_intval(ini)); } } } RETVAL_ZVAL(ini, 1, 0); RETURN_MM(); }
PHP_METHOD(air_view, render){ AIR_INIT_THIS; char *tpl_str; int tpl_len = 0; zend_bool ret_res = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &tpl_str, &tpl_len, &ret_res) == FAILURE) { RETURN_FALSE; } smart_str ss_path = {0}; if(tpl_str[0] != '/'){ zval *root_path = NULL; MAKE_STD_ZVAL(root_path); if(zend_get_constant(ZEND_STRL("ROOT_PATH"), root_path) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "ROOT_PATH not defined"); } smart_str_appendl(&ss_path, Z_STRVAL_P(root_path), Z_STRLEN_P(root_path)); smart_str_appendc(&ss_path, '/'); if(root_path != NULL){ zval_ptr_dtor(&root_path); } zval *tmp = NULL; zval **tmp_pp; zval *config = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_config"), 0 TSRMLS_CC); if(config != NULL && Z_TYPE_P(config) == IS_ARRAY && zend_hash_find(Z_ARRVAL_P(config), ZEND_STRL("path"), (void **)&tmp_pp) == SUCCESS){ smart_str_appendl(&ss_path, Z_STRVAL_PP(tmp_pp), Z_STRLEN_PP(tmp_pp)); }else{ zval *app_conf; zval *view_conf; if(air_config_get(NULL, ZEND_STRS("app"), &app_conf TSRMLS_CC) == FAILURE){ AIR_NEW_EXCEPTION(1, "@error config: app"); } zval *app_path = NULL; if(air_config_get(app_conf, ZEND_STRS("path"), &app_path) == FAILURE){ AIR_NEW_EXCEPTION(1, "@error config: app.path"); } zval *view_path = NULL; if(air_config_get_path(app_conf, ZEND_STRS("view.path"), &view_path) == FAILURE){ AIR_NEW_EXCEPTION(1, "@view config not found"); } smart_str_appendl(&ss_path, Z_STRVAL_P(app_path), Z_STRLEN_P(app_path)); smart_str_appendc(&ss_path, '/'); smart_str_appendl(&ss_path, Z_STRVAL_P(view_path), Z_STRLEN_P(view_path)); } smart_str_appendc(&ss_path, '/'); } smart_str_appendl(&ss_path, tpl_str, tpl_len); smart_str_0(&ss_path); //php_printf("full view path: %s\n", ss_path.c); //构造运行时所需基本变量 HashTable *origin_symbol_table = NULL; zval *output_handler = NULL; long chunk_size = 0; long flags = PHP_OUTPUT_HANDLER_STDFLAGS; zval *view_ret = NULL; //尝试缓存当前符号表 if(EG(active_symbol_table)){ origin_symbol_table = EG(active_symbol_table); } if (ret_res) { MAKE_STD_ZVAL(view_ret); if(php_output_start_user(output_handler, chunk_size, flags TSRMLS_CC) == FAILURE) { php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to create buffer"); RETURN_FALSE; } } ALLOC_HASHTABLE(EG(active_symbol_table)); zval *data = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_data"), 0 TSRMLS_CC); zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); //将当前的模板变量放到符号表去 ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), "var", 4, data, Z_REFCOUNT_P(data) + 1, PZVAL_IS_REF(data)); if(air_loader_include_file(ss_path.c TSRMLS_CC) == FAILURE){ air_throw_exception_ex(1, "tpl %s render failed!\n", ss_path.c); return ; } if(ret_res){ php_output_get_contents(view_ret TSRMLS_CC); php_output_discard(TSRMLS_C); RETVAL_ZVAL(view_ret, 1, 0); zval_ptr_dtor(&view_ret); } zend_hash_destroy(EG(active_symbol_table)); FREE_HASHTABLE(EG(active_symbol_table)); EG(active_symbol_table) = origin_symbol_table; smart_str_free(&ss_path); }
int msgpack_convert_object(zval *return_value, zval *tpl, zval **value) { zend_class_entry *ce, **pce; TSRMLS_FETCH(); switch (Z_TYPE_P(tpl)) { case IS_STRING: if (zend_lookup_class( Z_STRVAL_P(tpl), Z_STRLEN_P(tpl), &pce TSRMLS_CC) != SUCCESS) { MSGPACK_ERROR("[msgpack] (%s) Class '%s' not found", __FUNCTION__, Z_STRVAL_P(tpl)); return FAILURE; } ce = *pce; break; case IS_OBJECT: ce = zend_get_class_entry(tpl TSRMLS_CC); break; default: MSGPACK_ERROR("[msgpack] (%s) object type is unsupported", __FUNCTION__); return FAILURE; } if (Z_TYPE_PP(value) == IS_OBJECT) { zend_class_entry *vce; vce = zend_get_class_entry(*value TSRMLS_CC); if (strcmp(ce->name, vce->name) == 0) { *return_value = **value; zval_copy_ctor(return_value); zval_ptr_dtor(value); return SUCCESS; } } object_init_ex(return_value, ce); /* Run the constructor if there is one */ if (ce->constructor && (ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { zval *retval_ptr = NULL; zval ***params = NULL; int num_args = 0; zend_fcall_info fci; zend_fcall_info_cache fcc; #if ZEND_MODULE_API_NO >= 20090626 fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; fci.symbol_table = NULL; fci.object_ptr = return_value; fci.retval_ptr_ptr = &retval_ptr; fci.param_count = num_args; fci.params = params; fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object_ptr = return_value; #else fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; fci.symbol_table = NULL; fci.object_pp = &return_value; fci.retval_ptr_ptr = &retval_ptr; fci.param_count = num_args; fci.params = params; fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.object_pp = &return_value; #endif if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { if (params) { efree(params); } if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } MSGPACK_WARNING( "[msgpack] (%s) Invocation of %s's constructor failed", __FUNCTION__, ce->name); return FAILURE; } if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } if (params) { efree(params); } } switch (Z_TYPE_PP(value)) { case IS_ARRAY: { char *key; uint key_len; int key_type; ulong key_index; zval **data; HashPosition pos; HashTable *ht, *ret; HashTable *var = NULL; int num; ht = HASH_OF(*value); ret = HASH_OF(return_value); num = zend_hash_num_elements(ht); if (num <= 0) { zval_ptr_dtor(value); break; } /* string - php_only mode? */ if (ht->nNumOfElements != ht->nNextFreeElement || ht->nNumOfElements != ret->nNumOfElements) { HashTable *properties = NULL; HashPosition prop_pos; ALLOC_HASHTABLE(var); zend_hash_init(var, num, NULL, NULL, 0); zend_hash_internal_pointer_reset_ex(ht, &pos); for (;; zend_hash_move_forward_ex(ht, &pos)) { key_type = zend_hash_get_current_key_ex( ht, &key, &key_len, &key_index, 0, &pos); if (key_type == HASH_KEY_NON_EXISTANT) { break; } if (zend_hash_get_current_data_ex( ht, (void *)&data, &pos) != SUCCESS) { continue; } if (key_type == HASH_KEY_IS_STRING) { zval *val; MSGPACK_CONVERT_COPY_ZVAL(val, data); if (msgpack_convert_string_to_properties( return_value, key, key_len, val, var) != SUCCESS) { zval_ptr_dtor(&val); MSGPACK_WARNING( "[msgpack] (%s) " "illegal offset type, skip this decoding", __FUNCTION__); } } } /* index */ properties = Z_OBJ_HT_P(return_value)->get_properties( return_value TSRMLS_CC); if (HASH_OF(tpl)) { properties = HASH_OF(tpl); } zend_hash_internal_pointer_reset_ex(properties, &prop_pos); zend_hash_internal_pointer_reset_ex(ht, &pos); for (;; zend_hash_move_forward_ex(ht, &pos)) { key_type = zend_hash_get_current_key_ex( ht, &key, &key_len, &key_index, 0, &pos); if (key_type == HASH_KEY_NON_EXISTANT) { break; } if (zend_hash_get_current_data_ex( ht, (void *)&data, &pos) != SUCCESS) { continue; } switch (key_type) { case HASH_KEY_IS_LONG: { zval *val; MSGPACK_CONVERT_COPY_ZVAL(val, data); if (msgpack_convert_long_to_properties( ret, &properties, &prop_pos, key_index, val, var) != SUCCESS) { zval_ptr_dtor(&val); MSGPACK_WARNING( "[msgpack] (%s) " "illegal offset type, skip this decoding", __FUNCTION__); } break; } case HASH_KEY_IS_STRING: break; default: MSGPACK_WARNING( "[msgpack] (%s) key is not string nor array", __FUNCTION__); break; } } zend_hash_destroy(var); FREE_HASHTABLE(var); } else { HashPosition valpos; int (*convert_function)(zval *, zval *, zval **) = NULL; zval **arydata, *aryval; /* index */ zend_hash_internal_pointer_reset_ex(ret, &pos); zend_hash_internal_pointer_reset_ex(ht, &valpos); for (;; zend_hash_move_forward_ex(ret, &pos), zend_hash_move_forward_ex(ht, &valpos)) { key_type = zend_hash_get_current_key_ex( ret, &key, &key_len, &key_index, 0, &pos); if (key_type == HASH_KEY_NON_EXISTANT) { break; } if (zend_hash_get_current_data_ex( ret, (void *)&data, &pos) != SUCCESS) { continue; } switch (Z_TYPE_PP(data)) { case IS_ARRAY: convert_function = msgpack_convert_array; break; case IS_OBJECT: //case IS_STRING: -- may have default values of // class members, so it's not wise to allow convert_function = msgpack_convert_object; break; default: break; } if (zend_hash_get_current_data_ex( ht, (void *)&arydata, &valpos) != SUCCESS) { MSGPACK_WARNING( "[msgpack] (%s) can't get data value by index", __FUNCTION__); return FAILURE; } MSGPACK_CONVERT_COPY_ZVAL(aryval, arydata); if (convert_function) { zval *rv; ALLOC_INIT_ZVAL(rv); if (convert_function(rv, *data, &aryval) != SUCCESS) { zval_ptr_dtor(&aryval); MSGPACK_WARNING( "[msgpack] (%s) " "convert failure in convert_object", __FUNCTION__); return FAILURE; } zend_symtable_update( ret, key, key_len, &rv, sizeof(rv), NULL); } else { zend_symtable_update( ret, key, key_len, &aryval, sizeof(aryval), NULL); } } } zval_ptr_dtor(value); break; } default: { HashTable *properties = NULL; HashPosition prop_pos; properties = Z_OBJ_HT_P(return_value)->get_properties( return_value TSRMLS_CC); zend_hash_internal_pointer_reset_ex(properties, &prop_pos); if (msgpack_convert_long_to_properties( HASH_OF(return_value), &properties, &prop_pos, 0, *value, NULL) != SUCCESS) { MSGPACK_WARNING( "[msgpack] (%s) illegal offset type, skip this decoding", __FUNCTION__); } break; } } return SUCCESS; }
/** * Applies a format to a message before sending it to the log * * @param string $message * @param int $type * @param int $timestamp * @param array $context * * @return string */ PHP_METHOD(Phalcon_Logger_Formatter_Firephp, format) { HashTable *_7$$4; HashPosition _6$$4; zval *_18; zend_bool _11, _14; zend_long type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta = NULL, *body = NULL, *backtrace = NULL, *encoded = NULL, *len = NULL, *lastTrace = NULL, *_1 = NULL, *_2, *_3, *_9, *_10, *_12, *_13, *_15, *_0$$3 = NULL, *param$$4 = NULL, *backtraceItem$$4 = NULL, *key$$4 = NULL, **_8$$4, *_4$$5, *_5$$6, *_16$$11, *_17$$11; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message_param, &type_param, ×tamp_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); zephir_get_strval(message, _0$$3); } ZEPHIR_INIT_VAR(meta); zephir_create_array(meta, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, type); ZEPHIR_CALL_METHOD(&_1, this_ptr, "gettypestring", NULL, 0, _2); zephir_check_call_status(); zephir_array_update_string(&meta, SL("Type"), &_1, PH_COPY | PH_SEPARATE); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(param$$4); ZVAL_LONG(param$$4, 2); ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 165, param$$4); zephir_check_call_status(); ZEPHIR_MAKE_REF(backtrace); ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 183, backtrace); ZEPHIR_UNREF(backtrace); zephir_check_call_status(); if (zephir_array_isset_string(lastTrace, SS("file"))) { zephir_array_fetch_string(&_4$$5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 130 TSRMLS_CC); zephir_array_update_string(&meta, SL("File"), &_4$$5, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(lastTrace, SS("line"))) { zephir_array_fetch_string(&_5$$6, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 134 TSRMLS_CC); zephir_array_update_string(&meta, SL("Line"), &_5$$6, PH_COPY | PH_SEPARATE); } zephir_is_iterable(backtrace, &_7$$4, &_6$$4, 1, 0, "phalcon/logger/formatter/firephp.zep", 143); for ( ; zend_hash_get_current_data_ex(_7$$4, (void**) &_8$$4, &_6$$4) == SUCCESS ; zend_hash_move_forward_ex(_7$$4, &_6$$4) ) { ZEPHIR_GET_HMKEY(key$$4, _7$$4, _6$$4); ZEPHIR_GET_HVALUE(backtraceItem$$4, _8$$4); zephir_array_unset_string(&backtraceItem$$4, SS("object"), PH_SEPARATE); zephir_array_unset_string(&backtraceItem$$4, SS("args"), PH_SEPARATE); zephir_array_update_zval(&backtrace, key$$4, &backtraceItem$$4, PH_COPY | PH_SEPARATE); } zend_hash_destroy(_7$$4); FREE_HASHTABLE(_7$$4); } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (zephir_is_true(_9)) { zephir_array_update_string(&meta, SL("Label"), &message, PH_COPY | PH_SEPARATE); } _10 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _11 = !zephir_is_true(_10); if (_11) { _12 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _11 = !zephir_is_true(_12); } _13 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _14 = zephir_is_true(_13); if (_14) { _15 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _14 = !zephir_is_true(_15); } if (_11) { ZEPHIR_CPY_WRT(body, message); } else if (_14) { ZEPHIR_INIT_NVAR(body); ZVAL_STRING(body, "", 1); } else { ZEPHIR_INIT_NVAR(body); array_init(body); _16$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_16$$11)) { zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE); } _17$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (!(zephir_is_true(_17$$11))) { zephir_array_update_string(&body, SL("message"), &message, PH_COPY | PH_SEPARATE); } } ZEPHIR_INIT_VAR(_18); zephir_create_array(_18, 2, 0 TSRMLS_CC); zephir_array_fast_append(_18, meta); zephir_array_fast_append(_18, body); ZEPHIR_INIT_VAR(encoded); zephir_json_encode(encoded, &(encoded), _18, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(len); ZVAL_LONG(len, zephir_fast_strlen_ev(encoded)); ZEPHIR_CONCAT_VSVS(return_value, len, "|", encoded, "|"); RETURN_MM(); }
/** * Restore a memory stack applying GC to all observed variables */ static void zephir_memory_restore_stack_common(zend_zephir_globals_def *g) { size_t i; zephir_memory_entry *prev, *active_memory; zephir_symbol_table *active_symbol_table; zval *ptr; active_memory = g->active_memory; assert(active_memory != NULL); if (EXPECTED(!CG(unclean_shutdown))) { /* Clean active symbol table */ if (g->active_symbol_table) { active_symbol_table = g->active_symbol_table; if (active_symbol_table->scope == active_memory) { zend_hash_destroy(EG(current_execute_data)->symbol_table); FREE_HASHTABLE(EG(current_execute_data)->symbol_table); EG(current_execute_data)->symbol_table = active_symbol_table->symbol_table; g->active_symbol_table = active_symbol_table->prev; efree(active_symbol_table); } } /* Check for non freed hash key zvals, mark as null to avoid string freeing */ for (i = 0; i < active_memory->hash_pointer; ++i) { assert(active_memory->hash_addresses[i] != NULL); if (!Z_REFCOUNTED_P(active_memory->hash_addresses[i])) continue; if (Z_REFCOUNT_P(active_memory->hash_addresses[i]) <= 1) { ZVAL_NULL(active_memory->hash_addresses[i]); } else { zval_copy_ctor(active_memory->hash_addresses[i]); } } #ifndef ZEPHIR_RELEASE for (i = 0; i < active_memory->pointer; ++i) { if (active_memory->addresses[i] != NULL) { zval *var = active_memory->addresses[i]; if (Z_TYPE_P(var) > IS_CALLABLE) { fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]\n", __func__, (int)i, var, Z_TYPE_P(var), active_memory->func); } if (!Z_REFCOUNTED_P(var)) continue; if (Z_REFCOUNT_P(var) == 0) { fprintf(stderr, "%s: observed variable #%d (%p) has 0 references, type=%d [%s]\n", __func__, (int)i, var, Z_TYPE_P(var), active_memory->func); } else if (Z_REFCOUNT_P(var) >= 1000000) { fprintf(stderr, "%s: observed variable #%d (%p) has too many references (%u), type=%d [%s]\n", __func__, (int)i, var, Z_REFCOUNT_P(var), Z_TYPE_P(var), active_memory->func); } #if 0 /* Skip this check, PDO does return variables with is_ref = 1 and refcount = 1*/ else if (Z_REFCOUNT_PP(var) == 1 && Z_ISREF_PP(var)) { fprintf(stderr, "%s: observed variable #%d (%p) is a reference with reference count = 1, type=%d [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } #endif } } #endif /* Traverse all zvals allocated, reduce the reference counting or free them */ for (i = 0; i < active_memory->pointer; ++i) { ptr = active_memory->addresses[i]; if (EXPECTED(ptr != NULL)) { if (!Z_REFCOUNTED_P(ptr)) continue; if (Z_REFCOUNT_P(ptr) == 1) { zval_ptr_dtor(ptr); } else { Z_DELREF_P(ptr); } } } } #ifndef ZEPHIR_RELEASE active_memory->func = NULL; #endif prev = active_memory->prev; if (active_memory >= g->end_memory || active_memory < g->start_memory) { #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 0); #endif assert(prev != NULL); if (active_memory->hash_addresses != NULL) { efree(active_memory->hash_addresses); } if (active_memory->addresses != NULL) { efree(active_memory->addresses); } efree(g->active_memory); g->active_memory = prev; prev->next = NULL; } else { #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 1); #endif active_memory->pointer = 0; active_memory->hash_pointer = 0; g->active_memory = prev; } #ifndef ZEPHIR_RELEASE if (g->active_memory) { zephir_memory_entry *f = g->active_memory; if (f >= g->start_memory && f < g->end_memory - 1) { assert(f->permanent == 1); assert(f->next != NULL); if (f > g->start_memory) { assert(f->prev != NULL); } } } #endif }
/** * Unregisters one or all listeners for an event. * * @param string|\Xpl\Event\Event event Event ID or object. * @param callable callback [Optional] Callback to remove. If no callback is given, * then all of the event's listeners are removed. * @return \Xpl\Event\Manager * * @throws \InvalidArgumentException if event is not a string or Event instance. */ PHP_METHOD(Xpl_Event_Manager, off) { HashTable *_6$$8; HashPosition _5$$8; int ZEPHIR_LAST_CALL_STATUS; zval *event, *callback = NULL, *id = NULL, *listeners = NULL, *_4, *_0$$4, *_1$$5, *_2$$5, *_3$$5, *i$$8 = NULL, *listener$$8 = NULL, **_7$$8, *_8$$9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &event, &callback); if (!callback) { callback = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(event) == IS_STRING) { ZEPHIR_CPY_WRT(id, event); } else if (zephir_instance_of_ev(event, xpl_event_event_ce TSRMLS_CC)) { ZEPHIR_OBS_VAR(_0$$4); zephir_read_property(&_0$$4, event, SL("id"), PH_NOISY_CC); ZEPHIR_CPY_WRT(id, _0$$4); } else { ZEPHIR_INIT_VAR(_1$$5); object_init_ex(_1$$5, spl_ce_InvalidArgumentException); ZEPHIR_INIT_VAR(_2$$5); zephir_gettype(_2$$5, event TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$5); ZEPHIR_CONCAT_SV(_3$$5, "Event must be string or instance of Event, given: ", _2$$5); ZEPHIR_CALL_METHOD(NULL, _1$$5, "__construct", NULL, 5, _3$$5); zephir_check_call_status(); zephir_throw_exception_debug(_1$$5, "xpl/event/manager.zep", 118 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(listeners); _4 = zephir_fetch_nproperty_this(this_ptr, SL("listeners"), PH_NOISY_CC); if (zephir_array_isset_fetch(&listeners, _4, id, 0 TSRMLS_CC)) { if (Z_TYPE_P(callback) == IS_NULL) { zephir_array_unset(&listeners, id, PH_SEPARATE); } else { zephir_is_iterable(listeners, &_6$$8, &_5$$8, 1, 0, "xpl/event/manager.zep", 137); for ( ; zephir_hash_get_current_data_ex(_6$$8, (void**) &_7$$8, &_5$$8) == SUCCESS ; zephir_hash_move_forward_ex(_6$$8, &_5$$8) ) { ZEPHIR_GET_HMKEY(i$$8, _6$$8, _5$$8); ZEPHIR_GET_HVALUE(listener$$8, _7$$8); ZEPHIR_OBS_NVAR(_8$$9); zephir_read_property(&_8$$9, listener$$8, SL("callback"), PH_NOISY_CC); if (ZEPHIR_IS_EQUAL(callback, _8$$9)) { zephir_array_unset(&listeners, i$$8, PH_SEPARATE); } } zend_hash_destroy(_6$$8); FREE_HASHTABLE(_6$$8); } zephir_update_property_array(this_ptr, SL("listeners"), id, listeners TSRMLS_CC); } RETURN_THIS(); }
static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp) /* {{{ */ { xmlDocPtr newdocp = NULL; xmlDocPtr doc = NULL; xmlNodePtr node = NULL; xsltTransformContextPtr ctxt; php_libxml_node_object *object; char **params = NULL; int clone; zval *doXInclude, member, rv; zend_object_handlers *std_hnd; FILE *f; int secPrefsError = 0; int secPrefsValue; xsltSecurityPrefsPtr secPrefs = NULL; node = php_libxml_import_node(docp); if (node) { doc = node->doc; } if (doc == NULL) { php_error_docref(NULL, E_WARNING, "Invalid Document"); return NULL; } if (style == NULL) { php_error_docref(NULL, E_WARNING, "No stylesheet associated to this object"); return NULL; } if (intern->profiling) { if (php_check_open_basedir(intern->profiling)) { f = NULL; } else { f = VCWD_FOPEN(intern->profiling, "w"); } } else { f = NULL; } if (intern->parameter) { params = php_xsl_xslt_make_params(intern->parameter, 0); } intern->doc = emalloc(sizeof(php_libxml_node_object)); memset(intern->doc, 0, sizeof(php_libxml_node_object)); if (intern->hasKeys == 1) { doc = xmlCopyDoc(doc, 1); } else { object = Z_LIBXML_NODE_P(docp); intern->doc->document = object->document; } php_libxml_increment_doc_ref(intern->doc, doc); ctxt = xsltNewTransformContext(style, doc); ctxt->_private = (void *) intern; std_hnd = zend_get_std_object_handlers(); ZVAL_STRING(&member, "doXInclude"); doXInclude = std_hnd->read_property(id, &member, BP_VAR_IS, NULL, &rv); if (Z_TYPE_P(doXInclude) != IS_NULL) { convert_to_long(doXInclude); ctxt->xinclude = Z_LVAL_P(doXInclude); } zval_ptr_dtor(&member); secPrefsValue = intern->securityPrefs; /* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... */ if (secPrefsValue != XSL_SECPREF_NONE) { secPrefs = xsltNewSecurityPrefs(); if (secPrefsValue & XSL_SECPREF_READ_FILE ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_WRITE_FILE ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_CREATE_DIRECTORY ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_READ_NETWORK) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_WRITE_NETWORK) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) { secPrefsError = 1; } } if (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) { secPrefsError = 1; } } if (secPrefsError == 1) { php_error_docref(NULL, E_WARNING, "Can't set libxslt security properties, not doing transformation for security reasons"); } else { newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params, NULL, f, ctxt); } if (f) { fclose(f); } xsltFreeTransformContext(ctxt); if (secPrefs) { xsltFreeSecurityPrefs(secPrefs); } if (intern->node_list != NULL) { zend_hash_destroy(intern->node_list); FREE_HASHTABLE(intern->node_list); intern->node_list = NULL; } php_libxml_decrement_doc_ref(intern->doc); efree(intern->doc); intern->doc = NULL; if (params) { clone = 0; while(params[clone]) { efree(params[clone++]); } efree(params); } return newdocp; }
/* {{{ get_debug_info handler for Calendar */ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) { zval zv, zfields; Calendar_object *co; const Calendar *cal; HashTable *debug_info; *is_temp = 1; ALLOC_HASHTABLE(debug_info); zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); co = Z_INTL_CALENDAR_P(object); cal = co->ucal; if (cal == NULL) { ZVAL_FALSE(&zv); zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); return debug_info; } ZVAL_TRUE(&zv); zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); ZVAL_STRING(&zv, const_cast<char*>(cal->getType())); zend_hash_str_update(debug_info, "type", sizeof("type") - 1, &zv); { zval ztz, ztz_debug; int is_tmp; HashTable *debug_info_tz; timezone_object_construct(&cal->getTimeZone(), &ztz , 0); debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp); assert(is_tmp == 1); array_init(&ztz_debug); zend_hash_copy(Z_ARRVAL(ztz_debug), debug_info_tz, zval_add_ref); zend_hash_destroy(debug_info_tz); FREE_HASHTABLE(debug_info_tz); zend_hash_str_update(debug_info, "timeZone", sizeof("timeZone") - 1, &ztz_debug); } { UErrorCode uec = U_ZERO_ERROR; Locale locale = cal->getLocale(ULOC_VALID_LOCALE, uec); if (U_SUCCESS(uec)) { ZVAL_STRING(&zv, const_cast<char*>(locale.getName())); zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv); } else { ZVAL_STRING(&zv, const_cast<char*>(u_errorName(uec))); zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv); } } array_init_size(&zfields, UCAL_FIELD_COUNT); for (int i = 0; i < sizeof(debug_info_fields) / sizeof(*debug_info_fields); i++) { UErrorCode uec = U_ZERO_ERROR; const char *name = debug_info_fields[i].name; int32_t res = cal->get(debug_info_fields[i].field, uec); if (U_SUCCESS(uec)) { add_assoc_long(&zfields, name, (zend_long)res); } else { add_assoc_string(&zfields, name, const_cast<char*>(u_errorName(uec))); } } zend_hash_str_update(debug_info, "fields", sizeof("fields") - 1, &zfields); return debug_info; }
PHPAPI void destroy_uploaded_files_hash(void) /* {{{ */ { zend_hash_apply(SG(rfc1867_uploaded_files), unlink_filename); zend_hash_destroy(SG(rfc1867_uploaded_files)); FREE_HASHTABLE(SG(rfc1867_uploaded_files)); }