2006-07-14 05:35:31 +00:00
|
|
|
<?php
|
2010-08-14 17:42:40 +00:00
|
|
|
/**
|
2020-03-14 18:56:18 +00:00
|
|
|
* The set up for all MediaWiki web requests.
|
2014-08-28 22:05:14 +00:00
|
|
|
*
|
2020-03-14 18:56:18 +00:00
|
|
|
* It does:
|
|
|
|
|
* - web-related security checks,
|
|
|
|
|
* - decide how and from where to load site configuration (LocalSettings.php),
|
|
|
|
|
* - load Setup.php.
|
2013-02-15 07:31:48 +00:00
|
|
|
*
|
2011-06-28 18:21:59 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-08-14 17:42:40 +00:00
|
|
|
* @file
|
|
|
|
|
*/
|
2006-07-14 05:35:31 +00:00
|
|
|
|
2024-02-08 14:56:54 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
|
|
|
|
use MediaWiki\Settings\SettingsBuilder;
|
|
|
|
|
|
2017-02-20 22:44:19 +00:00
|
|
|
# T17461: Make IE8 turn off content sniffing. Everybody else should ignore this
|
2011-05-13 15:52:46 +00:00
|
|
|
# We're adding it here so that it's *always* set, even for alternate entry
|
|
|
|
|
# points and when $wgOut gets disabled or overridden.
|
|
|
|
|
header( 'X-Content-Type-Options: nosniff' );
|
|
|
|
|
|
2014-08-28 22:05:14 +00:00
|
|
|
# Valid web server entry point, enable includes.
|
|
|
|
|
# Please don't move this line to includes/Defines.php. This line essentially
|
|
|
|
|
# defines a valid entry point. If you put it in includes/Defines.php, then
|
|
|
|
|
# any script that includes it becomes an entry point, thereby defeating
|
|
|
|
|
# its purpose.
|
|
|
|
|
define( 'MEDIAWIKI', true );
|
|
|
|
|
|
2021-09-04 01:42:33 +00:00
|
|
|
/**
|
2022-02-20 20:25:59 +00:00
|
|
|
* @param SettingsBuilder $settings
|
2021-09-04 01:42:33 +00:00
|
|
|
* @return never
|
|
|
|
|
*/
|
2022-02-20 20:25:59 +00:00
|
|
|
function wfWebStartNoLocalSettings( SettingsBuilder $settings ) {
|
2020-04-04 13:29:06 +00:00
|
|
|
# LocalSettings.php is the per-site customization file. If it does not exist
|
|
|
|
|
# the wiki installer needs to be launched or the generated file uploaded to
|
|
|
|
|
# the root wiki directory. Give a hint, if it is not readable by the server.
|
2023-09-06 12:39:59 +00:00
|
|
|
require_once __DIR__ . '/Output/NoLocalSettings.php';
|
2020-04-04 13:29:06 +00:00
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 18:12:23 +00:00
|
|
|
require_once __DIR__ . '/BootstrapHelperFunctions.php';
|
2021-11-16 18:22:57 +00:00
|
|
|
|
2017-09-19 19:24:19 +00:00
|
|
|
// If no LocalSettings file exists, try to display an error page
|
|
|
|
|
// (use a callback because it depends on TemplateParser)
|
|
|
|
|
if ( !defined( 'MW_CONFIG_CALLBACK' ) ) {
|
2022-05-04 18:12:23 +00:00
|
|
|
wfDetectLocalSettingsFile();
|
2014-03-07 18:11:09 +00:00
|
|
|
if ( !is_readable( MW_CONFIG_FILE ) ) {
|
2017-09-19 19:24:19 +00:00
|
|
|
define( 'MW_CONFIG_CALLBACK', 'wfWebStartNoLocalSettings' );
|
2008-10-06 00:45:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-14 16:38:40 +00:00
|
|
|
|
2022-01-26 17:46:06 +00:00
|
|
|
function wfWebStartSetup( SettingsBuilder $settings ) {
|
2023-02-14 21:39:36 +00:00
|
|
|
// Initialize the default MediaWiki output buffering if no buffer is already active.
|
|
|
|
|
// This avoids clashes with existing buffers in order to avoid problems,
|
|
|
|
|
// like mixing gzip and non-gzip output.
|
2020-04-04 13:29:06 +00:00
|
|
|
if ( ob_get_level() == 0 ) {
|
2023-02-14 21:39:36 +00:00
|
|
|
// During HTTP requests, MediaWiki normally buffers the response body in a string
|
|
|
|
|
// within OutputPage and prints it when ready. PHP buffers provide protection against
|
|
|
|
|
// premature sending of HTTP headers due to output from PHP warnings and notices.
|
|
|
|
|
// They also can be used to implement gzip support in PHP without the webserver knowing
|
|
|
|
|
// which requests yield HTML and which yield large files that can be streamed.
|
2023-09-21 21:26:19 +00:00
|
|
|
ob_start( [ MediaWiki\Output\OutputHandler::class, 'handle' ] );
|
2017-09-19 19:24:19 +00:00
|
|
|
}
|
2020-04-04 13:29:06 +00:00
|
|
|
}
|
2019-05-11 01:17:43 +00:00
|
|
|
|
2020-04-04 13:29:06 +00:00
|
|
|
// Custom setup for WebStart entry point
|
|
|
|
|
if ( !defined( 'MW_SETUP_CALLBACK' ) ) {
|
2017-09-19 19:24:19 +00:00
|
|
|
define( 'MW_SETUP_CALLBACK', 'wfWebStartSetup' );
|
2007-02-19 23:03:37 +00:00
|
|
|
}
|
2007-04-15 00:20:24 +00:00
|
|
|
|
2022-05-04 18:12:23 +00:00
|
|
|
require_once __DIR__ . '/Setup.php';
|
2015-08-12 23:08:14 +00:00
|
|
|
|
|
|
|
|
# Multiple DBs or commits might be used; keep the request as transactional as possible
|
|
|
|
|
if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
|
|
|
|
|
ignore_user_abort( true );
|
2015-08-14 21:17:01 +00:00
|
|
|
}
|
2015-10-25 06:45:02 +00:00
|
|
|
|
2021-02-04 17:46:19 +00:00
|
|
|
if ( !defined( 'MW_API' ) && !defined( 'MW_REST_API' ) &&
|
2015-10-25 06:45:02 +00:00
|
|
|
RequestContext::getMain()->getRequest()->getHeader( 'Promise-Non-Write-API-Action' )
|
|
|
|
|
) {
|
|
|
|
|
header( 'Cache-Control: no-cache' );
|
|
|
|
|
header( 'Content-Type: text/html; charset=utf-8' );
|
|
|
|
|
HttpStatus::header( 400 );
|
2019-08-25 18:15:34 +00:00
|
|
|
$errorHtml = wfMessage( 'nonwrite-api-promise-error' )
|
|
|
|
|
->useDatabase( false )
|
|
|
|
|
->inContentLanguage()
|
|
|
|
|
->escaped();
|
|
|
|
|
$content = <<<HTML
|
2015-10-25 06:45:02 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
2024-06-09 11:21:45 +00:00
|
|
|
<head><meta charset="UTF-8" /><meta name="color-scheme" content="light dark" /></head>
|
2015-10-25 06:45:02 +00:00
|
|
|
<body>
|
2019-08-25 18:15:34 +00:00
|
|
|
$errorHtml
|
2015-10-25 06:45:02 +00:00
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
|
2019-08-25 18:15:34 +00:00
|
|
|
HTML;
|
2015-10-25 06:45:02 +00:00
|
|
|
header( 'Content-Length: ' . strlen( $content ) );
|
|
|
|
|
echo $content;
|
|
|
|
|
die();
|
|
|
|
|
}
|