From 287da38f69bd401a195c1a531fe7b145fab35f6a Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Mon, 3 Jun 2019 14:19:01 +0200 Subject: [PATCH 1/2] added utf8mb4 support in install script --- README.md | 2 ++ install/install_action.php | 18 +++++++++--------- install/install_adduser.php | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0109ddd..a8425ae 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ We Use BrowserStack for cross browser testing, as it provides full testing capab [ ![BrowserStack](https://live.browserstack.com/favicon.ico) BrowserStack](https://www.browserstack.com) +# Recomendations +We strongly recomment to use a ` utf8mb4 ` database collation, as it has the best compatibillity with smileys and other non standard symbols. (You can't tell the enduser, that they can't use smileys. Trust me, I tried.) # Requirements diff --git a/install/install_action.php b/install/install_action.php index 7fc2656..8912b2e 100644 --- a/install/install_action.php +++ b/install/install_action.php @@ -42,9 +42,9 @@ if (!is_null($connection->connect_error)) $CONFIG["installed"] = true; $CONFIG["host"] = $_POST['dbhost']; +$CONFIG["database"] = $_POST['database']; $CONFIG["username"] = $_POST['username']; $CONFIG["passwd"] = $_POST['passwd']; -$CONFIG["database"] = $_POST['database']; file_put_contents($_SESSION["docroot"].'/config/config.php', '"); @@ -54,14 +54,14 @@ CREATE TABLE `Einheit` ( `ID` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Standard` tinyint(1) NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `Einheit` ( `ID` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Standard` tinyint(1) NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `Einkauf` ( @@ -70,7 +70,7 @@ CREATE TABLE `Einkauf` ( `Einheit` int(11) NOT NULL DEFAULT '5', `Name` varchar(255) NOT NULL, `Erledigt` tinyint(1) NOT NULL DEFAULT '0' -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `users` ( @@ -81,14 +81,14 @@ CREATE TABLE `users` ( `password` char(128) NOT NULL, `salt` char(64) NOT NULL, `last_login` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `sessions` ( `session_id` varchar(255), `user` INT NOT NULL, `expires` datetime NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `Rezept` ( @@ -96,7 +96,7 @@ CREATE TABLE `Rezept` ( `Name` varchar(255) NOT NULL, `Dauer` int(11) NOT NULL, `Beschreibung` text NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `RezeptZutat` ( @@ -105,13 +105,13 @@ CREATE TABLE `RezeptZutat` ( `Menge` float NOT NULL, `Einheit` int(11) NOT NULL, `Zutat` int(11) NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE TABLE `Zutat` ( `ID` int(11) NOT NULL, `Name` varchar(255) NOT NULL -);"); +) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;"); array_push($SQLStatements, " CREATE VIEW `ViewEinkauf` AS select `Einkauf`.`ID` AS `ID`,`Einkauf`.`Anzahl` AS `Anzahl`,`Einheit`.`Name` AS `Einheit`,`Einkauf`.`Name` AS `Name`,`Einkauf`.`Erledigt` AS `Erledigt` from (`Einkauf` join `Einheit` on((`Einkauf`.`Einheit` = `Einheit`.`ID`))) ;"); diff --git a/install/install_adduser.php b/install/install_adduser.php index a4231d8..4b4b924 100644 --- a/install/install_adduser.php +++ b/install/install_adduser.php @@ -32,6 +32,6 @@ - + From 147d5edb222f89fb2cdeca317e6e166592acfb96 Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Mon, 3 Jun 2019 14:25:48 +0200 Subject: [PATCH 2/2] fixed error popup not showing up --- js/list.js | 3 +-- php/connect.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/list.js b/js/list.js index 89b02e1..814da20 100644 --- a/js/list.js +++ b/js/list.js @@ -102,15 +102,14 @@ function changeListItem(){ function checkItem() { var dataId = $(this).data("id"); + var dataIdSelector = (`[data-id='${dataId}']`); $.post({ url: "api/list/check", data: { - // function: "check", id: dataId, status: $(this).prop("checked") }, success: function () { - var dataIdSelector = (`[data-id='${dataId}']`); var color = $(dataIdSelector).data("color"); $(dataIdSelector).parent().parent().removeClass("bg-danger"); $(dataIdSelector).parent().parent().find(".dropdown-menu-button").removeClass("btn-danger"); diff --git a/php/connect.php b/php/connect.php index ebd09da..4260e5d 100644 --- a/php/connect.php +++ b/php/connect.php @@ -6,6 +6,7 @@ $passwd = $CONFIG['passwd'], $database = $CONFIG['database'] ); + $mysqli->set_charset("utf8"); if (!is_null($mysqli->connect_error)) { header("Location: /error/DBConnFailed");