Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * Display an error page when there is no LocalSettings.php file. |
4 | * |
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. |
9 | * |
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. |
14 | * |
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 |
19 | * |
20 | * @file |
21 | */ |
22 | |
23 | # T32219 : can not use pathinfo() on URLs since slashes do not match |
24 | use MediaWiki\Html\TemplateParser; |
25 | use Wikimedia\ObjectCache\EmptyBagOStuff; |
26 | |
27 | $matches = []; |
28 | $path = '/'; |
29 | foreach ( array_filter( explode( '/', $_SERVER['PHP_SELF'] ) ) as $part ) { |
30 | if ( !preg_match( '/\.(php)$/', $part, $matches ) ) { |
31 | $path .= "$part/"; |
32 | } else { |
33 | break; |
34 | } |
35 | } |
36 | |
37 | # Check to see if the installer is running |
38 | if ( !function_exists( 'session_name' ) ) { |
39 | $installerStarted = false; |
40 | } else { |
41 | if ( !wfIniGetBool( 'session.auto_start' ) ) { |
42 | session_name( 'mw_installer_session' ); |
43 | } |
44 | $oldReporting = error_reporting( E_ALL & ~E_NOTICE ); |
45 | $success = session_start(); |
46 | error_reporting( $oldReporting ); |
47 | $installerStarted = ( $success && isset( $_SESSION['installData'] ) ); |
48 | } |
49 | |
50 | $templateParser = new TemplateParser( null, new EmptyBagOStuff() ); |
51 | |
52 | # Render error page if no LocalSettings file can be found |
53 | try { |
54 | echo $templateParser->processTemplate( |
55 | 'NoLocalSettings', |
56 | [ |
57 | 'version' => ( defined( 'MW_VERSION' ) ? MW_VERSION : 'VERSION' ), |
58 | 'path' => $path, |
59 | 'localSettingsExists' => file_exists( MW_CONFIG_FILE ), |
60 | 'installerStarted' => $installerStarted |
61 | ] |
62 | ); |
63 | } catch ( Exception $e ) { |
64 | echo 'Error: ' . htmlspecialchars( $e->getMessage() ); |
65 | } |