Cleanup article.php to match article-flat.php where reading message-id from url.

This commit is contained in:
Retro_Guy 2024-05-14 03:06:03 -07:00
parent d540ccd0ca
commit 76324850a9
1 changed files with 19 additions and 22 deletions

View File

@ -11,28 +11,25 @@ $id = $_REQUEST["id"];
$group = _rawurldecode($_REQUEST["group"]);
if (strpos($id, '@') !== false) {
if ($CONFIG['article_database'] == '1') {
$id = '<'.trim($id, '<> ').'>';
$database = $spooldir . '/articles-overview.db3';
$articles_dbh = overview_db_open($database);
$articles_query = $articles_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid');
$articles_query->execute([
'messageid' => $id
]);
$found = 0;
while ($row = $articles_query->fetch()) {
$id = $row['number'];
$group = $row['newsgroup'];
$found = 1;
break;
}
$dbh = null;
if ($found) {
$findsection = get_section_by_group($row['newsgroup']);
$newurl = '/' . $findsection . '/article.php?id=' . $id . '&group=' . $row['newsgroup'] . '#' . $id;
header("Location: $newurl");
die();
}
$id = '<' . trim($id, '<> ') . '>';
$database = $spooldir . '/articles-overview.db3';
$overview_dbh = overview_db_open($database);
$overview_query = $overview_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid');
$overview_query->execute([
'messageid' => $id
]);
$found = 0;
while ($row = $overview_query->fetch()) {
$id = $row['number'];
$group = $row['newsgroup'];
$found = 1;
break;
}
$overview_dbh = null;
if ($found) {
$newurl = 'article-flat.php?id=' . $id . '&group=' . $row['newsgroup'] . '#' . $id;
header("Location: $newurl");
die();
}
}