Active protection against register_globals vulnerabilities. Unset all globals which...
[lhc/web/wiklou.git] / includes / WebStart.php
1 <?php
2
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.
6
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>');
12 }
13 foreach ( $_REQUEST as $name => $value ) {
14 unset( $GLOBALS[$name] );
15 }
16 }
17
18 $wgRequestTime = microtime(true);
19 # getrusage() does not exist on the Microsoft Windows platforms, catching this
20 if ( function_exists ( 'getrusage' ) ) {
21 $wgRUstart = getrusage();
22 } else {
23 $wgRUstart = array();
24 }
25 unset( $IP );
26 @ini_set( 'allow_url_fopen', 0 ); # For security
27
28 # Valid web server entry point, enable includes.
29 # Please don't move this line to includes/Defines.php. This line essentially
30 # defines a valid entry point. If you put it in includes/Defines.php, then
31 # any script that includes it becomes an entry point, thereby defeating
32 # its purpose.
33 define( 'MEDIAWIKI', true );
34
35 # Start profiler
36 require_once( './StartProfiler.php' );
37 wfProfileIn( 'WebStart.php-conf' );
38
39 # Load up some global defines.
40 require_once( './includes/Defines.php' );
41
42 # LocalSettings.php is the per site customization file. If it does not exit
43 # the wiki installer need to be launched or the generated file moved from
44 # ./config/ to ./
45 if( !file_exists( './LocalSettings.php' ) ) {
46 $IP = '.';
47 require_once( './includes/DefaultSettings.php' ); # used for printing the version
48 require_once( './includes/templates/NoLocalSettings.php' );
49 die();
50 }
51
52 # Include this site setttings
53 require_once( './LocalSettings.php' );
54 wfProfileOut( 'WebStart.php-conf' );
55
56 if ( !defined( 'MW_NO_SETUP' ) ) {
57 require_once( './includes/Setup.php' );
58 }
59 ?>