Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5038
nolocalsettingspathrewrite.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 10:17 PM
2014-11-21 22:17:21 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
nolocalsettingspathrewrite.patch
View Options
Index: includes/templates/NoLocalSettings.php
===================================================================
--- includes/templates/NoLocalSettings.php (revision 40940)
+++ includes/templates/NoLocalSettings.php (working copy)
@@ -10,17 +10,32 @@
} else {
$wgVersion = 'VERSION';
}
-# Set the path in case we hit a page such as /index.php/Main_Page
-# Could use <base href> 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 can't just do a dir listing here, as we don't 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's 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;
+ }
+ }
}
-#Remove filename in path, prevents going to corrupt URLs (e.g. http://server/path/api.phpconfig/index.php)
-if(substr($path, strlen($path)-1) != "/"){
- $path = substr($path, 0, strrpos($path, "/")+1);
-}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4601
Default Alt Text
nolocalsettingspathrewrite.patch (2 KB)
Attached To
Mode
T17544: Non-index entry points cause the "Wiki not set up" message to have corrupt URLs
Attached
Detach File
Event Timeline
Log In to Comment