feat(torrent): Bring back old torrent file naming (#1783)

* feat(torrent): Bring back old torrent file naming

* Update displaying_torrent.php

* Update Torrent.php
This commit is contained in:
Roman Kelesidis 2025-01-30 19:08:00 +03:00 committed by GitHub
commit 314c592aff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View file

@ -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 = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'reg\'}); return false;">' . $lang['BT_REG_ON_TRACKER'] . '</a>';
@ -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', [

View file

@ -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

View file

@ -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<br /><br />";