From 70cf8173ae33ac143d3cd3331eed6d0db136d086 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 31 Dec 2021 09:41:53 +0000 Subject: [PATCH] Add (thread) link to overboard results --- Rocksolid_Light/rocksolid/article-flat.php | 6 ++++++ Rocksolid_Light/rocksolid/newsportal.php | 23 ++++++++++++++++++++++ Rocksolid_Light/rocksolid/overboard.php | 17 ++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Rocksolid_Light/rocksolid/article-flat.php b/Rocksolid_Light/rocksolid/article-flat.php index 3305e59..2b3111c 100644 --- a/Rocksolid_Light/rocksolid/article-flat.php +++ b/Rocksolid_Light/rocksolid/article-flat.php @@ -88,6 +88,12 @@ if(isset($frames_on) && $frames_on === true) { echo ''.basename(getcwd()).' / '; echo ''.htmlspecialchars(group_display_name($group)).' / '.$subject.''; +if(!$message) { + echo "Article not found"; + include "tail.inc"; + exit(0); +} + if($message) { // load thread-data and get IDs of the actual subthread $thread=thread_load($group); diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 6e59293..37d0cbd 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1403,6 +1403,8 @@ function rslight_db_open($database, $table='overview') { $stmt->execute(); $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS id_newsgroup on overview(newsgroup)'); $stmt->execute(); + $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS id_msgid on overview(msgid)'); + $stmt->execute(); $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS id_newsgroup_number on overview(newsgroup,number)'); $stmt->execute(); $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS id_name on overview(name)'); @@ -1432,6 +1434,8 @@ function article_db_open($database) { $stmt->execute(); $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_date on articles(date)'); $stmt->execute(); + $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_msgid on articles(msgid)'); + $stmt->execute(); $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_name on articles(name)'); $stmt->execute(); @@ -1549,4 +1553,23 @@ $logfile=$logdir.'/newsportal.log'; exit(0); } } + +function get_data_from_msgid($msgid) { + global $spooldir; + $database = $spooldir.'/articles-overview.db3'; + $articles_dbh = rslight_db_open($database); + $articles_query = $articles_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid'); + $articles_query->execute(['messageid' => $msgid]); + $found = 0; + while ($row = $articles_query->fetch()) { + $found = 1; + break; + } + $dbh = null; + if($found) { + return $row; + } else { + return false; + } +} ?> diff --git a/Rocksolid_Light/rocksolid/overboard.php b/Rocksolid_Light/rocksolid/overboard.php index eed9ac5..41f0399 100755 --- a/Rocksolid_Light/rocksolid/overboard.php +++ b/Rocksolid_Light/rocksolid/overboard.php @@ -62,7 +62,7 @@ if (isset($_GET['thisgroup'])) { $cachetime = 60; # Maximum number of articles to show -$maxdisplay = 1000; +$maxdisplay = 500; # How many characters of the body to display per article $snippetlength = 240; @@ -219,6 +219,14 @@ foreach($files as $article) { $getid = explode(": ", $articleid[0]); $thismsgid = hash('crc32', serialize($getid[1])); + preg_match('/References:.*/i', $header, $ref); + $getrefs = explode(': ', $ref[0]); + $ref = preg_split("/[\s]+/", $getrefs[1]); + if($getrefs[1] && $refid = get_data_from_msgid($ref[0])) { + $threadref = $ref[0]; + } else { + $threadref = false; + } preg_match('/Content-Transfer-Encoding:.*/', $header, $te); $content_transfer_encoding = explode("Content-Transfer-Encoding: ", $te[0]); @@ -257,7 +265,12 @@ foreach($files as $article) { $this_output = ''; } $this_output = '

'; - $this_output.= ''.mb_decode_mimeheader($output[1])."\r\n"; + if($threadref) { + $this_output.= ''.mb_decode_mimeheader($output[1]).'" (thread)'."\r\n"; +// $this_output.= ''.mb_decode_mimeheader($output[1]).'" (thread)'."\r\n"; + } else { + $this_output.= ''.mb_decode_mimeheader($output[1])."\r\n"; + } $this_output.= '

'; $this_output.= ''.$groupname.''; $this_output.= '

';