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