diff --git a/.gitignore b/.gitignore
index bdc750e..6e24876 100755
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
.*.sw*
old
data/
+tmp/
diff --git a/TODO b/TODO
index 05a5b1d..a7e0429 100755
--- a/TODO
+++ b/TODO
@@ -5,10 +5,6 @@
* Refactor load method to avoir load_* methods !
* Test remember_me
-install.php :
-=============
-* TRUNCATE before CREATE TABLE in install.php
-
inc/Invoices.class.php :
========================
* Better way to store users in ? => reprendre cette partie
@@ -24,7 +20,6 @@ Tests :
* Remember me ?
* Add a bill
* Edit a bill
-* Change settings
Tests passed (quick tests) :
============================
@@ -32,3 +27,4 @@ Tests passed (quick tests) :
* Edit notice
* Add / Edit user
* Change password
+* Change settings
diff --git a/install.php b/install.php
index 77e36ee..f7c554d 100644
--- a/install.php
+++ b/install.php
@@ -26,16 +26,36 @@
//Create table "Users"
$db->query('CREATE TABLE IF NOT EXISTS '.$mysql_prefix.'Users (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, login VARCHAR(255), display_name VARCHAR(255), password VARCHAR(130), admin TINYINT(1)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci');
+
+ $count_users = $db->query('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = "'.$mysql_db.'" AND table_name = "'.$mysql_prefix.'"Users');
+ $count_users = $count_users->fetch();
+ if($count_users[0] > 0) {
+ $warning = 'Table '.$mysql_prefix.'Users already exists. Not doing anything on this table. Please check manually that this table is correct.
';
+ }
+
//Create table "Invoices"
$db->query('CREATE TABLE IF NOT EXISTS '.$mysql_prefix.'Invoices (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, date INT(11), users_in VARCHAR(255), buyer INT(11), amount FLOAT, what TEXT) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci');
- //Create table "Users_in_invoice"
+ $count_invoices = $db->query('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = "'.$mysql_db.'" AND table_name = "'.$mysql_prefix.'"Invoices');
+ $count_invoices = $count_users->fetch();
+ if($count_invoices[0] > 0) {
+ $warning .= 'Table '.$mysql_prefix.'Users already exists. Not doing anything on this table. Please check manually that this table is correct.
';
+ }
+
+
+ //Create table "Users_in_invoices"
$db->query('CREATE TABLE IF NOT EXISTS '.$mysql_prefix.'Users_in_invoices (invoice_id INT(11) NOT NULL, KEY invoice_id (invoice_id), user_id INT(11), KEY user_id (user_id), guests INT(11)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci');
+
+ $count_users_in_invoices = $db->query('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = "'.$mysql_db.'" AND table_name = "'.$mysql_prefix.'"Users_in_invoices');
+ $count_users_in_invoices = $count_users_in_invoices->fetch();
+ if($count_users_in_invoices[0] > 0) {
+ $warning .= 'Table '.$mysql_prefix.'Users_in_invoices already exists. Not doing anything on this table. Please check manually that this table is correct.
';
+ }
//Create table "Payback" - TODO
} catch (PDOException $e) {
- $error = 'Unable to connect to database, check your credentials and config.
Error message : '.$e->getMessage().'.';
+ $error = 'Unable to connect to database and create database, check your credentials and config.
Error message : '.$e->getMessage().'.';
}
if(!filter_var($_POST['email_webmaster'], FILTER_VALIDATE_EMAIL)) {
@@ -53,7 +73,7 @@
$salt = sprintf("$2a$%02d$", 10) . $salt; //prefix for blowfish
$config = "setPassword($admin->encrypt($_POST['admin_password']));
$admin->setAdmin(true);
$admin->save();
- header('location: index.php');
- exit();
+
+ if(empty($warning)) {
+ header('location: index.php');
+ exit();
+ }
+ else {
+ echo '
'.$warning.'Go to your instance.
'; + } } catch (Exception $e) { $erreur = 'An error occurred when inserting user in the database.You can also add a user.
-Id | -Login | -Display Name | -Is admin ? | -Edit | -Delete | -
---|---|---|---|---|---|
getId();?> | -getLogin();?> | -getDisplayName();?> | -getAdmin() ? "Yes" : "No";?> | -Edit | -getId() != $current_user->getId() ){ ?>Delete | -