예제 #1
0
 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.');
 }
예제 #2
0
 /**
  * Step 1: database
  *
  * Try to connect to the database and give a message if that's not possible so the user can check their
  * credentials or create the missing database
  * Create the database file and insert the submitted details
  *
  * @return void
  * @access public
  */
 public function database()
 {
     $this->_check();
     $this->set('title_for_layout', __d('croogo', 'Step 1: Database'));
     if (Configure::read('Croogo.installed')) {
         return $this->redirect(array('action' => 'adminuser'));
     }
     if (!empty($this->request->data)) {
         $InstallManager = new InstallManager();
         $result = $InstallManager->createDatabaseFile(array('Install' => $this->request->data));
         if ($result !== true) {
             $this->Session->setFlash($result, 'flash', array('class' => 'error'));
         } else {
             return $this->redirect(array('action' => 'data'));
         }
     }
     $currentConfiguration = array('exists' => false, 'valid' => false);
     if (file_exists(APP . 'Config' . DS . 'database.php')) {
         $currentConfiguration['exists'] = true;
     }
     if ($currentConfiguration['exists']) {
         try {
             $this->loadModel('Install.Install');
             $ds = $this->Install->getDataSource();
             $ds->cacheSources = false;
             $sources = $ds->listSources();
             $currentConfiguration['valid'] = true;
         } catch (Exception $e) {
         }
     }
     $this->set(compact('currentConfiguration'));
 }
예제 #3
0
 /**
  * Step 1: database
  *
  * Try to connect to the database and give a message if that's not possible so the user can check their
  * credentials or create the missing database
  * Create the database file and insert the submitted details
  *
  * @return void
  * @access public
  */
 public function database()
 {
     $this->_check();
     $this->set('title_for_layout', __d('croogo', '第一步:设置数据库信息'));
     if (Configure::read('Croogo.installed')) {
         $this->redirect(array('action' => 'adminuser'));
     }
     if (!empty($this->request->data)) {
         $InstallManager = new InstallManager();
         $result = $InstallManager->createDatabaseFile(array('Install' => $this->request->data));
         if ($result !== true) {
             $this->Session->setFlash($result, 'default', array('class' => 'error'));
         } else {
             $this->redirect(array('action' => 'data'));
         }
     }
 }