2006-07-14 05:35:31 +00:00
|
|
|
<?php
|
2010-08-14 17:42:40 +00:00
|
|
|
/**
|
|
|
|
|
* This does the initial setup for a web request.
|
|
|
|
|
* It does some security checks, starts the profiler and loads the
|
|
|
|
|
* configuration, and optionally loads Setup.php depending on whether
|
|
|
|
|
* MW_NO_SETUP is defined.
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2006-07-14 05:35:31 +00:00
|
|
|
|
2006-10-11 03:44:49 +00:00
|
|
|
# Protect against register_globals
|
|
|
|
|
# This must be done before any globals are set by the code
|
|
|
|
|
if ( ini_get( 'register_globals' ) ) {
|
|
|
|
|
if ( isset( $_REQUEST['GLOBALS'] ) ) {
|
2010-07-20 02:17:18 +00:00
|
|
|
die( '<a href="http://www.hardened-php.net/globals-problem">$GLOBALS overwrite vulnerability</a>');
|
2006-10-11 03:44:49 +00:00
|
|
|
}
|
2006-10-11 18:14:27 +00:00
|
|
|
$verboten = array(
|
|
|
|
|
'GLOBALS',
|
|
|
|
|
'_SERVER',
|
|
|
|
|
'HTTP_SERVER_VARS',
|
|
|
|
|
'_GET',
|
|
|
|
|
'HTTP_GET_VARS',
|
|
|
|
|
'_POST',
|
|
|
|
|
'HTTP_POST_VARS',
|
|
|
|
|
'_COOKIE',
|
|
|
|
|
'HTTP_COOKIE_VARS',
|
|
|
|
|
'_FILES',
|
|
|
|
|
'HTTP_POST_FILES',
|
|
|
|
|
'_ENV',
|
|
|
|
|
'HTTP_ENV_VARS',
|
|
|
|
|
'_REQUEST',
|
|
|
|
|
'_SESSION',
|
|
|
|
|
'HTTP_SESSION_VARS'
|
|
|
|
|
);
|
2006-10-11 03:44:49 +00:00
|
|
|
foreach ( $_REQUEST as $name => $value ) {
|
2006-10-11 18:14:27 +00:00
|
|
|
if( in_array( $name, $verboten ) ) {
|
2011-03-25 03:36:18 +00:00
|
|
|
header( "HTTP/1.1 500 Internal Server Error" );
|
2006-10-11 18:14:27 +00:00
|
|
|
echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
|
|
|
|
|
die( -1 );
|
|
|
|
|
}
|
2006-10-11 03:44:49 +00:00
|
|
|
unset( $GLOBALS[$name] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 05:35:31 +00:00
|
|
|
$wgRequestTime = microtime(true);
|
|
|
|
|
# getrusage() does not exist on the Microsoft Windows platforms, catching this
|
|
|
|
|
if ( function_exists ( 'getrusage' ) ) {
|
|
|
|
|
$wgRUstart = getrusage();
|
|
|
|
|
} else {
|
|
|
|
|
$wgRUstart = array();
|
|
|
|
|
}
|
|
|
|
|
unset( $IP );
|
|
|
|
|
|
|
|
|
|
# Valid web server entry point, enable includes.
|
|
|
|
|
# Please don't move this line to includes/Defines.php. This line essentially
|
|
|
|
|
# defines a valid entry point. If you put it in includes/Defines.php, then
|
|
|
|
|
# any script that includes it becomes an entry point, thereby defeating
|
|
|
|
|
# its purpose.
|
|
|
|
|
define( 'MEDIAWIKI', true );
|
|
|
|
|
|
2008-05-16 17:53:29 +00:00
|
|
|
# Full path to working directory.
|
|
|
|
|
# Makes it possible to for example to have effective exclude path in apc.
|
|
|
|
|
# Also doesn't break installations using symlinked includes, like
|
|
|
|
|
# dirname( __FILE__ ) would do.
|
2008-06-16 20:21:26 +00:00
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
|
if ( $IP === false ) {
|
|
|
|
|
$IP = realpath( '.' );
|
|
|
|
|
}
|
2008-05-16 17:53:29 +00:00
|
|
|
|
2008-10-06 00:45:18 +00:00
|
|
|
|
2006-07-14 05:35:31 +00:00
|
|
|
# Start profiler
|
2009-05-07 18:30:26 +00:00
|
|
|
if( file_exists("$IP/StartProfiler.php") ) {
|
|
|
|
|
require_once( "$IP/StartProfiler.php" );
|
|
|
|
|
} else {
|
|
|
|
|
require_once( "$IP/includes/ProfilerStub.php" );
|
|
|
|
|
}
|
2006-07-14 05:35:31 +00:00
|
|
|
wfProfileIn( 'WebStart.php-conf' );
|
|
|
|
|
|
|
|
|
|
# Load up some global defines.
|
2008-06-16 20:21:26 +00:00
|
|
|
require_once( "$IP/includes/Defines.php" );
|
2006-07-14 05:35:31 +00:00
|
|
|
|
2008-10-06 00:45:18 +00:00
|
|
|
# Check for PHP 5
|
|
|
|
|
if ( !function_exists( 'version_compare' )
|
|
|
|
|
|| version_compare( phpversion(), '5.0.0' ) < 0
|
|
|
|
|
) {
|
|
|
|
|
define( 'MW_PHP4', '1' );
|
|
|
|
|
require( "$IP/includes/DefaultSettings.php" );
|
|
|
|
|
require( "$IP/includes/templates/PHP4.php" );
|
|
|
|
|
exit;
|
2006-07-14 05:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-16 20:21:26 +00:00
|
|
|
# Start the autoloader, so that extensions can derive classes from core files
|
|
|
|
|
require_once( "$IP/includes/AutoLoader.php" );
|
2010-12-06 15:00:56 +00:00
|
|
|
# Load default settings
|
|
|
|
|
require_once( "$IP/includes/DefaultSettings.php" );
|
2008-06-16 20:21:26 +00:00
|
|
|
|
2008-10-06 00:45:18 +00:00
|
|
|
if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
|
|
|
|
|
# Use a callback function to configure MediaWiki
|
2011-01-02 06:48:07 +00:00
|
|
|
MWFunction::call( MW_CONFIG_CALLBACK );
|
|
|
|
|
|
2008-10-06 00:45:18 +00:00
|
|
|
} else {
|
2010-12-05 06:43:15 +00:00
|
|
|
if ( !defined('MW_CONFIG_FILE') )
|
|
|
|
|
define('MW_CONFIG_FILE', "$IP/LocalSettings.php");
|
|
|
|
|
|
|
|
|
|
# LocalSettings.php is the per site customization file. If it does not exist
|
2011-02-26 12:56:32 +00:00
|
|
|
# the wiki installer needs to be launched or the generated file uploaded to
|
|
|
|
|
# the root wiki directory
|
2010-12-05 06:43:15 +00:00
|
|
|
if( !file_exists( MW_CONFIG_FILE ) ) {
|
2008-10-06 00:45:18 +00:00
|
|
|
require_once( "$IP/includes/templates/NoLocalSettings.php" );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
|
2010-12-05 06:43:15 +00:00
|
|
|
require_once( MW_CONFIG_FILE );
|
2008-10-06 00:45:18 +00:00
|
|
|
}
|
2010-10-14 16:38:40 +00:00
|
|
|
|
|
|
|
|
if ( $wgEnableSelenium ) {
|
|
|
|
|
require_once( "$IP/includes/SeleniumWebSettings.php" );
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 05:35:31 +00:00
|
|
|
wfProfileOut( 'WebStart.php-conf' );
|
2007-02-19 23:03:37 +00:00
|
|
|
|
2008-05-16 17:53:29 +00:00
|
|
|
wfProfileIn( 'WebStart.php-ob_start' );
|
2007-02-19 23:03:37 +00:00
|
|
|
# Initialise output buffering
|
2010-09-04 04:00:09 +00:00
|
|
|
# Check that there is no previous output or previously set up buffers, because
|
|
|
|
|
# that would cause us to potentially mix gzip and non-gzip output, creating a
|
|
|
|
|
# big mess.
|
2010-12-06 20:57:42 +00:00
|
|
|
if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ob_get_level() == 0 ) {
|
2008-05-16 17:53:29 +00:00
|
|
|
require_once( "$IP/includes/OutputHandler.php" );
|
2007-02-19 23:03:37 +00:00
|
|
|
ob_start( 'wfOutputHandler' );
|
|
|
|
|
}
|
2007-04-15 00:20:24 +00:00
|
|
|
wfProfileOut( 'WebStart.php-ob_start' );
|
|
|
|
|
|
2006-07-14 05:35:31 +00:00
|
|
|
if ( !defined( 'MW_NO_SETUP' ) ) {
|
2008-05-16 17:53:29 +00:00
|
|
|
require_once( "$IP/includes/Setup.php" );
|
2006-07-14 05:35:31 +00:00
|
|
|
}
|
2010-10-14 16:38:40 +00:00
|
|
|
|