diff options
author | Zeev Suraski <zeev@php.net> | 1999-05-09 08:48:05 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 1999-05-09 08:48:05 +0000 |
commit | bc415d5a8883bbe5b15c12e9a30f916c8010204a (patch) | |
tree | 216499649825b9005a59c0e3c5b5be67c2092871 /main/php_ini.c | |
parent | 91cf2e59c47a30f075fe1c69d17550b956df9865 (diff) | |
download | php-git-bc415d5a8883bbe5b15c12e9a30f916c8010204a.tar.gz |
* Finalizing the PHP version of SAPI. Support POST and cookies among other things.
* Fully implement ISAPI support - POST and cookies among other things.
* Almost completely rewrote phpinfo(). Allow modules to easily display their
information in phpinfo() without modifying phpinfo() itself (prototype for
the module info function was changed, thus the large amount of updated module
files).
* Initial extended SAPI support for Apache, completely untested.
* CGI now uses SAPI fully as well.
Diffstat (limited to 'main/php_ini.c')
-rw-r--r-- | main/php_ini.c | 128 |
1 files changed, 120 insertions, 8 deletions
diff --git a/main/php_ini.c b/main/php_ini.c index 815b582cbd..fbe1ad0dab 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -34,6 +34,10 @@ #include "php_ini.h" #include "zend_alloc.h" #include "php_globals.h" +#include "ext/standard/info.h" + +#define ENTRY_NAME_COLOR "#999999" +#define CONTENTS_COLOR "#DDDDDD" static HashTable known_directives; @@ -93,7 +97,7 @@ int php_ini_rshutdown() * Registration / unregistration */ -int php_register_ini_entries(php_ini_entry *ini_entry, int module_number) +PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number) { php_ini_entry *p = ini_entry; php_ini_entry *hashed_ini_entry; @@ -126,13 +130,13 @@ int php_register_ini_entries(php_ini_entry *ini_entry, int module_number) } -void php_unregister_ini_entries(int module_number) +PHPAPI void php_unregister_ini_entries(int module_number) { _php3_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_remove_ini_entries, (void *) &module_number); } -int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type) +PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type) { php_ini_entry *ini_entry; char *duplicate; @@ -166,7 +170,7 @@ int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_ } -int php_restore_ini_entry(char *name, uint name_length) +PHPAPI int php_restore_ini_entry(char *name, uint name_length) { php_ini_entry *ini_entry; @@ -182,11 +186,25 @@ int php_restore_ini_entry(char *name, uint name_length) } +PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type)) +{ + php_ini_entry *ini_entry; + + if (_php3_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) { + return FAILURE; + } + + ini_entry->displayer = displayer; + return SUCCESS; +} + + + /* * Data retrieval */ -long php_ini_long(char *name, uint name_length, int orig) +PHPAPI long php_ini_long(char *name, uint name_length, int orig) { php_ini_entry *ini_entry; @@ -202,7 +220,7 @@ long php_ini_long(char *name, uint name_length, int orig) } -double php_ini_double(char *name, uint name_length, int orig) +PHPAPI double php_ini_double(char *name, uint name_length, int orig) { php_ini_entry *ini_entry; @@ -218,7 +236,7 @@ double php_ini_double(char *name, uint name_length, int orig) } -char *php_ini_string(char *name, uint name_length, int orig) +PHPAPI char *php_ini_string(char *name, uint name_length, int orig) { php_ini_entry *ini_entry; @@ -235,7 +253,101 @@ char *php_ini_string(char *name, uint name_length, int orig) -/* Standard message handlers for core_globals */ +static void php_ini_displayer_cb(php_ini_entry *ini_entry, int type) +{ + if (ini_entry->displayer) { + ini_entry->displayer(ini_entry, type); + } else { + char *display_string; + uint display_string_length; + + if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) { + display_string = ini_entry->orig_value; + display_string_length = ini_entry->orig_value_length; + } else if (ini_entry->value && ini_entry->value[0]) { + display_string = ini_entry->value; + display_string_length = ini_entry->value_length; + } else { + display_string = "<i>no value</i>"; + display_string_length = sizeof("<i>no value</i>")-1; + } + PHPWRITE(display_string, display_string_length); + } +} + + +PHP_INI_DISP(php_ini_boolean_displayer_cb) +{ + int value; + + if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) { + value = atoi(ini_entry->orig_value); + } else if (ini_entry->value) { + value = atoi(ini_entry->value); + } else { + value = 0; + } + if (value) { + PUTS("On"); + } else { + PUTS("Off"); + } +} + + +PHP_INI_DISP(php_ini_color_displayer_cb) +{ + char *value; + + if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) { + value = ini_entry->orig_value; + } else if (ini_entry->value) { + value = ini_entry->value; + } else { + value = NULL; + } + if (value) { + php3_printf("<font color=\"%s\">%s</font>", value, value); + } else { + PUTS("<i>no value</i>;"); + } +} + + +static int php_ini_displayer(php_ini_entry *ini_entry, int module_number) +{ + if (ini_entry->module_number != module_number) { + return 0; + } + + PUTS("<tr><td align=\"center\" bgcolor=\"" ENTRY_NAME_COLOR "\">"); + PHPWRITE(ini_entry->name, ini_entry->name_length-1); + PUTS("<td align=\"center\" bgcolor=\"" CONTENTS_COLOR "\">"); + php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ACTIVE); + PUTS("</td><td align=\"center\" bgcolor=\"" CONTENTS_COLOR "\">"); + php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ORIG); + PUTS("</td></tr>\n"); + return 0; +} + + +PHPAPI void display_ini_entries(zend_module_entry *module) +{ + int module_number; + + if (module) { + module_number = module->module_number; + } else { + module_number = 0; + } + PUTS("<table border=5 width=\"600\">\n"); + php_info_print_table_header(3, "Directive", "Master Value", "Local Value"); + zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_ini_displayer, (void *) module_number); + PUTS("</table>\n"); +} + + +/* Standard message handlers */ PHP_INI_MH(OnUpdateInt) { |