Re: [PHP-DEV] [PATCH] sapi/nsapi/nsapi.c

2003-02-03 Thread Uwe Schindler
The variables you explain are surely there. But a lot of scripts depend on 
other headers, which the client sent.
The SAPI module only creates Variables for a subset of them 
(HTTP_USER_AGENT). But not for all like
the other SAPI modules. So with this patch you get for example the missing 
HTTP_HOST-Header (HTTP/1.1)
because the patch creates for every variable in the request a 
HTTP_XXX-Variable. So you can see all headers the client have sent.
This is the way the other SAPI modules (APACHE) and the normal CGI 
environment works. Without it about 50% of the currently available PHP 
scripts do not run correctly.

You can try it with: http://www.emarcon.net/test.php which runs the patched 
Version. Yo will see all headers sent by your client not only the ones 
explained below and HTTP_USER_AGENT and HTTP_ACCEPT_*

Greetings from Germany,
Uwe

At 15:52 02.02.2003 -0800, you wrote:
Hi Uwe,
I haven't looked at the patch, but I am wondering if the nsapi sapi module 
creates variables for php that conform to the cgi spec.  Can you try the 
following url against a phpinfo(); script:

http://localhost/info.php/test/path?query=string

You should get:

PATH_INFO=/test/path
PATH_TRANSLATED=/your_web_document_root/test/path
QUERY_STRING=query=string
SCRIPT_NAME=/info.php
PHP_SELF=/info.php

If you do not, then the sapi module is not conformant to cgi spec, and 
still needs some work.
Shane

Uwe Schindler wrote:
I submit a patch for the NSAPI SAPI module and hope that it fixes a lot 
of problems I have (and others as seen in the bug database).
As a lot of variables which are needed by a lot of PHP scripts which use 
$_SERVER[...] are not transferred correctly to the PHP script that runs 
in iPlanet Webserver (4 or 6). An example are the Host and 
X-Forwarded headers. This is so, because the transferred variables are 
static in the SAPI module.
The new nsapi.c file now transfers _ALL_ variables from rc-rq-headers 
to php_register_variable(HTTP_+headername_uppercase, ...).
Also missing variables like SERVER_SOFTWARE are added.
A lot of customers complain about memory leaks in this module. I hope 
they are also fixed by freeing the by nsapi allocated strings (the return 
value of session_dns and http_uri2url).
The patch should work with Netscape/iPlanet Servers from version 3 on (I 
used no newer API calls).
If you are interested I could eventually create a patch for supporting 
the virtual servers in SunONE/iPlanet Web Server 6, because some vars 
only get the default-hostname not the real virtual server name (for 
example $_SERVER[SERVER_URL] which is often used in scripts to refer 
together with $_SERVER[PHP_SELF]). But this mut be done with #ifdefs 
because some new functions are in the nsapi since version 6. A good fix 
would be also to map $_SERVER[SERVER_URL] to 
http://$SERVER[HTTP_HOST];, because in iPlanet-Servers the Host 
variable is everytime available (if not in original HTTP-headers it is 
defined to be the default hostname).
Greetings,
Uwe

-
Uwe Schindler
Addr 1: Bamberger Str. 24a, D-96049 Bamberg
Addr 2: Drausnickstr. 153, D-91052 Erlangen
http://www.thetaphi.de - http:///www.schindlers-software.de
eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company)
Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)
Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!

-
Uwe Schindler
Addr 1: Bamberger Str. 24a, D-96049 Bamberg
Addr 2: Drausnickstr. 153, D-91052 Erlangen
http://www.thetaphi.de - http:///www.schindlers-software.de
eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company)
Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)

Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!  


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] sapi/nsapi/nsapi.c

2003-02-03 Thread Shane Caraveo
Excelent, The CGI vars are correct.  One less sapi module to deal with :)
Shane

Uwe Schindler wrote:

The variables you explain are surely there. But a lot of scripts depend 
on other headers, which the client sent.
The SAPI module only creates Variables for a subset of them 
(HTTP_USER_AGENT). But not for all like
the other SAPI modules. So with this patch you get for example the 
missing HTTP_HOST-Header (HTTP/1.1)
because the patch creates for every variable in the request a 
HTTP_XXX-Variable. So you can see all headers the client have sent.
This is the way the other SAPI modules (APACHE) and the normal CGI 
environment works. Without it about 50% of the currently available PHP 
scripts do not run correctly.

You can try it with: http://www.emarcon.net/test.php which runs the 
patched Version. Yo will see all headers sent by your client not only 
the ones explained below and HTTP_USER_AGENT and HTTP_ACCEPT_*

Greetings from Germany,
Uwe

At 15:52 02.02.2003 -0800, you wrote:

