From 8d21c376081af122a0abae53ddfe5babbad7961b Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 20 Nov 2023 08:09:53 +0700 Subject: [PATCH] Fixed announcer-list issue (#336) * Fixed announcer-list issue * Update CHANGELOG.md --- CHANGELOG.md | 2 +- library/includes/functions_torrent.php | 49 +++++++++++++++----------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55be9912..5242dcd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ **Merged pull requests:** - Release v2.1.5-2024.05-beta1 🎉 -- Fixed announcer-list issue [\#335](https://github.com/torrentpier/torrentpier-lts/pull/335) ([belomaxorka](https://github.com/belomaxorka)) +- Fixed announcer-list issue [\#335](https://github.com/torrentpier/torrentpier-lts/pull/335), [\#336](https://github.com/torrentpier/torrentpier-lts/pull/336) ([belomaxorka](https://github.com/belomaxorka)) - Some other changes / improvements ## [v2.1.5-2024.05-alpha5 [Final v2]](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2024.05-alpha5) (2024-06-04) diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 1f4198a0..7d2a06bf 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -492,14 +492,8 @@ function send_torrent_with_passkey ($filename) $tor['announce'] = $announce; } - // Delete all additional urls - if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) - { - unset($tor['announce-list']); - } - - // Creating announce-list if not exist - if (!isset($tor['announce-list']) || !is_array($tor['announce-list'])) + // Creating / cleaning announce-list + if (!isset($tor['announce-list']) || !is_array($tor['announce-list']) || $bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) { $tor['announce-list'] = array(); } @@ -515,18 +509,6 @@ function send_torrent_with_passkey ($filename) } unset($additional_announce_urls); - // Adding tracker announcer to announce-list - if ($bb_cfg['bt_replace_ann_url']) - { - // Adding tracker announcer as main announcer (At start) - array_unshift($tor['announce-list'], array($announce)); - } - else - { - // Adding tracker announcer (At end) - $tor['announce-list'] = array_merge($tor['announce-list'], array(array($announce))); - } - // Adding additional announce urls (If present) if (!empty($announce_urls_add)) { @@ -542,6 +524,33 @@ function send_torrent_with_passkey ($filename) } } + // Adding tracker announcer to announce-list + if (!empty($tor['announce-list'])) + { + if ($bb_cfg['bt_replace_ann_url']) + { + // Adding tracker announcer as main announcer (At start) + array_unshift($tor['announce-list'], array($announce)); + } + else + { + // Adding torrent announcer (At start) + array_unshift($tor['announce-list'], array($tor['announce'])); + + // Adding tracker announcer (At end) + if ($tor['announce'] != $announce) + { + $tor['announce-list'] = array_merge($tor['announce-list'], array(array($announce))); + } + } + } + + // Remove announce-list if empty + if (empty($tor['announce-list'])) + { + unset($tor['announce-list']); + } + // Add publisher & topic url $publisher_name = $bb_cfg['server_name']; $publisher_url = make_url(TOPIC_URL . $topic_id);