diff --git a/assets/less/classes/chat-quote.less b/assets/less/classes/chat-quote.less deleted file mode 100644 index 81e67301..00000000 --- a/assets/less/classes/chat-quote.less +++ /dev/null @@ -1,38 +0,0 @@ -.chat-quote { - display: block; - background-color: var(--accent-colour); - border: 1px solid var(--accent-colour); - color: #fff; - margin: 2px; - - &__line { - display: flex; - flex-wrap: wrap; - padding: 1px 4px; - background-color: fade(#000, 80%); - - &:nth-child(odd) { - background-color: fade(#000, 90%); - } - } - - &__time { - font-size: .8em; - margin: 0 4px 0 2px; - } - - &__username { - color: var(--user-colour); - font-weight: 700; - text-decoration: none; - - &[href]:hover { - text-decoration: underline; - } - } - - &__text { - width: 100%; - flex: 1 0 auto; - } -} diff --git a/assets/less/main.less b/assets/less/main.less index 649d8304..ea054932 100644 --- a/assets/less/main.less +++ b/assets/less/main.less @@ -120,7 +120,6 @@ html { @import "classes/index"; @import "classes/permissions"; @import "classes/auth"; -@import "classes/chat-quote"; // Manage @import "classes/manage/manage"; diff --git a/database/2019_01_10_225122_nuke_chat_quotes.php b/database/2019_01_10_225122_nuke_chat_quotes.php new file mode 100644 index 00000000..9be5c68d --- /dev/null +++ b/database/2019_01_10_225122_nuke_chat_quotes.php @@ -0,0 +1,16 @@ + $stats, 'latest_user' => $latestUser, 'online_users' => $onlineUsers, - 'chat_quote' => chat_quotes_random(), 'featured_changelog' => $changelog, 'featured_news' => $news, ]); diff --git a/public/manage/index.php b/public/manage/index.php index 33dfd4c9..83cf9052 100644 --- a/public/manage/index.php +++ b/public/manage/index.php @@ -32,58 +32,6 @@ switch ($_GET['v'] ?? null) { ]); break; - case 'quotes': - if (!perms_check($generalPerms, MSZ_PERM_GENERAL_VIEW_LOGS)) { - echo render_error(403); - break; - } - - $setId = (int)($_GET['s'] ?? ''); - $quoteId = (int)($_GET['q'] ?? ''); - - if (!empty($_POST['quote']) && csrf_verify('add_quote', $_POST['csrf'] ?? '')) { - $quoteTime = strtotime($_POST['quote']['time'] ?? ''); - $parentId = empty($_POST['quote']['parent']) ? null : (int)($_POST['quote']['parent']); - - $quoteId = chat_quotes_add( - $_POST['quote']['text'] ?? null, - $_POST['quote']['user']['name'] ?? null, - empty($_POST['quote']['user']['colour']) ? MSZ_COLOUR_INHERIT : (int)($_POST['quote']['user']['colour']), - empty($_POST['quote']['user']['id']) ? null : (int)($_POST['quote']['user']['id']), - empty($_POST['quote']['parent']) || $_POST['quote']['id'] == $parentId ? null : (int)($_POST['quote']['parent']), - $quoteTime ? $quoteTime : null, - empty($_POST['quote']['id']) ? null : (int)($_POST['quote']['id']) - ); - - header('Location: ?v=quotes' . ($setId ? '&s=' . $setId : '&q=' . $quoteId)); - break; - } - - if ($quoteId) { - tpl_vars([ - 'current_quote' => chat_quotes_single($quoteId), - 'quote_parent' => $setId, - ]); - } elseif ($setId > 0) { - tpl_var('quote_set', chat_quotes_set($setId)); - } - - $quotesPagination = pagination_create(chat_quotes_count(true), 15); - $quotesOffset = pagination_offset($quotesPagination, pagination_param()); - - if (!pagination_is_valid_offset($quotesOffset)) { - echo render_error(404); - break; - } - - $quotes = chat_quotes_parents($quotesPagination['offset']); - - echo tpl_render('manage.general.quotes', [ - 'quote_parents' => $quotes, - 'quotes_pagination' => $quotesPagination, - ]); - break; - case 'emoticons': if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) { echo render_error(403); diff --git a/src/chat_quotes.php b/src/chat_quotes.php deleted file mode 100644 index 2410e82a..00000000 --- a/src/chat_quotes.php +++ /dev/null @@ -1,124 +0,0 @@ - 0) { - $insert = db_prepare(' - UPDATE `msz_chat_quotes` - SET `quote_parent` = :parent, - `quote_user_id` = :user_id, - `quote_username` = :username, - `quote_user_colour` = :user_colour, - `quote_timestamp` = :time, - `quote_text` = :text - WHERE `quote_id` = :id - '); - $insert->bindValue('id', $quoteId); - } else { - $insert = db_prepare(' - INSERT INTO `msz_chat_quotes` ( - `quote_parent`, `quote_user_id`, `quote_username`, - `quote_user_colour`, `quote_timestamp`, `quote_text` - ) VALUES ( - :parent, :user_id, :username, :user_colour, :time, :text - ) - '); - } - - $insert->bindValue('parent', $parent < 1 ? null : $parent); - $insert->bindValue('user_id', $userId < 1 ? null : $userId); - $insert->bindValue('username', $username); - $insert->bindValue('user_colour', $colour); - $insert->bindValue('time', date('Y-m-d H:i:s', $time < 1 ? time() : $time)); - $insert->bindValue('text', $text); - - return $insert->execute() ? db_last_insert_id() : 0; -} - -function chat_quotes_count(bool $parentsOnly = false): int -{ - return db_query(sprintf(' - SELECT COUNT(`quote_id`) - FROM `msz_chat_quotes` - %s - ', $parentsOnly ? 'WHERE `quote_parent` IS NULL' : ''))->fetchColumn(); -} - -function chat_quotes_single(int $quoteId): array -{ - if ($quoteId < 1) { - return []; - } - - $getSingle = db_prepare(' - SELECT `quote_id`, `quote_parent`, `quote_user_id`, `quote_username`, `quote_user_colour`, `quote_timestamp`, `quote_text` - FROM `msz_chat_quotes` - WHERE `quote_id` = :quote - '); - $getSingle->bindValue('quote', $quoteId); - return db_fetch($getSingle); -} - -function chat_quotes_parents(int $offset = 0, int $take = MSZ_CHAT_QUOTES_TAKE): array -{ - $getAll = $take < 1 || $offset < 0; - - $getParents = db_prepare(sprintf(' - SELECT `quote_id`, `quote_user_id`, `quote_username`, `quote_user_colour`, `quote_timestamp`, `quote_text` - FROM `msz_chat_quotes` - WHERE `quote_parent` IS NULL - ORDER BY `quote_id` DESC - %s - ', $getAll ? '' : 'LIMIT :offset, :take')); - - if (!$getAll) { - $getParents->bindValue('take', $take); - $getParents->bindValue('offset', $offset); - } - - return db_fetch_all($getParents); -} - -function chat_quotes_set(int $parentId): array -{ - $getParent = db_prepare(' - SELECT `quote_id`, `quote_user_id`, `quote_username`, `quote_user_colour`, `quote_timestamp`, `quote_text` - FROM `msz_chat_quotes` - WHERE `quote_parent` IS NULL - AND `quote_id` = :parent - '); - $getParent->bindValue('parent', $parentId); - $parent = db_fetch($getParent); - return $parent ? array_merge([$parent], chat_quotes_children($parent['quote_id'])) : []; -} - -function chat_quotes_children(int $parentId): array -{ - $getChildren = db_prepare(' - SELECT `quote_id`, `quote_user_id`, `quote_username`, `quote_user_colour`, `quote_timestamp`, `quote_text` - FROM `msz_chat_quotes` - WHERE `quote_parent` = :parent - '); - $getChildren->bindValue('parent', $parentId); - return db_fetch($getChildren); -} - -function chat_quotes_random(): array -{ - $parent = db_query(' - SELECT `quote_id`, `quote_user_id`, `quote_username`, `quote_user_colour`, `quote_timestamp`, `quote_text` - FROM `msz_chat_quotes` - WHERE `quote_parent` IS NULL - ORDER BY RAND() - ')->fetch(PDO::FETCH_ASSOC); - - return $parent ? array_merge([$parent], chat_quotes_children($parent['quote_id'])) : []; -} diff --git a/templates/manage/general/quotes.twig b/templates/manage/general/quotes.twig deleted file mode 100644 index a82a5682..00000000 --- a/templates/manage/general/quotes.twig +++ /dev/null @@ -1,74 +0,0 @@ -{% extends 'manage/general/master.twig' %} -{% from 'home/macros.twig' import chat_quote_display %} -{% from 'macros.twig' import pagination, container_title %} -{% from '_layout/input.twig' import input_hidden, input_csrf, input_text %} - -{% block manage_content %} -
- {{ container_title('Quotes') }} - - {% if current_quote is defined %} -
- {{ input_csrf('add_quote') }} - {{ input_hidden('quote[id]', current_quote.quote_id|default(0)) }} - - * = optional - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Parent ID*{{ input_text('quote[parent]', '', current_quote.quote_parent|default(quote_parent), 'number') }}
User ID*{{ input_text('quote[user][id]', '', current_quote.quote_user_id|default(0), 'number') }}
Date/time*{{ input_text('quote[time]', '', (current_quote.quote_timestamp|default('')|date('Y-m-d H:i:s'))) }}
Username{{ input_text('quote[user][name]', '', current_quote.quote_username|default(), 'text', '', true) }}
User Colour{{ input_text('quote[user][colour]', '', current_quote.quote_user_colour|default(constant('MSZ_COLOUR_INHERIT')), 'number', '', true) }}
- -
- - -
- {% elseif quote_set is defined %} - {{ chat_quote_display(quote_set) }} - - Add - - Edit: - {% for key, quote in quote_set %} - {{ key + 1 }} ({{ quote.quote_username }}) - {% endfor %} - {% else %} - Create - - {% for parent in quote_parents %} -
- {{ container_title(parent.quote_timestamp|date('Y-m-d'), '?v=quotes&s=' ~ parent.quote_id) }} - {{ chat_quote_display([parent]) }} -
- {% endfor %} - - {{ pagination(quotes_pagination, '/manage/index.php', null, {'v': 'quotes'}) }} - {% endif %} -
-{% endblock %}