Пример #1
0
    $tables = $db->MetaTables();
    $sm = $db->getSchemaManager();
    foreach ($tables as $table) {
        $sm->dropTable($table);
    }
}
$cnt = new \Concrete\Controller\Install();
$cnt->on_start();
$fileWriteErrors = clone $cnt->fileWriteErrors;
$e = Loader::helper('validation/error');
// handle required items
if (!$cnt->get('imageTest')) {
    $e->add(t('GD library must be enabled to install concrete5.'));
}
if (!$cnt->get('mysqlTest')) {
    $e->add($cnt->getDBErrorMsg());
}
if (!$cnt->get('xmlTest')) {
    $e->add(t('SimpleXML and DOM must be enabled to install concrete5.'));
}
if (!$cnt->get('phpVtest')) {
    $e->add(t('concrete5 requires PHP 5.2 or greater.'));
}
if (is_object($fileWriteErrors)) {
    $e->add($fileWriteErrors);
}
$_POST['SAMPLE_CONTENT'] = $cliconfig['starting-point'];
$_POST['DB_SERVER'] = $cliconfig['db-server'];
$_POST['DB_USERNAME'] = $cliconfig['db-username'];
$_POST['DB_PASSWORD'] = $cliconfig['db-password'];
$_POST['DB_DATABASE'] = $cliconfig['db-database'];
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $options = $input->getOptions();
     if (isset($options['config'])) {
         if (!is_file($options['config'])) {
             throw new Exception('Unable to find the configuration file ' . $options['config']);
         }
         $configOptions = (include $options['config']);
         if (!is_array($configOptions)) {
             throw new Exception('The configuration file did not returned an array.');
         }
         foreach ($configOptions as $k => $v) {
             if (!$input->hasParameterOption("--{$k}")) {
                 $options[$k] = $v;
             }
         }
     }
     if (file_exists(DIR_CONFIG_SITE . '/database.php')) {
         throw new Exception('concrete5 is already installed.');
     }
     if (isset($options['default-locale'])) {
         if ($options['default-locale'] === 'en_US') {
             $options['default-locale'] = null;
         } else {
             $availableLocales = array_filter(scandir(DIR_BASE . '/application/languages'), function ($item) {
                 if (strpos($item, '.') === 0) {
                     return false;
                 }
                 $fullPath = DIR_BASE . '/application/languages/' . $item;
                 if (!is_dir($fullPath)) {
                     return false;
                 }
                 if (!is_file($fullPath . '/LC_MESSAGES/messages.mo')) {
                     return false;
                 }
                 return true;
             });
             if (!in_array($options['default-locale'], $availableLocales, true)) {
                 throw new Exception("'{$options['default-locale']}' is not a valid locale identifier.\nAvailable locales: " . ($availableLocales ? implode(', ', $availableLocales) : 'no locale found'));
             }
         }
     }
     Database::extend('install', function () use($options) {
         return Database::getFactory()->createConnection(array('host' => $options['db-server'], 'user' => $options['db-username'], 'password' => $options['db-password'], 'database' => $options['db-database']));
     });
     Database::setDefaultConnection('install');
     Config::set('database.connections.install', array());
     $cnt = new \Concrete\Controller\Install();
     $cnt->on_start();
     $fileWriteErrors = clone $cnt->fileWriteErrors;
     $e = Core::make('helper/validation/error');
     /* @var $e \Concrete\Core\Error\Error */
     if (!$cnt->get('imageTest')) {
         $e->add('GD library must be enabled to install concrete5.');
     }
     if (!$cnt->get('mysqlTest')) {
         $e->add($cnt->getDBErrorMsg());
     }
     if (!$cnt->get('xmlTest')) {
         $e->add('SimpleXML and DOM must be enabled to install concrete5.');
     }
     if (!$cnt->get('phpVtest')) {
         $e->add('concrete5 requires PHP ' . $cnt->getMinimumPhpVersion() . ' or greater.');
     }
     if (is_object($fileWriteErrors)) {
         $e->add($fileWriteErrors);
     }
     if (!$e->has()) {
         $_POST['DB_SERVER'] = $options['db-server'];
         $_POST['DB_USERNAME'] = $options['db-username'];
         $_POST['DB_PASSWORD'] = $options['db-password'];
         $_POST['DB_DATABASE'] = $options['db-database'];
         $_POST['SITE'] = $options['site'];
         $_POST['SAMPLE_CONTENT'] = $options['starting-point'];
         $_POST['uEmail'] = $options['admin-email'];
         $_POST['uPasswordConfirm'] = $_POST['uPassword'] = $options['admin-password'];
         $e = $cnt->configure();
     }
     if ($e->has()) {
         throw new Exception(implode("\n", $e->getList()));
     }
     try {
         $spl = StartingPointPackage::getClass($options['starting-point']);
         require DIR_CONFIG_SITE . '/site_install.php';
         require DIR_CONFIG_SITE . '/site_install_user.php';
         $routines = $spl->getInstallRoutines();
         foreach ($routines as $r) {
             $output->writeln($r->getProgress() . '%: ' . $r->getText());
             call_user_func(array($spl, $r->getMethod()));
         }
     } catch (Exception $ex) {
         $cnt->reset();
         throw $ex;
     }
     if (isset($options['default-locale'])) {
         Config::save('concrete.locale', $options['default-locale']);
     }
     if (isset($options['demo-username']) && isset($options['demo-password']) && isset($options['demo-email']) && is_string($options['demo-username']) && is_string($options['demo-password']) && is_string($options['demo-email']) && $options['demo-username'] !== '' && $options['demo-password'] !== '' && $options['demo-email'] !== '') {
         $output->write('Adding demo user... ');
         \UserInfo::add(array('uName' => $options['demo-username'], 'uEmail' => $options['demo-email'], 'uPassword' => $options['demo-password']))->getUserObject()->enterGroup(\Group::getByID(ADMIN_GROUP_ID));
         $output->writeln('done.');
     }
     Config::save('concrete.misc.seen_introduction', true);
     $output->writeln('Installation Complete!');
 }