From 2f4ea43863f7a5dd6d489a57b2940c003c57ee6d Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 8 Aug 2010 16:06:21 +0000 Subject: [PATCH] Greatly simplify path and extension detection for NoLocalSettings.php. Fixes bug 21215. --- includes/templates/NoLocalSettings.php | 29 +++----------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/includes/templates/NoLocalSettings.php b/includes/templates/NoLocalSettings.php index 45b758a96f..a9ec78a008 100644 --- a/includes/templates/NoLocalSettings.php +++ b/includes/templates/NoLocalSettings.php @@ -7,32 +7,9 @@ if ( !isset( $wgVersion ) ) { $wgVersion = 'VERSION'; } - -$scriptName = $_SERVER['SCRIPT_NAME']; -$ext = substr( $scriptName, strrpos( $scriptName, "." ) + 1 ); -$path = ''; -# Add any directories in the main folder that could contain an entrypoint (even possibly). -# We cannot just do a dir listing here, as we do not know where it is yet -# These must not also be the names of subfolders that may contain an entrypoint -$topdirs = array( 'extensions', 'includes' ); -foreach( $topdirs as $dir ){ - # Check whether a directory by this name is in the path - if( strrpos( $scriptName, "/" . $dir . "/" ) ){ - # If so, check whether it is the right folder - # First, get the number of directories up it is (to generate path) - $numToGoUp = substr_count( substr( $scriptName, strrpos( $scriptName, "/" . $dir . "/" ) + 1 ), "/" ); - # And generate the path using ..'s - for( $i = 0; $i < $numToGoUp; $i++ ){ - $realPath = "../" . $realPath; - } - # Checking existance (using the image here as it is something not likely to change, and to always be here) - if( file_exists( $realPath . "skins/common/images/mediawiki.png" ) ) { - # If so, get the path that we can use in this file, and stop looking - $path = substr( $scriptName, 0, strrpos( $scriptName, "/" . $dir . "/" ) + 1 ); - break; - } - } -} +$script = $_SERVER['SCRIPT_NAME']; +$path = pathinfo( $script, PATHINFO_DIRNAME ) . '/'; +$ext = pathinfo( $script, PATHINFO_EXTENSION ); ?> -- 2.20.1