mirror of
https://github.com/itflow-org/itflow
synced 2026-03-04 21:04:50 +00:00
Merge pull request #526 from wrongecho/setup-db-auth-helper
Add check of database credentials during setup
This commit is contained in:
@@ -782,6 +782,13 @@ if(isset($_POST['add_database'])){
|
|||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
$config_base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
|
$config_base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
|
||||||
|
|
||||||
|
// Test database connection before writing it to config.php
|
||||||
|
try {
|
||||||
|
mysqli_connect($host, $username, $password, $database);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
exit("<b>Database connection failed - please check and try again</b> <br> <br> $e");
|
||||||
|
}
|
||||||
|
|
||||||
$new_config = array();
|
$new_config = array();
|
||||||
$new_config[] = "<?php\n\n";
|
$new_config[] = "<?php\n\n";
|
||||||
$new_config[] = sprintf("\$dbhost = '%s';\n", addslashes($host));
|
$new_config[] = sprintf("\$dbhost = '%s';\n", addslashes($host));
|
||||||
|
|||||||
Reference in New Issue
Block a user