]> granicus.if.org Git - php/commitdiff
@ Support Zeus 3.3.8
authorBen Mansell <joosters@php.net>
Tue, 16 Jan 2001 10:44:52 +0000 (10:44 +0000)
committerBen Mansell <joosters@php.net>
Tue, 16 Jan 2001 10:44:52 +0000 (10:44 +0000)
Added changes to environment variable manipulations, to support Zeus 3.3.8
and increase compatibility between Zeus/IIS/Apache. Now, URLs like
http://foo.org/file.php/a/b/c/d work correctly.
# While testing, it looks like IIS+ISAPI is mishandling URLs like the above.
# The PATH_TRANSLATED given by ISAPI includes the /a/b/c/d bit of the URL,
# so using this var to find the script file to open on disk will not work.
# We now use SCRIPT_FILENAME if it is present (in Zeus 3.3.8)
# IIS doesn't seem to set this variable, it might be necessary to mangle
# SCRIPT_NAME and APPL_PHYSICAL_PATH together?

README.Zeus
sapi/isapi/php4isapi.c

index 603dc7703b45c093443fb8114516a98d64bb1e30..836aef87c8b7c2d8f570669176d3d75d2a7ff75e 100644 (file)
@@ -6,9 +6,11 @@ significant improvement in PHP 4 is that you can now run PHP as an
 ISAPI module, giving great performance benefits over traditional CGI
 code.
 
-Note that you will need to be running at least version 3.3.6 of the
+Note that you will need to be running at least version 3.3.8 of the
 webserver. If you are running an earlier version, please see our
 website (http://www.zeus.com) for upgrade instructions.
+Earlier versions of Zeus (3.3.6) can also run PHP, but it is
+suggested that you upgrade for full compatibility.
 
 
 To build the ISAPI version of PHP, start the configuration with:
index 65b5ec9b4d58b966f92c604ce0a1ac6b99869edc..ad314d9a4c5e72a78d55394df895ec85d4810366 100644 (file)
@@ -65,8 +65,6 @@ static char *isapi_special_server_variable_names[] = {
        "HTTPS",
 #ifndef WITH_ZEUS
        "SCRIPT_NAME",
-#else
-       "PATH_INFO",
 #endif
        NULL
 };
@@ -349,33 +347,44 @@ static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB,
 {
        char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
        DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
+       DWORD scriptname_len = ISAPI_SERVER_VAR_BUF_SIZE;
+       DWORD pathinfo_len = 0;
        char *strtok_buf = NULL;
 
-    /*
-     * Zeus' map module translates the given URL onto the PHP ISAPI library;
-     * from an internal point of view, SCRIPT_NAME and URL are correct,
-     * but from the end-users point of view, it is not... We need to
-     * reconstruct the SCRIPT_NAME and URL from PATH_INFO, and then
-     * finally clear out PATH_INFO.
-     */
-    variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
-    if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
-        php_register_variable( "SCRIPT_NAME", static_variable_buf, track_vars_array ELS_CC PLS_CC );
-        /* append query string to give url... extra byte for '?' */
-        if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) {
+       /* Get SCRIPT_NAME, we use this to work out which bit of the URL
+        * belongs in PHP's version of PATH_INFO
+        */
+       lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &scriptname_len);
+
+       /* Adjust Zeus' version of PATH_INFO, set PHP_SELF,
+        * and generate REQUEST_URI
+        */
+       if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
+
+               /* PHP_SELF is just PATH_INFO */
+               php_register_variable( "PHP_SELF", static_variable_buf, track_vars_array ELS_CC PLS_CC );
+
+               /* Chop off filename to get just the 'real' PATH_INFO' */
+               pathinfo_len = variable_len - scriptname_len;
+               php_register_variable( "PATH_INFO", static_variable_buf + scriptname_len - 1, track_vars_array ELS_CC PLS_CC );
+               /* append query string to give url... extra byte for '?' */
+               if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) {
                        /* append query string only if it is present... */
                        if ( strlen(lpECB->lpszQueryString) ) {
                                static_variable_buf[ variable_len - 1 ] = '?';
                                strcpy( static_variable_buf + variable_len, lpECB->lpszQueryString );
                        }
-            php_register_variable( "URL", static_variable_buf, track_vars_array ELS_CC PLS_CC );
-            php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array ELS_CC PLS_CC );
-        }
-    }
-    variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
-    if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
-        php_register_variable( "SCRIPT_FILENAME", static_variable_buf, track_vars_array ELS_CC PLS_CC );
-    }
+                       php_register_variable( "URL", static_variable_buf, track_vars_array ELS_CC PLS_CC );
+                       php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array ELS_CC PLS_CC );
+               }
+       }
+
+       /* Get and adjust PATH_TRANSLATED to what PHP wants */
+       variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
+       if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) {
+               static_variable_buf[ variable_len - pathinfo_len - 1 ] = '\0';
+               php_register_variable( "PATH_TRANSLATED", static_variable_buf, track_vars_array ELS_CC PLS_CC );
+       }
 }
 #endif
 
@@ -550,7 +559,7 @@ DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LP
 
                                if (auth_user && auth_user[0]) {
                                        SG(request_info).auth_user = estrdup(auth_user);
-                               }   
+                               }       
                                if (auth_password && auth_password[0]) {
                                        SG(request_info).auth_password = estrdup(auth_password);
                                }
@@ -652,8 +661,27 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
                init_request_info(sapi_globals, lpECB);
                SG(server_context) = lpECB;
 
+#ifdef WITH_ZEUS
+               /* PATH_TRANSLATED can contain extra PATH_INFO stuff after the
+                * file being loaded, so we must use SCRIPT_FILENAME instead
+                */
+               file_handle.filename = (char *)emalloc( ISAPI_SERVER_VAR_BUF_SIZE );
+               file_handle.free_filename = 1;
+               {
+                       DWORD filename_len = ISAPI_SERVER_VAR_BUF_SIZE;
+                       if( !lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_FILENAME", file_handle.filename, &filename_len) || file_handle.filename[ 0 ] == '\0' ) {
+                /* If we're running on an earlier version of Zeus, this
+                 * variable won't be present, so fall back to old behaviour.
+                 */
+                efree( file_handle.filename );
+                file_handle.filename = sapi_globals->request_info.path_translated;
+                file_handle.free_filename = 0;
+            }
+               }
+#else
                file_handle.filename = sapi_globals->request_info.path_translated;
                file_handle.free_filename = 0;
+#endif
                file_handle.type = ZEND_HANDLE_FILENAME;
                file_handle.opened_path = NULL;