aboutsummaryrefslogtreecommitdiffhomepage
path: root/install
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2015-02-14 15:12:02 +0100
committerThomas Citharel <tcit@tcit.fr>2015-02-14 15:12:02 +0100
commit054c9d8838e6d339f46d22f90655576fa1d1231d (patch)
treea4bf71980c55b60c843248b780c90c48e001ab30 /install
parent7780b8cb370625e27894636ecce555c8200b6108 (diff)
downloadwallabag-054c9d8838e6d339f46d22f90655576fa1d1231d.tar.gz
wallabag-054c9d8838e6d339f46d22f90655576fa1d1231d.tar.zst
wallabag-054c9d8838e6d339f46d22f90655576fa1d1231d.zip
(definitely) fixed utf8mb4 and check if user already exists in database before installing first user
Diffstat (limited to 'install')
-rwxr-xr-xinstall/index.php9
1 files changed, 9 insertions, 0 deletions
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);