index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // phpcs:disable 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. // phpcs:ignore MediaWiki.Usage.DirUsage.FunctionFound
  26. require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
  27. wfEntryPointCheck( 'html', dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
  28. define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
  29. define( 'MEDIAWIKI_INSTALL', true );
  30. // Resolve relative to regular MediaWiki root
  31. // instead of mw-config subdirectory.
  32. chdir( dirname( __DIR__ ) );
  33. require dirname( __DIR__ ) . '/includes/WebStart.php';
  34. wfInstallerMain();
  35. function wfInstallerMain() {
  36. global $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
  37. $request = RequestContext::getMain()->getRequest();
  38. $installer = InstallerOverrides::getWebInstaller( $request );
  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 ( $request->getCheck( 'uselang' ) ) {
  57. $langCode = $request->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. }