1 --- php-5.2.7/main/php_ini.c 2008-08-14 19:34:30.000000000 +0300
2 +++ php-5.2.7-inidir/main/php_ini.c 2008-12-05 12:53:24.747685251 +0200
7 + /* Search (global) php.ini file in search path */
9 + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
11 + fh.filename = php_ini_opened_path;
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);
19 + PG(open_basedir) = NULL;
20 + fh.handle.fp = NULL;
21 + efree(php_ini_opened_path);
22 + fh.filename = php_ini_opened_path = NULL;
26 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
29 fh.filename = php_ini_opened_path;
33 - /* If still no ini file found, search for php.ini file in search path */
34 - if (!fh.handle.fp) {
35 - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
37 - fh.filename = php_ini_opened_path;
42 if (free_ini_search_path) {
44 /* Scan and parse any .ini files found in scan path if path not empty. */
45 if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
46 struct dirent **namelist;
48 + int ndir, i, found = 0;
49 + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
50 + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
51 + sprintf(sapi_scan_dir, fmt, sapi_module.name);
53 if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
55 for (i = 0; i < ndir; i++) {
56 /* check for a .ini extension */
57 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
59 /* Here, add it to the list of ini files read */
62 + p = estrndup(ini_file, l);
63 + zend_llist_add_element(&scanned_ini_list, &p);
72 + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
75 + for (i = 0; i < ndir; i++) {
76 + /* check for a .ini extension */
77 + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
81 + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
82 + if (VCWD_STAT(ini_file, &sb) == 0) {
83 + if (S_ISREG(sb.st_mode)) {
84 + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
85 + fh.filename = ini_file;
86 + fh.type = ZEND_HANDLE_FP;
87 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
88 + /* Here, add it to the list of ini files read */
89 + l = strlen(ini_file);
91 p = estrndup(ini_file, l);
92 zend_llist_add_element(&scanned_ini_list, &p);
99 + efree(sapi_scan_dir);
104 * Don't need an extra byte for the \0 in this malloc as the last
105 * element will not get a trailing , which gives us the byte for the \0