From 054c9d8838e6d339f46d22f90655576fa1d1231d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 14 Feb 2015 15:12:02 +0100 Subject: (definitely) fixed utf8mb4 and check if user already exists in database before installing first user --- inc/poche/Database.class.php | 13 +++++++++---- inc/poche/config.inc.default.php | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'inc/poche') 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 { $this->handle = new PDO($db_path); break; case 'mysql': - $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; - $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - )); + if (MYSQL_USE_UTF8MB4) { + $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; + $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + )); + } else { + $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; + $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); + } break; case 'postgres': $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 @@ @define ('STORAGE_DB', 'poche'); @define ('STORAGE_USER', 'poche'); @define ('STORAGE_PASSWORD', 'poche'); +@define ('MYSQL_USE_UTF8MB4', FALSE); // This should be false unless you know what it is ################################################################################# # Do not trespass unless you know what you are doing -- cgit v1.2.3