From 4b5e22349803348ac5f29f73b6a2af322839265b Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 10 Jun 2021 00:50:17 +0800 Subject: [PATCH] improve torrent download url --- include/globalfunctions.php | 4 ++-- public/download.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 884767e5..9ab5e189 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -609,7 +609,7 @@ function isRunningInConsole(): bool return php_sapi_name() == 'cli'; } -function get_base_announce_url() +function get_tracker_schema_and_host(): array { global $https_announce_urls, $announce_urls; $httpsAnnounceUrls = array_filter($https_announce_urls); @@ -637,5 +637,5 @@ function get_base_announce_url() $base_announce_url = $announce_urls[0]; } do_log($log); - return $ssl_torrent . $base_announce_url; + return compact('ssl_torrent', 'base_announce_url'); } diff --git a/public/download.php b/public/download.php index 9b6e8731..b7600d1a 100644 --- a/public/download.php +++ b/public/download.php @@ -65,7 +65,9 @@ if (@ini_get('output_handler') == 'ob_gzhandler' AND @ob_get_length() !== false) } */ -$base_announce_url = get_base_announce_url(); +$trackerSchemaAndHost = get_tracker_schema_and_host(); +$ssl_torrent = $trackerSchemaAndHost['ssl_torrent']; +$base_announce_url = $trackerSchemaAndHost['base_announce_url']; $res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($res);