Esempio n. 1
0
 public function do_submit()
 {
     db::connect_root();
     db::query('CREATE DATABASE IF NOT EXISTS `' . get::fn($this->username) . '`');
     db::query('USE mysql');
     if (db::select('user')->retrieve(['user'])->filter(['`user`=:user AND `host`=:host'], ['user' => $this->username, 'host' => '127.0.0.1'])->execute()->rowCount()) {
         db::query('CREATE USER \'' . get::fn($this->username) . '\'@\'127.0.0.1\' IDENTIFIED BY \'' . $this->password . '\'', [], true);
     }
     if (db::select('user')->retrieve(['user'])->filter(['`user`=:user AND `host`=:host'], ['user' => $this->username, 'host' => 'localhost'])->execute()->rowCount()) {
         db::query('CREATE USER \'' . get::fn($this->username) . '\'@\'localhost\' IDENTIFIED BY \'' . $this->password . '\'', [], true);
     }
     db::query('GRANT ALL PRIVILEGES ON `' . get::fn($this->username) . '`.* TO \'' . get::fn($this->username) . '\'@\'127.0.0.1\'', [], true);
     db::query('GRANT ALL PRIVILEGES ON `' . get::fn($this->username) . '`.* TO \'' . get::fn($this->username) . '\'@\'localhost\'', [], true);
     if (!is_dir(root . '/.conf')) {
         mkdir(root . '/.conf');
     }
     ini::save(root . '/.conf/config.ini', ['mysql' => ['server' => '127.0.0.1', 'username' => get::fn($this->username), 'password' => $this->password, 'database' => get::fn($this->username)], 'site' => ['title_tag' => $this->site_name]]);
     ini::reload();
     db::default_connection();
     $cms_builder = new \module\cms\object\cms_builder();
     $cms_builder->manage();
     $i = 0;
     do {
         if ($this->{'user_' . $i} && $this->{'password_' . $i}) {
             $user = new _cms_user();
             $user->title = $this->{'user_' . $i};
             $user->password = $this->{'password_' . $i};
             $user->ulid = $this->{'user_level_' . $i} ?: 1;
         }
         $i++;
     } while (isset($this->{'user_' . $i}));
     ajax::current()->redirect = '/cms/login';
 }