Пример #1
0
 public static function reset_ocs_database()
 {
     EDatabase::q("DROP TABLE IF EXISTS `ocs_apitraffic`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_comment`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_content`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_fan`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_person`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_activity`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_friendship`;");
     EDatabase::q("DROP TABLE IF EXISTS `ocs_friendinvitation`;");
     OCSTest::install_ocs_database();
 }
Пример #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);
 }