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
|
|
|
|
2020-02-04 21:44:38 +00:00
|
|
|
/**
|
|
|
|
|
* @defgroup entrypoint Entry points
|
|
|
|
|
*
|
|
|
|
|
* These primary scripts live in the root directory. They are the ones used by
|
|
|
|
|
* web requests to interact with the wiki. Other PHP files in the repository
|
|
|
|
|
* do not need to be accessed directly by the web.
|
|
|
|
|
*/
|
|
|
|
|
|
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 );
|
|
|
|
|
|
2017-11-28 04:46:38 +00:00
|
|
|
# Full path to the installation directory.
|
2008-06-16 20:21:26 +00:00
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
|
if ( $IP === false ) {
|
2017-11-28 04:46:38 +00:00
|
|
|
$IP = dirname( __DIR__ );
|
2008-06-16 20:21:26 +00:00
|
|
|
}
|
2008-05-16 17:53:29 +00:00
|
|
|
|
2021-09-04 01:42:33 +00:00
|
|
|
/**
|
|
|
|
|
* @return never
|
|
|
|
|
*/
|
2020-04-04 13:29:06 +00:00
|
|
|
function wfWebStartNoLocalSettings() {
|
|
|
|
|
# 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.
|
|
|
|
|
global $IP;
|
|
|
|
|
require_once "$IP/includes/NoLocalSettings.php";
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
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' ) ) {
|
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
|
|
|
if ( !defined( 'MW_CONFIG_FILE' ) ) {
|
2013-05-08 06:48:56 +00:00
|
|
|
define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
|
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
|
|
|
}
|
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
|
|
|
|
2020-04-04 13:29:06 +00:00
|
|
|
function wfWebStartSetup() {
|
|
|
|
|
// Initialise output buffering
|
|
|
|
|
// Check for previously set up buffers, to avoid a mix of gzip and non-gzip output.
|
|
|
|
|
if ( ob_get_level() == 0 ) {
|
|
|
|
|
ob_start( 'MediaWiki\\OutputHandler::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
|
|
|
|
2017-01-13 01:01:14 +00:00
|
|
|
require_once "$IP/includes/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>
|
|
|
|
|
<head><meta charset="UTF-8" /></head>
|
|
|
|
|
<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();
|
|
|
|
|
}
|