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)
This commit is contained in:
Xkeeper 2019-01-02 11:49:23 -08:00
parent ef2cac19d2
commit 274a70e66f
No known key found for this signature in database
GPG Key ID: 397C04773ABE4045

View File

@ -45,6 +45,7 @@
$ppp = filter_int($_GET['ppp']) ? $_GET['ppp'] : ($log ? $loguser['postsperpage'] : 20); $ppp = filter_int($_GET['ppp']) ? $_GET['ppp'] : ($log ? $loguser['postsperpage'] : 20);
$ppp = max(min($ppp, 500), 1); $ppp = max(min($ppp, 500), 1);
$pid = null;
if (filter_int($_GET['pid'])) { if (filter_int($_GET['pid'])) {
$pid = $_GET['pid']; $pid = $_GET['pid'];
@ -151,7 +152,12 @@
$tlinks = implode(' | ', $tlinks); $tlinks = implode(' | ', $tlinks);
// Description for bots // Description for bots
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 = $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 = strip_tags(str_replace(array("[", "]", "\r\n"), array("<", ">", " "), $text));
$text = ((strlen($text) > 160) ? substr($text, 0, 157) . "..." : $text); $text = ((strlen($text) > 160) ? substr($text, 0, 157) . "..." : $text);
$text = str_replace("\"", "&quot;", $text); $text = str_replace("\"", "&quot;", $text);