Very early on I mentioned that SCRIPT_NAME is a more reliable option .. and it is .. it is not truly transportable though as SCRIPT_NAME can sometimes return the phpcgi.
The following is code based on that used in ..
Ultimate Seo Urls 5
Ultimate Seo Urls 5 PRO
and ..
KiSSMT Dynamic SEO Meta Tags
All of these have undergone extensive testing on both WinDoze and *nix servers. I have backwards developed the code to be php4 compatible.
In application_top.php where PHP self is set ..
// set php_self in the local scope if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
Change to ..
/**
* Reliably set PHP_SELF as a filename .. platform safe
*/
function setPhpSelf() {
$base = ( array( 'SCRIPT_NAME', 'PHP_SELF' ) );
foreach ( $base as $index => $key ) {
if ( array_key_exists( $key, $_SERVER ) && !empty( $_SERVER[$key] ) ) {
if ( false !== strpos( $_SERVER[$key], '.php' ) ) {
preg_match( '@[a-z0-9_]+\.php@i', $_SERVER[$key], $matches );
if ( is_array( $matches ) && ( array_key_exists( 0, $matches ) )
&& ( substr( $matches[0], -4, 4 ) == '.php' )
&& ( is_readable( $matches[0] ) ) ) {
return $matches[0];
}
}
}
}
return 'index.php';
} // end method
$PHP_SELF = setPhpSelf();
Edited by FWR Media, 16 December 2009, 21:18.















