summaryrefslogtreecommitdiff
path: root/includes/templates/NoLocalSettings.php
blob: 42682d605d4c014a7a17ee4f088f4a595a969302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
 * @file
 * @ingroup Templates
 */

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;
		}
	}
}
?>
<!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'>
	<head>
		<title>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></title>
		<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
		<style type='text/css' media='screen, projection'>
			html, body {
				color: #000;
				background-color: #fff;
				font-family: sans-serif;
				text-align: center;
			}

			h1 {
				font-size: 150%;
			}
		</style>
	</head>
	<body>
		<img src="<?php echo htmlspecialchars( $path ) ?>skins/common/images/mediawiki.png" alt='The MediaWiki logo' />

		<h1>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></h1>
		<div class='error'>
		<?php
		if ( file_exists( 'config/LocalSettings.php' ) ) {
			echo( 'To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory.' );
		} else {
			echo( "Please <a href=\"" . htmlspecialchars( $path ) . "config/index." . htmlspecialchars( $ext ) . "\" title='setup'> set up the wiki</a> first." );
		}
		?>

		</div>
	</body>
</html>