PATH_INFO

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
WindEagle
-


Joined: 11 Aug 2004
Posts: 3
Location: Brooklyn, NYC, USA

PostPosted: Sat Apr 30, 2005 8:55 am    Post subject: PATH_INFO Reply with quote

this is for both php 5.0.3 and 4.3.11(both the latest) and i also tested ur php5 preconfig

i have setup php before and the settings are no different from before so it can't be my fault and i have tried every other setting like changing from php style to standard and even activeperl style

example path: /script.php/path/info

REQUEST_URI: /script.php/path/info (this is good)
URL: /script.php/path/info/path/info (obviously u can't have doubles here)
PATH_INFO: *empty* (can't be empty)
PATH_TRANSLATED: *\script.php (well this is not right thats for sure)

it should be:

URL: /script.php/path/info
PATH_INFO: /path/info
PATH_TRANSLATED: *\path\info

the only work around for this problem is this:

these 2 functions are my own and you can use them if u like and if u make some improvements let me know, also if u do use them at least tell me and if u have some ideas on what type of functions u want maybe i can help you, i got a ton and make new ones all the time, also if u include my function inside some project let me know as well

Code:


   function str_pos ( $pHayStack , $pNeedle , &$pPos , $pOffset = 0 )
   {
      return ( ( ( $pPos = strpos( $pHayStack , $pNeedle , $pOffset ) ) === FALSE ) ? 0 : 1 );
   }

   function substrs ( $pHayStack , $pStarts , $pEnds = 0 , $pDefault  = '' )
   {
      if ( ! str_pos( $pHayStack , $pStarts , $start ) )
      {
         return $pDefault ;
      }else{
         $start = $start + strlen( $pStarts );
         $end = ( ( $pEnds ? ( str_pos( $pHayStack , $pEnds , $end , $start ) ? $end : $pDefault  ) : strlen( $pHayStack ) ) - $start );
         return ( $end ? substr( $pHayStack , $start , $end ) : $pDefault  );
      }
   }
if ( empty( $_SERVER[ 'PATH_INFO' ] ) || $_SERVER[ 'PATH_INFO' ] == $_SERVER[ 'SCRIPT_NAME' ] )
{
   $URI = $_SERVER[ 'SCRIPT_NAME' ].( empty( $_SERVER[ 'QUERY_STRING' ] ) ? '' : '?'.$_SERVER[ 'QUERY_STRING' ] );
   if ( $URI != $_SERVER[ 'REQUEST_URI' ] )
   {
      $_SERVER[ 'PATH_INFO' ] =  substrs( $_SERVER[ 'REQUEST_URI' ] , $_SERVER[ 'SCRIPT_NAME' ] , ( empty( $_SERVER[ 'QUERY_STRING' ] ) ? 0 : '?'.$_SERVER[ 'QUERY_STRING' ] ) );
      $_SERVER[ 'PATH_TRANSLATED' ] =  $_SERVER[ 'DOCUMENT_ROOT' ].$_SERVER[ 'PATH_INFO' ]; // i dont know the specification for this variable so i'm guessing this is right
      $_SERVER[ 'URL' ] = $_SERVER[ 'SCRIPT_NAME' ].$_SERVER[ 'PATH_INFO' ];
   }
}

Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Apr 30, 2005 2:31 pm    Post subject: Re: PATH_INFO Reply with quote

WindEagle,

The problem comes from PHP and is documented on http://php.net. PHP breaks the CGI specification and requires that the script name to be passed in PATH_INFO.

To make it CGI compliant, you should set in php.ini the parameter cgi.fix_pathinfo to yes and change the Type of the PHP interpreter in Abyss to Standard.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
WindEagle
-


Joined: 11 Aug 2004
Posts: 3
Location: Brooklyn, NYC, USA

PostPosted: Sun May 01, 2005 1:55 am    Post subject: Reply with quote

actually this is somewhat incorrect and this will prove it:

Environents:

Standard:

ORIG_PATH_INFO=/path/info
ORIG_PATH_TRANSLATED=*\path\info
ORIG_SCRIPT_FILENAME=*\script.php
ORIG_SCRIPT_NAME=/script.php
REQUEST_URI=/script.php/path/info
SCRIPT_FILENAME=*\script.php
SCRIPT_NAME=/script.php
URL=/script.php/path/info/path/info

PHP:

ORIG_PATH_INFO=/script.php
ORIG_PATH_TRANSLATED=*\script.php
ORIG_SCRIPT_FILENAME=*\script.php
ORIG_SCRIPT_NAME=/script.php
REQUEST_URI=/script.php/path/info
SCRIPT_FILENAME=*\script.php
SCRIPT_NAME=/script.php
URL=/script.php/path/info/path/info

as u can see its not the php that adds the ORIG_ and URL is incorrect and REQUEST_URI is the only one that is reliable so i suggest you check out exactly what and how u send in the environment info

this info was gotten using Sysinternals(www.sysinternals.com) Process Explorer and a simple php script with sleep(10) as its only code

so i suggest you guys jump on this pretty quckly to patch it up
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address
WindEagle
-


Joined: 11 Aug 2004
Posts: 3
Location: Brooklyn, NYC, USA

PostPosted: Sun May 01, 2005 2:15 am    Post subject: Reply with quote

sorry guys i made a mistake, i caught those environment variables after php had a chance to change them but URL variable is still incorrect and i know this because i changed the interpreter to the GNU env.exe i did get the 500 error but thats not what i wanted all i wanted was a chance to catch the process and i did it seems that u guys did a good job so its a php problem but u stil have to check what URL is supposed to be


also the only real good way to fix this right now is by using a prepend script that has this code:

Code:

$_SERVER[ 'URL' ] = $_SERVER[ 'REQUEST_URI' ];// I'm guessing this is what is supposed to be here
if ( isset( $_SERVER[ 'ORIG_PATH_INFO' ] ) )
{
    $_SERVER[ 'PATH_INFO' ] =  $_SERVER[ 'ORIG_PATH_INFO' ];
    $_SERVER[ 'PATH_TRANSLATED' ] =  $_SERVER[ 'ORIG_PATH_TRANSLATED' ];
}

Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group