3 # This does the initial setup for a web request. It does some security checks,
4 # starts the profiler and loads the configuration, and optionally loads
5 # Setup.php depending on whether MW_NO_SETUP is defined.
7 # Protect against register_globals
8 # This must be done before any globals are set by the code
9 if ( ini_get( 'register_globals' ) ) {
10 if ( isset( $_REQUEST['GLOBALS'] ) ) {
11 die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
31 foreach ( $_REQUEST as $name => $value ) {
32 if( in_array( $name, $verboten ) ) {
33 header( "HTTP/1.x 500 Internal Server Error" );
34 echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
37 unset( $GLOBALS[$name] );
41 $wgRequestTime = microtime(true);
42 # getrusage() does not exist on the Microsoft Windows platforms, catching this
43 if ( function_exists ( 'getrusage' ) ) {
44 $wgRUstart = getrusage();
50 # Valid web server entry point, enable includes.
51 # Please don't move this line to includes/Defines.php. This line essentially
52 # defines a valid entry point. If you put it in includes/Defines.php, then
53 # any script that includes it becomes an entry point, thereby defeating
55 define( 'MEDIAWIKI', true );
57 # Full path to working directory.
58 # Makes it possible to for example to have effective exclude path in apc.
59 # Also doesn't break installations using symlinked includes, like
60 # dirname( __FILE__ ) would do.
61 $IP = getenv( 'MW_INSTALL_PATH' );
62 if ( $IP === false ) {
63 $IP = realpath( '.' );
68 if( file_exists("$IP/StartProfiler.php") ) {
69 require_once( "$IP/StartProfiler.php" );
71 require_once( "$IP/includes/ProfilerStub.php" );
73 wfProfileIn( 'WebStart.php-conf' );
75 # Load up some global defines.
76 require_once( "$IP/includes/Defines.php" );
79 if ( !function_exists( 'version_compare' )
80 ||
version_compare( phpversion(), '5.0.0' ) < 0
82 define( 'MW_PHP4', '1' );
83 require( "$IP/includes/DefaultSettings.php" );
84 require( "$IP/includes/templates/PHP4.php" );
88 # Test for PHP bug which breaks PHP 5.0.x on 64-bit...
89 # As of 1.8 this breaks lots of common operations instead
90 # of just some rare ones like export.
91 $borked = str_replace( 'a', 'b', array( -1 => -1 ) );
92 if( !isset( $borked[-1] ) ) {
93 echo "PHP 5.0.x is buggy on your 64-bit system; you must upgrade to PHP 5.1.x\n" .
94 "or higher. ABORTING. (http://bugs.php.net/bug.php?id=34879 for details)\n";
98 # Start the autoloader, so that extensions can derive classes from core files
99 require_once( "$IP/includes/AutoLoader.php" );
101 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
102 # Use a callback function to configure MediaWiki
103 require_once( "$IP/includes/DefaultSettings.php" );
104 call_user_func( MW_CONFIG_CALLBACK
);
106 # LocalSettings.php is the per site customization file. If it does not exit
107 # the wiki installer need to be launched or the generated file moved from
109 if( !file_exists( "$IP/LocalSettings.php" ) ) {
110 require_once( "$IP/includes/DefaultSettings.php" ); # used for printing the version
111 require_once( "$IP/includes/templates/NoLocalSettings.php" );
115 # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
116 require_once( "$IP/LocalSettings.php" );
118 wfProfileOut( 'WebStart.php-conf' );
120 wfProfileIn( 'WebStart.php-ob_start' );
121 # Initialise output buffering
122 if ( ob_get_level() ) {
123 # Someone's been mixing configuration data with code!
125 } elseif ( !defined( 'MW_NO_OUTPUT_BUFFER' ) ) {
126 require_once( "$IP/includes/OutputHandler.php" );
127 ob_start( 'wfOutputHandler' );
129 wfProfileOut( 'WebStart.php-ob_start' );
131 if ( !defined( 'MW_NO_SETUP' ) ) {
132 require_once( "$IP/includes/Setup.php" );