1 --- php-5.3.0/main/php_ini.c 2009-07-06 17:36:45.529879052 +0200
2 +++ php-5.3.2/main/php_ini.c 2010-03-17 17:55:16.800313459 +0200
7 +static int php_csort(const struct dirent **a, const struct dirent **b)
9 + return strcmp((*a)->d_name,(*b)->d_name);
12 /* {{{ php_init_config
14 int php_init_config(TSRMLS_D)
19 + /* Search (global) php.ini file in search path */
20 + if (!fh.handle.fp) {
21 + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
23 + fh.filename = php_ini_opened_path;
24 + PG(safe_mode) = safe_mode_state;
25 + PG(open_basedir) = open_basedir;
26 + fh.type = ZEND_HANDLE_FP;
27 + zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
28 + safe_mode_state = PG(safe_mode);
29 + open_basedir = PG(open_basedir);
31 + PG(open_basedir) = NULL;
32 + fh.handle.fp = NULL;
33 + efree(php_ini_opened_path);
34 + fh.filename = php_ini_opened_path = NULL;
38 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
41 fh.filename = php_ini_opened_path;
45 - /* If still no ini file found, search for php.ini file in search path */
46 - if (!fh.handle.fp) {
47 - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
49 - fh.filename = php_ini_opened_path;
54 if (free_ini_search_path) {
56 zend_llist scanned_ini_list;
57 zend_llist_element *element;
59 + const char *fmt = "%s:" PHP_CONFIG_FILE_PATH "/%s.d";
61 /* List of found ini files */
62 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
64 /* Split by paths_separator and load ini-files from all paths */
65 - path_copy = estrdup(php_ini_scanned_path);
66 + path_copy = emalloc(strlen(php_ini_scanned_path) + strlen(fmt) + strlen(sapi_module.name));
67 + sprintf(path_copy, fmt, php_ini_scanned_path, sapi_module.name);
68 ini_path = php_strtok_r(path_copy, paths_separator, &last);
70 while (ini_path != NULL) {
72 struct dirent **namelist;
73 int ini_path_len = strlen(ini_path);
75 - if ((ndir = php_scandir(ini_path, &namelist, 0, php_alphasort)) > 0) {
76 + if ((ndir = php_scandir(ini_path, &namelist, 0, php_csort)) > 0) {
77 memset(&fh2, 0, sizeof(fh2));
79 for (i = 0; i < ndir; i++) {