/**
  * Handles connector requests.
  *
  * @param string $action
  */
 public function handle($action = '')
 {
     $this->beginTimer();
     /* prepare the settings */
     $settings = $_REQUEST;
     if (empty($settings['installmode'])) {
         $settings['installmode'] = modInstall::MODE_NEW;
     }
     $settings['installmode'] = $this->getInstallMode($settings['installmode']);
     $this->settings->fromArray($settings);
     /* load CLI args into settings */
     /* load the config.xml file */
     $config = $this->getConfig($settings['installmode']);
     if (empty($config)) {
         $this->end($this->install->lexicon('cli_no_config_file'));
     }
     $this->settings->fromArray($config);
     $this->settings->fromArray($settings);
     /* do again to allow CLI-based overrides of config.xml */
     /* load the driver */
     $this->install->loadDriver();
     /* Run tests */
     $mode = (int) $this->install->settings->get('installmode');
     $results = $this->install->test($mode);
     if (!$this->install->test->success) {
         $msg = "\n";
         foreach ($results['fail'] as $field => $result) {
             $msg .= $field . ': ' . $result['title'] . ' - ' . $result['message'];
         }
         $msg = $this->install->lexicon('cli_tests_failed', array('errors' => $msg));
         $this->end($msg);
     }
     /** Attempt to create the database */
     $this->checkDatabase();
     /* Run installer */
     $this->install->getService('runner', 'runner.modInstallRunnerWeb');
     $failed = true;
     $errors = array();
     if ($this->install->runner) {
         $success = $this->install->runner->run($mode);
         $results = $this->install->runner->getResults();
         $failed = false;
         foreach ($results as $item) {
             if ($item['class'] === 'failed') {
                 $failed = true;
                 $this->install->xpdo->log(xPDO::LOG_LEVEL_ERROR, $item['msg']);
                 $errors[] = $item;
                 break;
             }
         }
     }
     if ($failed) {
         $msg = "\n";
         foreach ($errors as $field => $result) {
             $msg .= $result['msg'];
         }
         $msg = $this->install->lexicon('cli_install_failed', array('errors' => $msg));
         $this->end($msg);
     }
     /* cleanup */
     $errors = $this->install->verify();
     foreach ($errors as $error) {
         $this->install->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error);
     }
     $cleanupErrors = $this->install->cleanup();
     foreach ($cleanupErrors as $key => $error) {
         $this->install->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error);
     }
     if ($this->settings->get('remove_setup_directory')) {
         $this->install->removeSetupDirectory();
     }
     $this->endTimer();
     $this->end('' . $this->install->lexicon('installation_finished', array('time' => $this->timeTotal)));
 }
Beispiel #2
0
} else {
    define('MODX_SETUP_URL', '/');
}
/* session loop-back tester */
if (!$isCommandLine && (!isset($_GET['s']) || $_GET['s'] != 'set') && !isset($_SESSION['session_test'])) {
    $_SESSION['session_test'] = 1;
    echo "<html><head><title>Loading...</title><script>window.location.href='" . MODX_SETUP_URL . "?s=set';</script></head><body></body></html>";
    exit;
} elseif (!$isCommandLine && isset($_GET['s']) && $_GET['s'] == 'set' && !isset($_SESSION['session_test'])) {
    die('<html><head><title></title></head><body><h1>FATAL ERROR: MODX Setup cannot continue.</h1><p>Make sure your PHP session configuration is valid and working.</p></body></html>');
}
$setupPath = strtr(realpath(dirname(__FILE__)), '\\', '/') . '/';
define('MODX_SETUP_PATH', $setupPath);
$installPath = strtr(realpath(dirname(dirname(__FILE__))), '\\', '/') . '/';
define('MODX_INSTALL_PATH', $installPath);
if (!(include MODX_SETUP_PATH . 'includes/config.core.php')) {
    die('<html><head><title></title></head><body><h1>FATAL ERROR: MODX Setup cannot continue.</h1><p>Make sure you have uploaded all of the setup/ files; your setup/includes/config.core.php file is missing.</p></body></html>');
}
if (!(include MODX_SETUP_PATH . 'includes/modinstall.class.php')) {
    die('<html><head><title></title></head><body><h1>FATAL ERROR: MODX Setup cannot continue.</h1><p>Make sure you have uploaded all of the setup/ files; your setup/includes/modinstall.class.php file is missing.</p></body></html>');
}
$modInstall = new modInstall();
if ($modInstall->getService('lexicon', 'modInstallLexicon')) {
    $modInstall->lexicon->load('default');
}
$modInstall->findCore();
$modInstall->doPreloadChecks();
$requestClass = $isCommandLine ? 'request.modInstallCLIRequest' : 'request.modInstallRequest';
$modInstall->getService('request', $requestClass);
echo $modInstall->request->handle();
exit;
Beispiel #3
0
<?php

/**
 * Handles AJAX requests
 *
 * @package setup
 */
/* do a little bit of environment cleanup if possible */
@ini_set('magic_quotes_runtime', 0);
@ini_set('magic_quotes_sybase', 0);
/* start session */
session_start();
/* set error reporting */
error_reporting(E_ALL & ~E_NOTICE);
$setupPath = strtr(realpath(dirname(dirname(__FILE__))), '\\', '/') . '/';
define('MODX_SETUP_PATH', $setupPath);
$installPath = strtr(realpath(dirname(dirname(dirname(__FILE__)))), '\\', '/') . '/';
define('MODX_INSTALL_PATH', $installPath);
if (!@(include MODX_SETUP_PATH . 'includes/config.core.php')) {
    die('Error loading core files!');
}
require_once MODX_CORE_PATH . 'xpdo/xpdo.class.php';
require_once MODX_SETUP_PATH . 'includes/modinstall.class.php';
$install = new modInstall();
$install->getService('lexicon', 'modInstallLexicon');
$install->lexicon->load('default');
$install->getService('request', 'request.modInstallConnectorRequest');
$install->request->handle();
@session_write_close();
exit;