diff --git a/src/installer/dbinstall_mysql.sql b/src/installer/dbinstall_mysql.sql index 6cfd429..03bc568 100644 --- a/src/installer/dbinstall_mysql.sql +++ b/src/installer/dbinstall_mysql.sql @@ -3,15 +3,15 @@ SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; -DROP TABLE IF EXISTS `tsw_config`; -CREATE TABLE `tsw_config` ( +DROP TABLE IF EXISTS `DBPREFIXconfig`; +CREATE TABLE `DBPREFIXconfig` ( `identifier` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `type` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'STRING' COMMENT 'STRING, INT, FLOAT, BOOL, JSON', `value` text COLLATE utf8mb4_unicode_ci, `user_editable` tinyint(1) NOT NULL DEFAULT '1' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tsw_config` (`identifier`, `type`, `value`, `user_editable`) VALUES +INSERT INTO `DBPREFIXconfig` (`identifier`, `type`, `value`, `user_editable`) VALUES ('cache_servericons', 'INT', '600', 1), ('onlinerecord_value', 'INT', '0', 0), ('onlinerecord_date', 'INT', '0', 0), @@ -36,8 +36,8 @@ INSERT INTO `tsw_config` (`identifier`, `type`, `value`, `user_editable`) VALUES ('imprint_enabled', 'BOOL', 'false', 1), ('imprint_url', 'STRING', 'imprint.php', 1); -DROP TABLE IF EXISTS `tsw_faq`; -CREATE TABLE `tsw_faq` ( +DROP TABLE IF EXISTS `DBPREFIXfaq`; +CREATE TABLE `DBPREFIXfaq` ( `faqid` int(11) NOT NULL, `langid` int(11) NOT NULL DEFAULT '1', `question` text COLLATE utf8mb4_unicode_ci NOT NULL, @@ -45,13 +45,13 @@ CREATE TABLE `tsw_faq` ( `lastmodify` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tsw_faq` (`faqid`, `langid`, `question`, `answer`, `lastmodify`) VALUES +INSERT INTO `DBPREFIXfaq` (`faqid`, `langid`, `question`, `answer`, `lastmodify`) VALUES (1, 1, 'What is the FAQ?', 'FAQ section allows you to show frequently asked questions and answers to them.', '2018-12-26 13:10:32'), (2, 1, 'How can I configure the FAQ?', 'An administrator can add, edit and remove questions in admin panel.', '2018-12-26 12:33:18'), (3, 1, 'Question 3', 'Answer 3 in HTML', '2018-12-26 13:10:32'); -DROP TABLE IF EXISTS `tsw_languages`; -CREATE TABLE `tsw_languages` ( +DROP TABLE IF EXISTS `DBPREFIXlanguages`; +CREATE TABLE `DBPREFIXlanguages` ( `langid` int(11) NOT NULL, `englishname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `nativename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -59,13 +59,13 @@ CREATE TABLE `tsw_languages` ( `isdefault` tinyint(1) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tsw_languages` (`langid`, `englishname`, `nativename`, `langcode`, `isdefault`) VALUES +INSERT INTO `DBPREFIXlanguages` (`langid`, `englishname`, `nativename`, `langcode`, `isdefault`) VALUES (1, 'English', 'English', 'en', 1), (2, 'English (US)', 'English (US)', 'en-us', 0), (3, 'Polish', 'Polski', 'pl', 0); -DROP TABLE IF EXISTS `tsw_news`; -CREATE TABLE `tsw_news` ( +DROP TABLE IF EXISTS `DBPREFIXnews`; +CREATE TABLE `DBPREFIXnews` ( `newsid` int(11) NOT NULL, `title` text COLLATE utf8mb4_unicode_ci NOT NULL, `langid` int(11) NOT NULL DEFAULT '1', @@ -74,11 +74,11 @@ CREATE TABLE `tsw_news` ( `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tsw_news` (`newsid`, `title`, `langid`, `added`, `edited`, `content`) VALUES +INSERT INTO `DBPREFIXnews` (`newsid`, `title`, `langid`, `added`, `edited`, `content`) VALUES (1, 'Welcome to ts-website!', 1, '2018-12-26 13:10:32', NULL, 'Hi there! If you are reading this, it means that TS-website has been installed successfully.
\r\nYou can login to your ACP to configure many parts of it.
\r\nNeed help? Join our Telegram group for support.\r\nHave a good day!'); -DROP TABLE IF EXISTS `tsw_translations`; -CREATE TABLE `tsw_translations` ( +DROP TABLE IF EXISTS `DBPREFIXtranslations`; +CREATE TABLE `DBPREFIXtranslations` ( `id` int(10) NOT NULL, `langid` int(10) NOT NULL, `identifier` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -86,7 +86,7 @@ CREATE TABLE `tsw_translations` ( `comment` text COLLATE utf8mb4_unicode_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tsw_translations` (`id`, `langid`, `identifier`, `value`, `comment`) VALUES +INSERT INTO `DBPREFIXtranslations` (`id`, `langid`, `identifier`, `value`, `comment`) VALUES (1, 1, 'AUTHORS', 'Wruczek ', 'Language authors'), (2, 3, 'AUTHORS', 'Wruczek ', NULL), (3, 1, 'COOKIEALERT_MESSAGE', 'Do you like cookies? 🍪 We use cookies to ensure you get the best experience on our website. Learn more', 'Remember to change link to a website in your language'), @@ -310,31 +310,31 @@ INSERT INTO `tsw_translations` (`id`, `langid`, `identifier`, `value`, `comment` (227, 3, 'ASSIGNER_SAVE_NO_CHANGE', 'Nie wprowadzono żadnych zmian', NULL); -ALTER TABLE `tsw_config` +ALTER TABLE `DBPREFIXconfig` ADD UNIQUE KEY `param` (`identifier`); -ALTER TABLE `tsw_faq` +ALTER TABLE `DBPREFIXfaq` ADD PRIMARY KEY (`faqid`); -ALTER TABLE `tsw_languages` +ALTER TABLE `DBPREFIXlanguages` ADD PRIMARY KEY (`langid`); -ALTER TABLE `tsw_news` +ALTER TABLE `DBPREFIXnews` ADD PRIMARY KEY (`newsid`); -ALTER TABLE `tsw_translations` +ALTER TABLE `DBPREFIXtranslations` ADD PRIMARY KEY (`id`); -ALTER TABLE `tsw_faq` +ALTER TABLE `DBPREFIXfaq` MODIFY `faqid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -ALTER TABLE `tsw_languages` +ALTER TABLE `DBPREFIXlanguages` MODIFY `langid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -ALTER TABLE `tsw_news` +ALTER TABLE `DBPREFIXnews` MODIFY `newsid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -ALTER TABLE `tsw_translations` +ALTER TABLE `DBPREFIXtranslations` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=228; COMMIT; diff --git a/src/installer/pages/2.php b/src/installer/pages/2.php index 8e0ea7a..0b5eab1 100644 --- a/src/installer/pages/2.php +++ b/src/installer/pages/2.php @@ -2,7 +2,8 @@ if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed"); if(!empty($_POST["allow-metrics-checkbox"])) { - setcookie("tsw_allow_metrics", "true", PHP_INT_MAX); + // set a 7 day cookie that tells us later to send the metrics + setcookie("tsw_allow_metrics", "true", time() + (86400 * 7)); } ?> diff --git a/src/installer/pages/3.php b/src/installer/pages/3.php index 236a563..6867e81 100644 --- a/src/installer/pages/3.php +++ b/src/installer/pages/3.php @@ -51,10 +51,10 @@ if (!empty($_POST)) { $errormessage = "Cannot read $sqlfile.sql file!"; } else { $sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery); - $sqlresult = $db->query($sqlquery); + $sqlresult = $db->pdo->exec($sqlquery); - if($sqlresult === false || !empty($db->error()[1])) { - throw new Exception($db->error()[2], $db->error()[1]); + if($sqlresult === false) { + throw new Exception("EXEC returned false"); } $phpcode = << - +
diff --git a/src/installer/pages/7.php b/src/installer/pages/7.php index 668de1b..1d900de 100644 --- a/src/installer/pages/7.php +++ b/src/installer/pages/7.php @@ -3,9 +3,9 @@ if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed"); use Wruczek\TSWebsite\Utils\TeamSpeakUtils; -//if(file_put_contents(__INSTALLER_LOCK_FILE, "WEBSITE_INSTALLED") === false) { -// die("Cannot write to private/INSTALLER_LOCK! Please check the file/directory permissions"); -//} +if(file_put_contents(__INSTALLER_LOCK_FILE, "WEBSITE_INSTALLED") === false) { + die("Cannot write to private/INSTALLER_LOCK! Please check the file/directory permissions"); +} // If we are allowed to collect metrics if(!empty($_COOKIE["tsw_allow_metrics"])) { @@ -64,20 +64,6 @@ if(!empty($_COOKIE["tsw_allow_metrics"])) { $response = curl_exec($ch); curl_close($ch); - //echo $response; - } else { // else try file_get_contents - $context = stream_context_create([ - "http" => [ - "method" => "POST", - "header" => "Content-type: application/json\r\n" . - "Accept: application/json\r\n" . - "Connection: close\r\n" . - "Content-length: " . strlen($data) . "\r\n", - "content" => $data - ] - ]); - - $response = file_get_contents($url, false, $context); //echo $response; } } diff --git a/src/private/templates/bans.latte b/src/private/templates/bans.latte index 564e2dc..2538805 100644 --- a/src/private/templates/bans.latte +++ b/src/private/templates/bans.latte @@ -13,7 +13,7 @@ {include "utils/data-problem.latte", message => __get("CANNOT_GET_DATA", "banlist")} {elseif empty($banlist)} {else}