3 * This does the initial setup for a web request.
4 * It does some security checks, starts the profiler and loads the
5 * configuration, and optionally loads Setup.php depending on whether
6 * MW_NO_SETUP is defined.
11 # Protect against register_globals
12 # This must be done before any globals are set by the code
13 if ( ini_get( 'register_globals' ) ) {
14 if ( isset( $_REQUEST['GLOBALS'] ) ) {
15 die( '<a href="http://www.hardened-php.net/globals-problem">$GLOBALS overwrite vulnerability</a>');
35 foreach ( $_REQUEST as $name => $value ) {
36 if( in_array( $name, $verboten ) ) {
37 header( "HTTP/1.1 500 Internal Server Error" );
38 echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
41 unset( $GLOBALS[$name] );
45 $wgRequestTime = microtime(true);
46 # getrusage() does not exist on the Microsoft Windows platforms, catching this
47 if ( function_exists ( 'getrusage' ) ) {
48 $wgRUstart = getrusage();
54 # Valid web server entry point, enable includes.
55 # Please don't move this line to includes/Defines.php. This line essentially
56 # defines a valid entry point. If you put it in includes/Defines.php, then
57 # any script that includes it becomes an entry point, thereby defeating
59 define( 'MEDIAWIKI', true );
61 # Full path to working directory.
62 # Makes it possible to for example to have effective exclude path in apc.
63 # Also doesn't break installations using symlinked includes, like
64 # dirname( __FILE__ ) would do.
65 $IP = getenv( 'MW_INSTALL_PATH' );
66 if ( $IP === false ) {
67 $IP = realpath( '.' );
72 if( file_exists("$IP/StartProfiler.php") ) {
73 require_once( "$IP/StartProfiler.php" );
75 require_once( "$IP/includes/ProfilerStub.php" );
77 wfProfileIn( 'WebStart.php-conf' );
79 # Load up some global defines.
80 require_once( "$IP/includes/Defines.php" );
83 if ( !function_exists( 'version_compare' )
84 ||
version_compare( phpversion(), '5.0.0' ) < 0
86 define( 'MW_PHP4', '1' );
87 require( "$IP/includes/DefaultSettings.php" );
88 require( "$IP/includes/templates/PHP4.php" );
92 # Start the autoloader, so that extensions can derive classes from core files
93 require_once( "$IP/includes/AutoLoader.php" );
94 # Load default settings
95 require_once( "$IP/includes/DefaultSettings.php" );
97 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
98 # Use a callback function to configure MediaWiki
99 MWFunction
::call( MW_CONFIG_CALLBACK
);
102 if ( !defined('MW_CONFIG_FILE') )
103 define('MW_CONFIG_FILE', "$IP/LocalSettings.php");
105 # LocalSettings.php is the per site customization file. If it does not exist
106 # the wiki installer needs to be launched or the generated file uploaded to
107 # the root wiki directory
108 if( !file_exists( MW_CONFIG_FILE
) ) {
109 require_once( "$IP/includes/templates/NoLocalSettings.php" );
113 # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
114 require_once( MW_CONFIG_FILE
);
117 if ( $wgEnableSelenium ) {
118 require_once( "$IP/includes/SeleniumWebSettings.php" );
121 wfProfileOut( 'WebStart.php-conf' );
123 wfProfileIn( 'WebStart.php-ob_start' );
124 # Initialise output buffering
125 # Check that there is no previous output or previously set up buffers, because
126 # that would cause us to potentially mix gzip and non-gzip output, creating a
128 if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ob_get_level() == 0 ) {
129 require_once( "$IP/includes/OutputHandler.php" );
130 ob_start( 'wfOutputHandler' );
132 wfProfileOut( 'WebStart.php-ob_start' );
134 if ( !defined( 'MW_NO_SETUP' ) ) {
135 require_once( "$IP/includes/Setup.php" );