]>
Commit | Line | Data |
---|---|---|
38d9a36f ER |
1 | --- php-4.3.0/main/php_ini.c Sat Jan 4 12:22:39 2003 |
2 | +++ php-4.4.2/main/php_ini.c 2006-04-04 18:50:17.756460517 +0300 | |
bb44e93f | 3 | @@ -430,6 +430,24 @@ |
80259e0d JB |
4 | } |
5 | } | |
6 | } | |
7 | + /* Search (global) php.ini file in search path */ | |
8 | + if (!fh.handle.fp) { | |
9 | + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); | |
10 | + if (fh.handle.fp) { | |
11 | + fh.filename = php_ini_opened_path; | |
708beb0c JB |
12 | + PG(safe_mode) = safe_mode_state; |
13 | + PG(open_basedir) = open_basedir; | |
14 | + fh.type = ZEND_HANDLE_FP; | |
15 | + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists); | |
16 | + safe_mode_state = PG(safe_mode); | |
17 | + open_basedir = PG(open_basedir); | |
18 | + PG(safe_mode) = 0; | |
19 | + PG(open_basedir) = NULL; | |
20 | + fh.handle.fp = NULL; | |
bb44e93f JB |
21 | + efree(php_ini_opened_path); |
22 | + fh.filename = php_ini_opened_path = NULL; | |
80259e0d | 23 | + } |
80259e0d JB |
24 | + } |
25 | /* Search php-%sapi-module-name%.ini file in search path */ | |
26 | if (!fh.handle.fp) { | |
27 | const char *fmt = "php-%s.ini"; | |
38d9a36f | 28 | @@ -363,11 +379,4 @@ |
80259e0d | 29 | } |
bb44e93f | 30 | } |
80259e0d JB |
31 | - /* Search php.ini file in search path */ |
32 | - if (!fh.handle.fp) { | |
33 | - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); | |
34 | - if (fh.handle.fp) { | |
35 | - fh.filename = php_ini_opened_path; | |
36 | - } | |
bb44e93f | 37 | - } |
9d6174b1 | 38 | } |
80259e0d | 39 | if (free_ini_search_path) { |
38d9a36f ER |
40 | @@ -431,9 +440,13 @@ |
41 | * parse any .ini files found in this directory. */ | |
42 | if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) { | |
43 | struct dirent **namelist; | |
44 | - int ndir, i; | |
45 | + int ndir, i, found = 0; | |
46 | + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d"; | |
47 | + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name)); | |
48 | + sprintf(sapi_scan_dir, fmt, sapi_module.name); | |
49 | ||
50 | if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) { | |
51 | + found += ndir; | |
52 | for (i = 0; i < ndir; i++) { | |
53 | /* check for a .ini extension */ | |
54 | if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { | |
55 | @@ -458,7 +471,39 @@ | |
56 | free(namelist[i]); | |
57 | } | |
58 | free(namelist); | |
59 | + } | |
60 | + | |
61 | + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) { | |
62 | + found += ndir; | |
63 | + | |
64 | + for (i = 0; i < ndir; i++) { | |
65 | + /* check for a .ini extension */ | |
66 | + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { | |
67 | + free(namelist[i]); | |
68 | + continue; | |
69 | + } | |
70 | + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name); | |
71 | + if (VCWD_STAT(ini_file, &sb) == 0) { | |
72 | + if (S_ISREG(sb.st_mode)) { | |
73 | + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) { | |
74 | + fh.filename = ini_file; | |
75 | + fh.type = ZEND_HANDLE_FP; | |
76 | + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists); | |
77 | + /* Here, add it to the list of ini files read */ | |
78 | + l = strlen(ini_file); | |
79 | + total_l += l + 2; | |
80 | + p = estrndup(ini_file, l); | |
81 | + zend_llist_add_element(&scanned_ini_list, &p); | |
82 | + } | |
83 | + } | |
84 | + } | |
85 | + free(namelist[i]); | |
86 | + } | |
87 | + free(namelist); | |
88 | + } | |
89 | + efree(sapi_scan_dir); | |
90 | ||
91 | + if (found) { | |
92 | /* | |
93 | * Don't need an extra byte for the \0 in this malloc as the last | |
94 | * element will not get a trailing , which gives us the byte for the \0 |