/** * We call it again, so that the user had already went through the First Step */ if (\Lobby\Install::step1() === false) { // The stuff mentioned in step 1 hasn't been done } elseif (isset($_POST['submit'])) { $dbhost = \H::input('dbhost', "POST"); $dbport = \H::input('dbport', "POST"); $dbname = \H::input('dbname', "POST"); $username = \H::input('dbusername', "POST"); $password = \H::input('dbpassword', "POST"); $prefix = \H::input('prefix', "POST"); /** * We give the database config to the Install Class */ \Lobby\Install::dbConfig(array("host" => $dbhost, "port" => $dbport, "dbname" => $dbname, "username" => $username, "password" => $password, "prefix" => $prefix)); /** * First, check if prefix is valid * Check if connection to database can be established using the credentials given by the user */ if ($prefix == "" || preg_match("/[^0-9,a-z,A-Z,\$,_]+/i", $prefix) != 0 || strlen($prefix) > 50) { ser("Error", "A Prefix should only contain basic Latin letters, digits 0-9, dollar, underscore and shouldn't exceed 50 characters. <a href='install.php?step=2'>Try Again</a>"); } elseif (\Lobby\Install::checkDatabaseConnection() !== false) { /** * Make the Config File */ \Lobby\Install::makeConfigFile(); /** * Create Tables */ if (\Lobby\Install::makeDatabase($prefix)) {
echo ser("Unable To Create Database Tables", "Are there any tables with the same name ? Or Does the user have the permissions to create tables ? Error :<blockquote>" . \Lobby\Install::$error . "</blockquote>" . \Lobby::l("/admin/install.php?step=2" . CSRF::getParam(), "Try Again", "class='btn'")); } } } } } else { $db_loc = $_POST['db_location']; $db_create = \Lobby\Install::createSQLiteDB($db_loc); /** * Prefix is "l_" and can't be changed */ if ($db_create && \Lobby\Install::makeDatabase("l_", "sqlite")) { /** * We give the database config to the Install Class */ \Lobby\Install::dbConfig(array("path" => str_replace(L_DIR, "", $db_loc), "prefix" => "l_")); /** * Make the Config File */ \Lobby\Install::makeConfigFile("sqlite"); /** * Enable app lEdit */ \Lobby::$installed = true; \Lobby\DB::__constructStatic(); $App = new \Lobby\Apps("ledit"); $App->enableApp(); echo sss("Success", "Database and <b>config.php</b> file was successfully created."); echo '<cl/><a href="?step=4' . CSRF::getParam() . '" class="btn">Proceed</a>'; } else { echo ser("Couldn't Make SQLite Database", "I was unable to make the database. Error :<blockquote>" . \Lobby\Install::$error . "</blockquote> <cl/>" . \Lobby::l("/admin/install.php?step=3&db_type=sqlite" . CSRF::getParam(), "Try Again", "class='btn'"));