1999-04-10 05:04:12 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-20 00:33:14 +08:00
|
|
|
| PHP Version 7 |
|
1999-04-10 05:04:12 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 17:03:12 +08:00
|
|
|
| Copyright (c) The PHP Group |
|
1999-04-10 05:04:12 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2001-05-06 23:20:56 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
1999-07-16 21:13:16 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
2001-05-06 23:20:56 +08:00
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
1999-04-10 05:04:12 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2018-11-02 00:30:28 +08:00
|
|
|
| Author: Zeev Suraski <zeev@php.net> |
|
1999-04-10 05:04:12 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#include "php.h"
|
1999-05-09 16:48:05 +08:00
|
|
|
#include "ext/standard/info.h"
|
2000-10-29 19:38:26 +08:00
|
|
|
#include "zend_ini.h"
|
2007-09-28 10:05:10 +08:00
|
|
|
#include "zend_ini_scanner.h"
|
2000-10-31 07:39:14 +08:00
|
|
|
#include "php_ini.h"
|
|
|
|
#include "ext/standard/dl.h"
|
|
|
|
#include "zend_extensions.h"
|
2001-05-06 23:20:56 +08:00
|
|
|
#include "zend_highlight.h"
|
2002-02-28 20:12:39 +08:00
|
|
|
#include "SAPI.h"
|
2002-03-05 08:21:28 +08:00
|
|
|
#include "php_main.h"
|
2003-02-19 17:25:16 +08:00
|
|
|
#include "php_scandir.h"
|
2003-10-19 18:39:27 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#include "win32/php_registry.h"
|
2018-09-17 15:48:33 +08:00
|
|
|
#include "win32/winutil.h"
|
2003-10-19 18:39:27 +08:00
|
|
|
#endif
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2003-02-19 17:25:16 +08:00
|
|
|
#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
|
|
|
|
#include <dirent.h>
|
2003-01-26 09:39:18 +08:00
|
|
|
#endif
|
2003-01-26 05:13:00 +08:00
|
|
|
|
2009-10-10 03:43:00 +08:00
|
|
|
#ifdef PHP_WIN32
|
2009-10-12 04:50:53 +08:00
|
|
|
#define TRANSLATE_SLASHES_LOWER(path) \
|
2009-10-10 03:43:00 +08:00
|
|
|
{ \
|
|
|
|
char *tmp = path; \
|
|
|
|
while (*tmp) { \
|
|
|
|
if (*tmp == '\\') *tmp = '/'; \
|
2009-10-12 22:40:27 +08:00
|
|
|
else *tmp = tolower(*tmp); \
|
2009-10-12 04:50:53 +08:00
|
|
|
tmp++; \
|
2009-10-10 03:43:00 +08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#else
|
2009-10-12 04:50:53 +08:00
|
|
|
#define TRANSLATE_SLASHES_LOWER(path)
|
2009-10-10 03:43:00 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-01-15 18:52:02 +08:00
|
|
|
typedef struct _php_extension_lists {
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_llist engine;
|
|
|
|
zend_llist functions;
|
2001-01-15 18:52:02 +08:00
|
|
|
} php_extension_lists;
|
1999-08-14 05:03:27 +08:00
|
|
|
|
2001-03-18 07:35:32 +08:00
|
|
|
/* True globals */
|
2007-11-10 00:27:43 +08:00
|
|
|
static int is_special_section = 0;
|
2007-09-28 10:05:10 +08:00
|
|
|
static HashTable *active_ini_hash;
|
2001-03-18 07:35:32 +08:00
|
|
|
static HashTable configuration_hash;
|
2008-04-15 19:31:58 +08:00
|
|
|
static int has_per_dir_config = 0;
|
|
|
|
static int has_per_host_config = 0;
|
2001-03-18 07:35:32 +08:00
|
|
|
PHPAPI char *php_ini_opened_path=NULL;
|
|
|
|
static php_extension_lists extension_lists;
|
2008-08-13 08:53:28 +08:00
|
|
|
PHPAPI char *php_ini_scanned_path=NULL;
|
2002-10-04 12:47:35 +08:00
|
|
|
PHPAPI char *php_ini_scanned_files=NULL;
|
2001-03-18 07:35:32 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ php_ini_displayer_cb
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
|
1999-05-09 16:48:05 +08:00
|
|
|
{
|
2002-05-10 04:03:36 +08:00
|
|
|
if (ini_entry->displayer) {
|
|
|
|
ini_entry->displayer(ini_entry, type);
|
|
|
|
} else {
|
|
|
|
char *display_string;
|
2014-10-27 20:15:47 +08:00
|
|
|
size_t display_string_length;
|
|
|
|
int esc_html=0;
|
2002-05-10 04:03:36 +08:00
|
|
|
|
2003-02-19 17:38:11 +08:00
|
|
|
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
if (ini_entry->orig_value && ZSTR_VAL(ini_entry->orig_value)[0]) {
|
|
|
|
display_string = ZSTR_VAL(ini_entry->orig_value);
|
|
|
|
display_string_length = ZSTR_LEN(ini_entry->orig_value);
|
2003-03-30 05:25:03 +08:00
|
|
|
esc_html = !sapi_module.phpinfo_as_text;
|
2002-05-10 04:03:36 +08:00
|
|
|
} else {
|
2003-03-30 05:25:03 +08:00
|
|
|
if (!sapi_module.phpinfo_as_text) {
|
2002-08-29 18:24:02 +08:00
|
|
|
display_string = "<i>no value</i>";
|
2003-02-19 17:38:11 +08:00
|
|
|
display_string_length = sizeof("<i>no value</i>") - 1;
|
2002-08-29 18:24:02 +08:00
|
|
|
} else {
|
|
|
|
display_string = "no value";
|
2003-02-19 17:38:11 +08:00
|
|
|
display_string_length = sizeof("no value") - 1;
|
2007-08-31 16:16:13 +08:00
|
|
|
}
|
2002-05-10 04:03:36 +08:00
|
|
|
}
|
2015-06-30 18:59:27 +08:00
|
|
|
} else if (ini_entry->value && ZSTR_VAL(ini_entry->value)[0]) {
|
|
|
|
display_string = ZSTR_VAL(ini_entry->value);
|
|
|
|
display_string_length = ZSTR_LEN(ini_entry->value);
|
2003-03-30 05:25:03 +08:00
|
|
|
esc_html = !sapi_module.phpinfo_as_text;
|
2002-05-10 04:03:36 +08:00
|
|
|
} else {
|
2003-03-30 05:25:03 +08:00
|
|
|
if (!sapi_module.phpinfo_as_text) {
|
2002-08-29 18:24:02 +08:00
|
|
|
display_string = "<i>no value</i>";
|
2003-02-19 17:38:11 +08:00
|
|
|
display_string_length = sizeof("<i>no value</i>") - 1;
|
2002-08-29 18:24:02 +08:00
|
|
|
} else {
|
|
|
|
display_string = "no value";
|
2003-02-19 17:38:11 +08:00
|
|
|
display_string_length = sizeof("no value") - 1;
|
2007-08-31 16:16:13 +08:00
|
|
|
}
|
2002-05-10 04:03:36 +08:00
|
|
|
}
|
2003-02-19 17:38:11 +08:00
|
|
|
|
|
|
|
if (esc_html) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_html_puts(display_string, display_string_length);
|
2002-05-10 04:03:36 +08:00
|
|
|
} else {
|
|
|
|
PHPWRITE(display_string, display_string_length);
|
|
|
|
}
|
|
|
|
}
|
1999-05-09 16:48:05 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
1999-05-09 16:48:05 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ display_ini_entries
|
|
|
|
*/
|
1999-05-09 16:48:05 +08:00
|
|
|
PHPAPI void display_ini_entries(zend_module_entry *module)
|
|
|
|
{
|
2018-12-19 07:49:56 +08:00
|
|
|
int module_number;
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
zend_bool first = 1;
|
2002-05-10 04:03:36 +08:00
|
|
|
|
|
|
|
if (module) {
|
|
|
|
module_number = module->module_number;
|
2007-08-31 16:16:13 +08:00
|
|
|
} else {
|
2002-05-10 04:03:36 +08:00
|
|
|
module_number = 0;
|
|
|
|
}
|
2018-12-19 07:49:56 +08:00
|
|
|
|
|
|
|
ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
|
|
|
|
if (ini_entry->module_number != module_number) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (first) {
|
|
|
|
php_info_print_table_start();
|
|
|
|
php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
if (!sapi_module.phpinfo_as_text) {
|
|
|
|
PUTS("<tr>");
|
|
|
|
PUTS("<td class=\"e\">");
|
|
|
|
PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
|
|
|
|
PUTS("</td><td class=\"v\">");
|
|
|
|
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
|
|
|
|
PUTS("</td><td class=\"v\">");
|
|
|
|
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
|
|
|
|
PUTS("</td></tr>\n");
|
|
|
|
} else {
|
|
|
|
PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
|
|
|
|
PUTS(" => ");
|
|
|
|
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
|
|
|
|
PUTS(" => ");
|
|
|
|
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
|
|
|
|
PUTS("\n");
|
|
|
|
}
|
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
if (!first) {
|
2008-12-31 03:08:54 +08:00
|
|
|
php_info_print_table_end();
|
|
|
|
}
|
1999-05-09 16:48:05 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
|
|
|
/* php.ini support */
|
2007-11-10 00:27:43 +08:00
|
|
|
#define PHP_EXTENSION_TOKEN "extension"
|
2009-05-19 05:33:38 +08:00
|
|
|
#define ZEND_EXTENSION_TOKEN "zend_extension"
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* {{{ config_zval_dtor
|
2001-06-06 21:06:12 +08:00
|
|
|
*/
|
2007-09-28 18:23:38 +08:00
|
|
|
PHPAPI void config_zval_dtor(zval *zvalue)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2007-09-28 10:05:10 +08:00
|
|
|
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
|
|
|
|
zend_hash_destroy(Z_ARRVAL_P(zvalue));
|
2014-02-17 21:59:18 +08:00
|
|
|
free(Z_ARR_P(zvalue));
|
2007-09-28 10:05:10 +08:00
|
|
|
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(Z_STR_P(zvalue), 1);
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Reset / free active_ini_sectin global */
|
|
|
|
#define RESET_ACTIVE_INI_HASH() do { \
|
|
|
|
active_ini_hash = NULL; \
|
2010-09-09 13:11:05 +08:00
|
|
|
is_special_section = 0; \
|
2007-09-28 10:05:10 +08:00
|
|
|
} while (0)
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_ini_parser_cb
|
|
|
|
*/
|
|
|
|
static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, HashTable *target_hash)
|
|
|
|
{
|
|
|
|
zval *entry;
|
|
|
|
HashTable *active_hash;
|
2007-11-10 00:27:43 +08:00
|
|
|
char *extension_name;
|
2007-09-28 10:05:10 +08:00
|
|
|
|
|
|
|
if (active_ini_hash) {
|
|
|
|
active_hash = active_ini_hash;
|
|
|
|
} else {
|
|
|
|
active_hash = target_hash;
|
|
|
|
}
|
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
switch (callback_type) {
|
|
|
|
case ZEND_INI_PARSER_ENTRY: {
|
|
|
|
if (!arg2) {
|
2007-09-28 10:05:10 +08:00
|
|
|
/* bare string - nothing to do */
|
2002-05-10 04:03:36 +08:00
|
|
|
break;
|
|
|
|
}
|
2007-09-28 10:05:10 +08:00
|
|
|
|
|
|
|
/* PHP and Zend extensions are not added into configuration hash! */
|
2007-11-10 00:27:43 +08:00
|
|
|
if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */
|
2014-08-26 01:24:55 +08:00
|
|
|
extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
|
2007-11-10 00:27:43 +08:00
|
|
|
zend_llist_add_element(&extension_lists.functions, &extension_name);
|
|
|
|
} else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
|
2014-08-26 01:24:55 +08:00
|
|
|
extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_llist_add_element(&extension_lists.engine, &extension_name);
|
2007-09-28 10:05:10 +08:00
|
|
|
|
|
|
|
/* All other entries are added into either configuration_hash or active ini section array */
|
2002-05-10 04:03:36 +08:00
|
|
|
} else {
|
2007-09-28 10:05:10 +08:00
|
|
|
/* Store in active hash */
|
2014-02-10 14:04:30 +08:00
|
|
|
entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2);
|
2014-08-26 01:24:55 +08:00
|
|
|
Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
|
2002-05-10 04:03:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-01-19 20:18:46 +08:00
|
|
|
|
|
|
|
case ZEND_INI_PARSER_POP_ENTRY: {
|
2014-02-10 14:04:30 +08:00
|
|
|
zval option_arr;
|
2007-09-28 10:05:10 +08:00
|
|
|
zval *find_arr;
|
2003-01-19 20:18:46 +08:00
|
|
|
|
|
|
|
if (!arg2) {
|
|
|
|
/* bare string - nothing to do */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* fprintf(stdout, "ZEND_INI_PARSER_POP_ENTRY: %s[%s] = %s\n",Z_STRVAL_P(arg1), Z_STRVAL_P(arg3), Z_STRVAL_P(arg2)); */
|
|
|
|
|
|
|
|
/* If option not found in hash or is not an array -> create array, otherwise add to existing array */
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) {
|
|
|
|
ZVAL_NEW_PERSISTENT_ARR(&option_arr);
|
2014-05-08 15:20:13 +08:00
|
|
|
zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, config_zval_dtor, 1);
|
2014-02-10 14:04:30 +08:00
|
|
|
find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr);
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
2003-01-19 20:18:46 +08:00
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* arg3 is possible option offset name */
|
2014-08-26 01:24:55 +08:00
|
|
|
if (arg3 && Z_STRLEN_P(arg3) > 0) {
|
2014-02-10 14:04:30 +08:00
|
|
|
entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2);
|
2003-01-19 20:18:46 +08:00
|
|
|
} else {
|
2014-02-10 14:04:30 +08:00
|
|
|
entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2);
|
2003-01-19 20:18:46 +08:00
|
|
|
}
|
2014-08-26 01:24:55 +08:00
|
|
|
Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
|
2003-01-19 20:18:46 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
case ZEND_INI_PARSER_SECTION: { /* Create an array of entries of each section */
|
|
|
|
|
|
|
|
/* fprintf(stdout, "ZEND_INI_PARSER_SECTION: %s\n",Z_STRVAL_P(arg1)); */
|
|
|
|
|
|
|
|
char *key = NULL;
|
2014-10-27 20:15:47 +08:00
|
|
|
size_t key_len;
|
2007-09-28 10:05:10 +08:00
|
|
|
|
2007-11-10 00:27:43 +08:00
|
|
|
/* PATH sections */
|
2017-06-09 07:43:08 +08:00
|
|
|
if (!zend_binary_strncasecmp(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), "PATH", sizeof("PATH") - 1, sizeof("PATH") - 1)) {
|
2007-09-28 10:05:10 +08:00
|
|
|
key = Z_STRVAL_P(arg1);
|
|
|
|
key = key + sizeof("PATH") - 1;
|
2014-08-26 01:24:55 +08:00
|
|
|
key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1;
|
2007-11-10 00:27:43 +08:00
|
|
|
is_special_section = 1;
|
2008-04-15 19:31:58 +08:00
|
|
|
has_per_dir_config = 1;
|
2009-10-10 03:43:00 +08:00
|
|
|
|
2013-03-12 16:15:50 +08:00
|
|
|
/* make the path lowercase on Windows, for case insensitivity. Does nothing for other platforms */
|
2009-10-12 04:50:53 +08:00
|
|
|
TRANSLATE_SLASHES_LOWER(key);
|
2007-09-28 10:05:10 +08:00
|
|
|
|
2007-11-10 00:27:43 +08:00
|
|
|
/* HOST sections */
|
2017-06-09 07:43:08 +08:00
|
|
|
} else if (!zend_binary_strncasecmp(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), "HOST", sizeof("HOST") - 1, sizeof("HOST") - 1)) {
|
2007-09-28 10:05:10 +08:00
|
|
|
key = Z_STRVAL_P(arg1);
|
|
|
|
key = key + sizeof("HOST") - 1;
|
2014-08-26 01:24:55 +08:00
|
|
|
key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1;
|
2007-11-10 00:27:43 +08:00
|
|
|
is_special_section = 1;
|
2008-04-15 19:31:58 +08:00
|
|
|
has_per_host_config = 1;
|
2009-10-10 04:01:16 +08:00
|
|
|
zend_str_tolower(key, key_len); /* host names are case-insensitive. */
|
2008-04-15 19:31:58 +08:00
|
|
|
|
2007-11-10 00:27:43 +08:00
|
|
|
} else {
|
|
|
|
is_special_section = 0;
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (key && key_len > 0) {
|
|
|
|
/* Strip any trailing slashes */
|
|
|
|
while (key_len > 0 && (key[key_len - 1] == '/' || key[key_len - 1] == '\\')) {
|
|
|
|
key_len--;
|
|
|
|
key[key_len] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Strip any leading whitespace and '=' */
|
|
|
|
while (*key && (
|
|
|
|
*key == '=' ||
|
|
|
|
*key == ' ' ||
|
|
|
|
*key == '\t'
|
|
|
|
)) {
|
|
|
|
key++;
|
|
|
|
key_len--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search for existing entry and if it does not exist create one */
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((entry = zend_hash_str_find(target_hash, key, key_len)) == NULL) {
|
|
|
|
zval section_arr;
|
|
|
|
|
|
|
|
ZVAL_NEW_PERSISTENT_ARR(§ion_arr);
|
2014-04-21 22:25:34 +08:00
|
|
|
zend_hash_init(Z_ARRVAL(section_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1);
|
2014-02-10 14:04:30 +08:00
|
|
|
entry = zend_hash_str_update(target_hash, key, key_len, §ion_arr);
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
2017-06-09 07:43:08 +08:00
|
|
|
if (Z_TYPE_P(entry) == IS_ARRAY) {
|
|
|
|
active_ini_hash = Z_ARRVAL_P(entry);
|
|
|
|
}
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
|
|
|
}
|
2002-05-10 04:03:36 +08:00
|
|
|
break;
|
|
|
|
}
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2007-11-10 00:27:43 +08:00
|
|
|
/* {{{ php_load_php_extension_cb
|
2001-06-06 21:06:12 +08:00
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void php_load_php_extension_cb(void *arg)
|
2001-01-15 11:21:05 +08:00
|
|
|
{
|
2010-06-08 20:54:11 +08:00
|
|
|
#ifdef HAVE_LIBDL
|
2014-12-14 06:06:14 +08:00
|
|
|
php_load_extension(*((char **) arg), MODULE_PERSISTENT, 0);
|
2010-06-08 20:54:11 +08:00
|
|
|
#endif
|
2001-01-15 18:52:02 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2001-01-15 18:52:02 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ php_load_zend_extension_cb
|
|
|
|
*/
|
2018-02-27 02:30:55 +08:00
|
|
|
#ifdef HAVE_LIBDL
|
2014-12-14 06:06:14 +08:00
|
|
|
static void php_load_zend_extension_cb(void *arg)
|
2001-01-15 18:52:02 +08:00
|
|
|
{
|
2013-03-17 15:42:25 +08:00
|
|
|
char *filename = *((char **) arg);
|
2017-07-22 04:26:37 +08:00
|
|
|
const size_t length = strlen(filename);
|
2013-03-17 15:42:25 +08:00
|
|
|
|
2015-01-31 05:32:00 +08:00
|
|
|
#ifndef PHP_WIN32
|
|
|
|
(void) length;
|
|
|
|
#endif
|
|
|
|
|
2013-03-17 15:42:25 +08:00
|
|
|
if (IS_ABSOLUTE_PATH(filename, length)) {
|
2019-03-31 20:01:36 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
char *err;
|
|
|
|
if (!php_win32_image_compatible(filename, NULL, &err)) {
|
|
|
|
php_error(E_CORE_WARNING, err);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
#endif
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_load_extension(filename);
|
2013-03-17 15:42:25 +08:00
|
|
|
} else {
|
2017-07-13 20:27:19 +08:00
|
|
|
DL_HANDLE handle;
|
2017-06-23 01:13:42 +08:00
|
|
|
char *libpath;
|
2013-03-17 15:42:25 +08:00
|
|
|
char *extension_dir = INI_STR("extension_dir");
|
2017-07-22 04:26:37 +08:00
|
|
|
int slash_suffix = 0;
|
2017-07-13 20:27:19 +08:00
|
|
|
char *err1, *err2;
|
2017-07-22 04:26:37 +08:00
|
|
|
|
|
|
|
if (extension_dir && extension_dir[0]) {
|
|
|
|
slash_suffix = IS_SLASH(extension_dir[strlen(extension_dir)-1]);
|
|
|
|
}
|
|
|
|
|
2016-01-29 02:50:18 +08:00
|
|
|
/* Try as filename first */
|
|
|
|
if (slash_suffix) {
|
|
|
|
spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */
|
2013-03-17 15:42:25 +08:00
|
|
|
} else {
|
2016-01-29 02:50:18 +08:00
|
|
|
spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */
|
|
|
|
}
|
2017-06-23 01:13:42 +08:00
|
|
|
|
2017-07-13 20:27:19 +08:00
|
|
|
handle = (DL_HANDLE)php_load_shlib(libpath, &err1);
|
|
|
|
if (!handle) {
|
2016-01-29 02:50:18 +08:00
|
|
|
/* If file does not exist, consider as extension name and build file name */
|
2017-06-23 01:13:42 +08:00
|
|
|
char *orig_libpath = libpath;
|
|
|
|
|
2016-01-29 02:50:18 +08:00
|
|
|
if (slash_suffix) {
|
2017-07-07 02:47:04 +08:00
|
|
|
spprintf(&libpath, 0, "%s" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, filename); /* SAFE */
|
2016-01-29 02:50:18 +08:00
|
|
|
} else {
|
2017-07-07 02:47:04 +08:00
|
|
|
spprintf(&libpath, 0, "%s%c" PHP_SHLIB_EXT_PREFIX "%s." PHP_SHLIB_SUFFIX, extension_dir, DEFAULT_SLASH, filename); /* SAFE */
|
2016-01-29 02:50:18 +08:00
|
|
|
}
|
2017-06-23 01:13:42 +08:00
|
|
|
|
2017-07-13 20:27:19 +08:00
|
|
|
handle = (DL_HANDLE)php_load_shlib(libpath, &err2);
|
|
|
|
if (!handle) {
|
|
|
|
php_error(E_CORE_WARNING, "Failed loading Zend extension '%s' (tried: %s (%s), %s (%s))",
|
|
|
|
filename, orig_libpath, err1, libpath, err2);
|
2016-01-29 02:50:18 +08:00
|
|
|
efree(orig_libpath);
|
2017-07-13 20:27:19 +08:00
|
|
|
efree(err1);
|
2016-01-29 02:50:18 +08:00
|
|
|
efree(libpath);
|
2017-07-13 20:27:19 +08:00
|
|
|
efree(err2);
|
2016-01-29 02:50:18 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-06-23 01:13:42 +08:00
|
|
|
|
2016-01-29 02:50:18 +08:00
|
|
|
efree(orig_libpath);
|
2017-07-13 20:27:19 +08:00
|
|
|
efree(err1);
|
2013-03-17 15:42:25 +08:00
|
|
|
}
|
2016-01-29 02:50:18 +08:00
|
|
|
|
2019-03-31 20:01:36 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
if (!php_win32_image_compatible(libpath, NULL, &err1)) {
|
|
|
|
php_error(E_CORE_WARNING, err1);
|
|
|
|
efree(err1);
|
|
|
|
efree(libpath);
|
|
|
|
DL_UNLOAD(handle);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-13 20:27:19 +08:00
|
|
|
zend_load_extension_handle(handle, libpath);
|
2013-03-17 15:42:25 +08:00
|
|
|
efree(libpath);
|
|
|
|
}
|
2001-01-15 11:21:05 +08:00
|
|
|
}
|
2018-02-27 02:30:55 +08:00
|
|
|
#else
|
|
|
|
static void php_load_zend_extension_cb(void *arg) { }
|
|
|
|
#endif
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2001-01-15 11:21:05 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ php_init_config
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
int php_init_config(void)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2006-08-03 19:04:52 +08:00
|
|
|
char *php_ini_file_name = NULL;
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
char *php_ini_search_path = NULL;
|
2008-08-14 01:49:13 +08:00
|
|
|
int php_ini_scanned_path_len;
|
2002-05-10 04:03:36 +08:00
|
|
|
char *open_basedir;
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
int free_ini_search_path = 0;
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_file_handle fh;
|
2015-03-04 07:05:28 +08:00
|
|
|
zend_string *opened_path = NULL;
|
2002-05-10 04:03:36 +08:00
|
|
|
|
2014-05-08 15:20:13 +08:00
|
|
|
zend_hash_init(&configuration_hash, 8, NULL, config_zval_dtor, 1);
|
2005-09-02 22:05:46 +08:00
|
|
|
|
2003-03-18 23:53:33 +08:00
|
|
|
if (sapi_module.ini_defaults) {
|
|
|
|
sapi_module.ini_defaults(&configuration_hash);
|
|
|
|
}
|
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
|
2007-11-27 00:34:30 +08:00
|
|
|
zend_llist_init(&extension_lists.functions, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
open_basedir = PG(open_basedir);
|
|
|
|
|
2002-05-11 11:41:17 +08:00
|
|
|
if (sapi_module.php_ini_path_override) {
|
2006-08-03 19:04:52 +08:00
|
|
|
php_ini_file_name = sapi_module.php_ini_path_override;
|
2002-05-11 11:41:17 +08:00
|
|
|
php_ini_search_path = sapi_module.php_ini_path_override;
|
|
|
|
free_ini_search_path = 0;
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
} else if (!sapi_module.php_ini_ignore) {
|
2006-12-28 20:18:54 +08:00
|
|
|
int search_path_size;
|
2002-05-11 11:41:17 +08:00
|
|
|
char *default_location;
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
char *env_location;
|
2002-08-12 13:37:03 +08:00
|
|
|
static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
|
2003-10-20 10:21:25 +08:00
|
|
|
#ifdef PHP_WIN32
|
2003-10-19 18:39:27 +08:00
|
|
|
char *reg_location;
|
2010-08-31 01:05:56 +08:00
|
|
|
char phprc_path[MAXPATHLEN];
|
2003-10-20 10:21:25 +08:00
|
|
|
#endif
|
2002-05-10 04:34:53 +08:00
|
|
|
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
env_location = getenv("PHPRC");
|
2010-08-31 01:05:56 +08:00
|
|
|
|
|
|
|
#ifdef PHP_WIN32
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
if (!env_location) {
|
2010-08-31 01:05:56 +08:00
|
|
|
char dummybuf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
SetLastError(0);
|
|
|
|
|
2015-09-25 19:16:53 +08:00
|
|
|
/*If the given buffer is not large enough to hold the data, the return value is
|
2015-01-03 17:22:58 +08:00
|
|
|
the buffer size, in characters, required to hold the string and its terminating
|
2010-08-31 01:05:56 +08:00
|
|
|
null character. We use this return value to alloc the final buffer. */
|
|
|
|
size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
|
|
|
|
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
|
|
|
|
/* The environment variable doesn't exist. */
|
|
|
|
env_location = "";
|
|
|
|
} else {
|
|
|
|
if (size == 0) {
|
|
|
|
env_location = "";
|
|
|
|
} else {
|
|
|
|
size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
|
2011-12-07 18:28:56 +08:00
|
|
|
if (size == 0) {
|
|
|
|
env_location = "";
|
|
|
|
} else {
|
|
|
|
env_location = phprc_path;
|
|
|
|
}
|
2010-08-31 01:05:56 +08:00
|
|
|
}
|
|
|
|
}
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
}
|
2010-08-31 05:34:54 +08:00
|
|
|
#else
|
|
|
|
if (!env_location) {
|
|
|
|
env_location = "";
|
|
|
|
}
|
2010-08-31 01:05:56 +08:00
|
|
|
#endif
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
/*
|
|
|
|
* Prepare search path
|
|
|
|
*/
|
|
|
|
|
2014-10-27 20:15:47 +08:00
|
|
|
search_path_size = MAXPATHLEN * 4 + (int)strlen(env_location) + 3 + 1;
|
2006-12-28 20:18:54 +08:00
|
|
|
php_ini_search_path = (char *) emalloc(search_path_size);
|
2002-05-11 11:41:17 +08:00
|
|
|
free_ini_search_path = 1;
|
|
|
|
php_ini_search_path[0] = 0;
|
2002-05-10 04:34:53 +08:00
|
|
|
|
2006-07-04 14:35:49 +08:00
|
|
|
/* Add environment location */
|
|
|
|
if (env_location[0]) {
|
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2006-07-04 14:35:49 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, env_location, search_path_size);
|
2006-08-03 19:04:52 +08:00
|
|
|
php_ini_file_name = env_location;
|
2006-07-04 14:35:49 +08:00
|
|
|
}
|
|
|
|
|
2003-10-19 18:39:27 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
/* Add registry location */
|
|
|
|
reg_location = GetIniPathFromRegistry();
|
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file
#
# Before this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
# With this patch:
#
# $ strace php -r 'echo 1;' 2>&1 | grep php.ini
# open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
# open("/www/php/lib/php.ini", O_RDONLY) = 3
# lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0
#
2005-07-29 22:29:27 +08:00
|
|
|
if (reg_location != NULL) {
|
2003-10-19 18:39:27 +08:00
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2003-10-19 18:39:27 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, reg_location, search_path_size);
|
2003-10-19 18:39:27 +08:00
|
|
|
efree(reg_location);
|
|
|
|
}
|
|
|
|
#endif
|
2002-05-10 04:03:36 +08:00
|
|
|
|
2006-09-05 19:54:15 +08:00
|
|
|
/* Add cwd (not with CLI) */
|
2010-11-12 01:24:27 +08:00
|
|
|
if (!sapi_module.php_ini_ignore_cwd) {
|
2002-08-12 13:37:03 +08:00
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2002-08-12 13:37:03 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, ".", search_path_size);
|
2002-05-11 11:41:17 +08:00
|
|
|
}
|
2002-05-10 04:03:36 +08:00
|
|
|
|
2011-12-07 18:33:13 +08:00
|
|
|
if (PG(php_binary)) {
|
|
|
|
char *separator_location, *binary_location;
|
|
|
|
|
|
|
|
binary_location = estrdup(PG(php_binary));
|
|
|
|
separator_location = strrchr(binary_location, DEFAULT_SLASH);
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2005-07-27 23:13:50 +08:00
|
|
|
if (separator_location && separator_location != binary_location) {
|
2005-07-27 23:12:18 +08:00
|
|
|
*(separator_location) = 0;
|
2002-05-11 11:41:17 +08:00
|
|
|
}
|
2002-08-12 13:37:03 +08:00
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2002-08-12 13:37:03 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, binary_location, search_path_size);
|
2002-05-11 11:41:17 +08:00
|
|
|
efree(binary_location);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add default location */
|
|
|
|
#ifdef PHP_WIN32
|
2003-02-19 17:38:11 +08:00
|
|
|
default_location = (char *) emalloc(MAXPATHLEN + 1);
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2002-08-12 13:37:03 +08:00
|
|
|
if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
|
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2002-08-12 13:37:03 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, default_location, search_path_size);
|
2002-05-11 11:41:17 +08:00
|
|
|
}
|
2003-12-07 00:04:34 +08:00
|
|
|
|
2009-10-12 05:04:35 +08:00
|
|
|
/* For people running under terminal services, GetWindowsDirectory will
|
|
|
|
* return their personal Windows directory, so lets add the system
|
|
|
|
* windows directory too */
|
|
|
|
if (0 < GetSystemWindowsDirectory(default_location, MAXPATHLEN)) {
|
|
|
|
if (*php_ini_search_path) {
|
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2003-12-07 00:04:34 +08:00
|
|
|
}
|
2009-10-12 05:04:35 +08:00
|
|
|
strlcat(php_ini_search_path, default_location, search_path_size);
|
2003-12-07 00:04:34 +08:00
|
|
|
}
|
2009-10-12 05:04:35 +08:00
|
|
|
efree(default_location);
|
|
|
|
|
2002-05-10 04:34:53 +08:00
|
|
|
#else
|
2002-05-11 11:41:17 +08:00
|
|
|
default_location = PHP_CONFIG_FILE_PATH;
|
2002-08-12 13:37:03 +08:00
|
|
|
if (*php_ini_search_path) {
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, paths_separator, search_path_size);
|
2002-08-12 13:37:03 +08:00
|
|
|
}
|
2006-12-28 20:18:54 +08:00
|
|
|
strlcat(php_ini_search_path, default_location, search_path_size);
|
2002-05-10 04:34:53 +08:00
|
|
|
#endif
|
2002-05-11 11:41:17 +08:00
|
|
|
}
|
2002-05-10 04:34:53 +08:00
|
|
|
|
2002-05-11 11:41:17 +08:00
|
|
|
PG(open_basedir) = NULL;
|
|
|
|
|
2008-08-13 08:53:28 +08:00
|
|
|
/*
|
|
|
|
* Find and open actual ini file
|
|
|
|
*/
|
|
|
|
|
2003-02-18 17:37:54 +08:00
|
|
|
memset(&fh, 0, sizeof(fh));
|
2008-08-13 08:53:28 +08:00
|
|
|
|
|
|
|
/* If SAPI does not want to ignore all ini files OR an overriding file/path is given.
|
|
|
|
* This allows disabling scanning for ini files in the PHP_CONFIG_FILE_SCAN_DIR but still
|
|
|
|
* load an optional ini file. */
|
|
|
|
if (!sapi_module.php_ini_ignore || sapi_module.php_ini_path_override) {
|
|
|
|
|
|
|
|
/* Check if php_ini_file_name is a file and can be opened */
|
2006-08-03 19:04:52 +08:00
|
|
|
if (php_ini_file_name && php_ini_file_name[0]) {
|
2014-08-26 02:22:49 +08:00
|
|
|
zend_stat_t statbuf;
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2006-08-03 19:04:52 +08:00
|
|
|
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
|
2002-11-13 04:56:47 +08:00
|
|
|
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
|
2006-08-03 19:04:52 +08:00
|
|
|
fh.handle.fp = VCWD_FOPEN(php_ini_file_name, "r");
|
|
|
|
if (fh.handle.fp) {
|
2015-03-04 07:05:28 +08:00
|
|
|
fh.filename = expand_filepath(php_ini_file_name, NULL);
|
2006-08-03 19:04:52 +08:00
|
|
|
}
|
2002-11-13 04:56:47 +08:00
|
|
|
}
|
2002-05-11 11:41:17 +08:00
|
|
|
}
|
|
|
|
}
|
2008-08-13 08:53:28 +08:00
|
|
|
|
|
|
|
/* Otherwise search for php-%sapi-module-name%.ini file in search path */
|
2002-11-13 04:56:47 +08:00
|
|
|
if (!fh.handle.fp) {
|
|
|
|
const char *fmt = "php-%s.ini";
|
2007-02-24 10:17:47 +08:00
|
|
|
char *ini_fname;
|
|
|
|
spprintf(&ini_fname, 0, fmt, sapi_module.name);
|
2015-03-04 07:05:28 +08:00
|
|
|
fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &opened_path);
|
2002-11-13 04:56:47 +08:00
|
|
|
efree(ini_fname);
|
|
|
|
if (fh.handle.fp) {
|
2015-06-30 18:59:27 +08:00
|
|
|
fh.filename = ZSTR_VAL(opened_path);
|
2002-11-13 04:56:47 +08:00
|
|
|
}
|
2002-08-12 13:37:03 +08:00
|
|
|
}
|
2008-08-13 08:53:28 +08:00
|
|
|
|
|
|
|
/* If still no ini file found, search for php.ini file in search path */
|
2002-11-13 04:56:47 +08:00
|
|
|
if (!fh.handle.fp) {
|
2015-03-04 07:05:28 +08:00
|
|
|
fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
|
2002-11-13 04:56:47 +08:00
|
|
|
if (fh.handle.fp) {
|
2015-06-30 18:59:27 +08:00
|
|
|
fh.filename = ZSTR_VAL(opened_path);
|
2002-11-13 04:56:47 +08:00
|
|
|
}
|
2002-07-29 20:17:34 +08:00
|
|
|
}
|
2002-05-19 22:45:31 +08:00
|
|
|
}
|
2003-02-19 17:38:11 +08:00
|
|
|
|
2002-05-11 11:41:17 +08:00
|
|
|
if (free_ini_search_path) {
|
|
|
|
efree(php_ini_search_path);
|
|
|
|
}
|
2003-02-19 17:38:11 +08:00
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
PG(open_basedir) = open_basedir;
|
|
|
|
|
2002-10-04 12:47:35 +08:00
|
|
|
if (fh.handle.fp) {
|
|
|
|
fh.type = ZEND_HANDLE_FP;
|
2007-09-28 10:05:10 +08:00
|
|
|
RESET_ACTIVE_INI_HASH();
|
2002-05-10 04:03:36 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash);
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2002-10-04 12:47:35 +08:00
|
|
|
{
|
|
|
|
zval tmp;
|
2007-08-31 16:16:13 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
|
2015-03-04 07:05:28 +08:00
|
|
|
if (opened_path) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(opened_path, 0);
|
2015-09-10 19:53:37 +08:00
|
|
|
} else {
|
|
|
|
efree((char *)fh.filename);
|
2003-02-19 17:38:11 +08:00
|
|
|
}
|
2014-08-26 01:24:55 +08:00
|
|
|
php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
2002-11-13 04:56:47 +08:00
|
|
|
}
|
2002-10-04 12:47:35 +08:00
|
|
|
|
2008-08-13 08:53:28 +08:00
|
|
|
/* Check for PHP_INI_SCAN_DIR environment variable to override/set config file scan directory */
|
|
|
|
php_ini_scanned_path = getenv("PHP_INI_SCAN_DIR");
|
|
|
|
if (!php_ini_scanned_path) {
|
|
|
|
/* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */
|
|
|
|
php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR;
|
|
|
|
}
|
2014-10-27 20:15:47 +08:00
|
|
|
php_ini_scanned_path_len = (int)strlen(php_ini_scanned_path);
|
2008-08-13 08:53:28 +08:00
|
|
|
|
|
|
|
/* Scan and parse any .ini files found in scan path if path not empty. */
|
|
|
|
if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
|
2003-01-26 05:13:00 +08:00
|
|
|
struct dirent **namelist;
|
|
|
|
int ndir, i;
|
2014-08-26 02:22:49 +08:00
|
|
|
zend_stat_t sb;
|
2007-09-28 10:05:10 +08:00
|
|
|
char ini_file[MAXPATHLEN];
|
|
|
|
char *p;
|
2011-01-10 16:28:47 +08:00
|
|
|
zend_file_handle fh2;
|
2007-09-28 10:05:10 +08:00
|
|
|
zend_llist scanned_ini_list;
|
|
|
|
zend_llist_element *element;
|
|
|
|
int l, total_l = 0;
|
2014-01-29 16:53:22 +08:00
|
|
|
char *bufpath, *debpath, *endpath;
|
|
|
|
int lenpath;
|
2007-09-28 10:05:10 +08:00
|
|
|
|
2014-01-29 16:53:22 +08:00
|
|
|
zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
|
|
|
|
memset(&fh2, 0, sizeof(fh2));
|
2007-09-28 10:05:10 +08:00
|
|
|
|
2014-01-29 16:53:22 +08:00
|
|
|
bufpath = estrdup(php_ini_scanned_path);
|
|
|
|
for (debpath = bufpath ; debpath ; debpath=endpath) {
|
|
|
|
endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR);
|
|
|
|
if (endpath) {
|
|
|
|
*(endpath++) = 0;
|
|
|
|
}
|
|
|
|
if (!debpath[0]) {
|
|
|
|
/* empty string means default builtin value
|
2015-11-11 06:06:06 +08:00
|
|
|
to allow "/foo/php.d:" or ":/foo/php.d" */
|
2014-01-29 16:53:22 +08:00
|
|
|
debpath = PHP_CONFIG_FILE_SCAN_DIR;
|
|
|
|
}
|
2014-10-27 20:15:47 +08:00
|
|
|
lenpath = (int)strlen(debpath);
|
2007-09-28 10:05:10 +08:00
|
|
|
|
2014-01-29 16:53:22 +08:00
|
|
|
if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) {
|
2010-09-09 13:11:05 +08:00
|
|
|
|
2014-01-29 16:53:22 +08:00
|
|
|
for (i = 0; i < ndir; i++) {
|
|
|
|
|
|
|
|
/* check for any file with .ini extension */
|
|
|
|
if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
|
|
|
|
free(namelist[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Reset active ini section */
|
|
|
|
RESET_ACTIVE_INI_HASH();
|
|
|
|
|
|
|
|
if (IS_SLASH(debpath[lenpath - 1])) {
|
|
|
|
snprintf(ini_file, MAXPATHLEN, "%s%s", debpath, namelist[i]->d_name);
|
|
|
|
} else {
|
|
|
|
snprintf(ini_file, MAXPATHLEN, "%s%c%s", debpath, DEFAULT_SLASH, namelist[i]->d_name);
|
|
|
|
}
|
|
|
|
if (VCWD_STAT(ini_file, &sb) == 0) {
|
|
|
|
if (S_ISREG(sb.st_mode)) {
|
|
|
|
if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
|
|
|
|
fh2.filename = ini_file;
|
|
|
|
fh2.type = ZEND_HANDLE_FP;
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash) == SUCCESS) {
|
2014-01-29 16:53:22 +08:00
|
|
|
/* Here, add it to the list of ini files read */
|
2014-10-27 20:15:47 +08:00
|
|
|
l = (int)strlen(ini_file);
|
2014-01-29 16:53:22 +08:00
|
|
|
total_l += l + 2;
|
|
|
|
p = estrndup(ini_file, l);
|
|
|
|
zend_llist_add_element(&scanned_ini_list, &p);
|
|
|
|
}
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
|
|
|
}
|
2014-01-29 16:53:22 +08:00
|
|
|
free(namelist[i]);
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
2014-01-29 16:53:22 +08:00
|
|
|
free(namelist);
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
2014-01-29 16:53:22 +08:00
|
|
|
}
|
|
|
|
efree(bufpath);
|
2003-01-26 05:13:00 +08:00
|
|
|
|
2014-01-29 16:53:22 +08:00
|
|
|
if (total_l) {
|
2014-10-27 20:15:47 +08:00
|
|
|
int php_ini_scanned_files_len = (php_ini_scanned_files) ? (int)strlen(php_ini_scanned_files) + 1 : 0;
|
2014-01-29 16:53:22 +08:00
|
|
|
php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
|
|
|
|
if (!php_ini_scanned_files_len) {
|
|
|
|
*php_ini_scanned_files = '\0';
|
|
|
|
}
|
|
|
|
total_l += php_ini_scanned_files_len;
|
|
|
|
for (element = scanned_ini_list.head; element; element = element->next) {
|
|
|
|
if (php_ini_scanned_files_len) {
|
|
|
|
strlcat(php_ini_scanned_files, ",\n", total_l);
|
2007-08-31 16:16:13 +08:00
|
|
|
}
|
2014-01-29 16:53:22 +08:00
|
|
|
strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
|
|
|
|
strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
|
2004-02-14 20:29:04 +08:00
|
|
|
}
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
2014-01-29 16:53:22 +08:00
|
|
|
zend_llist_destroy(&scanned_ini_list);
|
2008-08-13 08:53:28 +08:00
|
|
|
} else {
|
|
|
|
/* Make sure an empty php_ini_scanned_path ends up as NULL */
|
|
|
|
php_ini_scanned_path = NULL;
|
2002-05-10 04:03:36 +08:00
|
|
|
}
|
2006-09-20 04:33:12 +08:00
|
|
|
|
|
|
|
if (sapi_module.ini_entries) {
|
2007-09-28 10:05:10 +08:00
|
|
|
/* Reset active ini section */
|
|
|
|
RESET_ACTIVE_INI_HASH();
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_parse_ini_string(sapi_module.ini_entries, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash);
|
2006-09-20 04:33:12 +08:00
|
|
|
}
|
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
return SUCCESS;
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ php_shutdown_config
|
|
|
|
*/
|
2000-10-31 07:39:14 +08:00
|
|
|
int php_shutdown_config(void)
|
|
|
|
{
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_hash_destroy(&configuration_hash);
|
|
|
|
if (php_ini_opened_path) {
|
|
|
|
free(php_ini_opened_path);
|
2004-09-17 10:48:41 +08:00
|
|
|
php_ini_opened_path = NULL;
|
2002-05-10 04:03:36 +08:00
|
|
|
}
|
2002-10-04 12:47:35 +08:00
|
|
|
if (php_ini_scanned_files) {
|
|
|
|
free(php_ini_scanned_files);
|
2004-09-17 10:48:41 +08:00
|
|
|
php_ini_scanned_files = NULL;
|
2002-10-04 12:47:35 +08:00
|
|
|
}
|
2002-05-10 04:03:36 +08:00
|
|
|
return SUCCESS;
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2005-06-17 17:39:23 +08:00
|
|
|
/* {{{ php_ini_register_extensions
|
2001-06-06 21:06:12 +08:00
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
void php_ini_register_extensions(void)
|
2001-03-18 07:35:32 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
|
|
|
|
zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb);
|
2001-03-18 07:35:32 +08:00
|
|
|
|
2002-05-10 04:03:36 +08:00
|
|
|
zend_llist_destroy(&extension_lists.engine);
|
|
|
|
zend_llist_destroy(&extension_lists.functions);
|
2001-03-18 07:35:32 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2001-03-18 07:35:32 +08:00
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* {{{ php_parse_user_ini_file
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash)
|
2007-09-28 10:05:10 +08:00
|
|
|
{
|
2014-08-26 02:22:49 +08:00
|
|
|
zend_stat_t sb;
|
2007-09-28 10:05:10 +08:00
|
|
|
char ini_file[MAXPATHLEN];
|
|
|
|
zend_file_handle fh;
|
|
|
|
|
|
|
|
snprintf(ini_file, MAXPATHLEN, "%s%c%s", dirname, DEFAULT_SLASH, ini_filename);
|
|
|
|
|
|
|
|
if (VCWD_STAT(ini_file, &sb) == 0) {
|
|
|
|
if (S_ISREG(sb.st_mode)) {
|
|
|
|
memset(&fh, 0, sizeof(fh));
|
|
|
|
if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
|
|
|
|
fh.filename = ini_file;
|
|
|
|
fh.type = ZEND_HANDLE_FP;
|
|
|
|
|
|
|
|
/* Reset active ini section */
|
|
|
|
RESET_ACTIVE_INI_HASH();
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash) == SUCCESS) {
|
2007-09-28 10:05:10 +08:00
|
|
|
/* FIXME: Add parsed file to the list of user files read? */
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_ini_activate_config
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage)
|
2007-09-28 10:05:10 +08:00
|
|
|
{
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *str;
|
2007-09-28 10:05:10 +08:00
|
|
|
zval *data;
|
|
|
|
|
|
|
|
/* Walk through config hash and alter matching ini entries using the values found in the hash */
|
2015-02-10 20:43:12 +08:00
|
|
|
ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0);
|
2015-02-10 20:43:12 +08:00
|
|
|
} ZEND_HASH_FOREACH_END();
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2008-04-15 19:31:58 +08:00
|
|
|
/* {{{ php_ini_has_per_dir_config
|
|
|
|
*/
|
|
|
|
PHPAPI int php_ini_has_per_dir_config(void)
|
|
|
|
{
|
|
|
|
return has_per_dir_config;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* {{{ php_ini_activate_per_dir_config
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len)
|
2007-09-28 10:05:10 +08:00
|
|
|
{
|
2011-01-10 16:28:47 +08:00
|
|
|
zval *tmp2;
|
2007-09-28 10:05:10 +08:00
|
|
|
char *ptr;
|
|
|
|
|
2017-04-10 14:47:24 +08:00
|
|
|
#ifdef PHP_WIN32
|
2009-10-15 21:09:25 +08:00
|
|
|
char path_bak[MAXPATHLEN];
|
2011-01-19 22:21:46 +08:00
|
|
|
#endif
|
2011-01-17 22:29:16 +08:00
|
|
|
|
2017-04-10 14:47:24 +08:00
|
|
|
#ifdef PHP_WIN32
|
2013-07-15 23:34:36 +08:00
|
|
|
/* MAX_PATH is \0-terminated, path_len == MAXPATHLEN would overrun path_bak */
|
|
|
|
if (path_len >= MAXPATHLEN) {
|
|
|
|
#else
|
2011-01-17 22:29:16 +08:00
|
|
|
if (path_len > MAXPATHLEN) {
|
2013-07-15 23:34:36 +08:00
|
|
|
#endif
|
2011-01-17 22:29:16 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-01-19 22:21:46 +08:00
|
|
|
|
2017-04-10 14:47:24 +08:00
|
|
|
#ifdef PHP_WIN32
|
2009-10-15 21:09:25 +08:00
|
|
|
memcpy(path_bak, path, path_len);
|
2011-07-18 18:25:36 +08:00
|
|
|
path_bak[path_len] = 0;
|
2009-10-15 21:09:25 +08:00
|
|
|
TRANSLATE_SLASHES_LOWER(path_bak);
|
|
|
|
path = path_bak;
|
|
|
|
#endif
|
|
|
|
|
2007-09-28 10:05:10 +08:00
|
|
|
/* Walk through each directory in path and apply any found per-dir-system-configuration from configuration_hash */
|
2008-04-15 19:31:58 +08:00
|
|
|
if (has_per_dir_config && path && path_len) {
|
2007-09-28 10:05:10 +08:00
|
|
|
ptr = path + 1;
|
2009-10-15 21:09:25 +08:00
|
|
|
while ((ptr = strchr(ptr, '/')) != NULL) {
|
2007-09-28 10:05:10 +08:00
|
|
|
*ptr = 0;
|
|
|
|
/* Search for source array matching the path from configuration_hash */
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((tmp2 = zend_hash_str_find(&configuration_hash, path, strlen(path))) != NULL) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_ini_activate_config(Z_ARRVAL_P(tmp2), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
|
2007-09-28 10:05:10 +08:00
|
|
|
}
|
|
|
|
*ptr = '/';
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2008-04-15 19:31:58 +08:00
|
|
|
/* {{{ php_ini_has_per_host_config
|
|
|
|
*/
|
|
|
|
PHPAPI int php_ini_has_per_host_config(void)
|
|
|
|
{
|
|
|
|
return has_per_host_config;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2007-11-10 00:27:43 +08:00
|
|
|
/* {{{ php_ini_activate_per_host_config
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len)
|
2007-11-10 00:27:43 +08:00
|
|
|
{
|
|
|
|
zval *tmp;
|
|
|
|
|
2008-04-15 19:31:58 +08:00
|
|
|
if (has_per_host_config && host && host_len) {
|
2007-11-10 00:27:43 +08:00
|
|
|
/* Search for source array matching the host from configuration_hash */
|
2014-02-18 20:27:38 +08:00
|
|
|
if ((tmp = zend_hash_str_find(&configuration_hash, host, host_len)) != NULL) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
|
2007-11-10 00:27:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-09-02 00:57:33 +08:00
|
|
|
/* {{{ cfg_get_entry
|
|
|
|
*/
|
|
|
|
PHPAPI zval *cfg_get_entry_ex(zend_string *name)
|
|
|
|
{
|
|
|
|
return zend_hash_find(&configuration_hash, name);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ cfg_get_entry
|
|
|
|
*/
|
2014-12-02 16:14:22 +08:00
|
|
|
PHPAPI zval *cfg_get_entry(const char *name, size_t name_length)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2014-02-18 20:27:38 +08:00
|
|
|
return zend_hash_str_find(&configuration_hash, name, name_length);
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
/* {{{ cfg_get_long
|
2001-06-06 21:06:12 +08:00
|
|
|
*/
|
2014-08-26 01:24:55 +08:00
|
|
|
PHPAPI int cfg_get_long(const char *varname, zend_long *result)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2015-04-26 02:43:11 +08:00
|
|
|
zval *tmp;
|
2007-08-31 16:09:50 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
|
2007-04-16 16:09:56 +08:00
|
|
|
*result = 0;
|
2002-05-10 04:03:36 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2015-04-26 02:43:11 +08:00
|
|
|
*result = zval_get_long(tmp);
|
2002-05-10 04:03:36 +08:00
|
|
|
return SUCCESS;
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ cfg_get_double
|
|
|
|
*/
|
2008-08-13 01:20:25 +08:00
|
|
|
PHPAPI int cfg_get_double(const char *varname, double *result)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2015-04-26 02:43:11 +08:00
|
|
|
zval *tmp;
|
2007-08-31 16:09:50 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
|
2003-02-19 17:38:11 +08:00
|
|
|
*result = (double) 0;
|
2002-05-10 04:03:36 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2015-04-26 02:43:11 +08:00
|
|
|
*result = zval_get_double(tmp);
|
2002-05-10 04:03:36 +08:00
|
|
|
return SUCCESS;
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2000-10-31 07:39:14 +08:00
|
|
|
|
2001-06-06 21:06:12 +08:00
|
|
|
/* {{{ cfg_get_string
|
|
|
|
*/
|
2008-08-13 01:20:25 +08:00
|
|
|
PHPAPI int cfg_get_string(const char *varname, char **result)
|
2000-10-31 07:39:14 +08:00
|
|
|
{
|
2002-05-10 04:03:36 +08:00
|
|
|
zval *tmp;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
|
2003-02-19 17:38:11 +08:00
|
|
|
*result = NULL;
|
2002-05-10 04:03:36 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
*result = Z_STRVAL_P(tmp);
|
|
|
|
return SUCCESS;
|
2000-10-31 07:39:14 +08:00
|
|
|
}
|
2001-06-06 21:06:12 +08:00
|
|
|
/* }}} */
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2008-02-03 22:35:59 +08:00
|
|
|
PHPAPI HashTable* php_ini_get_configuration_hash(void) /* {{{ */
|
2007-09-28 10:05:10 +08:00
|
|
|
{
|
2008-02-03 22:35:59 +08:00
|
|
|
return &configuration_hash;
|
|
|
|
} /* }}} */
|