Пример #1
0
function wfInstallerMain()
{
    global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
    $installer = InstallerOverrides::getWebInstaller($wgRequest);
    if (!$installer->startSession()) {
        $installer->finish();
        exit;
    }
    $fingerprint = $installer->getFingerprint();
    if (isset($_SESSION['installData'][$fingerprint])) {
        $session = $_SESSION['installData'][$fingerprint];
    } else {
        $session = array();
    }
    if (!is_null($wgRequest->getVal('uselang'))) {
        $langCode = $wgRequest->getVal('uselang');
    } elseif (isset($session['settings']['_UserLang'])) {
        $langCode = $session['settings']['_UserLang'];
    } else {
        $langCode = 'en';
    }
    $wgLang = Language::factory($langCode);
    $installer->setParserLanguage($wgLang);
    $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
    $session = $installer->execute($session);
    $_SESSION['installData'][$fingerprint] = $session;
}
Пример #2
0
function wfInstallerMain()
{
    global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
    $installer = InstallerOverrides::getWebInstaller($wgRequest);
    if (!$installer->startSession()) {
        if ($installer->request->getVal("css")) {
            // Do not display errors on css pages
            $installer->outputCss();
            exit;
        }
        $errors = $installer->getPhpErrors();
        $installer->showError('config-session-error', $errors[0]);
        $installer->finish();
        exit;
    }
    $fingerprint = $installer->getFingerprint();
    if (isset($_SESSION['installData'][$fingerprint])) {
        $session = $_SESSION['installData'][$fingerprint];
    } else {
        $session = array();
    }
    if (!is_null($wgRequest->getVal('uselang'))) {
        $langCode = $wgRequest->getVal('uselang');
    } elseif (isset($session['settings']['_UserLang'])) {
        $langCode = $session['settings']['_UserLang'];
    } else {
        $langCode = 'en';
    }
    $wgLang = Language::factory($langCode);
    $installer->setParserLanguage($wgLang);
    $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
    $session = $installer->execute($session);
    $_SESSION['installData'][$fingerprint] = $session;
}
Пример #3
0
 function execute()
 {
     global $IP, $wgTitle;
     $siteName = isset($this->mArgs[0]) ? $this->mArgs[0] : "Don't care";
     // Will not be set if used with --env-checks
     $adminName = isset($this->mArgs[1]) ? $this->mArgs[1] : null;
     $wgTitle = Title::newFromText('Installer script');
     $dbpassfile = $this->getOption('dbpassfile', false);
     if ($dbpassfile !== false) {
         wfSuppressWarnings();
         $dbpass = file_get_contents($dbpassfile);
         wfRestoreWarnings();
         if ($dbpass === false) {
             $this->error("Couldn't open {$dbpassfile}", true);
         }
         $this->mOptions['dbpass'] = trim($dbpass, "\r\n");
     }
     $installer = InstallerOverrides::getCliInstaller($siteName, $adminName, $this->mOptions);
     $status = $installer->doEnvironmentChecks();
     if ($status->isGood()) {
         $installer->showMessage('config-env-good');
     } else {
         $installer->showStatusMessage($status);
         return;
     }
     if (!$this->hasOption('env-checks')) {
         $installer->execute();
         $installer->writeConfigurationFile($this->getOption('confpath', $IP));
     }
 }
 /**
  * Main entry point.
  *
  * @param array $session initial session array
  *
  * @return Array: new session array
  */
 public function execute(array $session)
 {
     $this->session = $session;
     if (isset($session['settings'])) {
         $this->settings = $session['settings'] + $this->settings;
     }
     $this->exportVars();
     $this->setupLanguage();
     if (($this->getVar('_InstallDone') || $this->getVar('_UpgradeDone')) && $this->request->getVal('localsettings')) {
         $this->request->response()->header('Content-type: application/x-httpd-php');
         $this->request->response()->header('Content-Disposition: attachment; filename="LocalSettings.php"');
         $ls = InstallerOverrides::getLocalSettingsGenerator($this);
         $rightsProfile = $this->rightsProfiles[$this->getVar('_RightsProfile')];
         foreach ($rightsProfile as $group => $rightsArr) {
             $ls->setGroupRights($group, $rightsArr);
         }
         echo $ls->getText();
         return $this->session;
     }
     $cssDir = $this->request->getVal('css');
     if ($cssDir) {
         $cssDir = $cssDir == 'rtl' ? 'rtl' : 'ltr';
         $this->request->response()->header('Content-type: text/css');
         echo $this->output->getCSS($cssDir);
         return $this->session;
     }
     if (isset($session['happyPages'])) {
         $this->happyPages = $session['happyPages'];
     } else {
         $this->happyPages = array();
     }
     if (isset($session['skippedPages'])) {
         $this->skippedPages = $session['skippedPages'];
     } else {
         $this->skippedPages = array();
     }
     $lowestUnhappy = $this->getLowestUnhappy();
     # Special case for Creative Commons partner chooser box.
     if ($this->request->getVal('SubmitCC')) {
         $page = $this->getPageByName('Options');
         $this->output->useShortHeader();
         $this->output->allowFrames();
         $page->submitCC();
         return $this->finish();
     }
     if ($this->request->getVal('ShowCC')) {
         $page = $this->getPageByName('Options');
         $this->output->useShortHeader();
         $this->output->allowFrames();
         $this->output->addHTML($page->getCCDoneBox());
         return $this->finish();
     }
     # Get the page name.
     $pageName = $this->request->getVal('page');
     if (in_array($pageName, $this->otherPages)) {
         # Out of sequence
         $pageId = false;
         $page = $this->getPageByName($pageName);
     } else {
         # Main sequence
         if (!$pageName || !in_array($pageName, $this->pageSequence)) {
             $pageId = $lowestUnhappy;
         } else {
             $pageId = array_search($pageName, $this->pageSequence);
         }
         # If necessary, move back to the lowest-numbered unhappy page
         if ($pageId > $lowestUnhappy) {
             $pageId = $lowestUnhappy;
             if ($lowestUnhappy == 0) {
                 # Knocked back to start, possible loss of session data.
                 $this->showSessionWarning = true;
             }
         }
         $pageName = $this->pageSequence[$pageId];
         $page = $this->getPageByName($pageName);
     }
     # If a back button was submitted, go back without submitting the form data.
     if ($this->request->wasPosted() && $this->request->getBool('submit-back')) {
         if ($this->request->getVal('lastPage')) {
             $nextPage = $this->request->getVal('lastPage');
         } elseif ($pageId !== false) {
             # Main sequence page
             # Skip the skipped pages
             $nextPageId = $pageId;
             do {
                 $nextPageId--;
                 $nextPage = $this->pageSequence[$nextPageId];
             } while (isset($this->skippedPages[$nextPage]));
         } else {
             $nextPage = $this->pageSequence[$lowestUnhappy];
         }
         $this->output->redirect($this->getUrl(array('page' => $nextPage)));
         return $this->finish();
     }
     # Execute the page.
     $this->currentPageName = $page->getName();
     $this->startPageWrapper($pageName);
     if ($page->isSlow()) {
         $this->disableTimeLimit();
     }
     $result = $page->execute();
     $this->endPageWrapper();
     if ($result == 'skip') {
         # Page skipped without explicit submission.
         # Skip it when we click "back" so that we don't just go forward again.
         $this->skippedPages[$pageName] = true;
         $result = 'continue';
     } else {
         unset($this->skippedPages[$pageName]);
     }
     # If it was posted, the page can request a continue to the next page.
     if ($result === 'continue' && !$this->output->headerDone()) {
         if ($pageId !== false) {
             $this->happyPages[$pageId] = true;
         }
         $lowestUnhappy = $this->getLowestUnhappy();
         if ($this->request->getVal('lastPage')) {
             $nextPage = $this->request->getVal('lastPage');
         } elseif ($pageId !== false) {
             $nextPage = $this->pageSequence[$pageId + 1];
         } else {
             $nextPage = $this->pageSequence[$lowestUnhappy];
         }
         if (array_search($nextPage, $this->pageSequence) > $lowestUnhappy) {
             $nextPage = $this->pageSequence[$lowestUnhappy];
         }
         $this->output->redirect($this->getUrl(array('page' => $nextPage)));
     }
     return $this->finish();
 }
