From 274a70e66f73317d3803ab1f5095fa281e57bbc3 Mon Sep 17 00:00:00 2001 From: Xkeeper Date: Wed, 2 Jan 2019 11:49:23 -0800 Subject: [PATCH] meta descriptions optionally use the linked post [closes #60] if a post is linked to directly (e.g. ?pid=xxxx) it will now use that post, rather than using the first post of the thread like before. (the first post of the thread is still used for threads/page links) --- thread.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/thread.php b/thread.php index d3ffee6..6ad48e8 100644 --- a/thread.php +++ b/thread.php @@ -45,6 +45,7 @@ $ppp = filter_int($_GET['ppp']) ? $_GET['ppp'] : ($log ? $loguser['postsperpage'] : 20); $ppp = max(min($ppp, 500), 1); + $pid = null; if (filter_int($_GET['pid'])) { $pid = $_GET['pid']; @@ -151,7 +152,12 @@ $tlinks = implode(' | ', $tlinks); // Description for bots - $text = $sql->resultq("SELECT text FROM posts_text pt LEFT JOIN posts p ON (pt.pid = p.id) WHERE p.thread=$id ORDER BY pt.pid ASC LIMIT 1"); + if ($pid !== null) { + // $pid is explicitly null or filter_int'd + $text = $sql->resultq("SELECT text FROM posts_text pt LEFT JOIN posts p ON (pt.pid = p.id) WHERE p.thread=$id AND p.id = '$pid' ORDER BY pt.pid ASC LIMIT 1"); + } else { + $text = $sql->resultq("SELECT text FROM posts_text pt LEFT JOIN posts p ON (pt.pid = p.id) WHERE p.thread=$id ORDER BY pt.pid ASC LIMIT 1"); + } $text = strip_tags(str_replace(array("[", "]", "\r\n"), array("<", ">", " "), $text)); $text = ((strlen($text) > 160) ? substr($text, 0, 157) . "..." : $text); $text = str_replace("\"", """, $text);