Hi Uwe,
I haven't looked at the patch, but I am wondering if the nsapi sapi 
module creates variables for php that conform to the cgi spec.  Can 
you try the following url against a phpinfo(); script:

http://localhost/info.php/test/path?query=string

You should get:

PATH_INFO=/test/path
PATH_TRANSLATED=/your_web_document_root/test/path
QUERY_STRING=query=string
SCRIPT_NAME=/info.php
PHP_SELF=/info.php

If you do not, then the sapi module is not conformant to cgi spec, and 
still needs some work.
Shane

Uwe Schindler wrote:

I submit a patch for the NSAPI SAPI module and hope that it fixes a 
lot of problems I have (and others as seen in the bug database).
As a lot of variables which are needed by a lot of PHP scripts which 
use $_SERVER[...] are not transferred correctly to the PHP script 
that runs in iPlanet Webserver (4 or 6). An example are the Host 
and X-Forwarded headers. This is so, because the transferred 
variables are static in the SAPI module.
The new nsapi.c file now transfers _ALL_ variables from 
rc-rq-headers to 
php_register_variable(HTTP_+headername_uppercase, ...).
Also missing variables like SERVER_SOFTWARE are added.
A lot of customers complain about memory leaks in this module. I hope 
they are also fixed by freeing the by nsapi allocated strings (the 
return value of session_dns and http_uri2url).
The patch should work with Netscape/iPlanet Servers from version 3 on 
(I used no newer API calls).
If you are interested I could eventually create a patch for 
supporting the virtual servers in SunONE/iPlanet Web Server 6, 
because some vars only get the default-hostname not the real virtual 
server name (for example $_SERVER[SERVER_URL] which is often used 
in scripts to refer together with $_SERVER[PHP_SELF]). But this mut 
be done with #ifdefs because some new functions are in the nsapi 
since version 6. A good fix would be also to map 
$_SERVER[SERVER_URL] to http://$SERVER[HTTP_HOST];, because in 
iPlanet-Servers the Host variable is everytime available (if not in 
original HTTP-headers it is defined to be the default hostname).
Greetings,
Uwe

-
Uwe Schindler
Addr 1: Bamberger Str. 24a, D-96049 Bamberg
Addr 2: Drausnickstr. 153, D-91052 Erlangen
http://www.thetaphi.de - http:///www.schindlers-software.de
eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company)
Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)
Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!


-
Uwe Schindler
Addr 1: Bamberger Str. 24a, D-96049 Bamberg
Addr 2: Drausnickstr. 153, D-91052 Erlangen
http://www.thetaphi.de - http:///www.schindlers-software.de
eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company)
Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)

Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!  







--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] sapi/nsapi/nsapi.c

2003-02-03 Thread Uwe Schindler
I worked this afternon on rewriting a lot of things in the module which now 
gives the php script almost the same variables like the apache sapi module 
(as provided).
For comparison: same request on two different servers, one with apache 
other with iplanet:

