Bug 336 - [Chameleon] $_SERVER['SCRIPT_FILENAME'] did not exist
: [Chameleon] $_SERVER['SCRIPT_FILENAME'] did not exist
Status: CLOSED FIXED
: Chameleon
Core
: 1.99
: PC Windows 2000
: P2 normal
: 1.99 beta 2
Assigned To:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2004-04-01 14:57 by
Modified: 2004-06-30 12:23 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2004-04-01 14:57:28
Windows 2000 Server
PHP 4.3.3

chameleon.php line 160

$GLOBALS['gszAppPath'] = dirname( $_SERVER['SCRIPT_FILENAME'] )."/";

$_SERVER['SCRIPT_FILENAME'] did not exist in the $_SERVER array when print_r'ed.

Resolution:  $_SERVER['SCRIPT_NAME'] existed.  Perform check for
isset($_SERVER['SCRIPT_FILENAME']) ?
------- Comment #1 From 2004-04-05 13:11:16 -------
Fixed. I added a check before using SCRIPT_FILENAME. Then if not set it use
SCRIPT_NAME.
------- Comment #2 From 2004-04-05 13:15:09 -------
Actually, it needs to be set to $_SERVER['PATH_TRANSLATED'] instead of
$_SERVER['SCRIPT_NAME'] after further research.  As well, it's not known how
other webservers under different OS' use the $_SERVER var.
------- Comment #3 From 2004-04-05 13:41:08 -------
Unfortunately PATH_TRANSLATED is only available in PHP 4.3.X and up....
------- Comment #4 From 2004-04-05 13:49:32 -------
Oh... It looks like it is. I've made a test on a old PHP and I got
PATH_TRANSLATED. Someone in the code added a test to prevent access that var if
not greater than 4.3.X. Not sure why.
------- Comment #5 From 2004-04-05 13:54:05 -------
Ok. I fixed the problem in CVS. It's now using PATH_TRANSLATED. I'm leaving the
bug open for a few days to make sure the test about version was useless. Any
comments ?
------- Comment #6 From 2004-04-05 15:23:07 -------
On my system phpinfo reports that I have no PATH_TRANSLATED ... but I do have
ORIG_PATH_TRANSLATED.  

http://ca.php.net/manual/en/reserved.variables.php#reserved.variables.server

$_SERVER is an array containing information such as headers, paths, and script
locations. The entries in this array are created by the webserver. There is no
guarantee that every webserver will provide any of these; servers may omit some,
or provide others not listed here.  That said, a large number of these variables
are accounted for in the CGI 1.1 specification, so you should be able to expect
those.

And from the CGI spec:

PATH_TRANSLATED

The server provides a translated version of PATH_INFO, which takes the path and
does any virtual-to-physical mapping to it. 

So it should be there, but in my case it is not.
------- Comment #7 From 2004-04-07 11:34:39 -------
Ok. Me and Bill have been able to reproduce the problem. When PATH_TRANSLATED is
not set we check for ORIG_PATH_TRANSLATED. And it fixed the problem.

Paul, can you try it on you system to make sure it's working and mark the bug
fixe dif so ?
------- Comment #8 From 2004-04-08 08:37:22 -------
updated version to 1.99
------- Comment #9 From 2004-05-21 11:06:16 -------
yes this seems to work.
------- Comment #10 From 2004-05-21 11:14:48 -------
I have just verified that ORIG_PATH_TRANSLATED exists on Win2K/XP under both IIS
and Apache $_SERVER.  This is sufficient for Windows OS.
------- Comment #11 From 2004-06-23 21:49:50 -------
Jay I would like you to show me how you verified this, thanks :)


------- Comment #12 From 2004-06-24 08:33:23 -------
Chris, 

I ran PHPInfo() ... it will list all the $_SERVER variables available on that
machine under that webserver.
------- Comment #13 From 2004-06-24 09:23:23 -------
verified, using beta 2 2004-06-20 and phpinfo()

SERVER["ORIG_PATH_TRANSLATED"] D:\\ms4w\\Apache\\htdocs\\phpinfo.php 
------- Comment #14 From 2004-06-30 12:23:20 -------
Verified on Fedora Core 1 Chameleon 20040625.  "PATH_TRANSLATED" is defined
instead of "ORIG_PATH_TRANSLATED".  So by testing on Windows and Linux, we
tested  both possibilities.


_SERVER["PATH_TRANSLATED"]	/var/www/html/nsavard/tests/phpinfo.phtml