summaryrefslogtreecommitdiff
path: root/sapi/nsapi
diff options
context:
space:
mode:
authorUwe Schindler <thetaphi@php.net>2003-06-01 21:14:58 +0000
committerUwe Schindler <thetaphi@php.net>2003-06-01 21:14:58 +0000
commit827734280b64e3424f97df9c5e37b7e97791592b (patch)
tree315ca6d67b5d8c4e7cc9c420d60f1850036def94 /sapi/nsapi
parentef4ffaaf1ad2dd59b55e4493f979221f0d2ff94e (diff)
downloadphp-git-827734280b64e3424f97df9c5e37b7e97791592b.tar.gz
Update of README for newer servers; apache-similar functions nsapi_request_headers and nsapi_response_headers with apache_* aliases; hide authorization-header in save mode.
Diffstat (limited to 'sapi/nsapi')
-rw-r--r--sapi/nsapi/nsapi-readme.txt44
-rw-r--r--sapi/nsapi/nsapi.c79
2 files changed, 96 insertions, 27 deletions
diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt
index 29f3b12288..602a61d816 100644
--- a/sapi/nsapi/nsapi-readme.txt
+++ b/sapi/nsapi/nsapi-readme.txt
@@ -1,9 +1,9 @@
-Configuration of your Netscape or iPlanet Web Server for PHP4
+Configuration of your Netscape/SunONE/iPlanet Web Server for PHP4
-------------------------------------------------------------
These instructions are targetted at Netscape Enterprise Web Server and
-SUN/Netscape Alliance iPlanet Web Server. On other web servers your
-milage may vary.
+SUN/Netscape Alliance iPlanet Web Server/SunONE Webserver.
+On other web servers your milage may vary.
Firstly you may need to add some paths to the LD_LIBRARY_PATH
environment for Netscape to find all the shared libs. This is best done
@@ -13,29 +13,31 @@ probably skip this step. The start script is located in:
<path-to-netscape-server>/https-servername/start
-Netscape config files are located in:
+Netscape/iPlanet/SunONE config files are located in:
- <path-to-netscape-server>/https-servername/config
+ <path-to-server>/https-servername/config
-Add the following line to mime.types:
+Add the following line to mime.types (you can do that by the administration server):
type=magnus-internal/x-httpd-php exts=php
-Add the following to obj.conf (for iPlanet/SunONE Web Server 6.0 and above however, you need to make the specified changes to the Init function
-in the server-id/config/magnus.conf file, and not the server-id/config/obj.conf file):
+Place the following two lines after mime.types init in
+<path-to-server>/https-servername/config/obj.conf (for servers < 6) or
+for iPlanet/SunONE Web Server 6.0 and above however at the end of the
+<path-to-server>/https-servername/config/magnus.conf file:
-"shlib" will vary depending on your OS:
+ Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/path/to/phplibrary"
+ Init fn=php4_init errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
- Unix: "<path-to-netscape-server>/bin/libphp4.so".
- Windows: "c:\path\to\PHP4\nsapiPHP4.dll"
+The "shlib" will vary depending on your OS:
+ Unix: "<path-to-server>/bin/libphp4.so".
+ Windows: "c:/path/to/PHP4/nsapiPHP4.dll"
-Note! Place following two lines after mime.types init ([] means optional):
- Init fn="load-modules" funcs="php4_init,php4_close,php4_execute,php4_auth_trans" shlib="/php4/nsapiPHP4.dll"
- Init fn=php4_init errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
+In obj.conf (for virtual server classes [SunONE 6.0] in their vserver.obj.conf):
<Object name="default">
.
@@ -45,16 +47,26 @@ Note! Place following two lines after mime.types init ([] means optional):
# all 'AddLog' lines
# You can modify some entries in php.ini request specific by adding it to the Service
# directive, e.g. doc_root="/path"
+ # For boolean ini-keys please use 0/1 as value, NOT "On","Off",... (this will not work
+ # correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On"
Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value ...]
.
.
+ .
</Object>
+This is only needed if you want to configure a directory that only consists of
+PHP scripts (same like a cgi-bin directory):
+
<Object name="x-httpd-php">
ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
- Service fn=php4_execute
- </Object>
+ Service fn="php4_execute" [inikey=value ...]
+ </Object>
+
+After that you can configure a directory in the Administration server and assign it
+the style "x-httpd-php". All files in it will get executed as PHP. This is nice to
+hide PHP usage by renaming files to .html
Authentication configuration
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index c42b07ae76..b34c042c1d 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -161,6 +161,8 @@ PHP_RSHUTDOWN_FUNCTION(nsapi);
PHP_MINFO_FUNCTION(nsapi);
PHP_FUNCTION(virtual);
+PHP_FUNCTION(nsapi_request_headers);
+PHP_FUNCTION(nsapi_response_headers);
ZEND_BEGIN_MODULE_GLOBALS(nsapi)
long read_timeout;
@@ -180,8 +182,13 @@ ZEND_DECLARE_MODULE_GLOBALS(nsapi)
* Every user visible function must have an entry in nsapi_functions[].
*/
function_entry nsapi_functions[] = {
- PHP_FE(virtual, NULL) /* Make subrequest */
- {NULL, NULL, NULL} /* Must be the last line in nsapi_functions[] */
+ PHP_FE(virtual, NULL) /* Make subrequest */
+ PHP_FE(nsapi_request_headers, NULL) /* get request headers */
+ PHP_FALIAS(getallheaders, nsapi_request_headers, NULL) /* compatibility */
+ PHP_FALIAS(apache_request_headers, nsapi_request_headers, NULL) /* compatibility */
+ PHP_FE(nsapi_response_headers, NULL) /* get response headers */
+ PHP_FALIAS(apache_response_headers, nsapi_response_headers, NULL) /* compatibility */
+ {NULL, NULL, NULL}
};
/* }}} */
@@ -196,7 +203,7 @@ zend_module_entry nsapi_module_entry = {
NULL,
NULL,
PHP_MINFO(nsapi),
- NO_VERSION_YET,
+ "$Id$",
STANDARD_MODULE_PROPERTIES
};
/* }}} */
@@ -297,7 +304,7 @@ PHP_MSHUTDOWN_FUNCTION(nsapi)
PHP_MINFO_FUNCTION(nsapi)
{
php_info_print_table_start();
- php_info_print_table_row(2, "NSAPI support", "enabled");
+ php_info_print_table_row(2, "NSAPI Module Version", nsapi_module_entry.version);
php_info_print_table_row(2, "Server Software", system_version());
php_info_print_table_row(2, "Sub-requests with virtual()",
(nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" );
@@ -384,6 +391,54 @@ PHP_FUNCTION(virtual)
}
/* }}} */
+/* {{{ proto array nsapi_request_headers(void)
+ Get all headers from the request */
+PHP_FUNCTION(nsapi_request_headers)
+{
+ register int i;
+ struct pb_entry *entry;
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ for (i=0; i < rc->rq->headers->hsize; i++) {
+ entry=rc->rq->headers->ht[i];
+ while (entry) {
+ if (!PG(safe_mode) || strcasecmp(entry->param->name, "authorization")) {
+ add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ }
+ entry=entry->next;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto array nsapi_response_headers(void)
+ Get all headers from the response */
+PHP_FUNCTION(nsapi_response_headers)
+{
+ register int i;
+ struct pb_entry *entry;
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_header();
+
+ for (i=0; i < rc->rq->srvhdrs->hsize; i++) {
+ entry=rc->rq->srvhdrs->ht[i];
+ while (entry) {
+ add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ entry=entry->next;
+ }
+ }
+}
+/* }}} */
+
/*************/
/* SAPI part */
@@ -551,15 +606,17 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
for (i=0; i < rc->rq->headers->hsize; i++) {
entry=rc->rq->headers->ht[i];
while (entry) {
- snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
- for(p = buf + 5; *p; p++) {
- *p = toupper(*p);
- if (*p < 'A' || *p > 'Z') {
- *p = '_';
+ if (!PG(safe_mode) || strcasecmp(entry->param->name, "authorization")) {
+ snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
+ for(p = buf + 5; *p; p++) {
+ *p = toupper(*p);
+ if (*p < 'A' || *p > 'Z') {
+ *p = '_';
+ }
}
+ buf[NS_BUF_SIZE]='\0';
+ php_register_variable(buf, entry->param->value, track_vars_array TSRMLS_CC);
}
- buf[NS_BUF_SIZE]='\0';
- php_register_variable(buf, entry->param->value, track_vars_array TSRMLS_CC);
entry=entry->next;
}
}