示例#1
0
 /**
  * Save configurations build by installer interface
  */
 public function make()
 {
     // prepare configurations to save
     /** @var array $cfg */
     $cfg = App::$Properties->getAll('default');
     $this->before();
     $cfg['baseDomain'] = $this->baseDomain;
     $cfg['database'] = $this->db;
     $cfg['adminEmail'] = $this->email;
     $cfg['singleLanguage'] = $this->singleLanguage;
     $cfg['multiLanguage'] = (bool) $this->multiLanguage;
     $cfg['passwordSalt'] = '$2a$07$' . Str::randomLatinNumeric(mt_rand(21, 30)) . '$';
     $cfg['debug']['cookie']['key'] = 'fdebug_' . Str::randomLatinNumeric(mt_rand(4, 16));
     $cfg['debug']['cookie']['value'] = Str::randomLatinNumeric(mt_rand(32, 128));
     // import database tables
     $connectName = 'install';
     include root . '/Private/Database/install.php';
     // insert admin user
     $user = new User();
     $user->setConnection('install');
     $user->login = $this->user['login'];
     $user->email = $this->user['email'];
     $user->role_id = 4;
     $user->password = App::$Security->password_hash($this->user['password'], $cfg['passwordSalt']);
     $user->save();
     $profile = new Profile();
     $profile->setConnection('install');
     $profile->user_id = $user->id;
     $profile->save();
     // set installation version
     $system = new System();
     $system->setConnection('install');
     $system->var = 'version';
     $system->data = Version::VERSION;
     $system->save();
     // write config data
     App::$Properties->writeConfig('default', $cfg);
     // make routing configs based on preset property
     $routing = [];
     switch ($this->mainpage) {
         case 'news':
             $routing = ['Alias' => ['Front' => ['/' => '/content/list/news', '/about' => '/content/read/page/about-page']]];
             break;
         case 'about':
             $routing = ['Alias' => ['Front' => ['/' => '/content/read/page/about-page']]];
             break;
     }
     // write routing configurations
     App::$Properties->writeConfig('routing', $routing);
     // write installer lock
     File::write('/Private/Install/install.lock', 'Installation is locked!');
 }