[PHP-DEV] RE: [PHP] PHP / NSAPI / Web server support From: Paul Egan (lumpy <email protected>)
Date: 01/21/01

The change from request_translate_uri to rq->vars "path"
also fixes the use of PATH_INFO and PHP as a default
index. Without this, PHP halts without error on
URI's like /app (with /app/index.php) or /script.php/commit.

The same problems with PATH_INFO & default index occur
when running PHP as a CGI. I've made a few changes to
cgi_main.c to fix this but havn't tested on anything but
NES 362.

I've been encountering quite a few bus error & seg faults
when using the NSAPI plugin (up to 5 a day) - these are
usually caught by uxwdog. Anybody else found the same?

I noticed also that the latest snapshot now includes the check
for ieeefp.h.

*** sapi/cgi/cgi_main.c.orig Sat Jan 20 00:09:12 2001
--- sapi/cgi/cgi_main.c Sat Jan 20 00:08:42 2001
***************
*** 168,174 ****
                          l += strlen(sn);
                  if (pi)
                          l += strlen(pi);
! if (pi && sn && !strcmp(pi, sn)) {
                          l -= strlen(pi);
                          pi = NULL;
                  }
--- 168,174 ----
                          l += strlen(sn);
                  if (pi)
                          l += strlen(pi);
! if (pi && sn && !strncmp(pi, sn, strlen(sn))) {
                          l -= strlen(pi);
                          pi = NULL;
                  }
***************
*** 314,323 ****
--- 314,337 ----
  
          SG(request_info).request_method = getenv("REQUEST_METHOD");
          SG(request_info).query_string = getenv("QUERY_STRING");
+ /*
          SG(request_info).request_uri = getenv("PATH_INFO");
          if (!SG(request_info).request_uri) {
                  SG(request_info).request_uri = getenv("SCRIPT_NAME");
          }
+ */
+
+ SG(request_info).request_uri = getenv("SCRIPT_NAME");
+ if (SG(request_info).request_uri && SG(request_info).argv0 && IS_SLASH(SG(request_info).request_uri[strlen(SG(request_info).request_uri)-1])) {
+ char *arg_file = strrchr(SG(request_info).argv0,DEFAULT_SLASH);
+ if (arg_file) {
+ char *script_name = emalloc(strlen(SG(request_info).request_uri)+strlen(arg_file)+1);
+ strcpy(script_name,SG(request_info).request_uri);
+ strcat(script_name,arg_file+1);
+ SG(request_info).request_uri = script_name;
+ }
+ }
+
          SG(request_info).path_translated = NULL; /* we have to update it later, when we have that information */
          SG(request_info).content_type = getenv("CONTENT_TYPE");
          SG(request_info).content_length = (content_length?atoi(content_length):0);
***************
*** 507,518 ****
                  ap_php_optarg = orig_optarg;
          }
  
          init_request_info(SLS_C);
          SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
          CG(extended_info) = 0;
  
- SG(request_info).argv0 = argv0;
-
          zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
  
          if (!cgi) { /* never execute the arguments if you are a CGI */
--- 521,532 ----
                  ap_php_optarg = orig_optarg;
          }
  
+ SG(request_info).argv0 = argv0;
+
          init_request_info(SLS_C);
          SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
          CG(extended_info) = 0;
  
          zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
  
          if (!cgi) { /* never execute the arguments if you are a CGI */

*** sapi/nsapi/nsapi.c.orig Sat Jan 20 15:11:01 2001
--- sapi/nsapi/nsapi.c Sat Jan 20 15:31:34 2001
***************
*** 101,106 ****
--- 101,107 ----
          { "HTTP_ACCEPT_LANGUAGE", "accept-language" },
          { "HTTP_AUTHORIZATION", "authorization" },
          { "HTTP_COOKIE", "cookie" },
+ { "HTTP_CLIENT_IP", "client-ip" },
          { "HTTP_IF_MODIFIED_SINCE", "if-modified-since" },
          { "HTTP_REFERER", "referer" },
          { "HTTP_USER_AGENT", "user-agent" },
***************
*** 445,457 ****
          char *query_string = pblock_findval("query", NSG(rq)->reqpb);
          char *uri = pblock_findval("uri", NSG(rq)->reqpb);
          char *path_info = pblock_findval("path-info", NSG(rq)->vars);
! char *path_translated = NULL;
          char *request_method = pblock_findval("method", NSG(rq)->reqpb);
          char *content_type = pblock_findval("content-type", NSG(rq)->headers);
          char *content_length = pblock_findval("content-length", NSG(rq)->headers);
  
          if (uri != NULL)
                  path_translated = request_translate_uri(uri, NSG(sn));
  
  #if defined(NSAPI_DEBUG)
          log_error(LOG_INFORM, "nsapi_request_ctor", NSG(sn), NSG(rq),
--- 446,460 ----
          char *query_string = pblock_findval("query", NSG(rq)->reqpb);
          char *uri = pblock_findval("uri", NSG(rq)->reqpb);
          char *path_info = pblock_findval("path-info", NSG(rq)->vars);
! char *path_translated = pblock_findval("path", NSG(rq)->vars);
          char *request_method = pblock_findval("method", NSG(rq)->reqpb);
          char *content_type = pblock_findval("content-type", NSG(rq)->headers);
          char *content_length = pblock_findval("content-length", NSG(rq)->headers);
  
+ /*
          if (uri != NULL)
                  path_translated = request_translate_uri(uri, NSG(sn));
+ */
  
  #if defined(NSAPI_DEBUG)
          log_error(LOG_INFORM, "nsapi_request_ctor", NSG(sn), NSG(rq),

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>