public function main() { $this->out(); $this->out('Database settings:'); $install['Install']['datasource'] = $this->in(__d('croogo', 'DataSource'), array('Mysql', 'Sqlite', 'Postgres', 'Sqlserver'), 'Mysql'); $install['Install']['datasource'] = 'Database/' . $install['Install']['datasource']; $install['Install']['host'] = $this->in(__d('croogo', 'Host'), null, 'localhost'); $install['Install']['login'] = $this->in(__d('croogo', 'Login'), null, 'root'); $install['Install']['password'] = $this->in(__d('croogo', 'Password'), null, ''); $install['Install']['database'] = $this->in(__d('croogo', 'Database'), null, 'croogo'); $install['Install']['prefix'] = $this->in(__d('croogo', 'Prefix'), null, ''); $install['Install']['port'] = $this->in(__d('croogo', 'Port'), null, null); $InstallManager = new InstallManager(); $InstallManager->createDatabaseFile($install); $this->out('Setting up database objects. Please wait...'); $Install = ClassRegistry::init('Install.Install'); try { $Install->setupDatabase(); } catch (Exception $e) { $this->err($e->getMessage()); $this->err('Please verify you have the correct credentials'); return $this->_stop(); } $InstallManager->createCroogoFile(); $this->out(); $this->out('Create Admin user:'******'croogo', 'Username'), null, null); if (empty($username)) { $this->err('Username must not be empty'); } } while (empty($username)); do { $password = $this->in(__d('croogo', 'Password')); $verify = $this->in(__d('croogo', 'Verify Password')); $passwordsMatched = $password == $verify; if (!$passwordsMatched) { $this->err('Passwords do not match'); } if (empty($password)) { $this->err('Password must not be empty'); } } while (empty($password) || !$passwordsMatched); $user['User']['username'] = $username; $user['User']['password'] = $password; $Install->addAdminUser($user); $InstallManager->createSettingsFile(); $InstallManager->installCompleted(); $this->out(); $this->success('Congratulations, Croogo has been installed successfully.'); }
/** * Step 2: Run the initial sql scripts to create the db and seed it with data * * @return void * @access public */ public function data() { $this->_check(); $this->set('title_for_layout', __d('croogo', '第二步:初始化数据库')); $this->loadModel('Install.Install'); $ds = $this->Install->getDataSource(); $ds->cacheSources = false; $sources = $ds->listSources(); if (!empty($sources)) { $this->Session->setFlash(__d('croogo', 'Warning: Database "%s" is not empty.', $ds->config['database']), 'default', array('class' => 'error')); } if (isset($this->request->params['named']['run'])) { $this->Install->setupDatabase(); $InstallManager = new InstallManager(); $result = $InstallManager->createCroogoFile(); $this->redirect(array('action' => 'adminuser')); } }
/** * Step 2: Run the initial sql scripts to create the db and seed it with data * * @return void * @access public */ public function data() { $this->_check(); $this->set('title_for_layout', __d('croogo', 'Step 2: Build database')); $this->loadModel('Install.Install'); $ds = $this->Install->getDataSource(); $ds->cacheSources = false; $sources = $ds->listSources(); if (!empty($sources)) { $this->Session->setFlash(__d('croogo', 'Warning: Database "%s" is not empty.', $ds->config['database']), 'default', array('class' => 'error')); } if ($this->request->query('run')) { set_time_limit(10 * MINUTE); $this->Install->setupDatabase(); $InstallManager = new InstallManager(); $result = $InstallManager->createCroogoFile(); if ($result !== true) { return $this->Session->setFlash($result, 'flash', array('class' => 'error')); } return $this->redirect(array('action' => 'adminuser')); } }
/** * Step 2: Run the initial sql scripts to create the db and seed it with data * * @return void * @access public */ public function data() { $this->_check(); $this->set('title_for_layout', __('Step 2: Build database')); if (isset($this->params['named']['run'])) { $this->loadModel('Install.Install'); $this->Install->setupDatabase(); $InstallManager = new InstallManager(); $result = $InstallManager->createCroogoFile(); $this->redirect(array('action' => 'adminuser')); } }