Recent Topics

1 Aug 18, 2006 22:59    

My server is using IIS, with PHP called via fastCGI. It appears that this may cause problems using the extra-path info because of the way that PHP registers the PATH_INFO server variable under CGI (see [url=http://www.php.net/manual/ini.sect.path-directory.php#ini.cgi.fix_pathinfo]PHP Manual[/url]). Here's what phpinfo() shows when using extra-path info with the URL http://mysite.com/blogs/index.php/someblog/

_SERVER["PATH_INFO"]        /someblog/
_SERVER["PATH_TRANSLATED"]  C:/Inetpub/wwwroot/someblog/
_SERVER["SCRIPT_NAME"]      /blogs/index.php
_SERVER["URL"]              /blogs/index.php
_SERVER["ORIG_PATH_INFO"]   /blogs/index.php/someblog/
_SERVER["ORIG_SCRIPT_NAME"] /blogs/index.php
_SERVER["SCRIPT_FILENAME"]  C:\Inetpub\wwwroot\blogs\index.php
_SERVER["PHP_SELF"]         /blogs/index.php

This translation causes the $ReqPath variable in b2evo to be valued as '/blogs/index.php', which then leads to the auto-detect portion of index.php (line 32) to not run since the extra-path info doesn't exist.

I can't change the value of cgi.fix_pathinfo in the PHP ini settings because it's a shared server and I don't know if any existing apps reply on it working this way. However, I don't mind hacking index.php to correct the problem at run time. My problem is that I don't know what the extra-path info should look like normally.

Can someone who is using extra-path info on an Apache server post the values of the server variables above using phpinfo on your index.php page? (Just be sure to remove any private path data)

Thanks!

2 Aug 18, 2006 23:11

Well, the fix appears to be relatively easy. In index.php change

if( empty($blog) )
{ // No blog requested by URL param, let's try to match something in the URL
	$Debuglog->add( 'No blog param received, checking extra path...', 'detectblog' );

	if( preg_match( '#^(.+?)index.php/([^/]+)#', $ReqHost.$ReqPath, $matches ) )
	{ // We have an URL blog name:
		$Debuglog->add( 'Found a potential URL blog name: '.$matches[2], 'detectblog' );
		if( (($Blog = & $BlogCache->get_by_urlname( $matches[2], false )) !== false) )
		{ // We found a matching blog:
			$blog = $Blog->ID;
		}
	}

to

if( empty($blog) )
{ // No blog requested by URL param, let's try to match something in the URL
	$Debuglog->add( 'No blog param received, checking extra path...', 'detectblog' );

	//When running PHP as a CGI module under IIS, extra-path info can go missing.
	//this is an attempt to fix that.
	if( isset( $_SERVER["ORIG_PATH_INFO"] ) )
	{
		$ReqPath = $_SERVER["ORIG_PATH_INFO"];
	}

	if( preg_match( '#^(.+?)index.php/([^/]+)#', $ReqHost.$ReqPath, $matches ) )
	{ // We have an URL blog name:
		$Debuglog->add( 'Found a potential URL blog name: '.$matches[2], 'detectblog' );
		if( (($Blog = & $BlogCache->get_by_urlname( $matches[2], false )) !== false) )
		{ // We found a matching blog:
			$blog = $Blog->ID;
		}
	}

It would be great if you could account for this in the core files. It seems safe to assume that if the ORIG_PATH_INFO server variable exists then the ReqPath needs to be adjusted.


Form is loading...