Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 577 lines (512 sloc) 15.62 kB
651e232 @zsuraski Testing 123
zsuraski authored
1 /*
2 +----------------------------------------------------------------------+
3893351 Update headers.
Sebastian Bergmann authored
3 | PHP Version 4 |
651e232 @zsuraski Testing 123
zsuraski authored
4 +----------------------------------------------------------------------+
2c5d4b8 Bump year.
Sebastian Bergmann authored
5 | Copyright (c) 1997-2003 The PHP Group |
651e232 @zsuraski Testing 123
zsuraski authored
6 +----------------------------------------------------------------------+
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
7 | This source file is subject to version 2.02 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
10 | http://www.php.net/license/2_02.txt. |
c5724cb @zsuraski License update
zsuraski authored
11 | If you did not receive a copy of the PHP license and are unable to |
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
651e232 @zsuraski Testing 123
zsuraski authored
14 +----------------------------------------------------------------------+
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
15 | Author: Zeev Suraski <zeev@zend.com> |
651e232 @zsuraski Testing 123
zsuraski authored
16 +----------------------------------------------------------------------+
17 */
18
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
19 /* $Id$ */
651e232 @zsuraski Testing 123
zsuraski authored
20
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
21 /* Check CWD for php.ini */
22 #define INI_CHECK_CWD
23
aceaabc @zsuraski PHP 4.0
zsuraski authored
24 #include "php.h"
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
25 #include "ext/standard/info.h"
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
26 #include "zend_ini.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
27 #include "php_ini.h"
28 #include "ext/standard/dl.h"
29 #include "zend_extensions.h"
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
30 #include "zend_highlight.h"
ab25640 Removed CWD from php_ini_search_path when using CLI SAPI.
Edin Kadribasic authored
31 #include "SAPI.h"
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
32 #include "php_main.h"
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
33 #include "php_scandir.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
34
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
35 #if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
36 #include <dirent.h>
82f6cef Fix broken build by adding scandir and alphasort for win32
Shane Caraveo authored
37 #endif
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
38
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
39 #ifndef S_ISREG
40 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
41 #endif
42
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
43 typedef struct _php_extension_lists {
42c82bb Revert the last patches.
foobar authored
44 zend_llist engine;
45 zend_llist functions;
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
46 } php_extension_lists;
58e24ac @zsuraski - Add PHP Modules workspace
zsuraski authored
47
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
48
49 /* True globals */
50 static HashTable configuration_hash;
51 PHPAPI char *php_ini_opened_path=NULL;
52 static php_extension_lists extension_lists;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
53 PHPAPI char *php_ini_scanned_files=NULL;
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
54
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
55 /* {{{ php_ini_displayer_cb
56 */
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
57 static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
58 {
42c82bb Revert the last patches.
foobar authored
59 if (ini_entry->displayer) {
60 ini_entry->displayer(ini_entry, type);
61 } else {
62 char *display_string;
63 uint display_string_length, esc_html=0;
64 TSRMLS_FETCH();
65
66 if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
67 if (ini_entry->orig_value && ini_entry->orig_value[0]) {
68 display_string = ini_entry->orig_value;
69 display_string_length = ini_entry->orig_value_length;
70 esc_html=1;
71 } else {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
72 if (PG(html_errors)) {
73 display_string = "<i>no value</i>";
74 display_string_length = sizeof("<i>no value</i>")-1;
75 } else {
76 display_string = "no value";
77 display_string_length = sizeof("no value")-1;
78 }
42c82bb Revert the last patches.
foobar authored
79 }
80 } else if (ini_entry->value && ini_entry->value[0]) {
81 display_string = ini_entry->value;
82 display_string_length = ini_entry->value_length;
83 esc_html=1;
84 } else {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
85 if (PG(html_errors)) {
86 display_string = "<i>no value</i>";
87 display_string_length = sizeof("<i>no value</i>")-1;
88 } else {
89 display_string = "no value";
90 display_string_length = sizeof("no value")-1;
91 }
42c82bb Revert the last patches.
foobar authored
92 }
93 if(esc_html) {
a769454 reenable php_html_puts
Sascha Schumann authored
94 php_html_puts(display_string, display_string_length TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
95 } else {
96 PHPWRITE(display_string, display_string_length);
97 }
98 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
99 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
100 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
101
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
102 /* {{{ php_ini_displayer
103 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
104 static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS_DC)
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
105 {
42c82bb Revert the last patches.
foobar authored
106 if (ini_entry->module_number != module_number) {
107 return 0;
108 }
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
109 if (PG(html_errors)) {
14a6cc8 Change phpinfo() to use CSS styling instead of HTML code.
Colin Viebrock authored
110 PUTS("<tr>");
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
111 PUTS("<td class=\"e\">");
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
112 PHPWRITE(ini_entry->name, ini_entry->name_length-1);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
113 PUTS("</td><td class=\"v\">");
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
114 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
115 PUTS("</td><td class=\"v\">");
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
116 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
117 PUTS("</td></tr>\n");
118 } else {
119 PHPWRITE(ini_entry->name, ini_entry->name_length-1);
120 PUTS(" => ");
121 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
122 PUTS(" => ");
123 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
124 PUTS("\n");
125 }
42c82bb Revert the last patches.
foobar authored
126 return 0;
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
127 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
128 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
129
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
130 /* {{{ display_ini_entries
131 */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
132 PHPAPI void display_ini_entries(zend_module_entry *module)
133 {
42c82bb Revert the last patches.
foobar authored
134 int module_number;
135 TSRMLS_FETCH();
136
137 if (module) {
138 module_number = module->module_number;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
139 } else {
42c82bb Revert the last patches.
foobar authored
140 module_number = 0;
141 }
142 php_info_print_table_start();
143 php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
2f4ed25 @zsuraski Compat fix
zsuraski authored
144 zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (long) module_number TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
145 php_info_print_table_end();
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
146 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
147 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
148
149 /* php.ini support */
150
151 #ifdef ZTS
152 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
153 # define ZEND_EXTENSION_TOKEN "zend_extension_debug_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
154 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
155 # define ZEND_EXTENSION_TOKEN "zend_extension_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
156 # endif
157 #else
158 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
159 # define ZEND_EXTENSION_TOKEN "zend_extension_debug"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
160 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
161 # define ZEND_EXTENSION_TOKEN "zend_extension"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
162 # endif
163 #endif
164
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
165 /* {{{ pvalue_config_destructor
166 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
167 static void pvalue_config_destructor(zval *pvalue)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
168 {
169 if (Z_TYPE_P(pvalue) == IS_STRING && Z_STRVAL_P(pvalue) != empty_string) {
170 free(Z_STRVAL_P(pvalue));
171 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
172 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
173 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
174
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
175 /* {{{ php_config_ini_parser_cb
176 */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
177 static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
178 {
42c82bb Revert the last patches.
foobar authored
179 switch (callback_type) {
180 case ZEND_INI_PARSER_ENTRY: {
181 zval *entry;
182
183 if (!arg2) {
184 break;
185 }
186 if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
187 zval copy;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
188
42c82bb Revert the last patches.
foobar authored
189 copy = *arg2;
190 zval_copy_ctor(&copy);
191 copy.refcount = 0;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
192 zend_llist_add_element(&extension_lists.functions, &copy);
42c82bb Revert the last patches.
foobar authored
193 } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
194 char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
195
42c82bb Revert the last patches.
foobar authored
196 zend_llist_add_element(&extension_lists.engine, &extension_name);
197 } else {
198 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
199 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
200 }
201 }
202 break;
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
203
204 case ZEND_INI_PARSER_POP_ENTRY: {
205 zval *hash;
206 zval **find_hash;
207 zval *element;
208
209 if (!arg2) {
210 /* bare string - nothing to do */
211 break;
212 }
213
214 if (zend_hash_find(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void **) &find_hash) == FAILURE) {
215 ALLOC_ZVAL(hash);
216 array_init(hash);
217
218 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &hash, sizeof(zval *), NULL);
219 } else {
220 hash = *find_hash;
221 }
222
223 ALLOC_ZVAL(element);
224 *element = *arg2;
225 zval_copy_ctor(element);
226 INIT_PZVAL(element);
227 add_next_index_zval(hash, element);
228 }
229 break;
230
42c82bb Revert the last patches.
foobar authored
231 case ZEND_INI_PARSER_SECTION:
232 break;
233 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
234 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
235 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
236
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
237 /* {{{ php_load_function_extension_cb
238 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
239 static void php_load_function_extension_cb(void *arg TSRMLS_DC)
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
240 {
42c82bb Revert the last patches.
foobar authored
241 zval *extension = (zval *) arg;
242 zval zval;
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
243
42c82bb Revert the last patches.
foobar authored
244 php_dl(extension, MODULE_PERSISTENT, &zval TSRMLS_CC);
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
245 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
246 /* }}} */
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
247
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
248 /* {{{ php_load_zend_extension_cb
249 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
250 static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
251 {
42c82bb Revert the last patches.
foobar authored
252 zend_load_extension(*((char **) arg));
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
253 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
254 /* }}} */
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
255
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
256 /* {{{ php_init_config
257 */
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
258 int php_init_config()
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
259 {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
260 char *env_location, *php_ini_search_path;
261 char *binary_location;
42c82bb Revert the last patches.
foobar authored
262 int safe_mode_state;
263 char *open_basedir;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
264 int free_ini_search_path=0;
42c82bb Revert the last patches.
foobar authored
265 zend_file_handle fh;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
266 struct stat sb;
267 char ini_file[MAXPATHLEN];
268 char *p;
269 zend_llist scanned_ini_list;
270 int l, total_l=0;
271 zend_llist_element *element;
42c82bb Revert the last patches.
foobar authored
272 TSRMLS_FETCH();
273
274 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
275 return FAILURE;
276 }
277
278 zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
279 zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
280 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
281
42c82bb Revert the last patches.
foobar authored
282 safe_mode_state = PG(safe_mode);
283 open_basedir = PG(open_basedir);
284
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
285 env_location = getenv("PHPRC");
286 if (!env_location) {
287 env_location="";
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
288 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
289 if (sapi_module.php_ini_path_override) {
290 php_ini_search_path = sapi_module.php_ini_path_override;
291 free_ini_search_path = 0;
292 } else {
293 char *default_location;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
294 static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
295
b9fd107 @zsuraski Use portable #define
zsuraski authored
296 php_ini_search_path = (char *) emalloc(MAXPATHLEN*3+strlen(env_location)+3+1);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
297 free_ini_search_path = 1;
298 php_ini_search_path[0] = 0;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
299
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
300 /*
301 * Prepare search path
302 */
42c82bb Revert the last patches.
foobar authored
303
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
304 /* Add cwd */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
305 #ifdef INI_CHECK_CWD
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
306 if (strcmp(sapi_module.name, "cli")!=0) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
307 if (*php_ini_search_path) {
308 strcat(php_ini_search_path, paths_separator);
309 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
310 strcat(php_ini_search_path, ".");
311 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
312 #endif
42c82bb Revert the last patches.
foobar authored
313
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
314 /* Add binary directory */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
315 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
316 binary_location = (char *) emalloc(MAXPATHLEN);
317 if (GetModuleFileName(0, binary_location, MAXPATHLEN)==0) {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
318 efree(binary_location);
319 binary_location = NULL;
42c82bb Revert the last patches.
foobar authored
320 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
321 #else
322 if (sapi_module.executable_location) {
323 binary_location = estrdup(sapi_module.executable_location);
324 } else {
325 binary_location = NULL;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
326 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
327 #endif
328 if (binary_location) {
329 char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
330
331 if (separator_location) {
332 *(separator_location+1) = 0;
333 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
334 if (*php_ini_search_path) {
335 strcat(php_ini_search_path, paths_separator);
336 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
337 strcat(php_ini_search_path, binary_location);
338 efree(binary_location);
339 }
340
341 /* Add environment location */
342 if (env_location[0]) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
343 if (*php_ini_search_path) {
344 strcat(php_ini_search_path, paths_separator);
345 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
346 strcat(php_ini_search_path, env_location);
347 }
348
349 /* Add default location */
350 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
351 default_location = (char *) emalloc(MAXPATHLEN+1);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
352
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
353 if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
354 if (*php_ini_search_path) {
355 strcat(php_ini_search_path, paths_separator);
356 }
357 strcat(php_ini_search_path, default_location);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
358 }
359 efree(default_location);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
360 #else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
361 default_location = PHP_CONFIG_FILE_PATH;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
362 if (*php_ini_search_path) {
363 strcat(php_ini_search_path, paths_separator);
364 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
365 strcat(php_ini_search_path, default_location);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
366 #endif
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
367 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
368
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
369 PG(safe_mode) = 0;
370 PG(open_basedir) = NULL;
371
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored
372 memset(&fh, 0, sizeof(fh));
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
373 /* Check if php_ini_path_override is a file */
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
374 if (!sapi_module.php_ini_ignore) {
375 if (sapi_module.php_ini_path_override && sapi_module.php_ini_path_override[0]) {
376 struct stat statbuf;
377
378 if (!VCWD_STAT(sapi_module.php_ini_path_override, &statbuf)) {
379 if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
380 fh.handle.fp = VCWD_FOPEN(sapi_module.php_ini_path_override, "r");
381 fh.filename = sapi_module.php_ini_path_override;
382 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
383 }
384 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
385 /* Search php-%sapi-module-name%.ini file in search path */
386 if (!fh.handle.fp) {
387 const char *fmt = "php-%s.ini";
388 char *ini_fname=emalloc(strlen(fmt)+strlen(sapi_module.name));
389 sprintf(ini_fname, fmt, sapi_module.name);
390 fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
391 efree(ini_fname);
392 if (fh.handle.fp) {
393 fh.filename = php_ini_opened_path;
394 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
395 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
396 /* Search php.ini file in search path */
397 if (!fh.handle.fp) {
398 fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
399 if (fh.handle.fp) {
400 fh.filename = php_ini_opened_path;
401 }
8f94a8a First try to open php-SAPI.ini and if it fails fall back to regular
Edin Kadribasic authored
402 }
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
403 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
404 if (free_ini_search_path) {
405 efree(php_ini_search_path);
406 }
42c82bb Revert the last patches.
foobar authored
407 PG(safe_mode) = safe_mode_state;
408 PG(open_basedir) = open_basedir;
409
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
410 if (fh.handle.fp) {
411 fh.type = ZEND_HANDLE_FP;
42c82bb Revert the last patches.
foobar authored
412
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
413 zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
414
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
415 {
416 zval tmp;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
417
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
418 Z_STRLEN(tmp) = strlen(fh.filename);
419 Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
420 Z_TYPE(tmp) = IS_STRING;
421 zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
422 if(php_ini_opened_path)
423 efree(php_ini_opened_path);
424 php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
425 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
426 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
427
428 /* If the config_file_scan_dir is set at compile-time, go and scan this directory and
429 * parse any .ini files found in this directory. */
173b949 Fixed bug: #22011 (-n must ignore all ini files)
foobar authored
430 if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
431 struct dirent **namelist;
432 int ndir, i;
433
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
434 if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) {
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
435 for (i = 0; i < ndir; i++) {
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
436 /* check for a .ini extension */
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
437 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
438 free(namelist[i]);
d454bec - Whitespace
Derick Rethans authored
439 continue;
440 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
441 snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
442 if (VCWD_STAT(ini_file, &sb) == 0) {
443 if (S_ISREG(sb.st_mode)) {
444 if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
445 fh.filename = ini_file;
446 zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
447 /* Here, add it to the list of ini files read */
448 l = strlen(ini_file);
449 total_l += l+2;
450 p = estrndup(ini_file,l);
451 zend_llist_add_element(&scanned_ini_list, &p);
452 }
453 }
454 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
455 free(namelist[i]);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
456 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
457 free(namelist);
458
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
459 /*
460 * Don't need an extra byte for the \0 in this malloc as the last
461 * element will not get a trailing , which gives us the byte for the \0
462 */
463 php_ini_scanned_files = (char *)malloc(total_l);
464 *php_ini_scanned_files = '\0';
465 for (element=scanned_ini_list.head; element; element=element->next) {
466 strcat(php_ini_scanned_files,*(char **)element->data);
467 strcat(php_ini_scanned_files,element->next ? ",\n":"\n");
468 }
469 zend_llist_destroy(&scanned_ini_list);
470 }
42c82bb Revert the last patches.
foobar authored
471 }
472 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
473 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
474 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
475
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
476 /* {{{ php_shutdown_config
477 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
478 int php_shutdown_config(void)
479 {
42c82bb Revert the last patches.
foobar authored
480 zend_hash_destroy(&configuration_hash);
481 if (php_ini_opened_path) {
482 free(php_ini_opened_path);
483 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
484 if (php_ini_scanned_files) {
485 free(php_ini_scanned_files);
486 }
42c82bb Revert the last patches.
foobar authored
487 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
488 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
489 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
490
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
491 /* {{{ php_ini_delayed_modules_startup
492 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
493 void php_ini_delayed_modules_startup(TSRMLS_D)
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
494 {
42c82bb Revert the last patches.
foobar authored
495 zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
496 zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb TSRMLS_CC);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
497
42c82bb Revert the last patches.
foobar authored
498 zend_llist_destroy(&extension_lists.engine);
499 zend_llist_destroy(&extension_lists.functions);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
500 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
501 /* }}} */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
502
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
503 /* {{{ cfg_get_entry
504 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
505 zval *cfg_get_entry(char *name, uint name_length)
506 {
42c82bb Revert the last patches.
foobar authored
507 zval *tmp;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
508
42c82bb Revert the last patches.
foobar authored
509 if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) {
510 return tmp;
511 } else {
512 return NULL;
513 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
514 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
515 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
516
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
517 /* {{{ cfg_get_long
518 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
519 PHPAPI int cfg_get_long(char *varname, long *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
520 {
42c82bb Revert the last patches.
foobar authored
521 zval *tmp, var;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
522
42c82bb Revert the last patches.
foobar authored
523 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
524 *result=(long)NULL;
525 return FAILURE;
526 }
527 var = *tmp;
528 zval_copy_ctor(&var);
529 convert_to_long(&var);
530 *result = Z_LVAL(var);
531 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
532 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
533 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
534
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
535 /* {{{ cfg_get_double
536 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
537 PHPAPI int cfg_get_double(char *varname, double *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
538 {
42c82bb Revert the last patches.
foobar authored
539 zval *tmp, var;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
540
42c82bb Revert the last patches.
foobar authored
541 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
542 *result=(double)0;
543 return FAILURE;
544 }
545 var = *tmp;
546 zval_copy_ctor(&var);
547 convert_to_double(&var);
548 *result = Z_DVAL(var);
549 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
550 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
551 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
552
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
553 /* {{{ cfg_get_string
554 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
555 PHPAPI int cfg_get_string(char *varname, char **result)
556 {
42c82bb Revert the last patches.
foobar authored
557 zval *tmp;
558
559 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
560 *result=NULL;
561 return FAILURE;
562 }
563 *result = Z_STRVAL_P(tmp);
564 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
565 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
566 /* }}} */
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
567
568 /*
569 * Local variables:
570 * tab-width: 4
571 * c-basic-offset: 4
572 * indent-tabs-mode: t
573 * End:
78747bd - Don't wrap lines... this is annoying while coding.
Derick Rethans authored
574 * vim600: sw=4 ts=4 fdm=marker
575 * vim<600: sw=4 ts=4
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
576 */
Something went wrong with that request. Please try again.