Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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