Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 487 lines (432 sloc) 12.939 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 +----------------------------------------------------------------------+
3893351 Update headers.
Sebastian Bergmann authored
5 | Copyright (c) 1997-2002 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"
0be5cca @fmk Fix build on WIn32
fmk authored
25 #ifndef PHP_WIN32
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
26 #include "build-defs.h"
0be5cca @fmk Fix build on WIn32
fmk authored
27 #endif
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
28 #include "ext/standard/info.h"
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
29 #include "zend_ini.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
30 #include "php_ini.h"
31 #include "ext/standard/dl.h"
32 #include "zend_extensions.h"
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
33 #include "zend_highlight.h"
ab25640 Removed CWD from php_ini_search_path when using CLI SAPI.
Edin Kadribasic authored
34 #include "SAPI.h"
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
35 #include "php_main.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
36
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
37 typedef struct _php_extension_lists {
42c82bb Revert the last patches.
foobar authored
38 zend_llist engine;
39 zend_llist functions;
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
40 } php_extension_lists;
58e24ac @zsuraski - Add PHP Modules workspace
zsuraski authored
41
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
42
43 /* True globals */
44 static HashTable configuration_hash;
45 PHPAPI char *php_ini_opened_path=NULL;
46 static php_extension_lists extension_lists;
47
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
48 /* {{{ php_ini_displayer_cb
49 */
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
50 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
51 {
42c82bb Revert the last patches.
foobar authored
52 if (ini_entry->displayer) {
53 ini_entry->displayer(ini_entry, type);
54 } else {
55 char *display_string;
56 uint display_string_length, esc_html=0;
57 TSRMLS_FETCH();
58
59 if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
60 if (ini_entry->orig_value && ini_entry->orig_value[0]) {
61 display_string = ini_entry->orig_value;
62 display_string_length = ini_entry->orig_value_length;
63 esc_html=1;
64 } else {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
65 if (PG(html_errors)) {
66 display_string = "<i>no value</i>";
67 display_string_length = sizeof("<i>no value</i>")-1;
68 } else {
69 display_string = "no value";
70 display_string_length = sizeof("no value")-1;
71 }
42c82bb Revert the last patches.
foobar authored
72 }
73 } else if (ini_entry->value && ini_entry->value[0]) {
74 display_string = ini_entry->value;
75 display_string_length = ini_entry->value_length;
76 esc_html=1;
77 } else {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
78 if (PG(html_errors)) {
79 display_string = "<i>no value</i>";
80 display_string_length = sizeof("<i>no value</i>")-1;
81 } else {
82 display_string = "no value";
83 display_string_length = sizeof("no value")-1;
84 }
42c82bb Revert the last patches.
foobar authored
85 }
86 if(esc_html) {
a769454 reenable php_html_puts
Sascha Schumann authored
87 php_html_puts(display_string, display_string_length TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
88 } else {
89 PHPWRITE(display_string, display_string_length);
90 }
91 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
92 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
93 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
94
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
95 /* {{{ php_ini_displayer
96 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
97 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
98 {
42c82bb Revert the last patches.
foobar authored
99 if (ini_entry->module_number != module_number) {
100 return 0;
101 }
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
102 if (PG(html_errors)) {
103 PUTS("<tr valign=\"baseline\" bgcolor=\"" PHP_CONTENTS_COLOR "\">");
104 PUTS("<td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>");
105 PHPWRITE(ini_entry->name, ini_entry->name_length-1);
106 PUTS("</b><br /></td><td align=\"center\">");
107 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
108 PUTS("</td><td align=\"center\">");
109 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
110 PUTS("</td></tr>\n");
111 } else {
112 PHPWRITE(ini_entry->name, ini_entry->name_length-1);
113 PUTS(" => ");
114 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
115 PUTS(" => ");
116 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
117 PUTS("\n");
118 }
42c82bb Revert the last patches.
foobar authored
119 return 0;
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
120 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
121 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
122
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
123 /* {{{ display_ini_entries
124 */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
125 PHPAPI void display_ini_entries(zend_module_entry *module)
126 {
42c82bb Revert the last patches.
foobar authored
127 int module_number;
128 TSRMLS_FETCH();
129
130 if (module) {
131 module_number = module->module_number;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
132 } else {
42c82bb Revert the last patches.
foobar authored
133 module_number = 0;
134 }
135 php_info_print_table_start();
136 php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
137 zend_hash_apply_with_argument(&EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (long) module_number TSRMLS_CC);
138 php_info_print_table_end();
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
139 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
140 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
141
142 /* php.ini support */
143
144 #ifdef ZTS
145 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
146 # 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
147 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
148 # define ZEND_EXTENSION_TOKEN "zend_extension_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
149 # endif
150 #else
151 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
152 # define ZEND_EXTENSION_TOKEN "zend_extension_debug"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
153 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
154 # define ZEND_EXTENSION_TOKEN "zend_extension"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
155 # endif
156 #endif
157
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
158 /* {{{ pvalue_config_destructor
159 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
160 static void pvalue_config_destructor(zval *pvalue)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
161 {
162 if (Z_TYPE_P(pvalue) == IS_STRING && Z_STRVAL_P(pvalue) != empty_string) {
163 free(Z_STRVAL_P(pvalue));
164 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
165 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
166 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
167
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
168 /* {{{ php_config_ini_parser_cb
169 */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
170 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
171 {
42c82bb Revert the last patches.
foobar authored
172 switch (callback_type) {
173 case ZEND_INI_PARSER_ENTRY: {
174 zval *entry;
175
176 if (!arg2) {
177 break;
178 }
179 if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
180 zval copy;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
181
42c82bb Revert the last patches.
foobar authored
182 copy = *arg2;
183 zval_copy_ctor(&copy);
184 copy.refcount = 0;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
185 zend_llist_add_element(&extension_lists.functions, &copy);
42c82bb Revert the last patches.
foobar authored
186 } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
187 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
188
42c82bb Revert the last patches.
foobar authored
189 zend_llist_add_element(&extension_lists.engine, &extension_name);
190 } else {
191 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
192 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
193 }
194 }
195 break;
196 case ZEND_INI_PARSER_SECTION:
197 break;
198 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
199 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
200 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
201
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
202 /* {{{ php_load_function_extension_cb
203 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
204 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
205 {
42c82bb Revert the last patches.
foobar authored
206 zval *extension = (zval *) arg;
207 zval zval;
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
208
42c82bb Revert the last patches.
foobar authored
209 php_dl(extension, MODULE_PERSISTENT, &zval TSRMLS_CC);
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
210 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
211 /* }}} */
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
212
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
213 /* {{{ php_load_zend_extension_cb
214 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
215 static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
216 {
42c82bb Revert the last patches.
foobar authored
217 zend_load_extension(*((char **) arg));
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
218 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
219 /* }}} */
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
220
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
221 /* {{{ php_init_config
222 */
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
223 int php_init_config()
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
224 {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
225 char *env_location, *php_ini_search_path;
226 char *binary_location;
42c82bb Revert the last patches.
foobar authored
227 int safe_mode_state;
228 char *open_basedir;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
229 int free_ini_search_path=0;
42c82bb Revert the last patches.
foobar authored
230 zend_file_handle fh;
231 TSRMLS_FETCH();
232
233 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
234 return FAILURE;
235 }
236
237 zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
238 zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
239
42c82bb Revert the last patches.
foobar authored
240 safe_mode_state = PG(safe_mode);
241 open_basedir = PG(open_basedir);
242
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
243 env_location = getenv("PHPRC");
244 if (!env_location) {
245 env_location="";
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
246 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
247 if (sapi_module.php_ini_path_override) {
248 php_ini_search_path = sapi_module.php_ini_path_override;
249 free_ini_search_path = 0;
250 } else {
251 char *default_location;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
252 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
253
b9fd107 @zsuraski Use portable #define
zsuraski authored
254 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
255 free_ini_search_path = 1;
256 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
257
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
258 /*
259 * Prepare search path
260 */
42c82bb Revert the last patches.
foobar authored
261
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
262 /* Add cwd */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
263 #ifdef INI_CHECK_CWD
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
264 if (strcmp(sapi_module.name, "cli")!=0) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
265 if (*php_ini_search_path) {
266 strcat(php_ini_search_path, paths_separator);
267 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
268 strcat(php_ini_search_path, ".");
269 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
270 #endif
42c82bb Revert the last patches.
foobar authored
271
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
272 /* Add binary directory */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
273 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
274 binary_location = (char *) emalloc(MAXPATHLEN);
275 if (GetModuleFileName(0, binary_location, MAXPATHLEN)==0) {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
276 efree(binary_location);
277 binary_location = NULL;
42c82bb Revert the last patches.
foobar authored
278 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
279 #else
280 if (sapi_module.executable_location) {
281 binary_location = estrdup(sapi_module.executable_location);
282 } else {
283 binary_location = NULL;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
284 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
285 #endif
286 if (binary_location) {
287 char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
288
289 if (separator_location) {
290 *(separator_location+1) = 0;
291 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
292 if (*php_ini_search_path) {
293 strcat(php_ini_search_path, paths_separator);
294 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
295 strcat(php_ini_search_path, binary_location);
296 efree(binary_location);
297 }
298
299 /* Add environment location */
300 if (env_location[0]) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
301 if (*php_ini_search_path) {
302 strcat(php_ini_search_path, paths_separator);
303 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
304 strcat(php_ini_search_path, env_location);
305 }
306
307 /* Add default location */
308 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
309 default_location = (char *) emalloc(MAXPATHLEN+1);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
310
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
311 if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
312 if (*php_ini_search_path) {
313 strcat(php_ini_search_path, paths_separator);
314 }
315 strcat(php_ini_search_path, default_location);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
316 }
317 efree(default_location);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
318 #else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
319 default_location = PHP_CONFIG_FILE_PATH;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
320 if (*php_ini_search_path) {
321 strcat(php_ini_search_path, paths_separator);
322 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
323 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
324 #endif
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
325 }
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 PG(safe_mode) = 0;
328 PG(open_basedir) = NULL;
329
330 fh.handle.fp = NULL;
331 /* Check if php_ini_path_override is a file */
332 if (sapi_module.php_ini_path_override && sapi_module.php_ini_path_override[0]) {
333 struct stat statbuf;
334
335 if (!VCWD_STAT(sapi_module.php_ini_path_override, &statbuf)) {
336 if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
337 fh.handle.fp = VCWD_FOPEN(sapi_module.php_ini_path_override, "r");
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
338 fh.filename = sapi_module.php_ini_path_override;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
339 }
340 }
341 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
342 /* Search php-%sapi-module-name%.ini file in search path */
343 if (!fh.handle.fp) {
344 const char *fmt = "php-%s.ini";
345 char *ini_fname=emalloc(strlen(fmt)+strlen(sapi_module.name));
346 sprintf(ini_fname, fmt, sapi_module.name);
347 fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
348 efree(ini_fname);
349 if (fh.handle.fp) {
350 fh.filename = php_ini_opened_path;
351 }
352 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
353 /* Search php.ini file in search path */
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
354 if (!fh.handle.fp) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
355 fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
356 if (fh.handle.fp) {
357 fh.filename = php_ini_opened_path;
8f94a8a First try to open php-SAPI.ini and if it fails fall back to regular
Edin Kadribasic authored
358 }
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
359 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
360 if (free_ini_search_path) {
361 efree(php_ini_search_path);
362 }
42c82bb Revert the last patches.
foobar authored
363 PG(safe_mode) = safe_mode_state;
364 PG(open_basedir) = open_basedir;
365
366 if (!fh.handle.fp) {
367 return SUCCESS; /* having no configuration file is ok */
368 }
369 fh.type = ZEND_HANDLE_FP;
370
371 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
372
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
373 {
42c82bb Revert the last patches.
foobar authored
374 zval tmp;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
375
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
376 Z_STRLEN(tmp) = strlen(fh.filename);
377 Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
42c82bb Revert the last patches.
foobar authored
378 Z_TYPE(tmp) = IS_STRING;
379 zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
380 if(php_ini_opened_path)
381 efree(php_ini_opened_path);
42c82bb Revert the last patches.
foobar authored
382 php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
383 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
384
42c82bb Revert the last patches.
foobar authored
385 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
386 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
387 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
388
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
389 /* {{{ php_shutdown_config
390 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
391 int php_shutdown_config(void)
392 {
42c82bb Revert the last patches.
foobar authored
393 zend_hash_destroy(&configuration_hash);
394 if (php_ini_opened_path) {
395 free(php_ini_opened_path);
396 }
397 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
398 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
399 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
400
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
401 /* {{{ php_ini_delayed_modules_startup
402 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
403 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
404 {
42c82bb Revert the last patches.
foobar authored
405 zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
406 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
407
42c82bb Revert the last patches.
foobar authored
408 zend_llist_destroy(&extension_lists.engine);
409 zend_llist_destroy(&extension_lists.functions);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
410 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
411 /* }}} */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
412
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
413 /* {{{ cfg_get_entry
414 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
415 zval *cfg_get_entry(char *name, uint name_length)
416 {
42c82bb Revert the last patches.
foobar authored
417 zval *tmp;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
418
42c82bb Revert the last patches.
foobar authored
419 if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) {
420 return tmp;
421 } else {
422 return NULL;
423 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
424 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
425 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
426
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
427 /* {{{ cfg_get_long
428 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
429 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
430 {
42c82bb Revert the last patches.
foobar authored
431 zval *tmp, var;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
432
42c82bb Revert the last patches.
foobar authored
433 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
434 *result=(long)NULL;
435 return FAILURE;
436 }
437 var = *tmp;
438 zval_copy_ctor(&var);
439 convert_to_long(&var);
440 *result = Z_LVAL(var);
441 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
442 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
443 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
444
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
445 /* {{{ cfg_get_double
446 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
447 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
448 {
42c82bb Revert the last patches.
foobar authored
449 zval *tmp, var;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
450
42c82bb Revert the last patches.
foobar authored
451 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
452 *result=(double)0;
453 return FAILURE;
454 }
455 var = *tmp;
456 zval_copy_ctor(&var);
457 convert_to_double(&var);
458 *result = Z_DVAL(var);
459 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
460 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
461 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
462
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
463 /* {{{ cfg_get_string
464 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
465 PHPAPI int cfg_get_string(char *varname, char **result)
466 {
42c82bb Revert the last patches.
foobar authored
467 zval *tmp;
468
469 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
470 *result=NULL;
471 return FAILURE;
472 }
473 *result = Z_STRVAL_P(tmp);
474 return SUCCESS;
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 /* }}} */
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
477
478 /*
479 * Local variables:
480 * tab-width: 4
481 * c-basic-offset: 4
482 * indent-tabs-mode: t
483 * End:
78747bd - Don't wrap lines... this is annoying while coding.
Derick Rethans authored
484 * vim600: sw=4 ts=4 fdm=marker
485 * vim<600: sw=4 ts=4
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
486 */
Something went wrong with that request. Please try again.