diff --git a/filelist.php b/filelist.php index fc8c1374b..fe24f1796 100644 --- a/filelist.php +++ b/filelist.php @@ -35,13 +35,15 @@ if (!$row = DB()->fetch_row($sql)) { } // Previous/next topic links -$topics_sql = ' +$sql = ' (SELECT topic_id FROM ' . BB_BT_TORRENTS . ' WHERE topic_id < ' . $topic_id . ' ORDER BY topic_id DESC LIMIT 1) UNION (SELECT topic_id FROM ' . BB_BT_TORRENTS . ' WHERE topic_id >= ' . $topic_id . ' ORDER BY topic_id ASC LIMIT 2) ORDER BY topic_id ASC'; -$topics = DB()->fetch_rowset($topics_sql); +if (!$topics = DB()->fetch_rowset($sql)) { + bb_die($lang['INVALID_TOPIC_ID_DB'], 404); +} $topic_ids = array_column($topics, 'topic_id'); $current_index = array_search($topic_id, $topic_ids); @@ -61,6 +63,7 @@ $template->assign_vars([ 'U_NEXT_TOPIC' => "filelist.php?t=$next_topic_id", 'U_PREV_TOPIC' => "filelist.php?t=$prev_topic_id", ]); +unset($prev_topic_id, $next_topic_id, $current_index, $topic_ids, $topics); // Protocol meta $meta_v1 = !empty($row['info_hash']);