Commit 28f8aab3 authored by Tobias Reich's avatar Tobias Reich
Browse files

Fixed "No way to back out during database creation #195"

parent caa59c72
......@@ -47,6 +47,18 @@ var settings = {
}
// Creation failed
if (data.indexOf("Warning: Creation failed!")!==-1) {
buttons = [
["Retry", function() { setTimeout(settings.createConfig, 400) }],
["", function() {}]
];
modal.show("Creation Failed", "Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.", buttons, null, false);
return false;
}
// Could not create file
if (data.indexOf("Warning: Could not create file!")!==-1) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -72,8 +72,13 @@ class Database extends Module {
$database = new mysqli($host, $user, $password);
if ($database->connect_errno) return 'Warning: Connection failed!';
else {
# Check if user can create a database
$result = $database->query('CREATE DATABASE lychee_dbcheck');
if (!$result) return 'Warning: Creation failed!';
else $database->query('DROP DATABASE lychee_dbcheck');
# Save config.php
$config = "<?php
###
......@@ -92,12 +97,10 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
?>";
# Save file
if (file_put_contents(LYCHEE_CONFIG_FILE, $config)===false) return 'Warning: Could not create file!';
return true;
# Save file
if (file_put_contents(LYCHEE_CONFIG_FILE, $config)===false) return 'Warning: Could not create file!';
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment