/** * @param array $args */ public function config(array $args = array()) { $data['guessUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . dirname(str_ireplace('installer/', '', $_SERVER['REQUEST_URI'])); if (isset($_POST['submit'])) { $dbconfig = array('db' => array('driver' => $_POST['dbtype'], 'host' => $_POST['dbhost'], 'database' => $_POST['dbname'], 'username' => $_POST['dbuser'], 'password' => $_POST['dbpass'], 'port' => '', 'prefix' => $_POST['dbpref'])); $gameTheme = \Config::get('site.theme'); \Config::destroyAll(); \Config::set($dbconfig); try { $installer = new Installer($this->container); foreach (glob(__DIR__ . '/Config/Sql/*.sql') as $query) { $installer->runSqlFile($query, $_POST['dbpref']); } } catch (\Exception $e) { die($e->getMessage()); \View::set("fail", 'Please check your database configurations'); $error = 1; } if (!isset($error)) { $dbtype = $_POST['dbtype']; $dbhost = $_POST['dbhost']; $dbname = $_POST['dbname']; $dbuser = $_POST['dbuser']; $dbpass = $_POST['dbpass']; $dbpref = $_POST['dbpref']; $gamename = $_POST['gamename']; $gameurl = $_POST['gameurl']; /* Generate configuration file */ $config = <<<CONFIG <?php /** * Database Configuration */ \\Config::set('db', array( \t'driver' => '{$dbtype}', \t'host'\t => '{$dbhost}', \t'database' => '{$dbname}', \t'username' => '{$dbuser}', \t'password' => '{$dbpass}', \t'port' => '', \t'prefix' => '{$dbpref}' )); CONFIG; $fh = fopen('config/config.php', 'w+'); fwrite($fh, $config); fclose($fh); \App::loadHooks(); \App::loadModels(); /* Generate Settings */ $settings = \App::getModel('setting'); $settings->update(2, $gamename); $settings->update(3, $gameurl); $settings->update(4, $gameTheme); $settings->buildCache(); $settings->updateConfig(); session_unset(); $routes = $this->app->getModel('route'); try { $routes->buildCache(); } catch (\Exception $e) { printf('<div><strong>ezRPG Exception</strong></div>%s<pre>', $e->getMessage()); var_dump($e); die; } header("location: {$gameurl}/Installer/admin"); } } \View::setTemplate('config.twig'); \View::set('dbhost', !isset($_POST['dbhost']) ? '127.0.0.1' : $_POST['dbhost']); \View::set('dbuser', !isset($_POST['dbuser']) ? '' : $_POST['dbuser']); \View::set('dbname', !isset($_POST['dbname']) ? '' : $_POST['dbname']); \View::set('dbpref', !isset($_POST['dbpref']) ? '' : $_POST['dbpref']); \View::set('dbtype', !isset($_POST['dbtype']) ? '' : $_POST['dbtype']); \View::set('gamename', !isset($_POST['gamename']) ? 'lyraEngine' : $_POST['gamename']); \View::set('gameurl', !isset($_POST['gameurl']) ? $data['guessUrl'] : $_POST['gameurl']); }
public function updateConfig() { $set = $this->getAll(); $db = \Config::get('db'); \Config::destroyAll(); \Config::set($set); \Config::set('db', $db); }