From 906ed844d3d3bbbedd04b3aba094dd1b357d2bbf Mon Sep 17 00:00:00 2001 From: nonmakina Date: Sun, 17 Jan 2021 21:31:06 -0600 Subject: [PATCH 01/12] Implements fixes and changes to be able to view the bumplock status of a thread --- inc/config.php | 3 ++- inc/instance-config.php | 3 +++ post.php | 2 +- templates/post_thread.html | 8 ++++---- templates/themes/catalog/catalog.html | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/inc/config.php b/inc/config.php index b5178fc4..80f3c01f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1223,7 +1223,8 @@ // $config['font_awesome'] is false (default). // $config['image_sticky'] = 'static/sticky.png'; // $config['image_locked'] = 'static/locked.gif'; - // $config['image_bumplocked'] = 'static/sage.png'. + // $config['image_bumplocked'] = 'static/sage.png'; + // $config['image_cycled'] = 'static/cycled.png'; // If you want to put images and other dynamic-static stuff on another (preferably cookieless) domain. // This will override $config['root'] and $config['dir']['...'] directives. "%s" will get replaced with diff --git a/inc/instance-config.php b/inc/instance-config.php index c752938f..d9b75721 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -120,6 +120,9 @@ $config['mod']['editpost'] = MOD; $config['mod']['rawhtml'] = MOD; $config['mod']['mod_board_log'] = MOD; +// Allow everyone to see bumplocks +$config['mod']['view_bumplock'] = -1; + $config['allow_thread_deletion'] = false; // Max attachments per post diff --git a/post.php b/post.php index bf42d052..70ba29e2 100644 --- a/post.php +++ b/post.php @@ -1357,7 +1357,7 @@ function handle_post(){ query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error()); } - if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies']+1 < $config['reply_limit'])) { + if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies'] < $config['reply_limit'])) { bumpThread($post['thread']); } diff --git a/templates/post_thread.html b/templates/post_thread.html index 6b114f6b..3838d515 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -21,28 +21,28 @@ {% if config.font_awesome %} {% else %} - Sticky + Sticky {% endif %} {% endif %} {% if post.locked %} {% if config.font_awesome %} {% else %} - Locked + Locked {% endif %} {% endif %} {% if post.bumplocked and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %} {% if config.font_awesome %} {% else %} - Bumplocked + Bumplocked {% endif %} {% endif %} {% if post.cycle %} {% if config.font_awesome %} {% else %} - Cyclical + Cyclical {% endif %} {% endif %} {% if index %} diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index e39debee..6a8e819e 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -65,7 +65,7 @@ id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}">
- R: {{ post.replies }} / I: {{ post.images }}{% if post.sticky %} (sticky){% endif %}{% if post.locked %}  {% endif %} + R: {{ post.replies }} / I: {{ post.images }}{% if post.sticky %} (sticky){% endif %}{% if post.sage %} (sage){% endif %}{% if (config.reply_limit > 0) and (post.replies >= config.reply_limit) %} (full){% endif %}{% if post.locked %}  {% endif %} {% if post.subject %}