iplanet:
_GET[huhu] haha
_SERVER[QUERY_STRING] huhu=haha
_SERVER[REQUEST_LINE] GET /test.php/testpfad?huhu=haha HTTP/1.1
_SERVER[REQUEST_METHOD] GET
_SERVER[PHP_SELF] /test.php/testpfad
_SERVER[SERVER_PROTOCOL] HTTP/1.1
_SERVER[HTTP_ACCEPT] */*
_SERVER[HTTP_ACCEPT_LANGUAGE] de
_SERVER[HTTP_ACCEPT_ENCODING] gzip, deflate
_SERVER[HTTP_USER_AGENT] Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 
5.0; T312461)
_SERVER[HTTP_HOST] edvs0.awi-bremerhaven.de
_SERVER[HTTP_CONNECTION] Keep-Alive
_SERVER[PATH_INFO] /testpfad
_SERVER[SCRIPT_FILENAME] /pangaea/webserver/docs/test.php
_SERVER[REMOTE_ADDR] 217.81.211.4
_SERVER[REMOTE_HOST] 217.81.211.4
_SERVER[SERVER_PORT] 80
_SERVER[SERVER_NAME] edvs0.awi-bremerhaven.de
_SERVER[SERVER_URL] http://edvs0.awi-bremerhaven.de
_SERVER[SERVER_SOFTWARE] iPlanet-WebServer-Enterprise/6.0
_SERVER[HTTPS] OFF
_SERVER[GATEWAY_INTERFACE] CGI/1.1
_SERVER[DOCUMENT_ROOT] /pangaea/webserver/docs
_SERVER[PATH_TRANSLATED] /pangaea/webserver/docs/testpfad
_SERVER[REQUEST_URI] /test.php/testpfad?huhu=haha
_SERVER[SCRIPT_NAME] /test.php

apache:
_GET[huhu] haha
_SERVER[DOCUMENT_ROOT] /data/web4u/html
_SERVER[HTTP_ACCEPT] */*
_SERVER[HTTP_ACCEPT_ENCODING] gzip, deflate
_SERVER[HTTP_ACCEPT_LANGUAGE] de
_SERVER[HTTP_CONNECTION] Keep-Alive
_SERVER[HTTP_HOST] www.web4u.cz
_SERVER[HTTP_USER_AGENT] Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 
5.0; T312461)
_SERVER[PATH] 
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin
_SERVER[REMOTE_ADDR] 217.81.211.4
_SERVER[REMOTE_PORT] 58578
_SERVER[SCRIPT_FILENAME] /data/web4u/html/phpinfo.php4
_SERVER[SERVER_ADDR] 194.228.111.51
_SERVER[SERVER_ADMIN] [EMAIL PROTECTED]
_SERVER[SERVER_NAME] www.web4u.cz
_SERVER[SERVER_PORT] 80
_SERVER[SERVER_SIGNATURE] ADDRESSApache/1.3.27 Server at www.web4u.cz 
Port 80/ADDRESS
_SERVER[SERVER_SOFTWARE] Apache/1.3.27 (Unix) PHP/4.2.3 (LD+WD4 patch) 
PHP/3.0.18 (CZ 0.33) (LD+FU+WD2 patch)
_SERVER[GATEWAY_INTERFACE] CGI/1.1
_SERVER[SERVER_PROTOCOL] HTTP/1.1
_SERVER[REQUEST_METHOD] GET
_SERVER[QUERY_STRING] huhu=haha
_SERVER[REQUEST_URI] /phpinfo.php4/testpfad?huhu=haha
_SERVER[SCRIPT_NAME] /phpinfo.php4
_SERVER[PATH_INFO] /testpfad
_SERVER[PATH_TRANSLATED] /data/web4u/html/testpfad
_SERVER[PHP_SELF] /phpinfo.php4/testpfad

In the original module were also errors in the variables PATH_TRANSLATED 
(contained the full path, same as PHP_SELF) and SCRIPT_NAME.
Also one open issue is, as I see in your mailing list archive, 
DOCUMENT_ROOT: It works with my modification even with virtual servers.

If I can do any further improvements let me know it. I have some experience 
with NSAPI so I could help to make the module always up-to-date when new 
servers of iPlanet/SUN came on the market.

With this new file the memory leaks (webserver eats up memory during afew 
days running) are also disappeared (all by NSAPI allocated strings are freed).

Uwe

P.S.: I have attached the finished nsapi.c file (in complete) because a 
patch has almost the same size :)
The patch I send yesterday was not fully correct.

At 11:14 03.02.2003 -0800, Shane Caraveo wrote:
Excelent, The CGI vars are correct.  One less sapi module to deal with :)
Shane

Uwe Schindler wrote:

The variables you explain are surely there. But a lot of scripts depend 
on other headers, which the client sent.
The SAPI module only creates Variables for a subset of them 
(HTTP_USER_AGENT). But not for all like
the other SAPI modules. So with this patch you get for example the 
missing HTTP_HOST-Header (HTTP/1.1)
because the patch creates for every variable in the request a 
HTTP_XXX-Variable. So you can see all headers the client have sent.
This is the way the other SAPI modules (APACHE) and the normal CGI 
environment works. Without it about 50% of the currently available PHP 
scripts do not run correctly.
You can try it with: http://www.emarcon.net/test.php which runs the 
patched Version. Yo will see all headers sent by your client not only the 
ones explained below and HTTP_USER_AGENT and HTTP_ACCEPT_*
Greetings from Germany,
Uwe
At 15:52 02.02.2003 -0800, you wrote:

Hi Uwe,
I haven't looked at the patch, but I am wondering if the nsapi sapi 
module creates variables for php that conform to the cgi spec.  Can you 
try the following url against a phpinfo(); script:

http://localhost/info.php/test/path?query=string

You should get:

PATH_INFO=/test/path
PATH_TRANSLATED=/your_web_document_root/test/path
QUERY_STRING=query=string
SCRIPT_NAME=/info.php
PHP_SELF=/info.php

If you do not, then the sapi module is not conformant to cgi spec, and 
still needs some work.
Shane

Uwe Schindler wrote:

