diff options
Diffstat (limited to 'main/php_ini.c')
-rw-r--r-- | main/php_ini.c | 119 |
1 files changed, 53 insertions, 66 deletions
diff --git a/main/php_ini.c b/main/php_ini.c index d5d920a807..f6c2edf235 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -29,6 +29,7 @@ #include "php_scandir.h" #ifdef PHP_WIN32 #include "win32/php_registry.h" +#include "win32/winutil.h" #endif #if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H @@ -68,7 +69,7 @@ PHPAPI char *php_ini_scanned_files=NULL; /* {{{ php_ini_displayer_cb */ -static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) +static ZEND_COLD void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) { if (ini_entry->displayer) { ini_entry->displayer(ini_entry, type); @@ -114,69 +115,48 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) } /* }}} */ -/* {{{ php_ini_displayer - */ -static int php_ini_displayer(zval *el, void *arg) -{ - zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el); - int module_number = *(int *)arg; - - if (ini_entry->module_number != module_number) { - return 0; - } - if (!sapi_module.phpinfo_as_text) { - PUTS("<tr>"); - PUTS("<td class=\"e\">"); - PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name)); - PUTS("</td><td class=\"v\">"); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE); - PUTS("</td><td class=\"v\">"); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG); - PUTS("</td></tr>\n"); - } else { - PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name)); - PUTS(" => "); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE); - PUTS(" => "); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG); - PUTS("\n"); - } - return 0; -} -/* }}} */ - -/* {{{ php_ini_available - */ -static int php_ini_available(zval *el, void *arg) -{ - zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el); - int *module_number_available = (int *)arg; - if (ini_entry->module_number == *(int *)module_number_available) { - *(int *)module_number_available = -1; - return ZEND_HASH_APPLY_STOP; - } else { - return ZEND_HASH_APPLY_KEEP; - } -} -/* }}} */ - /* {{{ display_ini_entries */ -PHPAPI void display_ini_entries(zend_module_entry *module) +PHPAPI ZEND_COLD void display_ini_entries(zend_module_entry *module) { - int module_number, module_number_available; + int module_number; + zend_ini_entry *ini_entry; + zend_bool first = 1; if (module) { module_number = module->module_number; } else { module_number = 0; } - module_number_available = module_number; - zend_hash_apply_with_argument(EG(ini_directives), php_ini_available, &module_number_available); - if (module_number_available == -1) { - php_info_print_table_start(); - php_info_print_table_header(3, "Directive", "Local Value", "Master Value"); - zend_hash_apply_with_argument(EG(ini_directives), php_ini_displayer, (void *)&module_number); + + ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) { + if (ini_entry->module_number != module_number) { + continue; + } + if (first) { + php_info_print_table_start(); + php_info_print_table_header(3, "Directive", "Local Value", "Master Value"); + first = 0; + } + if (!sapi_module.phpinfo_as_text) { + PUTS("<tr>"); + PUTS("<td class=\"e\">"); + PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name)); + PUTS("</td><td class=\"v\">"); + php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE); + PUTS("</td><td class=\"v\">"); + php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG); + PUTS("</td></tr>\n"); + } else { + PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name)); + PUTS(" => "); + php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE); + PUTS(" => "); + php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG); + PUTS("\n"); + } + } ZEND_HASH_FOREACH_END(); + if (!first) { php_info_print_table_end(); } } @@ -359,6 +339,13 @@ static void php_load_zend_extension_cb(void *arg) #endif if (IS_ABSOLUTE_PATH(filename, length)) { +#ifdef PHP_WIN32 + char *err; + if (!php_win32_image_compatible(filename, NULL, &err)) { + php_error(E_CORE_WARNING, err); + return; + } +#endif zend_load_extension(filename); } else { DL_HANDLE handle; @@ -404,6 +391,16 @@ static void php_load_zend_extension_cb(void *arg) efree(err1); } +#ifdef PHP_WIN32 + if (!php_win32_image_compatible(libpath, NULL, &err1)) { + php_error(E_CORE_WARNING, err1); + efree(err1); + efree(libpath); + DL_UNLOAD(handle); + return; + } +#endif + zend_load_extension_handle(handle, libpath); efree(libpath); } @@ -966,13 +963,3 @@ PHPAPI HashTable* php_ini_get_configuration_hash(void) /* {{{ */ { return &configuration_hash; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ |