From f660da3e80fa7eb8a8a7bf17907a5d25442d22af Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 3 Nov 2008 00:33:01 +0000 Subject: [PATCH] (bug 15544) Non-index entry points cause the "Wiki not set up" message to have corrupt URLs. Patch by Matt Johnston with tiny changes in comments. Fixed patch compared to r40719, finds the correct path if in any subdirectory (of those listed) or if in the main directory. Also validates if it has the right place. --- RELEASE-NOTES | 2 ++ includes/templates/NoLocalSettings.php | 29 +++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 92cb7e9833..6ff481b9be 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -311,6 +311,8 @@ The following extensions are migrated into MediaWiki 1.14: a warning * (bug 16143) Fix redirect loop on special pages starting with lower case letters * (bug 15737) Fix notices while expanding using PPCustomFrame +* (bug 15544) Non-index entry points cause the "Wiki not set up" message to + have corrupt URLs === API changes in 1.14 === diff --git a/includes/templates/NoLocalSettings.php b/includes/templates/NoLocalSettings.php index 75a7e95a93..107f792ffd 100644 --- a/includes/templates/NoLocalSettings.php +++ b/includes/templates/NoLocalSettings.php @@ -10,12 +10,31 @@ if ( isset( $wgVersion ) ) { } else { $wgVersion = 'VERSION'; } -# Set the path in case we hit a page such as /index.php/Main_Page -# Could use but then we have to worry about http[s]/port #/etc. -$ext = strpos( $_SERVER['SCRIPT_NAME'], 'index.php5' ) === false ? 'php' : 'php5'; + +$scriptName = $_SERVER['SCRIPT_NAME']; +$ext = substr( $scriptName, strpos( $scriptName, "." ) + 1 ); $path = ''; -if( isset( $_SERVER['SCRIPT_NAME'] )) { - $path = htmlspecialchars( preg_replace('/index.php5?/', '', $_SERVER['SCRIPT_NAME']) ); +# 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; + } + } } ?> -- 2.20.1