mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Buh-bye php3_ini
This commit is contained in:
parent
4472d05025
commit
bb6dff9c67
@ -90,10 +90,6 @@
|
||||
#include "functions/php3_sysvshm.h"
|
||||
#include "functions/php3_dav.h"
|
||||
|
||||
|
||||
extern php3_ini_structure php3_ini;
|
||||
extern php3_ini_structure php3_ini_master;
|
||||
|
||||
unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
|
||||
unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
|
||||
unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define DEBUG_CFG_PARSER 1
|
||||
#include "php.h"
|
||||
#include "php_globals.h"
|
||||
#include "php_ini.h"
|
||||
#include "functions/dl.h"
|
||||
#include "functions/file.h"
|
||||
#include "functions/php3_browscap.h"
|
||||
@ -248,22 +249,22 @@ int php3_init_config(void)
|
||||
|
||||
int php3_minit_browscap(INIT_FUNC_ARGS)
|
||||
{
|
||||
TLS_VARS;
|
||||
char *browscap = INI_STR("browscap");
|
||||
|
||||
if (php3_ini.browscap) {
|
||||
if (browscap) {
|
||||
if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
cfgin = fopen(php3_ini.browscap,"r");
|
||||
cfgin = fopen(browscap, "r");
|
||||
if (!cfgin) {
|
||||
php3_error(E_WARNING,"Cannot open '%s' for reading",php3_ini.browscap);
|
||||
php3_error(E_WARNING,"Cannot open '%s' for reading", browscap);
|
||||
return FAILURE;
|
||||
}
|
||||
init_cfg_scanner();
|
||||
active__php3_hash_table = &GLOBAL(browser_hash);
|
||||
parsing_mode = PARSING_MODE_BROWSCAP;
|
||||
currently_parsed_filename = php3_ini.browscap;
|
||||
currently_parsed_filename = browscap;
|
||||
yyparse();
|
||||
fclose(cfgin);
|
||||
}
|
||||
@ -281,9 +282,7 @@ int php3_shutdown_config(void)
|
||||
|
||||
int php3_mshutdown_browscap(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
TLS_VARS;
|
||||
|
||||
if (php3_ini.browscap) {
|
||||
if (INI_STR("browscap")) {
|
||||
_php3_hash_destroy(&GLOBAL(browser_hash));
|
||||
}
|
||||
return SUCCESS;
|
||||
|
@ -111,10 +111,10 @@ PHPAPI int _php3_check_open_basedir(char *path)
|
||||
int local_open_basedir_pos;
|
||||
|
||||
/* Only check when open_basedir is available */
|
||||
if (php3_ini.open_basedir && *php3_ini.open_basedir) {
|
||||
if (PG(open_basedir) && *PG(open_basedir)) {
|
||||
|
||||
/* Special case basedir==".": Use script-directory */
|
||||
if ((strcmp(php3_ini.open_basedir, ".") == 0) &&
|
||||
if ((strcmp(PG(open_basedir), ".") == 0) &&
|
||||
GLOBAL(request_info).filename &&
|
||||
*GLOBAL(request_info).filename
|
||||
) {
|
||||
@ -149,7 +149,7 @@ PHPAPI int _php3_check_open_basedir(char *path)
|
||||
|
||||
} else {
|
||||
/* Else use the unmodified path */
|
||||
strcpy(local_open_basedir, php3_ini.open_basedir);
|
||||
strcpy(local_open_basedir, PG(open_basedir));
|
||||
}
|
||||
|
||||
/* Resolve the real path into resolved_name */
|
||||
@ -186,8 +186,8 @@ PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options & USE_PATH && php3_ini.include_path != NULL) {
|
||||
return php3_fopen_with_path(path, mode, php3_ini.include_path, NULL);
|
||||
if (options & USE_PATH && PG(include_path) != NULL) {
|
||||
return php3_fopen_with_path(path, mode, PG(include_path), NULL);
|
||||
} else {
|
||||
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
|
||||
if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path, cm))) {
|
||||
@ -212,7 +212,7 @@ FILE *php3_fopen_for_parser(void)
|
||||
fn = GLOBAL(request_info).filename;
|
||||
path_info = GLOBAL(request_info).path_info;
|
||||
#if HAVE_PWD_H
|
||||
if (php3_ini.user_dir && *php3_ini.user_dir
|
||||
if (PG(user_dir) && *PG(user_dir)
|
||||
&& path_info && '/' == path_info[0] && '~' == path_info[1]) {
|
||||
|
||||
char user[32];
|
||||
@ -230,11 +230,11 @@ FILE *php3_fopen_for_parser(void)
|
||||
|
||||
pw = getpwnam(user);
|
||||
if (pw && pw->pw_dir) {
|
||||
fn = emalloc(strlen(php3_ini.user_dir) + strlen(path_info) + strlen(pw->pw_dir) + 4);
|
||||
fn = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4);
|
||||
if (fn) {
|
||||
strcpy(fn, pw->pw_dir); /* safe */
|
||||
strcat(fn, "/"); /* safe */
|
||||
strcat(fn, php3_ini.user_dir); /* safe */
|
||||
strcat(fn, PG(user_dir)); /* safe */
|
||||
strcat(fn, "/"); /* safe */
|
||||
strcat(fn, s + 1); /* safe (shorter than path_info) */
|
||||
STR_FREE(GLOBAL(request_info).filename);
|
||||
@ -245,16 +245,16 @@ FILE *php3_fopen_for_parser(void)
|
||||
} else
|
||||
#endif
|
||||
#if WIN32
|
||||
if (php3_ini.doc_root && path_info && ('/' == *php3_ini.doc_root ||
|
||||
'\\' == *php3_ini.doc_root || strstr(php3_ini.doc_root,":\\") ||
|
||||
strstr(php3_ini.doc_root,":/"))) {
|
||||
if (PG(doc_root) && path_info && ('/' == *PG(doc_root) ||
|
||||
'\\' == *PG(doc_root) || strstr(PG(doc_root),":\\") ||
|
||||
strstr(PG(doc_root),":/"))) {
|
||||
#else
|
||||
if (php3_ini.doc_root && '/' == *php3_ini.doc_root && path_info) {
|
||||
if (PG(doc_root) && '/' == *PG(doc_root) && path_info) {
|
||||
#endif
|
||||
l = strlen(php3_ini.doc_root);
|
||||
l = strlen(PG(doc_root));
|
||||
fn = emalloc(l + strlen(path_info) + 2);
|
||||
if (fn) {
|
||||
memcpy(fn, php3_ini.doc_root, l);
|
||||
memcpy(fn, PG(doc_root), l);
|
||||
if ('/' != fn[l - 1] || '\\' != fn[l - 1]) /* l is never 0 */
|
||||
fn[l++] = '/';
|
||||
if ('/' == path_info[0])
|
||||
@ -334,8 +334,8 @@ PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char *
|
||||
if (*filename == '/') {
|
||||
#endif
|
||||
if (PG(safe_mode)) {
|
||||
if(php3_ini.doc_root) {
|
||||
snprintf(trypath, MAXPATHLEN, "%s%s", php3_ini.doc_root, filename);
|
||||
if(PG(doc_root)) {
|
||||
snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename);
|
||||
} else {
|
||||
strncpy(trypath,filename,MAXPATHLEN);
|
||||
}
|
||||
@ -883,7 +883,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i
|
||||
|
||||
} else {
|
||||
if (options & USE_PATH) {
|
||||
fp = php3_fopen_with_path((char *) path, mode, php3_ini.include_path, NULL);
|
||||
fp = php3_fopen_with_path((char *) path, mode, PG(include_path), NULL);
|
||||
} else {
|
||||
int cm=2;
|
||||
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
|
||||
|
221
main/main.c
221
main/main.c
@ -99,7 +99,6 @@ struct sapi_request_info *sapi_rqst;
|
||||
#include "getopt.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
int compiler_globals_id;
|
||||
int executor_globals_id;
|
||||
@ -109,6 +108,10 @@ int executor_globals_id;
|
||||
php_core_globals core_globals;
|
||||
#endif
|
||||
|
||||
void _php3_build_argv(char * ELS_DC);
|
||||
static void php3_timeout(int dummy);
|
||||
static void php3_set_timeout(long seconds INLINE_TLS);
|
||||
|
||||
void *gLock; /*mutex variable */
|
||||
|
||||
|
||||
@ -120,7 +123,8 @@ void *gLock; /*mutex variable */
|
||||
HashTable configuration_hash;
|
||||
char *php3_ini_path = NULL;
|
||||
|
||||
PHP_INI_MH(OnSetPrecision)
|
||||
|
||||
static PHP_INI_MH(OnSetPrecision)
|
||||
{
|
||||
ELS_FETCH();
|
||||
|
||||
@ -129,6 +133,46 @@ PHP_INI_MH(OnSetPrecision)
|
||||
}
|
||||
|
||||
|
||||
static PHP_INI_MH(OnChangeMaxExecutionTime)
|
||||
{
|
||||
int new_timeout;
|
||||
|
||||
if (new_value) {
|
||||
new_timeout = atoi(new_value);
|
||||
} else {
|
||||
new_timeout = 0;
|
||||
}
|
||||
php3_set_timeout(new_timeout);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static PHP_INI_MH(OnChangeMemoryLimit)
|
||||
{
|
||||
int new_limit;
|
||||
|
||||
if (new_value) {
|
||||
new_limit = atoi(new_value);
|
||||
} else {
|
||||
new_limit = 2<<30; /* effectively, no limit */
|
||||
}
|
||||
return zend_set_memory_limit(new_limit);
|
||||
}
|
||||
|
||||
|
||||
static PHP_INI_MH(OnUpdateErrorReporting)
|
||||
{
|
||||
ELS_FETCH();
|
||||
|
||||
if (!new_value) {
|
||||
EG(error_reporting) = E_ALL & ~E_NOTICE;
|
||||
} else {
|
||||
EG(error_reporting) = atoi(new_value);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Need to convert to strings and make use of:
|
||||
* DEFAULT_SHORT_OPEN_TAG
|
||||
* PHP_SAFE_MODE
|
||||
@ -136,6 +180,9 @@ PHP_INI_MH(OnSetPrecision)
|
||||
* Need to be read from the environment (?):
|
||||
* PHP_AUTO_PREPEND_FILE
|
||||
* PHP_AUTO_APPEND_FILE
|
||||
* PHP_DOCUMENT_ROOT
|
||||
* PHP_USER_DIR
|
||||
* PHP_INCLUDE_PATH
|
||||
*/
|
||||
|
||||
#ifndef SAFE_MODE_EXEC_DIR
|
||||
@ -167,17 +214,41 @@ PHP_INI_BEGIN()
|
||||
PHP_INI_ENTRY("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, safe_mode))
|
||||
PHP_INI_ENTRY("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, sql_safe_mode))
|
||||
PHP_INI_ENTRY("safe_mode_exec_dir", SAFE_MODE_EXEC_DIR, PHP_INI_SYSTEM, OnUpdateString, (void *) XtOffsetOf(php_core_globals, safe_mode_exec_dir))
|
||||
PHP_INI_ENTRY("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, enable_dl))
|
||||
|
||||
PHP_INI_ENTRY("SMTP", "localhost", PHP_INI_ALL, NULL, NULL)
|
||||
PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL, NULL)
|
||||
PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL, NULL)
|
||||
|
||||
PHP_INI_ENTRY("error_reporting", NULL, PHP_INI_ALL, OnUpdateErrorReporting, NULL)
|
||||
PHP_INI_ENTRY("display_errors", "1", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, display_errors))
|
||||
PHP_INI_ENTRY("track_errors", "0", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, track_errors))
|
||||
PHP_INI_ENTRY("log_errors", "0", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, log_errors))
|
||||
PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, (void *) XtOffsetOf(php_core_globals, error_log))
|
||||
|
||||
PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, (void *) XtOffsetOf(php_core_globals, auto_prepend_file))
|
||||
PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, (void *) XtOffsetOf(php_core_globals, auto_append_file))
|
||||
|
||||
PHP_INI_ENTRY("y2k_compliance", "0", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, y2k_compliance))
|
||||
|
||||
PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, doc_root))
|
||||
PHP_INI_ENTRY("user_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, user_dir))
|
||||
PHP_INI_ENTRY("include_path", NULL, PHP_INI_ALL, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, include_path))
|
||||
PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, open_basedir))
|
||||
PHP_INI_ENTRY("extension_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, extension_dir))
|
||||
|
||||
PHP_INI_ENTRY("upload_tmp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, upload_tmp_dir))
|
||||
PHP_INI_ENTRY("upload_max_filesize", "2097152", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, upload_max_filesize))
|
||||
|
||||
PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL, NULL)
|
||||
|
||||
PHP_INI_ENTRY("define_syslog_variables", "0", PHP_INI_ALL, NULL, NULL)
|
||||
|
||||
PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnChangeMaxExecutionTime, NULL)
|
||||
PHP_INI_ENTRY("memory_limit", "8388608", PHP_INI_ALL, OnChangeMemoryLimit, NULL)
|
||||
|
||||
PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, gpc_order))
|
||||
PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, (void *) XtOffsetOf(php_core_globals, arg_separator))
|
||||
PHP_INI_END()
|
||||
|
||||
|
||||
@ -206,17 +277,6 @@ request_rec *php3_rqst = NULL; /* request record pointer for apache module versi
|
||||
|
||||
#endif
|
||||
|
||||
php3_ini_structure php3_ini;
|
||||
php3_ini_structure php3_ini_master;
|
||||
|
||||
void _php3_build_argv(char * ELS_DC);
|
||||
static void php3_timeout(int dummy);
|
||||
static void php3_set_timeout(long seconds INLINE_TLS);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if APACHE
|
||||
void php3_apache_puts(const char *s)
|
||||
{
|
||||
@ -247,14 +307,14 @@ void php3_log_err(char *log_message)
|
||||
TLS_VARS;
|
||||
|
||||
/* Try to use the specified logging location. */
|
||||
if (php3_ini.error_log != NULL) {
|
||||
if (PG(error_log) != NULL) {
|
||||
#if HAVE_SYSLOG_H
|
||||
if (strcmp(php3_ini.error_log, "syslog")) {
|
||||
if (strcmp(PG(error_log), "syslog")) {
|
||||
syslog(LOG_NOTICE, log_message);
|
||||
return;
|
||||
} else {
|
||||
#endif
|
||||
log_file = fopen(php3_ini.error_log, "a");
|
||||
log_file = fopen(PG(error_log), "a");
|
||||
if (log_file != NULL) {
|
||||
fprintf(log_file, log_message);
|
||||
fprintf(log_file, "\n");
|
||||
@ -395,12 +455,15 @@ PHPAPI void php3_error(int type, const char *format,...)
|
||||
php3_log_err(log_buffer);
|
||||
}
|
||||
if (PG(display_errors)) {
|
||||
if(php3_ini.error_prepend_string) {
|
||||
PUTS(php3_ini.error_prepend_string);
|
||||
char *prepend_string = INI_STR("error_prepend_string");
|
||||
char *append_string = INI_STR("error_append_string");
|
||||
|
||||
if (prepend_string) {
|
||||
PUTS(prepend_string);
|
||||
}
|
||||
php3_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, error_filename, error_lineno);
|
||||
if(php3_ini.error_append_string) {
|
||||
PUTS(php3_ini.error_append_string);
|
||||
if (append_string) {
|
||||
PUTS(append_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,7 +501,7 @@ static void php3_timeout(int dummy)
|
||||
{
|
||||
TLS_VARS;
|
||||
|
||||
php3_error(E_ERROR, "Maximum execution time of %d seconds exceeded", php3_ini.max_execution_time);
|
||||
php3_error(E_ERROR, "Maximum execution time of %d seconds exceeded", PG(max_execution_time));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -529,7 +592,7 @@ static void php_message_handler_for_zend(long message, void *data)
|
||||
{
|
||||
switch (message) {
|
||||
case ZMSG_ENABLE_TRACK_VARS:
|
||||
php3_ini.track_vars = 1;
|
||||
PG(track_vars) = 1;
|
||||
break;
|
||||
case ZMSG_FAILED_INCLUDE_FOPEN:
|
||||
php3_error(E_WARNING, "Failed opening '%s' for inclusion", php3_strip_url_passwd((char *) data));
|
||||
@ -578,7 +641,7 @@ int php3_request_startup(CLS_D ELS_DC)
|
||||
}
|
||||
#endif
|
||||
|
||||
php3_set_timeout(php3_ini.max_execution_time _INLINE_TLS);
|
||||
php3_set_timeout(PG(max_execution_time) _INLINE_TLS);
|
||||
|
||||
GLOBAL(initialized) = 0;
|
||||
|
||||
@ -598,12 +661,10 @@ int php3_request_startup(CLS_D ELS_DC)
|
||||
|
||||
/* initialize global variables */
|
||||
{
|
||||
EG(error_reporting) = php3_ini.errors;
|
||||
GLOBAL(header_is_being_sent) = 0;
|
||||
GLOBAL(php3_track_vars) = php3_ini.track_vars;
|
||||
}
|
||||
|
||||
if (php3_init_request_info((void *) &php3_ini)) {
|
||||
if (php3_init_request_info(NULL)) {
|
||||
php3_printf("Unable to initialize request info.\n");
|
||||
return FAILURE;
|
||||
}
|
||||
@ -669,7 +730,7 @@ void php3_request_shutdown(void *dummy INLINE_TLS)
|
||||
|
||||
if (GLOBAL(initialized) & INIT_REQUEST_INFO) {
|
||||
SHUTDOWN_DEBUG("Request info");
|
||||
php3_destroy_request_info((void *) &php3_ini);
|
||||
php3_destroy_request_info(NULL);
|
||||
GLOBAL(initialized) &= ~INIT_REQUEST_INFO;
|
||||
}
|
||||
if (GLOBAL(initialized) & INIT_SCANNER) {
|
||||
@ -738,114 +799,10 @@ void php3_request_shutdown(void *dummy INLINE_TLS)
|
||||
|
||||
static int php3_config_ini_startup(ELS_D)
|
||||
{
|
||||
/* set the memory limit to a reasonable number so that we can get
|
||||
* through this startup phase properly
|
||||
*/
|
||||
php3_ini.memory_limit=1<<23; /* 8MB */
|
||||
|
||||
if (php3_init_config() == FAILURE) {
|
||||
php3_printf("PHP: Unable to parse configuration file.\n");
|
||||
return FAILURE;
|
||||
}
|
||||
#if !(USE_SAPI)
|
||||
GLOBAL(module_initialized) |= INIT_CONFIG;
|
||||
#endif
|
||||
/* initialize run-time variables */
|
||||
/* I have remarked out some stuff
|
||||
that may or may not be needed */
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (cfg_get_long("max_execution_time", &php3_ini.max_execution_time) == FAILURE) {
|
||||
php3_ini.max_execution_time = 30;
|
||||
}
|
||||
if (cfg_get_long("memory_limit", &php3_ini.memory_limit) == FAILURE) {
|
||||
php3_ini.memory_limit = 1<<23; /* 8MB */
|
||||
}
|
||||
if (cfg_get_long("error_reporting", &php3_ini.errors) == FAILURE) {
|
||||
php3_ini.errors = E_ALL & ~E_NOTICE;
|
||||
}
|
||||
EG(error_reporting) = php3_ini.errors;
|
||||
if (cfg_get_string("error_log", &php3_ini.error_log) == FAILURE) {
|
||||
php3_ini.error_log = NULL;
|
||||
}
|
||||
if (cfg_get_long("y2k_compliance", &php3_ini.y2k_compliance) == FAILURE) {
|
||||
php3_ini.y2k_compliance = 0;
|
||||
}
|
||||
if (cfg_get_long("define_syslog_variables", &php3_ini.define_syslog_variables) == FAILURE) {
|
||||
php3_ini.define_syslog_variables = 0;
|
||||
}
|
||||
if (cfg_get_string("doc_root", &php3_ini.doc_root) == FAILURE) {
|
||||
if ((temp = getenv("PHP_DOCUMENT_ROOT"))) {
|
||||
php3_ini.doc_root = temp;
|
||||
} else {
|
||||
php3_ini.doc_root = NULL;
|
||||
}
|
||||
}
|
||||
if (cfg_get_string("user_dir", &php3_ini.user_dir) == FAILURE) {
|
||||
if ((temp = getenv("PHP_USER_DIR"))) {
|
||||
php3_ini.user_dir = temp;
|
||||
} else {
|
||||
php3_ini.user_dir = NULL;
|
||||
}
|
||||
}
|
||||
if (cfg_get_long("track_vars", &php3_ini.track_vars) == FAILURE) {
|
||||
php3_ini.track_vars = PHP_TRACK_VARS;
|
||||
}
|
||||
if (cfg_get_string("include_path", &php3_ini.include_path) == FAILURE) {
|
||||
if ((temp = getenv("PHP_INCLUDE_PATH"))) {
|
||||
php3_ini.include_path = temp;
|
||||
} else {
|
||||
php3_ini.include_path = NULL;
|
||||
}
|
||||
}
|
||||
if (cfg_get_string("upload_tmp_dir", &php3_ini.upload_tmp_dir) == FAILURE) {
|
||||
/* php3_ini.upload_tmp_dir = UPLOAD_TMPDIR; */
|
||||
php3_ini.upload_tmp_dir = NULL;
|
||||
}
|
||||
if (cfg_get_long("upload_max_filesize", &php3_ini.upload_max_filesize) == FAILURE) {
|
||||
php3_ini.upload_max_filesize = 2097152; /* 2 Meg default */
|
||||
}
|
||||
if (cfg_get_string("extension_dir", &php3_ini.extension_dir) == FAILURE) {
|
||||
php3_ini.extension_dir = NULL;
|
||||
}
|
||||
if (cfg_get_long("engine", &php3_ini.engine) == FAILURE) {
|
||||
php3_ini.engine = 1;
|
||||
}
|
||||
if (cfg_get_long("last_modified", &php3_ini.last_modified) == FAILURE) {
|
||||
php3_ini.last_modified = 0;
|
||||
}
|
||||
if (cfg_get_long("xbithack", &php3_ini.xbithack) == FAILURE) {
|
||||
php3_ini.xbithack = 0;
|
||||
}
|
||||
if (cfg_get_string("browscap", &php3_ini.browscap) == FAILURE) {
|
||||
php3_ini.browscap = NULL;
|
||||
}
|
||||
if (cfg_get_string("arg_separator", &php3_ini.arg_separator) == FAILURE) {
|
||||
php3_ini.arg_separator = "&";
|
||||
}
|
||||
if (cfg_get_string("gpc_order", &php3_ini.gpc_order) == FAILURE) {
|
||||
php3_ini.gpc_order = "GPC";
|
||||
}
|
||||
if (cfg_get_string("error_prepend_string", &php3_ini.error_prepend_string) == FAILURE) {
|
||||
php3_ini.error_prepend_string = NULL;
|
||||
}
|
||||
if (cfg_get_string("error_append_string", &php3_ini.error_append_string) == FAILURE) {
|
||||
php3_ini.error_append_string = NULL;
|
||||
}
|
||||
if (cfg_get_string("open_basedir", &php3_ini.open_basedir) == FAILURE) {
|
||||
php3_ini.open_basedir = NULL;
|
||||
}
|
||||
if (cfg_get_long("enable_dl", &php3_ini.enable_dl) == FAILURE) {
|
||||
php3_ini.enable_dl = 1;
|
||||
}
|
||||
/* THREADX Will have to look into this on windows
|
||||
* Make a master copy to use as a basis for every per-dir config.
|
||||
* Without two copies we would have a previous requst's per-dir
|
||||
* config carry forward to the next one.
|
||||
*/
|
||||
memcpy(&php3_ini_master, &php3_ini, sizeof(php3_ini));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -978,7 +935,7 @@ int _php3_hash_environment(void)
|
||||
pval *tmp;
|
||||
ELS_FETCH();
|
||||
|
||||
p = php3_ini.gpc_order;
|
||||
p = PG(gpc_order);
|
||||
while(*p) {
|
||||
switch(*p++) {
|
||||
case 'p':
|
||||
|
@ -200,8 +200,6 @@ extern char *strerror(int);
|
||||
|
||||
#include "fopen-wrappers.h"
|
||||
|
||||
#include "mod_php3.h" /* the php3_ini structure comes from here */
|
||||
|
||||
#if APACHE /* apache httpd */
|
||||
# if HAVE_AP_CONFIG_H
|
||||
#include "ap_config.h"
|
||||
@ -378,8 +376,6 @@ PHPAPI int cfg_get_long(char *varname, long *result);
|
||||
PHPAPI int cfg_get_double(char *varname, double *result);
|
||||
PHPAPI int cfg_get_string(char *varname, char **result);
|
||||
|
||||
extern PHPAPI php3_ini_structure php3_ini;
|
||||
|
||||
|
||||
/* Output support */
|
||||
#include "output.h"
|
||||
|
@ -32,13 +32,34 @@ struct _php_core_globals {
|
||||
long safe_mode;
|
||||
long sql_safe_mode;
|
||||
char *safe_mode_exec_dir;
|
||||
long enable_dl;
|
||||
|
||||
long max_execution_time;
|
||||
long memory_limit;
|
||||
|
||||
long track_errors;
|
||||
long display_errors;
|
||||
long log_errors;
|
||||
char *error_log;
|
||||
|
||||
char *doc_root;
|
||||
char *user_dir;
|
||||
char *include_path;
|
||||
char *open_basedir;
|
||||
char *extension_dir;
|
||||
|
||||
char *upload_tmp_dir;
|
||||
long upload_max_filesize;
|
||||
|
||||
char *auto_prepend_file;
|
||||
char *auto_append_file;
|
||||
|
||||
char *arg_separator;
|
||||
char *gpc_order;
|
||||
|
||||
long track_vars;
|
||||
|
||||
long y2k_compliance;
|
||||
};
|
||||
|
||||
|
||||
|
@ -289,3 +289,26 @@ PHP_INI_MH(OnUpdateString)
|
||||
*p = new_value;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
PHP_INI_MH(OnUpdateStringUnempty)
|
||||
{
|
||||
char **p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) &core_globals;
|
||||
#else
|
||||
char *base;
|
||||
PLS_FETCH();
|
||||
|
||||
base = (char *) core_globals;
|
||||
#endif
|
||||
|
||||
if (new_value && !new_value[0]) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
p = (char **) (base+(size_t) mh_arg);
|
||||
|
||||
*p = new_value;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -70,5 +70,6 @@ pval *cfg_get_entry(char *name, uint name_length);
|
||||
PHP_INI_MH(OnUpdateInt);
|
||||
PHP_INI_MH(OnUpdateReal);
|
||||
PHP_INI_MH(OnUpdateString);
|
||||
PHP_INI_MH(OnUpdateStringUnempty);
|
||||
|
||||
#endif /* _PHP_INI_H */
|
||||
|
131
mod_php3.c
131
mod_php3.c
@ -298,69 +298,14 @@ static void *php3_merge_dir(pool *p, void *basev, void *addv)
|
||||
/* Start with the base config */
|
||||
memcpy(new,base,sizeof(php3_ini_structure));
|
||||
|
||||
/* Now, add any fields that have changed in *add compared to the master config */
|
||||
if (add->smtp != orig.smtp) new->smtp = add->smtp;
|
||||
if (add->sendmail_path != orig.sendmail_path) new->sendmail_path = add->sendmail_path;
|
||||
if (add->sendmail_from != orig.sendmail_from) new->sendmail_from = add->sendmail_from;
|
||||
if (add->errors != orig.errors) new->errors = add->errors;
|
||||
if (add->doc_root != orig.doc_root) new->doc_root = add->doc_root;
|
||||
if (add->user_dir != orig.user_dir) new->user_dir = add->user_dir;
|
||||
if (add->track_vars != orig.track_vars) new->track_vars = add->track_vars;
|
||||
if (add->cgi_ext != orig.cgi_ext) new->cgi_ext = add->cgi_ext;
|
||||
if (add->isapi_ext != orig.isapi_ext) new->isapi_ext = add->isapi_ext;
|
||||
if (add->nsapi_ext != orig.nsapi_ext) new->nsapi_ext = add->nsapi_ext;
|
||||
if (add->include_path != orig.include_path) new->include_path = add->include_path;
|
||||
if (add->upload_tmp_dir != orig.upload_tmp_dir) new->upload_tmp_dir = add->upload_tmp_dir;
|
||||
if (add->upload_max_filesize != orig.upload_max_filesize) new->upload_max_filesize = add->upload_max_filesize;
|
||||
if (add->extension_dir != orig.extension_dir) new->extension_dir = add->extension_dir;
|
||||
if (add->error_log != orig.error_log) new->error_log = add->error_log;
|
||||
/* skip the highlight stuff */
|
||||
if (add->xbithack != orig.xbithack) new->xbithack = add->xbithack;
|
||||
if (add->engine != orig.engine) new->engine = add->engine;
|
||||
if (add->last_modified != orig.last_modified) new->last_modified = add->last_modified;
|
||||
if (add->max_execution_time != orig.max_execution_time) new->max_execution_time = add->max_execution_time;
|
||||
if (add->memory_limit != orig.memory_limit) new->memory_limit = add->memory_limit;
|
||||
if (add->browscap != orig.browscap) new->browscap = add->browscap;
|
||||
if (add->arg_separator != orig.arg_separator) new->arg_separator = add->arg_separator;
|
||||
if (add->gpc_order != orig.gpc_order) new->gpc_order = add->gpc_order;
|
||||
if (add->error_prepend_string != orig.error_prepend_string) new->error_prepend_string = add->error_prepend_string;
|
||||
if (add->error_append_string != orig.error_append_string) new->error_append_string = add->error_append_string;
|
||||
if (add->open_basedir != orig.open_basedir) new->open_basedir = add->open_basedir;
|
||||
if (add->enable_dl != orig.enable_dl) new->enable_dl = add->enable_dl;
|
||||
if (add->dav_script != orig.dav_script) new->dav_script = add->dav_script;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
#if MODULE_MAGIC_NUMBER > 19961007
|
||||
const char *php3flaghandler(cmd_parms * cmd, php3_ini_structure * conf, int val)
|
||||
{
|
||||
#else
|
||||
char *php3flaghandler(cmd_parms * cmd, php3_ini_structure * conf, int val)
|
||||
{
|
||||
#endif
|
||||
int c = (int) cmd->info;
|
||||
|
||||
switch (c) {
|
||||
case 5:
|
||||
conf->track_vars = val;
|
||||
break;
|
||||
case 7:
|
||||
conf->engine = val;
|
||||
break;
|
||||
case 8:
|
||||
conf->xbithack = val;
|
||||
break;
|
||||
case 9:
|
||||
conf->last_modified = val;
|
||||
break;
|
||||
case 13:
|
||||
conf->enable_dl = val;
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#if MODULE_MAGIC_NUMBER > 19961007
|
||||
#define CONST_PREFIX const
|
||||
@ -404,54 +349,6 @@ char *php3take1handler(cmd_parms * cmd, php3_ini_structure * conf, char *arg)
|
||||
case 0:
|
||||
conf->errors = atoi(arg);
|
||||
break;
|
||||
case 1:
|
||||
conf->doc_root = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 2:
|
||||
conf->user_dir = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 4:
|
||||
conf->include_path = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 7:
|
||||
conf->upload_tmp_dir = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 8:
|
||||
conf->extension_dir = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 9:
|
||||
conf->error_log = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 10:
|
||||
conf->arg_separator = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 11:
|
||||
conf->max_execution_time = atoi(arg);
|
||||
break;
|
||||
case 12:
|
||||
conf->memory_limit = atoi(arg);
|
||||
break;
|
||||
case 13:
|
||||
conf->sendmail_path = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 14:
|
||||
conf->browscap = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 15:
|
||||
conf->gpc_order = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 16:
|
||||
conf->error_prepend_string = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 17:
|
||||
conf->error_append_string = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 18:
|
||||
conf->open_basedir = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
case 19:
|
||||
conf->upload_max_filesize = atol(arg);
|
||||
break;
|
||||
case 20:
|
||||
conf->dav_script = pstrdup(cmd->pool, arg);
|
||||
break;
|
||||
@ -538,34 +435,6 @@ command_rec php3_commands[] =
|
||||
{
|
||||
{"php4_directive", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},
|
||||
{"php4_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
|
||||
{"php3_error_reporting", php3take1handler, (void *)0, OR_OPTIONS, TAKE1, "error reporting level"},
|
||||
{"php3_doc_root", php3take1handler, (void *)1, ACCESS_CONF|RSRC_CONF, TAKE1, "directory"}, /* not used yet */
|
||||
{"php3_user_dir", php3take1handler, (void *)2, ACCESS_CONF|RSRC_CONF, TAKE1, "user directory"}, /* not used yet */
|
||||
{"php3_include_path", php3take1handler, (void *)4, OR_OPTIONS, TAKE1, "colon-separated path"},
|
||||
{"php3_auto_prepend_file", php3take1handler, (void *)5, OR_OPTIONS, TAKE1, "file name"},
|
||||
{"php3_auto_append_file", php3take1handler, (void *)6, OR_OPTIONS, TAKE1, "file name"},
|
||||
{"php3_upload_tmp_dir", php3take1handler, (void *)7, ACCESS_CONF|RSRC_CONF, TAKE1, "directory"},
|
||||
{"php3_extension_dir", php3take1handler, (void *)8, ACCESS_CONF|RSRC_CONF, TAKE1, "directory"},
|
||||
{"php3_error_log", php3take1handler, (void *)9, OR_OPTIONS, TAKE1, "error log file"},
|
||||
{"php3_arg_separator", php3take1handler, (void *)10, OR_OPTIONS, TAKE1, "GET method arg separator"},
|
||||
{"php3_max_execution_time", php3take1handler, (void *)11, OR_OPTIONS, TAKE1, "Max script run time in seconds"},
|
||||
{"php3_memory_limit", php3take1handler, (void *)12, OR_OPTIONS, TAKE1, "Max memory in bytes a script may use"},
|
||||
{"php3_sendmail_path", php3take1handler, (void *)13, OR_OPTIONS, TAKE1, "Full path to sendmail binary"},
|
||||
{"php3_browscap", php3take1handler, (void *)14, OR_OPTIONS, TAKE1, "Full path to browscap file"},
|
||||
{"php3_gpc_order", php3take1handler, (void *)15, OR_OPTIONS, TAKE1, "Set GET-COOKIE-POST order [default is GPC]"},
|
||||
{"php3_error_prepend_string", php3take1handler, (void *)16, OR_OPTIONS, TAKE1, "String to add before an error message from PHP"},
|
||||
{"php3_error_append_string", php3take1handler, (void *)17, OR_OPTIONS, TAKE1, "String to add after an error message from PHP"},
|
||||
{"php3_open_basedir", php3take1handler, (void *)18, OR_OPTIONS|RSRC_CONF, TAKE1, "Limit opening of files to this directory"},
|
||||
{"php3_upload_max_filesize", php3take1handler, (void *)19, OR_OPTIONS|RSRC_CONF, TAKE1, "Limit uploaded files to this many bytes"},
|
||||
#if HAVE_MOD_DAV
|
||||
{"php3_dav_script", php3take1handler, (void *)20, OR_OPTIONS|RSRC_CONF, TAKE1,
|
||||
"Lets PHP handle DAV requests by parsing this script."},
|
||||
#endif
|
||||
{"php3_track_vars", php3flaghandler, (void *)5, OR_OPTIONS, FLAG, "on|off"},
|
||||
{"php3_engine", php3flaghandler, (void *)7, RSRC_CONF|ACCESS_CONF, FLAG, "on|off"},
|
||||
{"php3_xbithack", php3flaghandler, (void *)8, OR_OPTIONS, FLAG, "on|off"},
|
||||
{"php3_last_modified", php3flaghandler, (void *)9, OR_OPTIONS, FLAG, "on|off"},
|
||||
{"php3_enable_dl", php3flaghandler, (void *)13, RSRC_CONF|ACCESS_CONF, FLAG, "on|off"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
26
mod_php3.h
26
mod_php3.h
@ -38,34 +38,10 @@
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
long errors;
|
||||
char *doc_root;
|
||||
char *user_dir;
|
||||
long track_vars;
|
||||
char *cgi_ext;
|
||||
char *isapi_ext;
|
||||
char *nsapi_ext;
|
||||
char *include_path;
|
||||
char *upload_tmp_dir;
|
||||
long upload_max_filesize;
|
||||
char *extension_dir;
|
||||
char *error_log;
|
||||
long sql_safe_mode;
|
||||
long xbithack;
|
||||
long engine;
|
||||
long last_modified;
|
||||
long max_execution_time;
|
||||
long memory_limit;
|
||||
char *browscap;
|
||||
char *arg_separator;
|
||||
char *gpc_order;
|
||||
long y2k_compliance;
|
||||
long define_syslog_variables;
|
||||
char *error_prepend_string;
|
||||
char *error_append_string;
|
||||
char *open_basedir;
|
||||
long enable_dl;
|
||||
char *dav_script;
|
||||
long xbithack;
|
||||
} php3_ini_structure;
|
||||
|
||||
#if MSVC5
|
||||
|
@ -96,7 +96,6 @@ int php3_init_request_info(void *conf)
|
||||
|
||||
int php3_destroy_request_info(void *conf)
|
||||
{
|
||||
TLS_VARS;
|
||||
STR_FREE(GLOBAL(request_info).current_user);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user