diff options
-rwxr-xr-x | install/index.php | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/install/index.php b/install/index.php index fc16af0c..77e50864 100755 --- a/install/index.php +++ b/install/index.php | |||
@@ -144,16 +144,43 @@ else if (isset($_POST['install'])) { | |||
144 | $sql_structure = file_get_contents('install/postgres.sql'); | 144 | $sql_structure = file_get_contents('install/postgres.sql'); |
145 | } | 145 | } |
146 | // create database structure | 146 | // create database structure |
147 | $query = $handle->exec($sql_structure); | 147 | if (!$handle) { |
148 | 148 | $continue = false; | |
149 | $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username)); | 149 | $errors[] = "Couldn't connect to your database server. Please check credentials."; |
150 | if (!empty($usertest)) { | 150 | } else { |
151 | $continue = false; | 151 | $query = $handle->exec($sql_structure); |
152 | $errors[] = "An user already exists with this username in database."; | 152 | |
153 | } | 153 | $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username)); |
154 | if (!empty($usertest)) { | ||
155 | $continue = false; | ||
156 | $errors[] = "An user already exists with this username in database."; | ||
157 | } | ||
158 | } | ||
154 | 159 | ||
155 | } catch (PDOException $e) { | 160 | } catch (PDOException $e) { |
156 | $errors[] = $e->getMessage(); | 161 | /* Error codes : |
162 | / 7 : PostgreSQL issues | ||
163 | / 1045 : Access denied to the user : user doesn't exists | ||
164 | / 1044 : Access denied to the user : user doesn't have the rights to connect to this database | ||
165 | / 2005 : Unknown database server | ||
166 | */ | ||
167 | switch ($e->getCode()) { | ||
168 | case 7: | ||
169 | $errors[] = "PostgreSQL has encountered an issue : " . $e->getMessage(); | ||
170 | break; | ||
171 | case 1045: | ||
172 | $errors[] = "The password for this user is incorrect, or this user doesn't exist."; | ||
173 | break; | ||
174 | case 1044: | ||
175 | $errors[] = "The user isn't allowed to use this database."; | ||
176 | break; | ||
177 | case 2005: | ||
178 | $errors[] = "The server can't be reached."; | ||
179 | break; | ||
180 | default: | ||
181 | $errors[] = "A error happened while connecting to your database : " . $e->getMessage(); | ||
182 | break; | ||
183 | } | ||
157 | $continue = false; | 184 | $continue = false; |
158 | } | 185 | } |
159 | } | 186 | } |