A lot of php3_ini -> php_ini work

This commit is contained in:
Zeev Suraski 1999-04-10 13:32:47 +00:00
parent 79f9f0ce88
commit e3d2234b80
5 changed files with 40 additions and 103 deletions

View File

@ -132,11 +132,22 @@ PHP_INI_MH(OnSetPrecision)
/* Need to convert to strings and make use of:
* DEFAULT_SHORT_OPEN_TAG
* PHP_SAFE_MODE
*
* Need to be read from the environment (?):
* PHP_AUTO_PREPEND_FILE
* PHP_AUTO_APPEND_FILE
*/
#ifndef SAFE_MODE_EXEC_DIR
# define SAFE_MODE_EXEC_DIR "/"
#endif
#ifdef PHP_PROG_SENDMAIL
# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t"
#else
# define DEFAULT_SENDMAIL_PATH NULL
#endif
PHP_INI_BEGIN()
PHP_INI_ENTRY("short_open_tag", "1", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, short_tags))
PHP_INI_ENTRY("asp_tags", "0", PHP_INI_ALL, OnUpdateInt, (void *) XtOffsetOf(php_core_globals, asp_tags))
@ -156,6 +167,17 @@ 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("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("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("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_END()
@ -360,19 +382,19 @@ PHPAPI void php3_error(int type, const char *format,...)
}
/* get include file name */
if (php3_ini.log_errors || php3_ini.display_errors) {
if (PG(log_errors) || PG(display_errors)) {
va_start(args, format);
size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
va_end(args);
buffer[sizeof(buffer) - 1] = 0;
if (php3_ini.log_errors) {
if (PG(log_errors)) {
char log_buffer[1024];
snprintf(log_buffer, 1024, "PHP 3 %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
php3_log_err(log_buffer);
}
if (php3_ini.display_errors) {
if (PG(display_errors)) {
if(php3_ini.error_prepend_string) {
PUTS(php3_ini.error_prepend_string);
}
@ -383,7 +405,7 @@ PHPAPI void php3_error(int type, const char *format,...)
}
}
}
if (php3_ini.track_errors) {
if (PG(track_errors)) {
pval tmp;
va_start(args, format);
@ -740,20 +762,6 @@ static int php3_config_ini_startup(ELS_D)
if (cfg_get_long("memory_limit", &php3_ini.memory_limit) == FAILURE) {
php3_ini.memory_limit = 1<<23; /* 8MB */
}
if (cfg_get_string("SMTP", &php3_ini.smtp) == FAILURE) {
php3_ini.smtp = "localhost";
}
if (cfg_get_string("sendmail_path", &php3_ini.sendmail_path) == FAILURE
|| !php3_ini.sendmail_path[0]) {
#ifdef PHP_PROG_SENDMAIL
php3_ini.sendmail_path = PHP_PROG_SENDMAIL " -t";
#else
php3_ini.sendmail_path = NULL;
#endif
}
if (cfg_get_string("sendmail_from", &php3_ini.sendmail_from) == FAILURE) {
php3_ini.sendmail_from = NULL;
}
if (cfg_get_long("error_reporting", &php3_ini.errors) == FAILURE) {
php3_ini.errors = E_ALL & ~E_NOTICE;
}
@ -761,19 +769,6 @@ static int php3_config_ini_startup(ELS_D)
if (cfg_get_string("error_log", &php3_ini.error_log) == FAILURE) {
php3_ini.error_log = NULL;
}
if (cfg_get_long("track_errors", &php3_ini.track_errors) == FAILURE) {
php3_ini.track_errors = 0;
}
if (cfg_get_long("display_errors", &php3_ini.display_errors) == FAILURE) {
php3_ini.display_errors = 1;
}
if (cfg_get_long("log_errors", &php3_ini.log_errors) == FAILURE) {
php3_ini.log_errors = 0;
}
if (cfg_get_long("warn_plus_overloading", &php3_ini.warn_plus_overloading) == FAILURE) {
php3_ini.warn_plus_overloading = 0;
}
if (cfg_get_long("y2k_compliance", &php3_ini.y2k_compliance) == FAILURE) {
php3_ini.y2k_compliance = 0;
}
@ -804,20 +799,6 @@ static int php3_config_ini_startup(ELS_D)
php3_ini.include_path = NULL;
}
}
if (cfg_get_string("auto_prepend_file", &php3_ini.auto_prepend_file) == FAILURE) {
if ((temp = getenv("PHP_AUTO_PREPEND_FILE"))) {
php3_ini.auto_prepend_file = temp;
} else {
php3_ini.auto_prepend_file = NULL;
}
}
if (cfg_get_string("auto_append_file", &php3_ini.auto_append_file) == FAILURE) {
if ((temp = getenv("PHP_AUTO_APPEND_FILE"))) {
php3_ini.auto_append_file = temp;
} else {
php3_ini.auto_append_file = 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;
@ -1255,26 +1236,15 @@ static void php3_parse(zend_file_handle *primary_file CLS_DC ELS_DC)
_php3_hash_environment();
#if 0
if (php3_ini.auto_prepend_file && php3_ini.auto_prepend_file[0]) {
require_filename(php3_ini.auto_prepend_file CLS_CC);
}
require_file(primary_file CLS_CC);
if (php3_ini.auto_append_file && php3_ini.auto_append_file[0]) {
require_filename(php3_ini.auto_append_file CLS_CC);
}
pass_two(CG(main_op_array));
#endif
if (php3_ini.auto_prepend_file && php3_ini.auto_prepend_file[0]) {
prepend_file.filename = php3_ini.auto_prepend_file;
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
prepend_file.filename = PG(auto_prepend_file);
prepend_file.type = ZEND_HANDLE_FILENAME;
prepend_file_p = &prepend_file;
} else {
prepend_file_p = NULL;
}
if (php3_ini.auto_append_file && php3_ini.auto_append_file[0]) {
append_file.filename = php3_ini.auto_append_file;
if (PG(auto_append_file) && PG(auto_append_file)[0]) {
append_file.filename = PG(auto_append_file);
append_file.type = ZEND_HANDLE_FILENAME;
append_file_p = &append_file;
} else {

View File

@ -32,6 +32,13 @@ struct _php_core_globals {
long safe_mode;
long sql_safe_mode;
char *safe_mode_exec_dir;
long track_errors;
long display_errors;
long log_errors;
char *auto_prepend_file;
char *auto_append_file;
};

View File

@ -303,9 +303,6 @@ static void *php3_merge_dir(pool *p, void *basev, void *addv)
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->track_errors != orig.track_errors) new->track_errors = add->track_errors;
if (add->display_errors != orig.display_errors) new->display_errors = add->display_errors;
if (add->log_errors != orig.log_errors) new->log_errors = add->log_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;
@ -313,8 +310,6 @@ static void *php3_merge_dir(pool *p, void *basev, void *addv)
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->auto_prepend_file != orig.auto_prepend_file) new->auto_prepend_file = add->auto_prepend_file;
if (add->auto_append_file != orig.auto_append_file) new->auto_append_file = add->auto_append_file;
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;
@ -347,9 +342,6 @@ char *php3flaghandler(cmd_parms * cmd, php3_ini_structure * conf, int val)
int c = (int) cmd->info;
switch (c) {
case 0:
conf->track_errors = val;
break;
case 5:
conf->track_vars = val;
break;
@ -362,12 +354,6 @@ char *php3flaghandler(cmd_parms * cmd, php3_ini_structure * conf, int val)
case 9:
conf->last_modified = val;
break;
case 10:
conf->log_errors = val;
break;
case 11:
conf->display_errors = val;
break;
case 13:
conf->enable_dl = val;
break;
@ -427,20 +413,6 @@ char *php3take1handler(cmd_parms * cmd, php3_ini_structure * conf, char *arg)
case 4:
conf->include_path = pstrdup(cmd->pool, arg);
break;
case 5:
if (strncasecmp(arg, "none", 4)) {
conf->auto_prepend_file = pstrdup(cmd->pool, arg);
} else {
conf->auto_prepend_file = "";
}
break;
case 6:
if (strncasecmp(arg, "none", 4)) {
conf->auto_append_file = pstrdup(cmd->pool, arg);
} else {
conf->auto_append_file = "";
}
break;
case 7:
conf->upload_tmp_dir = pstrdup(cmd->pool, arg);
break;
@ -589,13 +561,10 @@ command_rec php3_commands[] =
{"php3_dav_script", php3take1handler, (void *)20, OR_OPTIONS|RSRC_CONF, TAKE1,
"Lets PHP handle DAV requests by parsing this script."},
#endif
{"php3_track_errors", php3flaghandler, (void *)0, OR_OPTIONS, FLAG, "on|off"},
{"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_log_errors", php3flaghandler, (void *)10, OR_OPTIONS, FLAG, "on|off"},
{"php3_display_errors", php3flaghandler, (void *)11, OR_OPTIONS, FLAG, "on|off"},
{"php3_enable_dl", php3flaghandler, (void *)13, RSRC_CONF|ACCESS_CONF, FLAG, "on|off"},
{NULL}
};

View File

@ -38,14 +38,7 @@
#endif
typedef struct {
char *smtp; /*win 32 only*/
char *sendmail_path;
char *sendmail_from; /*win 32 only*/
long errors;
long track_errors;
long display_errors;
long log_errors;
long warn_plus_overloading;
char *doc_root;
char *user_dir;
long track_vars;
@ -53,8 +46,6 @@ typedef struct {
char *isapi_ext;
char *nsapi_ext;
char *include_path;
char *auto_prepend_file;
char *auto_append_file;
char *upload_tmp_dir;
long upload_max_filesize;
char *extension_dir;

View File

@ -31,7 +31,7 @@
#include <memory.h>
#include <winbase.h>
#include "sendmail.h"
#include "php_ini.h"
/*
extern int _daylight;
@ -126,8 +126,8 @@ int TSendMail(char *host, int *error,
strcpy(GLOBAL(MailHost), host);
}
if (php3_ini.sendmail_from){
RPath = estrdup(php3_ini.sendmail_from);
if (INI_STR("sendmail_from")){
RPath = estrdup(INI_STR("sendmail_from"));
} else {
return 19;
}