A few small improvements and fixes

This commit is contained in:
Wruczek 2018-12-27 19:51:27 +01:00
parent 628af52b54
commit 14e41b1900
6 changed files with 35 additions and 48 deletions

View File

@ -3,15 +3,15 @@ SET AUTOCOMMIT = 0;
START TRANSACTION; START TRANSACTION;
SET time_zone = "+00:00"; SET time_zone = "+00:00";
DROP TABLE IF EXISTS `tsw_config`; DROP TABLE IF EXISTS `DBPREFIXconfig`;
CREATE TABLE `tsw_config` ( CREATE TABLE `DBPREFIXconfig` (
`identifier` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `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', `type` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'STRING' COMMENT 'STRING, INT, FLOAT, BOOL, JSON',
`value` text COLLATE utf8mb4_unicode_ci, `value` text COLLATE utf8mb4_unicode_ci,
`user_editable` tinyint(1) NOT NULL DEFAULT '1' `user_editable` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) 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), ('cache_servericons', 'INT', '600', 1),
('onlinerecord_value', 'INT', '0', 0), ('onlinerecord_value', 'INT', '0', 0),
('onlinerecord_date', '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_enabled', 'BOOL', 'false', 1),
('imprint_url', 'STRING', 'imprint.php', 1); ('imprint_url', 'STRING', 'imprint.php', 1);
DROP TABLE IF EXISTS `tsw_faq`; DROP TABLE IF EXISTS `DBPREFIXfaq`;
CREATE TABLE `tsw_faq` ( CREATE TABLE `DBPREFIXfaq` (
`faqid` int(11) NOT NULL, `faqid` int(11) NOT NULL,
`langid` int(11) NOT NULL DEFAULT '1', `langid` int(11) NOT NULL DEFAULT '1',
`question` text COLLATE utf8mb4_unicode_ci NOT NULL, `question` text COLLATE utf8mb4_unicode_ci NOT NULL,
@ -45,13 +45,13 @@ CREATE TABLE `tsw_faq` (
`lastmodify` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP `lastmodify` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) 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?', '<b>FAQ</b> section allows you to show frequently asked questions and answers to them.', '2018-12-26 13:10:32'), (1, 1, 'What is the FAQ?', '<b>FAQ</b> 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 <a href=\"admin\">admin panel</a>.', '2018-12-26 12:33:18'), (2, 1, 'How can I configure the FAQ?', 'An administrator can add, edit and remove questions in <a href=\"admin\">admin panel</a>.', '2018-12-26 12:33:18'),
(3, 1, 'Question 3', 'Answer 3 in <b>HTML</b>', '2018-12-26 13:10:32'); (3, 1, 'Question 3', 'Answer 3 in <b>HTML</b>', '2018-12-26 13:10:32');
DROP TABLE IF EXISTS `tsw_languages`; DROP TABLE IF EXISTS `DBPREFIXlanguages`;
CREATE TABLE `tsw_languages` ( CREATE TABLE `DBPREFIXlanguages` (
`langid` int(11) NOT NULL, `langid` int(11) NOT NULL,
`englishname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `englishname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`nativename` 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' `isdefault` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) 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), (1, 'English', 'English', 'en', 1),
(2, 'English (US)', 'English (US)', 'en-us', 0), (2, 'English (US)', 'English (US)', 'en-us', 0),
(3, 'Polish', 'Polski', 'pl', 0); (3, 'Polish', 'Polski', 'pl', 0);
DROP TABLE IF EXISTS `tsw_news`; DROP TABLE IF EXISTS `DBPREFIXnews`;
CREATE TABLE `tsw_news` ( CREATE TABLE `DBPREFIXnews` (
`newsid` int(11) NOT NULL, `newsid` int(11) NOT NULL,
`title` text COLLATE utf8mb4_unicode_ci NOT NULL, `title` text COLLATE utf8mb4_unicode_ci NOT NULL,
`langid` int(11) NOT NULL DEFAULT '1', `langid` int(11) NOT NULL DEFAULT '1',
@ -74,11 +74,11 @@ CREATE TABLE `tsw_news` (
`content` longtext COLLATE utf8mb4_unicode_ci NOT NULL `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) 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, '<b>Hi there!</b> If you are reading this, it means that TS-website has been installed successfully.<br>\r\nYou can login to your <a href=\"admin\">ACP</a> to configure many parts of it.<br>\r\nNeed help? Join our <a href=\"https://t.me/tswebsite\" target=\"_blank\">Telegram group</a> for support.\r\nHave a good day!'); (1, 'Welcome to ts-website!', 1, '2018-12-26 13:10:32', NULL, '<b>Hi there!</b> If you are reading this, it means that TS-website has been installed successfully.<br>\r\nYou can login to your <a href=\"admin\">ACP</a> to configure many parts of it.<br>\r\nNeed help? Join our <a href=\"https://t.me/tswebsite\" target=\"_blank\">Telegram group</a> for support.\r\nHave a good day!');
DROP TABLE IF EXISTS `tsw_translations`; DROP TABLE IF EXISTS `DBPREFIXtranslations`;
CREATE TABLE `tsw_translations` ( CREATE TABLE `DBPREFIXtranslations` (
`id` int(10) NOT NULL, `id` int(10) NOT NULL,
`langid` int(10) NOT NULL, `langid` int(10) NOT NULL,
`identifier` varchar(128) COLLATE utf8mb4_unicode_ci 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 `comment` text COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 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 <wruczekk@gmail.com>', 'Language authors'), (1, 1, 'AUTHORS', 'Wruczek <wruczekk@gmail.com>', 'Language authors'),
(2, 3, 'AUTHORS', 'Wruczek <wruczekk@gmail.com>', NULL), (2, 3, 'AUTHORS', 'Wruczek <wruczekk@gmail.com>', NULL),
(3, 1, 'COOKIEALERT_MESSAGE', '<b>Do you like cookies?</b> &#x1F36A; We use cookies to ensure you get the best experience on our website. <a href=\"http://cookiesandyou.com/\" target=\"_blank\">Learn more</a>', 'Remember to change link to a website in your language'), (3, 1, 'COOKIEALERT_MESSAGE', '<b>Do you like cookies?</b> &#x1F36A; We use cookies to ensure you get the best experience on our website. <a href=\"http://cookiesandyou.com/\" target=\"_blank\">Learn more</a>', '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); (227, 3, 'ASSIGNER_SAVE_NO_CHANGE', 'Nie wprowadzono żadnych zmian', NULL);
ALTER TABLE `tsw_config` ALTER TABLE `DBPREFIXconfig`
ADD UNIQUE KEY `param` (`identifier`); ADD UNIQUE KEY `param` (`identifier`);
ALTER TABLE `tsw_faq` ALTER TABLE `DBPREFIXfaq`
ADD PRIMARY KEY (`faqid`); ADD PRIMARY KEY (`faqid`);
ALTER TABLE `tsw_languages` ALTER TABLE `DBPREFIXlanguages`
ADD PRIMARY KEY (`langid`); ADD PRIMARY KEY (`langid`);
ALTER TABLE `tsw_news` ALTER TABLE `DBPREFIXnews`
ADD PRIMARY KEY (`newsid`); ADD PRIMARY KEY (`newsid`);
ALTER TABLE `tsw_translations` ALTER TABLE `DBPREFIXtranslations`
ADD PRIMARY KEY (`id`); ADD PRIMARY KEY (`id`);
ALTER TABLE `tsw_faq` ALTER TABLE `DBPREFIXfaq`
MODIFY `faqid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; 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; 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; 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; MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=228;
COMMIT; COMMIT;

View File

@ -2,7 +2,8 @@
if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed"); if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed");
if(!empty($_POST["allow-metrics-checkbox"])) { 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));
} }
?> ?>

View File

@ -51,10 +51,10 @@ if (!empty($_POST)) {
$errormessage = "Cannot read $sqlfile.sql file!"; $errormessage = "Cannot read $sqlfile.sql file!";
} else { } else {
$sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery); $sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery);
$sqlresult = $db->query($sqlquery); $sqlresult = $db->pdo->exec($sqlquery);
if($sqlresult === false || !empty($db->error()[1])) { if($sqlresult === false) {
throw new Exception($db->error()[2], $db->error()[1]); throw new Exception("EXEC returned false");
} }
$phpcode = <<<EOT $phpcode = <<<EOT
@ -159,7 +159,7 @@ EOT;
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span> <span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
</div> </div>
<input class="form-control" name="dbpassword" placeholder="Password" autocomplete="off"> <input type="password" class="form-control" name="dbpassword" placeholder="Password" autocomplete="off">
</div> </div>
<div class="input-group mb-2"> <div class="input-group mb-2">

View File

@ -3,9 +3,9 @@ if(!defined("__TSWEBSITE_VERSION")) die("Direct access not allowed");
use Wruczek\TSWebsite\Utils\TeamSpeakUtils; use Wruczek\TSWebsite\Utils\TeamSpeakUtils;
//if(file_put_contents(__INSTALLER_LOCK_FILE, "WEBSITE_INSTALLED") === false) { if(file_put_contents(__INSTALLER_LOCK_FILE, "WEBSITE_INSTALLED") === false) {
// die("Cannot write to <code>private/INSTALLER_LOCK</code>! Please check the file/directory permissions"); die("Cannot write to <code>private/INSTALLER_LOCK</code>! Please check the file/directory permissions");
//} }
// If we are allowed to collect metrics // If we are allowed to collect metrics
if(!empty($_COOKIE["tsw_allow_metrics"])) { if(!empty($_COOKIE["tsw_allow_metrics"])) {
@ -64,20 +64,6 @@ if(!empty($_COOKIE["tsw_allow_metrics"])) {
$response = curl_exec($ch); $response = curl_exec($ch);
curl_close($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; //echo $response;
} }
} }

View File

@ -13,7 +13,7 @@
{include "utils/data-problem.latte", message => __get("CANNOT_GET_DATA", "banlist")} {include "utils/data-problem.latte", message => __get("CANNOT_GET_DATA", "banlist")}
{elseif empty($banlist)} {elseif empty($banlist)}
<div class="alert alert-info text-center" role="alert"> <div class="alert alert-info text-center" role="alert">
{_"BANS_EMPTY"} <i class="fas fa-info-circle"></i>{_"BANS_EMPTY"}
</div> </div>
{else} {else}
<div id="responsive-table-details-tip" class="alert alert-info alert-dismissible fade show" style="display: none" role="alert"> <div id="responsive-table-details-tip" class="alert alert-info alert-dismissible fade show" style="display: none" role="alert">

View File

@ -56,7 +56,7 @@ $navActiveIndex = isset($navActiveIndex) ? (int) $navActiveIndex : 0;
<nav id="main-navbar" class="navbar navbar-expand-lg fixed-top nav-fix-scroll navbar-dark bg-primary"> <nav id="main-navbar" class="navbar navbar-expand-lg fixed-top nav-fix-scroll navbar-dark bg-primary">
<div class="container"> <div class="container">
<a class="navbar-brand" href="."> <a class="navbar-brand" href=".">
<img src="img/icon/defaulticon-64.png" width="32" height="32" class="d-inline-block align-top mr-1" alt="Brand image"> <img src="img/icons/defaulticon-64.png" width="32" height="32" class="d-inline-block align-top mr-1" alt="Brand image">
{$config["nav_brand"]} {$config["nav_brand"]}
</a> </a>