Localisation updates from http://translatewiki.net.
[mediawiki.git] / includes / PHPVersionError.php
blobe8ecf6dbf43e6ae03d820687d3110757dd8d357f
1 <?php
2 /**
3 * Display something vaguely comprehensible in the event of a totally unrecoverable error.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
23 /**
24 * Display something vaguely comprehensible in the event of a totally unrecoverable error.
25 * Does not assume access to *anything*; no globals, no autoloader, no database, no localisation.
26 * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php
27 * no longer need to be).
29 * Calling this function kills execution immediately.
31 * @param string $type Which entry point we are protecting. One of:
32 * - index.php
33 * - load.php
34 * - api.php
35 * - cli
37 * @note Since we can't rely on anything, the minimum PHP versions and MW current
38 * version are hardcoded here
40 function wfPHPVersionError( $type ) {
41 $mwVersion = '1.22';
42 $minimumVersionPHP = '5.3.2';
44 $phpVersion = phpversion();
45 $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
46 $message = "MediaWiki $mwVersion requires at least PHP version $minimumVersionPHP, you are using PHP $phpVersion.";
47 if ( $type == 'cli' ) {
48 $finalOutput = "You are using PHP version $phpVersion but MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher. ABORTING.\n" .
49 "Check if you have a newer php executable with a different name, such as php5.\n";
50 } elseif ( $type == 'index.php' ) {
51 $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
52 $encLogo = htmlspecialchars(
53 str_replace( '//', '/', $pathinfo['dirname'] . '/' ) .
54 'skins/common/images/mediawiki.png'
57 header( "$protocol 500 MediaWiki configuration Error" );
58 header( 'Content-type: text/html; charset=UTF-8' );
59 // Don't cache error pages! They cause no end of trouble...
60 header( 'Cache-control: none' );
61 header( 'Pragma: no-cache' );
63 $finalOutput = <<<HTML
64 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
65 <html xmlns='http://www.w3.org/1999/xhtml' lang='en'>
66 <head>
67 <title>MediaWiki {$mwVersion}</title>
68 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
69 <style type='text/css' media='screen'>
70 body {
71 color: #000;
72 background-color: #fff;
73 font-family: sans-serif;
74 padding: 2em;
75 text-align: center;
77 p, img, h1 {
78 text-align: left;
79 margin: 0.5em 0;
81 h1 {
82 font-size: 120%;
84 </style>
85 </head>
86 <body>
87 <img src="{$encLogo}" alt='The MediaWiki logo' />
88 <h1>MediaWiki {$mwVersion} internal error</h1>
89 <div class='error'>
90 <p>
91 {$message}
92 </p>
93 <p>
94 Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
95 PHP versions less than 5.3.0 are no longer supported by the PHP Group and will not receive
96 security or bugfix updates.
97 </p>
98 <p>
99 If for some reason you are unable to upgrade your PHP version, you will need to
100 <a href="http://www.mediawiki.org/wiki/Download">download</a> an older version
101 of MediaWiki from our website. See our
102 <a href="http://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
103 for details of which versions are compatible with prior versions of PHP.
104 </p>
105 </div>
106 </body>
107 </html>
108 HTML;
109 // Handle everything that's not index.php
110 } else {
111 // So nothing thinks this is JS or CSS
112 $finalOutput = ( $type == 'load.php' ) ? "/* $message */" : $message;
113 header( "$protocol 500 MediaWiki configuration Error" );
115 echo( "$finalOutput\n" );
116 die( 1 );