public function do_submit() { session::set(true, 'admin'); _ajax::current()->redirect = '/cms/dashboard'; }
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'; }
/** * */ public function load_page() { $compiler = new compiler(); $options = ['ajax' => ajax, 'admin' => core::is_admin(), "dev" => dev, "debug" => debug]; try { $compiler_page = $compiler->load(uri, $options); } catch (\Exception $e) { if ($this->path) { if (!is_numeric($this->path[0])) { $this->module_name = $this->path[0]; } else { $this->module_name = 'pages'; } } else { $this->module_name = ini::get('site', 'default_module', 'pages'); } $compiler_page = new compiler_page(); if (class_exists('module\\' . $this->module_name . '\\controller')) { $class_name = 'module\\' . $this->module_name . '\\controller'; $this->module = new $class_name(); $this->module->__controller($this->path); $this->module->page = $this->pagination_page; if (!ajax) { $compiler_page->content = $this->module->view_object->get_page(); } else { $compiler_page->content = $this->module->view_object->get(); $compiler_page->ajax = ajax::current(); } $push_state = $this->module->get_push_state(); if ($push_state) { $push_state->data->actions = array_merge($push_state->data->actions, self::$push_state_ajax_calls); } $compiler_page->push_state = $push_state; } $compiler->save(uri, $compiler_page, $options); } if (!ajax) { if ($compiler_page->push_state) { $compiler_page->push_state->type = push_state::REPLACE; $compiler_page->push_state->get(); } echo $compiler_page->content; } else { ajax::set_current($compiler_page->ajax); if ($compiler_page->push_state) { ajax::push_state($compiler_page->push_state); } $class = new \ReflectionClass('\\classes\\ajax'); $function = $class->getMethod('inject'); $function->invokeArgs(null, $compiler_page->content); } }