MediaWiki REL1_38
WebStart.php
Go to the documentation of this file.
1<?php
36# T17461: Make IE8 turn off content sniffing. Everybody else should ignore this
37# We're adding it here so that it's *always* set, even for alternate entry
38# points and when $wgOut gets disabled or overridden.
40
41header( 'X-Content-Type-Options: nosniff' );
42
43# Valid web server entry point, enable includes.
44# Please don't move this line to includes/Defines.php. This line essentially
45# defines a valid entry point. If you put it in includes/Defines.php, then
46# any script that includes it becomes an entry point, thereby defeating
47# its purpose.
48define( 'MEDIAWIKI', true );
49
50# Full path to the installation directory.
51$IP = getenv( 'MW_INSTALL_PATH' );
52if ( $IP === false ) {
53 $IP = dirname( __DIR__ );
54}
55
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 require_once MW_INSTALL_PATH . '/includes/NoLocalSettings.php';
66 die();
67}
68
69require_once "$IP/includes/BootstrapHelperFunctions.php";
70
71// If no LocalSettings file exists, try to display an error page
72// (use a callback because it depends on TemplateParser)
73if ( !defined( 'MW_CONFIG_CALLBACK' ) ) {
75 if ( !is_readable( MW_CONFIG_FILE ) ) {
76 define( 'MW_CONFIG_CALLBACK', 'wfWebStartNoLocalSettings' );
77 }
78}
79
80function wfWebStartSetup( SettingsBuilder $settings ) {
81 // Initialise output buffering
82 // Check for previously set up buffers, to avoid a mix of gzip and non-gzip output.
83 if ( ob_get_level() == 0 ) {
84 ob_start( 'MediaWiki\\OutputHandler::handle' );
85 }
86}
87
88// Custom setup for WebStart entry point
89if ( !defined( 'MW_SETUP_CALLBACK' ) ) {
90 define( 'MW_SETUP_CALLBACK', 'wfWebStartSetup' );
91}
92
93require_once "$IP/includes/Setup.php";
94
95# Multiple DBs or commits might be used; keep the request as transactional as possible
96if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
97 ignore_user_abort( true );
98}
99
100if ( !defined( 'MW_API' ) && !defined( 'MW_REST_API' ) &&
101 RequestContext::getMain()->getRequest()->getHeader( 'Promise-Non-Write-API-Action' )
102) {
103 header( 'Cache-Control: no-cache' );
104 header( 'Content-Type: text/html; charset=utf-8' );
105 HttpStatus::header( 400 );
106 $errorHtml = wfMessage( 'nonwrite-api-promise-error' )
107 ->useDatabase( false )
108 ->inContentLanguage()
109 ->escaped();
110 $content = <<<HTML
111<!DOCTYPE html>
112<html>
113<head><meta charset="UTF-8" /></head>
114<body>
115$errorHtml
116</body>
117</html>
118
119HTML;
120 header( 'Content-Length: ' . strlen( $content ) );
121 echo $content;
122 die();
123}
wfDetectLocalSettingsFile(string $installationPath)
Decide and remember where to load LocalSettings from.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
$IP
Definition WebStart.php:51
if($IP===false) wfWebStartNoLocalSettings(SettingsBuilder $settings)
Definition WebStart.php:61
if(!defined('MW_CONFIG_CALLBACK')) wfWebStartSetup(SettingsBuilder $settings)
Definition WebStart.php:80
static header( $code)
Output an HTTP status code header.
Utility for loading settings files.
$content
Definition router.php:76