Merge "Fix font of mw-ui-button"
[lhc/web/wiklou.git] / includes / WebStart.php
1 <?php
2 /**
3 * This does the initial set up for a web request, including a few
4 * security checks and loading the initializer.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 */
23
24 # Die if register_globals is enabled (PHP <=5.3)
25 # This must be done before any globals are set by the code
26 if ( ini_get( 'register_globals' ) ) {
27 die( 'MediaWiki does not support installations where register_globals is enabled. '
28 . 'Please see <a href="https://www.mediawiki.org/wiki/register_globals">mediawiki.org</a> '
29 . 'for help on how to disable it.' );
30 }
31
32 # bug 15461: Make IE8 turn off content sniffing. Everybody else should ignore this
33 # We're adding it here so that it's *always* set, even for alternate entry
34 # points and when $wgOut gets disabled or overridden.
35 header( 'X-Content-Type-Options: nosniff' );
36
37 # getrusage() does not exist on the Microsoft Windows platforms, catching this
38 $wgRUstart = function_exists( 'getrusage' ) ? getrusage() : array();
39 unset( $IP );
40
41 # Full path to working directory.
42 # Makes it possible to for example to have effective exclude path in apc.
43 # __DIR__ breaks symlinked includes, but realpath() returns false
44 # if we don't have permissions on parent directories.
45 $IP = getenv( 'MW_INSTALL_PATH' );
46 if ( $IP === false ) {
47 $IP = realpath( '.' ) ?: dirname( __DIR__ );
48 }
49
50 require_once "$IP/includes/Initialize.php";
51
52 wfProfileIn( 'WebStart.php-conf' );
53
54 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
55 # Use a callback function to configure MediaWiki
56 call_user_func( MW_CONFIG_CALLBACK );
57 } else {
58 if ( !defined( 'MW_CONFIG_FILE' ) ) {
59 define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
60 }
61
62 # LocalSettings.php is the per site customization file. If it does not exist
63 # the wiki installer needs to be launched or the generated file uploaded to
64 # the root wiki directory. Give a hint, if it is not readable by the server.
65 if ( !is_readable( MW_CONFIG_FILE ) ) {
66 require_once "$IP/includes/templates/NoLocalSettings.php";
67 die();
68 }
69
70 # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
71 require_once MW_CONFIG_FILE;
72 }
73
74 wfProfileOut( 'WebStart.php-conf' );
75
76 wfProfileIn( 'WebStart.php-ob_start' );
77 # Initialise output buffering
78 # Check that there is no previous output or previously set up buffers, because
79 # that would cause us to potentially mix gzip and non-gzip output, creating a
80 # big mess.
81 if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ob_get_level() == 0 ) {
82 require_once "$IP/includes/OutputHandler.php";
83 ob_start( 'wfOutputHandler' );
84 }
85 wfProfileOut( 'WebStart.php-ob_start' );
86
87 if ( !defined( 'MW_NO_SETUP' ) ) {
88 require_once "$IP/includes/Setup.php";
89 }