Generate .torrent file names based on topic titles (#958)

This commit is contained in:
Constantine Kovalensky 2023-10-05 23:08:36 +04:00 committed by GitHub
commit e2bf40bd64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -88,7 +88,7 @@ if ($tor_auth_reg || $tor_auth_del) {
$tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
} }
$display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.torrent'; $display_name = wbr($t_data['topic_title']) . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.torrent';
if (!$tor_reged) { if (!$tor_reged) {
$template->assign_block_vars('postrow.attach.tor_not_reged', [ $template->assign_block_vars('postrow.attach.tor_not_reged', [

View file

@ -55,7 +55,7 @@ class IPHelper extends Ip
/** /**
* Long to IP * Long to IP
* Decodes long form from both IPv4 & IPv6. * Decodes long format from both IPv4 & IPv6.
* *
* @param string $ip * @param string $ip
* @return string * @return string

View file

@ -495,12 +495,17 @@ class Torrent
} }
// Get $topic_id // Get $topic_id
$topic_id_sql = 'SELECT topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int)$post_id; $topic_id_sql = 'SELECT p.topic_id, t.topic_title
FROM ' . BB_POSTS . ' p
JOIN ' . BB_TOPICS . ' t ON p.topic_id = t.topic_id
WHERE p.post_id = ' . (int)$post_id;
if (!($topic_id_result = DB()->sql_query($topic_id_sql))) { if (!($topic_id_result = DB()->sql_query($topic_id_sql))) {
bb_die('Could not query post information'); bb_die('Could not query post information');
} }
$topic_id_row = DB()->sql_fetchrow($topic_id_result); $topic_id_row = DB()->sql_fetchrow($topic_id_result);
$topic_id = $topic_id_row['topic_id']; $topic_id = $topic_id_row['topic_id'];
$topic_title = $topic_id_row['topic_title'];
if (!$attachment['tracker_status']) { if (!$attachment['tracker_status']) {
bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']); bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']);
@ -585,7 +590,8 @@ class Torrent
// Send torrent // Send torrent
$output = \Arokettu\Bencode\Bencode::encode($tor); $output = \Arokettu\Bencode\Bencode::encode($tor);
$dl_fname = '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.torrent';
$dl_fname = wbr($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.torrent';
if (!empty($_COOKIE['explain'])) { if (!empty($_COOKIE['explain'])) {
$out = "attach path: $filename<br /><br />"; $out = "attach path: $filename<br /><br />";