GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Sep-2004, 01:41
Biozero Biozero is offline
New Member
 
Join Date: Dec 2003
Location: A long time ago in a galaxy far, far away...
Posts: 3
Biozero is on a distinguished road

Trouble with CGI Variables PATH_*


Using PHP, the CGI variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED'] are always initialized to an empty string on my local server:
  • Windows XP Professional SP1
  • Apache 2.0.48
  • PHP 5.0.0RC3, as a module


Here are descriptions of what I expect:
PATH_TRANSLATED: Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

PATH_INFO: A URL that refers to a script may contain additional information, commonly called 'extra path information'. This is appended to the url and marked by a leading slash. The server puts this information in the PATH_INFO variable, which can be used as a method to pass arguments to the script.

The problem is repeatable to some degree on a remote server:
  • Linux (don't know which)
  • Apache 1.3.31
  • PHP 4.3.8, as a module
The remote server provides a correct PATH_TRANSLATED (AFAIK - appears identical to SCRIPT_FILENAME), but again, no PATH_INFO.


Are my definitions of the variables and interpretations of them correct; what is? Does anyone else have this problem, and with what setup? What other ways can be used to get these values? Because the called page isn't the executing page in this case, getcwd() and similar aren't options.

Thanks!
  #2  
Old 29-Sep-2004, 17:22
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
It looks like standard behavious to me. Here's what I found from the ie.php.net:

Quote:
'PATH_TRANSLATED'
Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined.

Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.

I'd not heard of PATH_INFO before this. I see it's part of the CGI spec though.
Hope this helps!
GF
  #3  
Old 30-Sep-2004, 00:30
Biozero Biozero is offline
New Member
 
Join Date: Dec 2003
Location: A long time ago in a galaxy far, far away...
Posts: 3
Biozero is on a distinguished road
I think my project hit a brick wall here. The note in the manual must be relatively new; last time I tried fixing this (~2 months ago), I checked that page only too often.

The new note implies that non-Apache servers do provide PATH_TRANSLATED, or that other server software packages have already made this change (is this true, which?):
Quote:
As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI...

Also, why does Apache not provide PATH_INFO by default?
Quote:
This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined.

Could it be that by running PHP as a module as opposed to a CGI, some CGI standards don't apply? "...under the Apache 2 SAPI..."

Thanks for that link to the manual, though. I can finally get back to work on the actual work :D .
  #4  
Old 30-Sep-2004, 17:36
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Yeah, I see this is quite a hummdinger. PATH_INFO strikes me a a very useful variable, especially for helping SEs with pretty request strings.

After a quick search through the Apache manual, I found something which may be related:
apache.active-venture.com

Quote:
Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME environment variables by looking at the filename, not the URL. While this resulted in the correct values in many cases, when the filesystem path was overloaded to contain path information, it could result in errant behavior. For example, if the following appeared in a config file:

Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph

In this case, user.cgi is the CGI script, the "/ralph" is information to be passed onto the CGI. If this configuration was in place, and a request came for "/cgi-ralph/script/", the code would set PATH_INFO to "/ralph/script", and SCRIPT_NAME to "/cgi-". Obviously, the latter is incorrect. In certain cases, this could even cause the server to crash.

This must be more of an Apache thing than a PHP one, and it doesn't look like it's been handled too well with only a strange workaround available.

GF
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variables out of an iframe by url JUNK KED MySQL / PHP Forum 5 31-Jul-2007 09:33
Visual C++ 6.0 trouble LuciWiz MS Visual C++ / MFC Forum 3 02-Aug-2004 06:40
Having trouble trying to format C: Nickster64 Computer Software Forum - Windows 2 27-Jul-2004 07:31
getting variables from $_GET & $_POST Dunc MySQL / PHP Forum 2 29-Mar-2004 05:45

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:50.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.