aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Database.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-xinc/poche/Database.class.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 2c80b64b..f6ba4708 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -23,12 +23,18 @@ class Database {
23 { 23 {
24 switch (STORAGE) { 24 switch (STORAGE) {
25 case 'sqlite': 25 case 'sqlite':
26 // Check if /db is writeable
27 if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) {
28 die('An error occured: "db" directory must be writeable for your web server user!');
29 }
26 $db_path = 'sqlite:' . STORAGE_SQLITE; 30 $db_path = 'sqlite:' . STORAGE_SQLITE;
27 $this->handle = new PDO($db_path); 31 $this->handle = new PDO($db_path);
28 break; 32 break;
29 case 'mysql': 33 case 'mysql':
30 $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; 34 $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4';
31 $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); 35 $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array(
36 PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
37 ));
32 break; 38 break;
33 case 'postgres': 39 case 'postgres':
34 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; 40 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB;
@@ -113,10 +119,10 @@ class Database {
113 $query = $this->executeQuery($sql, array()); 119 $query = $this->executeQuery($sql, array());
114 } 120 }
115 121
116 public function install($login, $password) 122 public function install($login, $password, $email = '')
117 { 123 {
118 $sql = 'INSERT INTO users ( username, password, name, email) VALUES (?, ?, ?, ?)'; 124 $sql = 'INSERT INTO users ( username, password, name, email) VALUES (?, ?, ?, ?)';
119 $params = array($login, $password, $login, ' '); 125 $params = array($login, $password, $login, $email);
120 $query = $this->executeQuery($sql, $params); 126 $query = $this->executeQuery($sql, $params);
121 127
122 $sequence = ''; 128 $sequence = '';