Add (thread) link to overboard results

This commit is contained in:
Retro_Guy 2021-12-31 09:41:53 +00:00
parent d1df0982bf
commit 70cf8173ae
3 changed files with 44 additions and 2 deletions

View File

@ -88,6 +88,12 @@ if(isset($frames_on) && $frames_on === true) {
echo '<a href="'.$file_index.'" target='.$frame['menu'].'>'.basename(getcwd()).'</a> / ';
echo '<a href="'.$file_thread.'?group='.rawurlencode($group).'" target='.$frame["content"].'>'.htmlspecialchars(group_display_name($group)).'</a> / '.$subject.'</h1>';
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);

View File

@ -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;
}
}
?>

View File

@ -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 = '<tr class="np_result_line2"><td class="np_result_line2" style="word-wrap:break-word";>';
}
$this_output = '<p class=np_ob_subject>';
$this_output.= '<b><a href="'.$url.'">'.mb_decode_mimeheader($output[1])."</a></b>\r\n";
if($threadref) {
$this_output.= '<b><a href="'.$url.'">'.mb_decode_mimeheader($output[1]).'"</a></b><font class="np_ob_group"><a href="article-flat.php?id='.$refid[number].'&group='.$groupname.'#'.$refid[number].'"> (thread)</a></font>'."\r\n";
// $this_output.= '<b><a href="'.$url.'">'.mb_decode_mimeheader($output[1]).'"</a></b><font class="np_ob_group"><a href="article-flat.php?group='.$groupname.'&id='.$threadref.'"> (thread)</a></font>'."\r\n";
} else {
$this_output.= '<b><a href="'.$url.'">'.mb_decode_mimeheader($output[1])."</a></b>\r\n";
}
$this_output.= '</p><p class=np_ob_group>';
$this_output.= '<a href="'.$groupurl.'"><span class="visited">'.$groupname.'</span></a>';
$this_output.= '</p>';