Added the ability to add additional announce URLs into torrent files (#999)

This commit is contained in:
Roman Kelesidis 2023-10-27 14:45:05 +07:00 committed by GitHub
commit 17612d27d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 7 deletions

View file

@ -11,10 +11,27 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$announce_urls = [];
// Here you can define additional allowed announce urls
// For example, if you want to add http://demo.torrentpier.com
// add this line: $announce_urls[] = 'http://demo.torrentpier.com/bt/announce.php';
$announce_urls = $additional_announce_urls = [];
// ==============================================================================================================================
// Allowed Announcer URLs
// ------------------------------------------------------------------------------------------------------------------------------
// Examples:
// $announce_urls[] = 'http://demo.torrentpier.com/bt/announce.php';
// $announce_urls[] = 'http://tracker.openbittorrent.com:80/announce';
// $announce_urls[] = 'udp://tracker.openbittorrent.com:6969/announce';
// ------------------------------------------------------------------------------------------------------------------------------
// Note:
// - Add URLs without GET parameters at the end
// - For this file to work, you need to enable the "Check announce url" option in the admin panel in "Forum Settings"
// ==============================================================================================================================
// Additional announcer URLs that will be added to your giveaways
// ------------------------------------------------------------------------------------------------------------------------------
// Examples:
// $additional_announce_urls[] = 'http://tracker.openbittorrent.com:80/announce';
// $additional_announce_urls[] = 'udp://tracker.openbittorrent.com:6969/announce';
// ------------------------------------------------------------------------------------------------------------------------------
// Note:
// - It is better not to add advertisers with GET parameters (for example passkey or another access authenticator)
// - For this file to work, you need to disable the option “Delete all additional announce urls” in the admin panel in “Forum Settings”
// ==============================================================================================================================

View file

@ -328,6 +328,7 @@ class Torrent
}
if ($bb_cfg['bt_check_announce_url']) {
$announce_urls = [];
include INC_DIR . '/torrent_announce_urls.php';
$ann = $tor['announce'] ?? '';
@ -337,6 +338,7 @@ class Torrent
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
self::torrent_error_exit($msg);
}
unset($announce_urls);
}
$info = $tor['info'] ?? [];
@ -553,18 +555,27 @@ class Torrent
$tor['announce'] = $announce;
}
// Get additional announce urls
$additional_announce_urls = $announce_urls_add = [];
include INC_DIR . '/torrent_announce_urls.php';
foreach ($additional_announce_urls as $additional_announce_url) {
$announce_urls_add[] = [$additional_announce_url];
}
unset($additional_announce_urls);
// Delete all additional urls
if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) {
unset($tor['announce-list']);
} elseif (isset($tor['announce-list'])) {
$tor['announce-list'] = array_merge($tor['announce-list'], [[$announce]]);
$tor['announce-list'] = array_merge($tor['announce-list'], [[$announce]], $announce_urls_add);
}
// Add retracker
if (isset($bb_cfg['tracker']['retracker']) && $bb_cfg['tracker']['retracker']) {
if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) {
if (!isset($tor['announce-list'])) {
$tor['announce-list'] = [[$announce], [$bb_cfg['tracker']['retracker_host']]];
$tor['announce-list'] = [[$announce], $announce_urls_add, [$bb_cfg['tracker']['retracker_host']]];
} else {
$tor['announce-list'] = array_merge($tor['announce-list'], [[$bb_cfg['tracker']['retracker_host']]]);
}