Пример #5
0
 function execute()
 {
     global $IP, $wgTitle;
     $siteName = isset($this->mArgs[0]) ? $this->mArgs[0] : "Don't care";
     // Will not be set if used with --env-checks
     $adminName = isset($this->mArgs[1]) ? $this->mArgs[1] : null;
     $wgTitle = Title::newFromText('Installer script');
     $dbpassfile = $this->getOption('dbpassfile', false);
     if ($dbpassfile !== false) {
         if ($this->getOption('dbpass', false) !== false) {
             $this->error('WARNING: You provide the options "dbpass" and "dbpassfile". The content of "dbpassfile" overwrites "dbpass".');
         }
         wfSuppressWarnings();
         $dbpass = file_get_contents($dbpassfile);
         wfRestoreWarnings();
         if ($dbpass === false) {
             $this->error("Couldn't open {$dbpassfile}", true);
         }
         $this->mOptions['dbpass'] = trim($dbpass, "\r\n");
     }
     $passfile = $this->getOption('passfile', false);
     if ($passfile !== false) {
         if ($this->getOption('pass', false) !== false) {
             $this->error('WARNING: You provide the options "pass" and "passfile". The content of "passfile" overwrites "pass".');
         }
         wfSuppressWarnings();
         $pass = file_get_contents($passfile);
         wfRestoreWarnings();
         if ($pass === false) {
             $this->error("Couldn't open {$passfile}", true);
         }
         $this->mOptions['pass'] = str_replace(array("\n", "\r"), "", $pass);
     } elseif ($this->getOption('pass', false) === false) {
         $this->error('You need to provide the option "pass" or "passfile"', true);
     }
     $installer = InstallerOverrides::getCliInstaller($siteName, $adminName, $this->mOptions);
     $status = $installer->doEnvironmentChecks();
     if ($status->isGood()) {
         $installer->showMessage('config-env-good');
     } else {
         $installer->showStatusMessage($status);
         return;
     }
     if (!$this->hasOption('env-checks')) {
         $installer->execute();
         $installer->writeConfigurationFile($this->getOption('confpath', $IP));
     }
 }
