aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Database.class.php8
-rwxr-xr-xinstall/index.php6
-rw-r--r--install/mysql.sql12
3 files changed, 15 insertions, 11 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index dfd7ae34..7aaf9740 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -24,15 +24,17 @@ class Database {
24 switch (STORAGE) { 24 switch (STORAGE) {
25 case 'sqlite': 25 case 'sqlite':
26 // Check if /db is writeable 26 // Check if /db is writeable
27 if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) { 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!'); 28 die('An error occured: "db" directory must be writeable for your web server user!');
29 } 29 }
30 $db_path = 'sqlite:' . STORAGE_SQLITE; 30 $db_path = 'sqlite:' . STORAGE_SQLITE;
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; 34 $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4';
35 $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 ));
36 break; 38 break;
37 case 'postgres': 39 case 'postgres':
38 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; 40 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB;
diff --git a/install/index.php b/install/index.php
index 1ae782a2..2b080c16 100755
--- a/install/index.php
+++ b/install/index.php
@@ -101,12 +101,14 @@ else if (isset($_POST['install'])) {
101 $content = file_get_contents('inc/poche/config.inc.php'); 101 $content = file_get_contents('inc/poche/config.inc.php');
102 102
103 if ($_POST['db_engine'] == 'mysql') { 103 if ($_POST['db_engine'] == 'mysql') {
104 $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; 104 $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database'] . ';charset=utf8mb4';
105 $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['mysql_server']."');", $content); 105 $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['mysql_server']."');", $content);
106 $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['mysql_database']."');", $content); 106 $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['mysql_database']."');", $content);
107 $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['mysql_user']."');", $content); 107 $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['mysql_user']."');", $content);
108 $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['mysql_password']."');", $content); 108 $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['mysql_password']."');", $content);
109 $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']); 109 $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password'], array(
110 PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
111 ));
110 112
111 $sql_structure = file_get_contents('install/mysql.sql'); 113 $sql_structure = file_get_contents('install/mysql.sql');
112 } 114 }
diff --git a/install/mysql.sql b/install/mysql.sql
index de5640e4..1b65cd35 100644
--- a/install/mysql.sql
+++ b/install/mysql.sql
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS `config` (
3 `name` varchar(255) NOT NULL, 3 `name` varchar(255) NOT NULL,
4 `value` varchar(255) NOT NULL, 4 `value` varchar(255) NOT NULL,
5 PRIMARY KEY (`id`) 5 PRIMARY KEY (`id`)
6) ENGINE=InnoDB DEFAULT CHARSET=utf8; 6) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
7 7
8CREATE TABLE IF NOT EXISTS `entries` ( 8CREATE TABLE IF NOT EXISTS `entries` (
9 `id` int(11) NOT NULL AUTO_INCREMENT, 9 `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `entries` (
14 `content` blob NOT NULL, 14 `content` blob NOT NULL,
15 `user_id` int(11) NOT NULL, 15 `user_id` int(11) NOT NULL,
16 PRIMARY KEY (`id`) 16 PRIMARY KEY (`id`)
17) ENGINE=InnoDB DEFAULT CHARSET=utf8; 17) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
18 18
19CREATE TABLE IF NOT EXISTS `users` ( 19CREATE TABLE IF NOT EXISTS `users` (
20 `id` int(11) NOT NULL AUTO_INCREMENT, 20 `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS `users` (
23 `name` varchar(255) NOT NULL, 23 `name` varchar(255) NOT NULL,
24 `email` varchar(255) NOT NULL, 24 `email` varchar(255) NOT NULL,
25 PRIMARY KEY (`id`) 25 PRIMARY KEY (`id`)
26) ENGINE=InnoDB DEFAULT CHARSET=utf8; 26) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
27 27
28CREATE TABLE IF NOT EXISTS `users_config` ( 28CREATE TABLE IF NOT EXISTS `users_config` (
29 `id` int(11) NOT NULL AUTO_INCREMENT, 29 `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -31,13 +31,13 @@ CREATE TABLE IF NOT EXISTS `users_config` (
31 `name` varchar(255) NOT NULL, 31 `name` varchar(255) NOT NULL,
32 `value` varchar(255) NOT NULL, 32 `value` varchar(255) NOT NULL,
33 PRIMARY KEY (`id`) 33 PRIMARY KEY (`id`)
34) ENGINE=InnoDB DEFAULT CHARSET=utf8; 34) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
35 35
36CREATE TABLE IF NOT EXISTS `tags` ( 36CREATE TABLE IF NOT EXISTS `tags` (
37 `id` int(11) NOT NULL AUTO_INCREMENT, 37 `id` int(11) NOT NULL AUTO_INCREMENT,
38 `value` varchar(255) NOT NULL, 38 `value` varchar(255) NOT NULL,
39 PRIMARY KEY (`id`) 39 PRIMARY KEY (`id`)
40) ENGINE=InnoDB DEFAULT CHARSET=utf8; 40) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
41 41
42CREATE TABLE IF NOT EXISTS `tags_entries` ( 42CREATE TABLE IF NOT EXISTS `tags_entries` (
43 `id` int(11) NOT NULL AUTO_INCREMENT, 43 `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -46,4 +46,4 @@ CREATE TABLE IF NOT EXISTS `tags_entries` (
46 FOREIGN KEY(entry_id) REFERENCES entries(id) ON DELETE CASCADE, 46 FOREIGN KEY(entry_id) REFERENCES entries(id) ON DELETE CASCADE,
47 FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE, 47 FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE,
48 PRIMARY KEY (`id`) 48 PRIMARY KEY (`id`)
49) ENGINE=InnoDB DEFAULT CHARSET=utf8; 49) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;