"mysql", "server" => $dbhostname, "username" => $dbusername, "password" => $dbpassword, "database_name" => $dbname, "prefix" => $dbprefix, "port" => 3306, "charset" => "utf8mb4" ]; } else { // no sqlite support for now :( $errormessage = "Please fill in your database details"; // $usingMysql = false; // $dbconfig = [ // "database_type" => "sqlite", // "database_file" => __LOCALDB_FILE // ]; } // try to connect only if dbconfig is defined if (isset($dbconfig)) { try { $db = new Medoo($dbconfig); $sqlfiles = []; if ($usingMysql) { $sqlfiles = [ "dbinstall_mysql", "dbinstall_mysql_lang" ]; } else { // no other option yet } foreach ($sqlfiles as $file) { $sqlquery = file_get_contents(__DIR__ . "/../$file.sql"); if($sqlquery === false) { throw new Exception("Cannot read SQL file: $file.sql"); } $sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery); $sqlresult = $db->pdo->exec($sqlquery); if ($sqlresult === false) { throw new Exception("EXEC returned false"); } } // if all queries succeeded, create a config file and save connection info there $phpcode = << $value) { $confarray .= sprintf(' "%s" => "%s",' . PHP_EOL, addcslashes($key, '"'), addcslashes($value, '"')); } // Remove semicolon and new line from the end $confarray = rtrim($confarray, "," . PHP_EOL); // Replace all variables with sprintf $phpcode = sprintf($phpcode, date("d-m-Y H:i:s"), __TSWEBSITE_VERSION, __TSWEBSITE_COMMIT, $confarray); if(file_put_contents(__CONFIG_FILE, $phpcode) === false) { $errormessage = "Cannot write to " . __CONFIG_FILE . "! Please check the file/directory permissions"; } else { // redirect to next step on success header("Location: ?step=" . ($stepNumber + 1)); } } catch (Exception $e) { $errormessage = htmlspecialchars("Error " . $e->getCode() . ": " . $e->getMessage()); if($e->getCode() === 1045) { $errormessage .= '
You have entered wrong username and/or password. Please check it and try again.'; } if($e->getCode() === 1049) { $errormessage .= '
Please manually create database "' . htmlspecialchars($dbname) . '" and try again.'; } } } } ?>

Database details

">