Пример #6
0
 /**
  * Write LocalSettings.php to a given path
  *
  * @param string $path Full path to write LocalSettings.php to
  */
 public function writeConfigurationFile($path)
 {
     $ls = InstallerOverrides::getLocalSettingsGenerator($this);
     $ls->writeFile("{$path}/LocalSettings.php");
 }
Пример #7
0
 function execute()
 {
     global $IP;
     $siteName = $this->getArg(0, 'MediaWiki');
     // Will not be set if used with --env-checks
     $adminName = $this->getArg(1);
     $dbpassfile = $this->getOption('dbpassfile');
     if ($dbpassfile !== null) {
         if ($this->getOption('dbpass') !== null) {
             $this->error('WARNING: You have provided the options "dbpass" and "dbpassfile". ' . 'The content of "dbpassfile" overrides "dbpass".');
         }
         MediaWiki\suppressWarnings();
         $dbpass = file_get_contents($dbpassfile);
         // returns false on failure
         MediaWiki\restoreWarnings();
         if ($dbpass === false) {
             $this->error("Couldn't open {$dbpassfile}", true);
         }
         $this->mOptions['dbpass'] = trim($dbpass, "\r\n");
     }
     $passfile = $this->getOption('passfile');
     if ($passfile !== null) {
         if ($this->getOption('pass') !== null) {
             $this->error('WARNING: You have provided the options "pass" and "passfile". ' . 'The content of "passfile" overrides "pass".');
         }
         MediaWiki\suppressWarnings();
         $pass = file_get_contents($passfile);
         // returns false on failure
         MediaWiki\restoreWarnings();
         if ($pass === false) {
             $this->error("Couldn't open {$passfile}", true);
         }
         $this->mOptions['pass'] = trim($pass, "\r\n");
     } elseif ($this->getOption('pass') === null) {
         $this->error('You need to provide the option "pass" or "passfile"', true);
     }
     $installer = InstallerOverrides::getCliInstaller($siteName, $adminName, $this->mOptions);
     $status = $installer->doEnvironmentChecks();
     if ($status->isGood()) {
         $installer->showMessage('config-env-good');
     } else {
         $installer->showStatusMessage($status);
         return;
     }
     if (!$this->hasOption('env-checks')) {
         $installer->execute();
         $installer->writeConfigurationFile($this->getOption('confpath', $IP));
     }
 }