From f79bceb752682819c32f36e982241e3b3bdd1668 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Sun, 17 Jan 2021 21:37:47 -0600 Subject: [PATCH 02/12] Incorrect variable fix --- templates/post_thread.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/post_thread.html b/templates/post_thread.html index 3838d515..448bbd72 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -31,7 +31,7 @@ Locked {% endif %} {% endif %} - {% if post.bumplocked and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %} + {% if post.sage and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %} {% if config.font_awesome %} {% else %} From 6448c3fe831c32b3507f54a61889dc88580f0de5 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:11:47 -0600 Subject: [PATCH 03/12] Adds function to count posts and images of a thread --- templates/themes/semirand/theme.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index cd670a52..ae82bdd8 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -97,6 +97,17 @@ return $query->fetchAll(PDO::FETCH_ASSOC); } + /** + * Retrieve count of images and posts in a thread + */ + private function fetchThreadCount($board, $thread_id) { + $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id"); + $query->bindValue(':id', $thread_id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + return $query->fetchAll(PDO::FETCH_ASSOC); + } + /** * Intersperse random threads between those in bump order */ @@ -138,27 +149,15 @@ $config['threads_preview']; $replies = $this->fetchReplies($post['board'], $post['id'], $preview_count); - // Chomp the last few replies $disp_replies = $replies; - $disp_img_count = 0; foreach ($disp_replies as $reply) { - if ($reply['files'] !== '') - ++$disp_img_count; - // Append the reply to the thread as it's being built $thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod)); } - // Count the number of omitted image replies - $omitted_img_count = count(array_filter($replies, function($p) { - return $p['files'] !== ''; - })); - - // Set the corresponding omitted numbers on the thread - if (!empty($replies)) { - $thread->omitted = count($replies); - $thread->omitted_images = $omitted_img_count; - } + $threadCount = $this->fetchThreadCount($post['board'], $post['id']); + $thread->omitted = $threadCount['post_count']; + $thread->omitted_images = $threadCount['file_count']; // Board name and link $html = '

/' . From 26f8c332ef9603033760b3f6724e0f4f1c255f21 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:26:18 -0600 Subject: [PATCH 04/12] Fetch one, instead of all --- templates/themes/semirand/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index ae82bdd8..9f5592e7 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -105,7 +105,7 @@ $query->bindValue(':id', $thread_id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - return $query->fetchAll(PDO::FETCH_ASSOC); + return $query->fetch(PDO::FETCH_ASSOC); } /** From f9bf65ecb74c01a01c4f75323f3f3734118c2914 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:31:02 -0600 Subject: [PATCH 05/12] Add offset --- templates/themes/semirand/theme.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index 9f5592e7..11403bd3 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -100,9 +100,10 @@ /** * Retrieve count of images and posts in a thread */ - private function fetchThreadCount($board, $thread_id) { - $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id"); + private function fetchThreadCount($board, $thread_id, $preview_count) { + $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC OFFSET :offset"); $query->bindValue(':id', $thread_id, PDO::PARAM_INT); + $query->bindValue(':offset', $preview_count, PDO::PARAM_INT); $query->execute() or error(db_error($query)); return $query->fetch(PDO::FETCH_ASSOC); @@ -155,7 +156,7 @@ $thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod)); } - $threadCount = $this->fetchThreadCount($post['board'], $post['id']); + $threadCount = $this->fetchThreadCount($post['board'], $post['id'], $preview_count); $thread->omitted = $threadCount['post_count']; $thread->omitted_images = $threadCount['file_count']; From 771a1e16299ca6fbf24a174e65392073daa48176 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:35:34 -0600 Subject: [PATCH 06/12] Add offset --- templates/themes/semirand/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index 11403bd3..7db5ef9e 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -101,7 +101,7 @@ * Retrieve count of images and posts in a thread */ private function fetchThreadCount($board, $thread_id, $preview_count) { - $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC OFFSET :offset"); + $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615;"); $query->bindValue(':id', $thread_id, PDO::PARAM_INT); $query->bindValue(':offset', $preview_count, PDO::PARAM_INT); $query->execute() or error(db_error($query)); From e936312db509c5a355b4bb1131f644556aed242a Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:49:46 -0600 Subject: [PATCH 07/12] Fix offset --- templates/themes/semirand/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index 7db5ef9e..c0412962 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -101,7 +101,7 @@ * Retrieve count of images and posts in a thread */ private function fetchThreadCount($board, $thread_id, $preview_count) { - $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615;"); + $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM (SELECT * FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615);"); $query->bindValue(':id', $thread_id, PDO::PARAM_INT); $query->bindValue(':offset', $preview_count, PDO::PARAM_INT); $query->execute() or error(db_error($query)); From f40beb76407eee61f78906f2b068dc78e56b8e92 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Mon, 18 Jan 2021 04:59:13 -0600 Subject: [PATCH 08/12] Fix filecount --- templates/themes/semirand/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index c0412962..3897a4e4 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -101,7 +101,7 @@ * Retrieve count of images and posts in a thread */ private function fetchThreadCount($board, $thread_id, $preview_count) { - $query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM (SELECT * FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615);"); + $query = prepare("SELECT SUM(t.num_files) as file_count, COUNT(t.id) as post_count FROM (SELECT * FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615) as t;"); $query->bindValue(':id', $thread_id, PDO::PARAM_INT); $query->bindValue(':offset', $preview_count, PDO::PARAM_INT); $query->execute() or error(db_error($query)); From 0a9cbc745384689aa885fdde09b7cd6d9fcce450 Mon Sep 17 00:00:00 2001 From: Dedushka Date: Mon, 18 Jan 2021 21:46:21 -0500 Subject: [PATCH 09/12] Allow robots --- robots.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/robots.txt b/robots.txt index 1f53798b..de1da8f7 100644 --- a/robots.txt +++ b/robots.txt @@ -1,2 +1,3 @@ User-agent: * -Disallow: / +Disallow: /templates/ +Allow: / From f74d2a2fdccface0c9f3abbfeb049ffe6d34ecdb Mon Sep 17 00:00:00 2001 From: Dedushka Date: Mon, 18 Jan 2021 22:32:20 -0500 Subject: [PATCH 10/12] Fix minor bug that disallows deletion of themes --- inc/mod/pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 4a2afc73..9319a98c 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -3219,7 +3219,7 @@ function mod_theme_uninstall($theme_name) { // Clean cache Cache::delete("themes"); - Cache::delete("theme_settings_".$theme); + Cache::delete("theme_settings_".$theme_name); header('Location: ?/themes', true, $config['redirect_http']); } From 714a92af44e75949e358c66ea266ff4f138efd4b Mon Sep 17 00:00:00 2001 From: Dedushka Date: Tue, 19 Jan 2021 14:53:10 -0500 Subject: [PATCH 11/12] Revert bad change that commented this out on mod post edit page --- inc/mod/pages.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 4a2afc73..7c3fc0fa 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2020,18 +2020,18 @@ function mod_edit_post($board, $edit_raw_html, $postID) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . link_for($post) . '#' . $postID, true, $config['redirect_http']); } else { // Remove modifiers - //$post['body_nomarkup'] = remove_modifiers($post['body_nomarkup']); + $post['body_nomarkup'] = remove_modifiers($post['body_nomarkup']); - //$post['body_nomarkup'] = utf8tohtml($post['body_nomarkup']); - //$post['body'] = utf8tohtml($post['body']); - /*if ($config['minify_html']) { + $post['body_nomarkup'] = utf8tohtml($post['body_nomarkup']); + $post['body'] = utf8tohtml($post['body']); + if ($config['minify_html']) { $post['body_nomarkup'] = str_replace("\n", ' ', $post['body_nomarkup']); $post['body'] = str_replace("\n", ' ', $post['body']); $post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']); $post['body'] = str_replace("\r", '', $post['body']); $post['body_nomarkup'] = str_replace("\t", ' ', $post['body_nomarkup']); $post['body'] = str_replace("\t", ' ', $post['body']); - }*/ + } mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); } From f3f38794c42c8d147d7cb3222faa4512b38535a9 Mon Sep 17 00:00:00 2001 From: nonmakina Date: Tue, 19 Jan 2021 16:57:08 -0600 Subject: [PATCH 12/12] Improves readibility --- stylesheets/dark.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stylesheets/dark.css b/stylesheets/dark.css index 86c9bca9..b36a64c6 100644 --- a/stylesheets/dark.css +++ b/stylesheets/dark.css @@ -5,8 +5,8 @@ body { background: #1E1E1E; color: #999999; - font-family: sans-serif; - font-size: 12px; + font-family: Verdana, sans-serif; + font-size: 14px; } .quote { color:#B8D962;