index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // @codingStandardsIgnoreFile Generic.Arrays.DisallowLongArraySyntax
  3. /**
  4. * New version of MediaWiki web-based config/installation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. * http://www.gnu.org/copyleft/gpl.html
  20. *
  21. * @file
  22. */
  23. // Bail on old versions of PHP, or if composer has not been run yet to install
  24. // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
  25. // @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound
  26. require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
  27. // @codingStandardsIgnoreEnd
  28. wfEntryPointCheck( 'mw-config/index.php' );
  29. define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
  30. define( 'MEDIAWIKI_INSTALL', true );
  31. // Resolve relative to regular MediaWiki root
  32. // instead of mw-config subdirectory.
  33. chdir( dirname( __DIR__ ) );
  34. require dirname( __DIR__ ) . '/includes/WebStart.php';
  35. wfInstallerMain();
  36. function wfInstallerMain() {
  37. global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
  38. $installer = InstallerOverrides::getWebInstaller( $wgRequest );
  39. if ( !$installer->startSession() ) {
  40. if ( $installer->request->getVal( "css" ) ) {
  41. // Do not display errors on css pages
  42. $installer->outputCss();
  43. exit;
  44. }
  45. $errors = $installer->getPhpErrors();
  46. $installer->showError( 'config-session-error', $errors[0] );
  47. $installer->finish();
  48. exit;
  49. }
  50. $fingerprint = $installer->getFingerprint();
  51. if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
  52. $session = $_SESSION['installData'][$fingerprint];
  53. } else {
  54. $session = array();
  55. }
  56. if ( !is_null( $wgRequest->getVal( 'uselang' ) ) ) {
  57. $langCode = $wgRequest->getVal( 'uselang' );
  58. } elseif ( isset( $session['settings']['_UserLang'] ) ) {
  59. $langCode = $session['settings']['_UserLang'];
  60. } else {
  61. $langCode = 'en';
  62. }
  63. $wgLang = Language::factory( $langCode );
  64. RequestContext::getMain()->setLanguage( $wgLang );
  65. $installer->setParserLanguage( $wgLang );
  66. $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
  67. $session = $installer->execute( $session );
  68. $_SESSION['installData'][$fingerprint] = $session;
  69. }