From 314c592affbef4b8db48d562b9633aad27059a76 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 30 Jan 2025 19:08:00 +0300 Subject: [PATCH] feat(torrent): Bring back old torrent file naming (#1783) * feat(torrent): Bring back old torrent file naming * Update displaying_torrent.php * Update Torrent.php --- library/attach_mod/displaying_torrent.php | 8 ++++++-- library/config.php | 3 ++- src/Legacy/Torrent.php | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 604c5bf2e..373b6b863 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -79,7 +79,7 @@ $tor_auth_del = ($tor_auth && $tor_reged); $tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO']; $download_link = DL_URL . $attach_id; -$description = ($comment) ?: preg_replace("#.torrent$#i", '', $display_name); +$description = ($comment) ?: preg_replace("#" . "." . TORRENT_EXT . "$#i", '', $display_name); if ($tor_auth_reg || $tor_auth_del) { $reg_tor_url = '' . $lang['BT_REG_ON_TRACKER'] . ''; @@ -88,7 +88,11 @@ if ($tor_auth_reg || $tor_auth_del) { $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; } -$display_name = $t_data['topic_title'] . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; +if ($bb_cfg['tracker']['use_old_torrent_name_format']) { + $display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.' . TORRENT_EXT; +} else { + $display_name = $t_data['topic_title'] . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; +} if (!$tor_reged) { $template->assign_block_vars('postrow.attach.tor_not_reged', [ diff --git a/library/config.php b/library/config.php index 7cf586bf1..3f60765c0 100644 --- a/library/config.php +++ b/library/config.php @@ -736,7 +736,8 @@ $bb_cfg['tracker'] = [ 'gold_silver_enabled' => true, // golden / silver days mode (If enabled, then disable "freeleech") 'hybrid_stat_protocol' => 1, // For hybrid torrents there are two identical requests sent by clients, for counting stats we gotta choose one, you can change this to '2' in future, when v1 protocol is outdated 'disabled_v1_torrents' => false, // disallow registration of v1-only torrents, for future implementations where client will use v2 only and there won't be need for v1, thus relieving tracker - 'disabled_v2_torrents' => false // disallow registration of v2-only torrents + 'disabled_v2_torrents' => false, // disallow registration of v2-only torrents + 'use_old_torrent_name_format' => false, // when enabled, the names of torrent files will have the classic format: [yoursite.com].txxx.torrent ]; // Ratio settings diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index 7489b10ac..791ff30bd 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -644,7 +644,11 @@ class Torrent // Send torrent $output = Bencode::encode($tor); - $dl_fname = html_ent_decode($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.' . TORRENT_EXT; + if ($bb_cfg['tracker']['use_old_torrent_name_format']) { + $dl_fname = '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.' . TORRENT_EXT; + } else { + $dl_fname = html_ent_decode($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.' . TORRENT_EXT; + } if (!empty($_COOKIE['explain'])) { $out = "attach path: $filename

";