Cleanup article-flat.php when article is requested by message-id.

This commit is contained in:
Retro_Guy 2024-05-13 15:20:15 -07:00
parent c8b9af9d7a
commit aca70518ad
1 changed files with 19 additions and 21 deletions

View File

@ -23,29 +23,27 @@ $id = $_REQUEST["id"];
$group = _rawurldecode($_REQUEST["group"]); $group = _rawurldecode($_REQUEST["group"]);
if (strpos($id, '@') !== false) { if (strpos($id, '@') !== false) {
if ($CONFIG['article_database'] == '1') {
$id = '<' . trim($id, '<> ') . '>'; $id = '<' . trim($id, '<> ') . '>';
$database = $spooldir . '/articles-overview.db3'; $database = $spooldir . '/articles-overview.db3';
$articles_dbh = overview_db_open($database); $overview_dbh = overview_db_open($database);
$articles_query = $articles_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid'); $overview_query = $overview_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid');
$articles_query->execute([ $overview_query->execute([
'messageid' => $id 'messageid' => $id
]); ]);
$found = 0; $found = 0;
while ($row = $articles_query->fetch()) { while ($row = $overview_query->fetch()) {
$id = $row['number']; $id = $row['number'];
$group = $row['newsgroup']; $group = $row['newsgroup'];
$found = 1; $found = 1;
break; break;
} }
$dbh = null; $overview_dbh = null;
if ($found) { if ($found) {
$newurl = 'article-flat.php?id=' . $id . '&group=' . $row['newsgroup'] . '#' . $id; $newurl = 'article-flat.php?id=' . $id . '&group=' . $row['newsgroup'] . '#' . $id;
header("Location: $newurl"); header("Location: $newurl");
die(); die();
} }
} }
}
// Switch to correct section in case group has been moved and link is to old section // Switch to correct section in case group has been moved and link is to old section
$findsection = get_section_by_group($group); $findsection = get_section_by_group($group);