示例#1
0
 /**
  * set temporary database information for the database class
  * @param string $name
  * @param string $host
  * @param string $user
  * @param string $pass
  * @return null
  */
 public static function load()
 {
     //loading vars from config file
     EDatabase::$db_name = EConfig::$data["database"]["name"];
     EDatabase::$db_host = EConfig::$data["database"]["host"];
     EDatabase::$db_user = EConfig::$data["database"]["user"];
     EDatabase::$db_pass = EConfig::$data["database"]["password"];
     EDatabase::open_session();
 }
示例#2
0
 public function step1($args)
 {
     $working = false;
     $name = EHeaderDataParser::post('name');
     $host = EHeaderDataParser::post('host');
     $user = EHeaderDataParser::post('user');
     $pass = EHeaderDataParser::post('password');
     $pass2 = EHeaderDataParser::post('password2');
     $notification = '';
     $database_path = ELoader::$prev_path . '/config/database.conf.php';
     $cf = new EConfigFile();
     $cf->set_abs_file($database_path);
     if (empty($name) and !empty($cf->get('name'))) {
         $name = $cf->get('name');
     }
     if (empty($host) and !empty($cf->get('host'))) {
         $host = $cf->get('host');
     }
     if (empty($user) and !empty($cf->get('user'))) {
         $user = $cf->get('user');
     }
     if (empty($pass) and !empty($cf->get('password'))) {
         $pass = $pass2 = $cf->get('password');
     }
     if (!empty($name) and !empty($user) and !empty($host) and !empty($pass) and !empty($pass2)) {
         if ($pass != $pass2) {
             $this->_error('Warning! Your passwords didn\'t match! Please reinsert them!');
         } else {
             $cf->set('name', $name);
             $cf->set('user', $user);
             $cf->set('host', $host);
             $cf->set('password', $pass);
             EDatabase::set_db_info($name, $host, $user, $pass);
             EUtility::hide_output();
             // hiding output as mysqli functions are surely outputting something
             if (!EDatabase::open_session()) {
                 EUtility::show_output();
                 $notification = $this->_error('Couldn\'t open connection to database! Please check config!');
             } else {
                 OCSTest::install_ocs_database();
                 //execute soft install
                 $out = EUtility::show_output();
                 if (!empty($out)) {
                     $notification = $this->_error('Something went wrong with install phase! Please check config!');
                 } else {
                     $notification = $this->_notify('We can connect to database! Database is installed and configuration saved!');
                     $working = true;
                     $cf->save();
                 }
             }
         }
     }
     $data = array();
     $data['name'] = $name;
     $data['user'] = $user;
     $data['host'] = $host;
     $data['pass'] = $pass;
     $data['pass2'] = $pass2;
     $data['working'] = $working;
     $data['notification'] = $notification;
     EStructure::view('wizard/step1', $data);
 }