Fix database date: 0000-00-00 -> NULL

This commit is contained in:
Chocobozzz
2017-02-05 17:07:56 +01:00
parent 1aac22b46d
commit ab7f85b404
14 changed files with 125 additions and 28 deletions
+22 -15
View File
@@ -8,7 +8,7 @@
if(isset($_GET['logout'])){
session_destroy();
header("Location: .");
exit -1;
exit(-1);
}
// Get the configuration files ?
@@ -79,7 +79,7 @@
if($data && passEqual($_POST['admin_pass'], $data['admin_pass'])) {
$_SESSION['admin_id'] = $data['admin_id'];
header("Location: index.php?admin");
exit -1;
exit(-1);
}
else {
$error = true;
@@ -110,7 +110,7 @@
if(isInstalled($bdd) == true) {
printError('OpenVPN-admin is already installed. Redirection.');
header( "refresh:3;url=index.php?admin" );
exit -1;
exit(-1);
}
// If the user sent the installation form
@@ -122,18 +122,26 @@
if($admin_pass != $admin_repeat_pass) {
printError('The passwords do not correspond. Redirection.');
header( "refresh:3;url=index.php?installation" );
exit -1;
exit(-1);
}
// Create the tables or die
$sql_file = dirname(__FILE__) . '/sql/import.sql';
try {
$sql = file_get_contents($sql_file);
$bdd->exec($sql);
}
catch (PDOException $e) {
printError($e->getMessage());
exit -1;
// Create the initial tables
$migrations = getMigrationSchemas();
foreach ($migrations as $migration_value) {
$sql_file = dirname(__FILE__) . "/sql/schema-$migration_value.sql";
try {
$sql = file_get_contents($sql_file);
$bdd->exec($sql);
}
catch (PDOException $e) {
printError($e->getMessage());
exit(1);
}
unlink($sql_file);
// Update schema to the new value
updateSchema($bdd, $migration_value);
}
// Generate the hash
@@ -143,7 +151,6 @@
$req = $bdd->prepare('INSERT INTO admin (admin_id, admin_pass) VALUES (?, ?)');
$req->execute(array($admin_username, $hash_pass));
unlink($sql_file);
rmdir(dirname(__FILE__) . '/sql');
printSuccess('Well done, OpenVPN-Admin is installed. Redirection.');
header( "refresh:3;url=index.php?admin" );
@@ -154,7 +161,7 @@
require(dirname(__FILE__) . '/include/html/form/installation.php');
}
exit -1;
exit(-1);
}
// --------------- CONFIGURATION ---------------