/** * Prepare and process config form * * @access public * @param void * @return boolean */ function execute() { if (!$this->installer->isExecutedStep(INSTALL_SYSTEM_CONFIG)) { $this->goToStep(INSTALL_SYSTEM_CONFIG); } // if $installation = new installation(new Output_Html()); $installation->setDatabaseType((string) trim($this->getFromStorage('database_type'))); $installation->setDatabaseHost((string) trim($this->getFromStorage('database_host'))); $installation->setDatabaseUsername((string) trim($this->getFromStorage('database_user'))); $installation->setDatabasePassword((string) $this->getFromStorage('database_pass')); $installation->setDatabaseName((string) trim($this->getFromStorage('database_name'))); $installation->setTablePrefix((string) trim($this->getFromStorage('database_prefix'))); ob_start(); if ($installation->execute()) { $all_ok = true; $this->installer->clearStorage(); // lets clear data from session... its a DB pass we are talking about here $path = $_SERVER['PHP_SELF']; $path = substr($path, 0, strpos($path, 'public')); } else { $all_ok = false; $path = ''; } // if tpl_assign('all_ok', $all_ok); tpl_assign('relative_url', $path); tpl_assign('status_messages', explode("\n", trim(ob_get_clean()))); $this->setContentFromTemplate('finish.php'); return false; }
public function index() { if (app::$site->users()->count() > 0) { go('panel/login'); } if ($problems = installation::check()) { $content = view('installation/check', array('problems' => $problems)); } else { $form = app::form('installation', array('language' => c::get('panel.language', 'en'))); $form->cancel = false; $form->save = l::get('installation.signup.button'); $form->centered = true; foreach (app::languages() as $lang) { $form->fields()->get('language')->options[$lang->code()] = $lang->title(); } $form->on('submit', function ($form) { try { app::$site->users()->create($form->serialize()); go('panel/login/welcome'); } catch (Exception $e) { $form->alert($e->getMessage()); } }); $content = view('installation/signup', array('form' => $form)); } return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content)); }
public function index() { if (site()->users()->count() > 0) { go(panel()->urls()->login()); } if ($problems = installation::check()) { $content = view('installation/check', array('problems' => $problems)); } else { $form = panel()->form('installation', array('language' => kirby()->option('panel.language', 'en'))); $form->cancel = false; $form->save = l('installation.signup.button'); $form->centered = true; foreach (panel()->languages() as $lang) { $form->fields()->get('language')->options[$lang->code()] = $lang->title(); } $form->on('submit', function ($form) { try { // fetch all the form data $data = $form->serialize(); // make sure that the first user is an admin $data['role'] = 'admin'; // try to create the new user $user = panel()->site()->users()->create($data); // store the new username for the login screen s::set('username', $user->username()); // redirect to the login go(panel()->urls()->login() . '/welcome'); } catch (Exception $e) { $form->alert($e->getMessage()); } }); $content = view('installation/signup', array('form' => $form)); } return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content)); }
<?php require_once dirname(__FILE__) . '/include.php'; if (!isset($argv) || !is_array($argv)) { die('Input arguments dbtype dbhost dbuser dbpass dbname tblprefix missing'); } // if $installation = new installation(new Output_Console()); $installation->setDatabaseType((string) trim(array_var($argv, 1))); $installation->setDatabaseHost((string) trim(array_var($argv, 2))); $installation->setDatabaseUsername((string) trim(array_var($argv, 3))); $installation->setDatabasePassword((string) array_var($argv, 4)); $installation->setDatabaseName((string) trim(array_var($argv, 5))); $installation->setTablePrefix((string) trim(array_var($argv, 6))); $installation->execute();