1 --- php-5.2.11/main/php_ini.c 2009-09-24 22:48:12.128424374 +0300
2 +++ php-5.2.11/main/php_ini.c 2009-09-24 22:50:19.481745134 +0300
7 +static int php_csort(const struct dirent **a, const struct dirent **b)
9 + return strcmp((*a)->d_name,(*b)->d_name);
13 /* {{{ php_init_config
15 int php_init_config(TSRMLS_D)
20 + /* Search (global) php.ini file in search path */
21 + if (!fh.handle.fp) {
22 + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
24 + fh.filename = php_ini_opened_path;
25 + PG(safe_mode) = safe_mode_state;
26 + PG(open_basedir) = open_basedir;
27 + fh.type = ZEND_HANDLE_FP;
28 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
29 + safe_mode_state = PG(safe_mode);
30 + open_basedir = PG(open_basedir);
32 + PG(open_basedir) = NULL;
33 + fh.handle.fp = NULL;
34 + efree(php_ini_opened_path);
35 + fh.filename = php_ini_opened_path = NULL;
39 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
42 fh.filename = php_ini_opened_path;
46 - /* If still no ini file found, search for php.ini file in search path */
47 - if (!fh.handle.fp) {
48 - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
50 - fh.filename = php_ini_opened_path;
55 if (free_ini_search_path) {
57 /* Scan and parse any .ini files found in scan path if path not empty. */
58 if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
59 struct dirent **namelist;
61 + int ndir, i, found = 0;
62 + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
63 + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
64 + sprintf(sapi_scan_dir, fmt, sapi_module.name);
66 - if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
67 + if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_csort)) > 0) {
69 for (i = 0; i < ndir; i++) {
70 /* check for a .ini extension */
71 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
73 /* Here, add it to the list of ini files read */
76 + p = estrndup(ini_file, l);
77 + zend_llist_add_element(&scanned_ini_list, &p);
86 + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_csort)) > 0) {
89 + for (i = 0; i < ndir; i++) {
90 + /* check for a .ini extension */
91 + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
95 + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
96 + if (VCWD_STAT(ini_file, &sb) == 0) {
97 + if (S_ISREG(sb.st_mode)) {
98 + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
99 + fh.filename = ini_file;
100 + fh.type = ZEND_HANDLE_FP;
101 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
102 + /* Here, add it to the list of ini files read */
103 + l = strlen(ini_file);
105 p = estrndup(ini_file, l);
106 zend_llist_add_element(&scanned_ini_list, &p);
113 + efree(sapi_scan_dir);
118 * Don't need an extra byte for the \0 in this malloc as the last
119 * element will not get a trailing , which gives us the byte for the \0