]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/templates/NoLocalSettings.php
MediaWiki 1.17.1
[autoinstallsdev/mediawiki.git] / includes / templates / NoLocalSettings.php
index 45b758a96f1584c2fe6c63bcd5f067489ce9b1bc..facb616779ad0982a41c360cb4484e4d3a845243 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 /**
+ * Template used when there is no LocalSettings.php file
+ *
  * @file
  * @ingroup Templates
  */
@@ -8,31 +10,27 @@ 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;
-               }
+$matches = array();
+$ext = 'php';
+$path = '/';
+foreach( array_filter( explode( '/', $_SERVER['PHP_SELF'] ) ) as $part ) {
+       if( !preg_match( '/\.(php5?)$/', $part, $matches ) ) {
+               $path .= "$part/";
+       } else {
+               $ext = $matches[1] == 'php5' ? 'php5' : 'php';
        }
 }
+
+# Check to see if the installer is running
+if ( !function_exists( 'session_name' ) ) {
+       $installerStarted = false;
+} else {
+       session_name( 'mw_installer_session' );
+       $oldReporting = error_reporting( E_ALL & ~E_NOTICE );
+       $success = session_start();
+       error_reporting( $oldReporting );
+       $installerStarted = ( $success && isset( $_SESSION['installData'] ) );
+}
 ?>
 <!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' lang='en'>
@@ -57,13 +55,16 @@ foreach( $topdirs as $dir ){
 
                <h1>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></h1>
                <div class='error'>
+               <p>LocalSettings.php not found.</p>
+               <p>
                <?php
-               if ( file_exists( 'config/LocalSettings.php' ) ) {
-                       echo( 'To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory.' );
+               if ( $installerStarted ) {
+                       echo( "Please <a href=\"" . htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext ) . "\"> complete the installation</a> and download LocalSettings.php." );
                } else {
-                       echo( "Please <a href=\"" . htmlspecialchars( $path ) . "config/index." . htmlspecialchars( $ext ) . "\" title='setup'> set up the wiki</a> first." );
+                       echo( "Please <a href=\"" . htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext ) . "\"> set up the wiki</a> first." );
                }
                ?>
+               </p>
 
                </div>
        </body>