I submit a patch for the NSAPI SAPI module and hope that it fixes a lot 
of problems I have (and others as seen in 

[PHP-DEV] [PATCH] sapi/nsapi/nsapi.c

2003-02-02 Thread Uwe Schindler
I submit a patch for the NSAPI SAPI module and hope that it fixes a lot of 
problems I have (and others as seen in the bug database).

As a lot of variables which are needed by a lot of PHP scripts which use 
$_SERVER[...] are not transferred correctly to the PHP script that runs 
in iPlanet Webserver (4 or 6). An example are the Host and X-Forwarded 
headers. This is so, because the transferred variables are static in the 
SAPI module.

The new nsapi.c file now transfers _ALL_ variables from rc-rq-headers to 
php_register_variable(HTTP_+headername_uppercase, ...).

Also missing variables like SERVER_SOFTWARE are added.
A lot of customers complain about memory leaks in this module. I hope they 
are also fixed by freeing the by nsapi allocated strings (the return value 
of session_dns and http_uri2url).

The patch should work with Netscape/iPlanet Servers from version 3 on (I 
used no newer API calls).

If you are interested I could eventually create a patch for supporting the 
virtual servers in SunONE/iPlanet Web Server 6, because some vars only 
get the default-hostname not the real virtual server name (for example 
$_SERVER[SERVER_URL] which is often used in scripts to refer together 
with $_SERVER[PHP_SELF]). But this mut be done with #ifdefs because some 
new functions are in the nsapi since version 6. A good fix would be also to 
map $_SERVER[SERVER_URL] to http://$SERVER[HTTP_HOST];, because in 
iPlanet-Servers the Host variable is everytime available (if not in 
original HTTP-headers it is defined to be the default hostname).

Greetings,
Uwe


-
Uwe Schindler
Addr 1: Bamberger Str. 24a, D-96049 Bamberg
Addr 2: Drausnickstr. 153, D-91052 Erlangen
http://www.thetaphi.de - http:///www.schindlers-software.de
eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company)
Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)

Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!  --- nsapi.c.old Sun Oct 27 00:00:36 2002
+++ nsapi.c Sun Feb  2 23:46:05 2003
@@ -2,7 +2,7 @@
+--+

| PHP Version 4|

+--+

-   | Copyright (c) 1997-2002 The PHP Group|

+   | Copyright (c) 1997-2003 The PHP Group|

+--+

| This source file is subject to version 2.02 of the PHP license,  |

| that is bundled with this package in the file LICENSE, and is|

@@ -66,6 +66,8 @@
 #define NSLS_CC, NSLS_C

 #define NSG(v) (request_context-v)

 

+#define NSHEADER_BUF_SIZE 1024

+

 /*

  * ZTS needs to be defined for NSAPI to work

  */

@@ -95,17 +97,7 @@
 

 static nsapi_equiv nsapi_headers[] = {

{ CONTENT_LENGTH, content-length },

-   { CONTENT_TYPE,   content-type },

-   { HTTP_ACCEPT,accept },

-   { HTTP_ACCEPT_ENCODING,   accept-encoding },

-   { HTTP_ACCEPT_LANGUAGE,   accept-language },

-   { HTTP_ACCEPT_CHARSET,accept-charset },

-   { HTTP_AUTHORIZATION, authorization },

-   { HTTP_COOKIE,cookie },

-   { HTTP_IF_MODIFIED_SINCE, if-modified-since },

-   { HTTP_REFERER,   referer },

-   { HTTP_USER_AGENT,user-agent },

-   { HTTP_USER_DEFINED,  user-defined }

+   { CONTENT_TYPE,   content-type }

 };

 static size_t nsapi_headers_size = sizeof(nsapi_headers)/sizeof(nsapi_headers[0]);

 

@@ -114,6 +106,7 @@
{ REQUEST_LINE,   clf-request },

{ REQUEST_METHOD, method },

{ SCRIPT_NAME,uri },

+   { PHP_SELF,   uri },

{ SERVER_PROTOCOL,protocol }

 };

 static size_t nsapi_reqpb_size = sizeof(nsapi_reqpb)/sizeof(nsapi_reqpb[0]);

@@ -130,7 +123,8 @@
 static nsapi_equiv nsapi_client[] = {

{ HTTPS_KEYSIZE,  keysize },

{ HTTPS_SECRETSIZE,   secret-keysize },

-   { REMOTE_ADDR,ip }

+   { REMOTE_ADDR,ip },

+   { REMOTE_HOST,ip }

 };

 static size_t nsapi_client_size = sizeof(nsapi_client)/sizeof(nsapi_client[0]);

 

@@ -281,8 +275,10 @@
 {

nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);

size_t i;

-   char *value;

-   char buf[128];

+   char *value,*p;

+   char c;

+   char buf[NSHEADER_BUF_SIZE + 1];

+   struct pb_entry *entry;

 

for (i = 0; i  nsapi_reqpb_size; i++) {

value = pblock_findval(nsapi_reqpb[i].nsapi_eq, rc-rq-reqpb);