[PHP-DEV] PHP 4.0 Bug #7782 Updated: Cannot use PATH_INFO fully with php isapi
ID: 7782 User Update by: [EMAIL PROTECTED] Status: Open Bug Type: Feature/Change Request Description: Cannot use PATH_INFO fully with php isapi Hi, Due to some problems we have had with the isapi version of php under IIS, we have made some changes in the sourcecode of this isapi module to support Apache style PATH_INFO and PATH_TRANSLATED variables. We tested it with IIS 5 on Windows 2000 Server. (See also Bug number 7782). What we have done: - In the function init_request_info we have added some code which will translate the path_translated server variable to a path which points to the requested script on disk. - In the function sapi_isapi_register_server_variables2 we have added some translations for the variables $PATH_INFO and $PATH_TRANSLATED PATH_INFO will now be translated from: /script/path/script.php/some/non/existing/path to /some/non/existing/path PATH_TRANSLATED will be translated from: d:\Inetpub\wwwroot\script.php\some\non\existing\path to d:\Inetpub\wwwroot\script.php - We have added a function named sapi_isapi_get_server_var which will retrieve the requested server variable and returns a pointer to it. This function has been added to make things more structured (because of the need to check for a INSUFFICIENT BUFFER error). We have made a patch file of these changes against the cvs version 1.7 of php4isapi.c. This path file is attached to this e-mail. Please keep in mind that we did not have the opportunity to test this fix with Zeus. We hope you can/will commit this fix to the php cvs repository. With kind regards, Gijsbert te Riet, Muze. [EMAIL PROTECTED] patch: 16a17 | IIS PATH_TRANSLATED / PATH_INFO fix: Gijsbert te Riet [EMAIL PROTECTED] | 83a85 PATH_INFO, 88a91 REQUEST_URI, 464a468,492 static char *sapi_isapi_get_server_var(LPEXTENSION_CONTROL_BLOCK lpECB, char *varname, DWORD *buffer_len) { char*buffer; buffer=emalloc(*buffer_len=ISAPI_SERVER_VAR_BUF_SIZE); if (!lpECB-GetServerVariable(lpECB-ConnID, varname, buffer, buffer_len)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { buffer = (char *) erealloc(buffer, *buffer_len); if (!lpECB-GetServerVariable(lpECB-ConnID, varname, buffer, buffer_len)) { efree(buffer); buffer=0; } } else { efree(buffer); buffer=0; } } return buffer; } 468,469c496 DWORD variable_len; char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; --- DWORD varsize, varbufsize; 470a498 char *var_buf1, *var_buf2; 473,478c501,508 variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if (lpECB-GetServerVariable(lpECB-ConnID, *p, static_variable_buf, variable_len) static_variable_buf[0]) { php_register_variable(*p, static_variable_buf, track_vars_array ELS_CC PLS_CC); if (recorded_values) { recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len); --- if (variable_buf=sapi_isapi_get_server_var(lpECB, *p, varsize)) { // translate PATH_INFO to Apache compatible PATH_INFO if (strcmp(*p, PATH_INFO) == 0) { if (var_buf1=sapi_isapi_get_server_var(lpECB, SCRIPT_NAME, varbufsize)) { memmove(variable_buf, variable_buf + strlen(var_buf1), strlen(variable_buf) - strlen(var_buf1) + 1); efree(var_buf1); } 480,484c510,519 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { variable_buf = (char *) emalloc(variable_len); if (lpECB-GetServerVariable(lpECB-ConnID, *p, variable_buf, variable_len) variable_buf[0]) { php_register_variable(*p, variable_buf, track_vars_array ELS_CC PLS_CC); --- // translate PATH_TRANSLATED to Apache compatible PATH_TRANSLATED if (strcmp(*p, PATH_TRANSLATED) == 0) { if (var_buf1=sapi_isapi_get_server_var(lpECB, PATH_INFO, varbufsize)) { if (var_buf2=sapi_isapi_get_server_var(lpECB, SCRIPT_NAME, varbufsize)) { variable_buf[strlen(variable_buf)-(strlen(var_buf1)-strlen(var_buf2))]='\0';
[PHP-DEV] Re: PHP 4.0 Bug #9373 Updated: Filesystem read not binary safe?
On 22 Feb 2001, Bug Database wrote: ID: 9373 Updated by: sniper Reported By: [EMAIL PROTECTED] Old-Status: Open Status: Closed Bug Type: Filesystem function related Assigned To: Comments: This should be fixed in CVS already. Please try a dev build from http://www.php4win.de/ --Jani Hi, we've tried the dev build (4.05.dev) and it seems to work, thanks! however (there's always an however:) we've still got a problem. In the distribution of Ariadne we've included a serialized array in a separate file. When reading this file using the following code: $data=fread($fp,$fs); $mod-data=unserialize($data); unserialize fails halfway through the data. Also the string length of $data is smaller than the file length. After changing the code to this: $data=fread($fp,$fs); $data=str_replace("\n","\r\n",$data); $mod-data=unserialize($data); unserialize() ran fine... it seems that fread still 'fixes' return/linefeeds (btw: the first version of the code runs fine with either the cgi or the unix apache module version). regards, Auke van Slooten http://www.muze.nl/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] Re: PHP 4.0 Bug #9373 Updated: Filesystem read notbinary safe?
On Fri, 23 Feb 2001, Hartmut Holzgraefe wrote: did you add 'b' to the fopen() mode to enforce binary operation? i.e. $fp=fopen($filename,"rb") instead of plain "b"? No we didn't, and yes, if you do, everything works fine :) Thanks for the heads up. Still, it took me some time to find it in the manual even after your email... maybe it's a good idea to simply add it in the list with 'a','r', 'w' and the rest? Also, it says in bright and shiny letters in the manual 'fread -- Binary-safe file read'... somehow I didn't expect that that means I still need to tell fopen about it too :)) thanks for the good work, php4.05.dev runs very stable on our systems now, and it's blazing fast :) regards, Auke van Slooten Muze -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DEV] PHP 4.0 Bug #9373 Updated: Filesystem read not binary safe?
ID: 9373 User Update by: [EMAIL PROTECTED] Status: Open Bug Type: Filesystem function related Description: Filesystem read not binary safe? I've been checking it a bit further, it seems that all filesystem read and write functions fail under the windows apache module. fread and even fgetc will stop at char(26) and also, if they ancounter a 0D 0A (13 10, return+linefeed), even fgetc will only return a 0A. This is exactly the same behaviour as when it reads a single 0A, so there's no possible workaround. It seems simply impossible to read a binary file correctly. Even ftell seems to be in on the joke. I've made a file containing ' 09 0D 0A 0A ' reading it with: $curr=ftell($fp); while ($char=fgetc($fp)) { $new=ftell($fp); if ($new($curr+1)) { echo " 0D"; } echo strtoupper(dechex(ord($char))); $curr=$new; } returns: 09 0D 0A 0D 0A ftell actually counts the nonexisting second 0D btw. ftell also doesn't start at 0, if you do a fseek($fp, 0) and then a ftell($fp), it will return a semirandom number (at least I haven't found out what it is). Previous Comments: --- [2001-02-21 09:05:31] [EMAIL PROTECTED] Running PHP 4.0.4pl1 as an apache module (php4apache.dll) When reading and writing files using any function except include() and require() the reading and writing seems to stop whenever a char(0) is encountered... I'm not exactly sure that is what happens, but textfiles are read and written without problems, binary files are cut short. e.g.: ?php readfile("someimage.gif"); ? delivers only a small part of the image, resulting in a broken image tag (usually) or the top part of the image (sometimes). Whereas: ?php include("someimage.gif"); ? does deliver the entire image (or a parse error :) --- Full Bug description available at: http://bugs.php.net/?id=9373 -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DEV] PHP 4.0 Bug #9373: Filesystem read not binary safe?
From: [EMAIL PROTECTED] Operating system: Windows NT PHP version: 4.0.4pl1 PHP Bug Type: Filesystem function related Bug description: Filesystem read not binary safe? Running PHP 4.0.4pl1 as an apache module (php4apache.dll) When reading and writing files using any function except include() and require() the reading and writing seems to stop whenever a char(0) is encountered... I'm not exactly sure that is what happens, but textfiles are read and written without problems, binary files are cut short. e.g.: ?php readfile("someimage.gif"); ? delivers only a small part of the image, resulting in a broken image tag (usually) or the top part of the image (sometimes). Whereas: ?php include("someimage.gif"); ? does deliver the entire image (or a parse error :) -- Edit Bug report at: http://bugs.php.net/?id=9373edit=1 -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]