RESEND : Fix for $DOCUMENT_ROOT in ISAPI module for IIS servers on Windows system

From: Date: Fri, 04 Aug 2000 17:19:25 +0000
Subject: RESEND : Fix for $DOCUMENT_ROOT in ISAPI module for IIS servers on Windows system
Groups: php.dev 
Request: Send a blank email to php-dev+get-27730@lists.php.net to get a copy of this message
Hello everyone, I'm resending this fix since no-one seems to be taking care of entering it in the CVS and i personnaly can't do it. There was a small mistake i made so use this one instead of the previous one. Can someone check this fix and enter it in CVS please ? If there are issues just contact me. darkwing@videotron.ca This is my first Fix submission and i'm sure its not a big deal. The reason i mention it is that i believe that this fix should be checked carefully as i am very new to the OSS and PHP environments. I took the time to verify with a unix/apache user and when he echoes $DOCUMENT_ROOT, it's reporting the root of the virtual folder he is in. The fix should probably apply to PWS too but i havent verified it since i don't have any PWS installed here. I also cannot garantee that i'm using the correct fonctions but it seems to work for me. Feel free to fix whatever mistake i may have made. Specs & Test Case: NT4 SP5 server on local intranet with TCP/IP. IIS4 with 2 webs on 2 different IP's. (168.192.0.11 & 168.192.0.12) Web1 is HELPER located in d:\wwwroot Web2 is SHOPPER located in d:\wwwshop I have entries in LMHOSTS on remote Win2K to identify both. created /test.php in both webs containing : <? echo $DOCUMENT_ROOT; ?> the current output is : nothing, blank, nada, niet, white screen of emptyness for both webs :-) with the fix, the output is : for http://helper/test.php : d:\\wwwroot\\ for http://shopper/testp.php : d:\\wwwshop\\ HOW I FIXED IT: After having done lots of research in the code and trying to figure out where $DOCUMENT_ROOT was defined kinda showed me it was not defined properly. I still can't figure out where it was defined/initialized in the 4.0.1pl2 source code. It seemed to only be define for the CGI version of PHP. I've also taken the time to verify how apache server were handling $DOCUMENT_ROOT by having a IRC user run my test scripts on his server with 2 different subwebs and he got the expected result. Meaning 2 different system paths. THE SOURCE CHANGE: I have changed only 1 file to achieve my results: sapi/isapi/php4isapi.c remember that i changed 4.0.1pl2 version of it. function : sapi_isapi_register_server_variables() ... around line 307 ----------------------------------------------------------------------- static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) { char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; char *variable_buf; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; char *variable; char *strtok_buf = NULL; LPEXTENSION_CONTROL_BLOCK lpECB; char **p = isapi_server_variables; lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); ... ... ... variable = php_strtok_r(variable_buf, "\r\n", &strtok_buf); while (variable) { char *colon = strchr(variable, ':'); if (colon) { char *value = colon+1; while (*value==' ') { value++; } *colon = 0; php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); *colon = ':'; } variable = php_strtok_r(NULL, "\r\n", &strtok_buf); } ---------------- MY NEW CODE ------------- #ifdef PHP_WIN32 { HSE_URL_MAPEX_INFO humi; DWORD plen = 1; if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, "/", &plen, (LPDWORD) &humi)) { // Remove trailing \ humi.lpszPath[strlen(humi.lpszPath) - 1] = '\0'; php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array ELS_CC PLS_CC); } } #endif --------------- END OF MY CODE ------------- if (variable_buf!=static_variable_buf) { efree(variable_buf); } } ----------------------------------------------------------------------- Regards, DarkByte

« previous php.dev (#27730) next »