Another try to make sure config.php is written before going further
This commit is contained in:
59
setup.php
59
setup.php
@@ -803,39 +803,42 @@ if (isset($_POST['add_database'])) {
|
|||||||
$new_config .= "\$repo_branch = 'master';\n";
|
$new_config .= "\$repo_branch = 'master';\n";
|
||||||
$new_config .= "\$installation_id = '$installation_id';\n";
|
$new_config .= "\$installation_id = '$installation_id';\n";
|
||||||
|
|
||||||
if (file_put_contents("config.php", $new_config) === false) {
|
if (file_put_contents("config.php", $new_config) !== false && file_exists('config.php')) {
|
||||||
$_SESSION['alert_message'] = "Failed to write the config.php file to the filesystem. Please input the database information again.";
|
|
||||||
header("Location: setup.php?database");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
include("config.php");
|
include("config.php");
|
||||||
|
|
||||||
// Name of the file
|
// Name of the file
|
||||||
$filename = 'db.sql';
|
$filename = 'db.sql';
|
||||||
// Temporary variable, used to store current query
|
// Temporary variable, used to store current query
|
||||||
$templine = '';
|
$templine = '';
|
||||||
// Read in entire file
|
// Read in entire file
|
||||||
$lines = file($filename);
|
$lines = file($filename);
|
||||||
// Loop through each line
|
// Loop through each line
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
// Skip it if it's a comment
|
// Skip it if it's a comment
|
||||||
if (substr($line, 0, 2) == '--' || $line == '')
|
if (substr($line, 0, 2) == '--' || $line == '')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Add this line to the current segment
|
// Add this line to the current segment
|
||||||
$templine .= $line;
|
$templine .= $line;
|
||||||
// If it has a semicolon at the end, it's the end of the query
|
// If it has a semicolon at the end, it's the end of the query
|
||||||
if (substr(trim($line), -1, 1) == ';') {
|
if (substr(trim($line), -1, 1) == ';') {
|
||||||
// Perform the query
|
// Perform the query
|
||||||
mysqli_query($mysqli, $templine);
|
mysqli_query($mysqli, $templine);
|
||||||
// Reset temp variable to empty
|
// Reset temp variable to empty
|
||||||
$templine = '';
|
$templine = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Database successfully added, now lets add a user.";
|
$_SESSION['alert_message'] = "Database successfully added, now lets add a user.";
|
||||||
header("Location: setup.php?user");
|
header("Location: setup.php?user");
|
||||||
|
exit;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// There was an error writing the file
|
||||||
|
// Display an error message and redirect to the setup page
|
||||||
|
$_SESSION['alert_message'] = "Did not successfully write the config.php file to the filesystem, Please Input the database information again.";
|
||||||
|
header("Location: setup.php?database");
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user