diff options
-rwxr-xr-x | inc/poche/Database.class.php | 13 | ||||
-rwxr-xr-x | inc/poche/config.inc.default.php | 1 | ||||
-rwxr-xr-x | install/index.php | 9 |
3 files changed, 19 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 6bac0f5d..a987b7cc 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -31,10 +31,15 @@ class Database { | |||
31 | $this->handle = new PDO($db_path); | 31 | $this->handle = new PDO($db_path); |
32 | break; | 32 | break; |
33 | case 'mysql': | 33 | case 'mysql': |
34 | $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; | 34 | if (MYSQL_USE_UTF8MB4) { |
35 | $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( | 35 | $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; |
36 | PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', | 36 | $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( |
37 | )); | 37 | PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', |
38 | )); | ||
39 | } else { | ||
40 | $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; | ||
41 | $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); | ||
42 | } | ||
38 | break; | 43 | break; |
39 | case 'postgres': | 44 | case 'postgres': |
40 | $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; | 45 | $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; |
diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php index 6750383e..16b96f7e 100755 --- a/inc/poche/config.inc.default.php +++ b/inc/poche/config.inc.default.php | |||
@@ -20,6 +20,7 @@ | |||
20 | @define ('STORAGE_DB', 'poche'); | 20 | @define ('STORAGE_DB', 'poche'); |
21 | @define ('STORAGE_USER', 'poche'); | 21 | @define ('STORAGE_USER', 'poche'); |
22 | @define ('STORAGE_PASSWORD', 'poche'); | 22 | @define ('STORAGE_PASSWORD', 'poche'); |
23 | @define ('MYSQL_USE_UTF8MB4', FALSE); // This should be false unless you know what it is | ||
23 | 24 | ||
24 | ################################################################################# | 25 | ################################################################################# |
25 | # Do not trespass unless you know what you are doing | 26 | # Do not trespass unless you know what you are doing |
diff --git a/install/index.php b/install/index.php index 46638f8f..191c2574 100755 --- a/install/index.php +++ b/install/index.php | |||
@@ -83,6 +83,7 @@ else if (isset($_POST['install'])) { | |||
83 | $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password'], array( | 83 | $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password'], array( |
84 | PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', | 84 | PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', |
85 | )); | 85 | )); |
86 | $content = str_replace("define ('MYSQL_USE_UTF8MB4', FALSE);", "define ('MYSQL_USE_UTF8MB4', TRUE);", $content); | ||
86 | } else { // regular UTF8 | 87 | } else { // regular UTF8 |
87 | $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; | 88 | $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; |
88 | $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']); | 89 | $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']); |
@@ -126,6 +127,14 @@ else if (isset($_POST['install'])) { | |||
126 | } | 127 | } |
127 | } | 128 | } |
128 | } | 129 | } |
130 | |||
131 | $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username)); | ||
132 | if (!empty($usertest)) { | ||
133 | $continue = false; | ||
134 | $errors[] = "An user already exists with this username in database."; | ||
135 | } | ||
136 | |||
137 | |||
129 | if ($continue) { | 138 | if ($continue) { |
130 | $sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')"; | 139 | $sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')"; |
131 | $params = array($username, $salted_password, $username); | 140 | $params = array($username, $salted_password, $username); |