diff --git a/library/includes/functions.php b/library/includes/functions.php
index 27d17ab62..4ba569caa 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -1861,20 +1861,23 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key,
return false;
}
+ $v1_support = !empty($infohash);
+ $v2_support = !empty($infohash_v2);
+
$magnet = 'magnet:?';
- if (!empty($infohash)) {
+ if ($v1_support) {
$magnet .= 'xt=urn:btih:' . bin2hex($infohash);
}
- if (!empty($infohash_v2)) {
- if (!empty($infohash)) {
+ if ($v2_support) {
+ if ($v1_support) {
$magnet .= '&';
}
$magnet .= 'xt=urn:btmh:1220' . bin2hex($infohash_v2);
}
- return '
';
+ return '
';
}
function set_die_append_msg($forum_id = null, $topic_id = null, $group_id = null)
diff --git a/library/language/source/main.php b/library/language/source/main.php
index 302c7b735..ad06eb6c8 100644
--- a/library/language/source/main.php
+++ b/library/language/source/main.php
@@ -1084,6 +1084,7 @@ $lang['SEEDING'] = 'Seed';
$lang['LEECHING'] = 'Leech';
$lang['IS_REGISTERED'] = 'Registered';
$lang['MAGNET'] = 'Magnet-link';
+$lang['MAGNET_v2'] = 'Magnet-link (BitTorrent v2 supported)';
//torrent status mod
$lang['TOR_STATUS'] = 'Status';
diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php
index f750727f6..971b78406 100644
--- a/src/Legacy/Torrent.php
+++ b/src/Legacy/Torrent.php
@@ -389,7 +389,8 @@ class Torrent
if (isset($info['length'])) {
$totallen = (float)$info['length'];
- } elseif (isset($bt_v1, $info['files']) && \is_array($info['files'])) {
+ }
+ elseif (isset($bt_v1, $info['files']) && \is_array($info['files'])) {
foreach ($info['files'] as $fn => $f) {
// Exclude padding files
if (($f['attr'] ?? null) !== 'p') {
diff --git a/src/Legacy/TorrentFileList.php b/src/Legacy/TorrentFileList.php
index 682b449df..648022cfe 100644
--- a/src/Legacy/TorrentFileList.php
+++ b/src/Legacy/TorrentFileList.php
@@ -42,7 +42,7 @@ class TorrentFileList
public function get_filelist()
{
global $html;
- if (($this->tor_decoded['info']['meta version'] ?? null) == 2) {
+ if (($this->tor_decoded['info']['meta version'] ?? 1) === 2) {
if (is_array($this->tor_decoded['info']['file tree'] ?? null)) {
return $this->fileTreeList($this->tor_decoded['info']['file tree']); //v2
}
@@ -87,7 +87,7 @@ class TorrentFileList
continue;
}
// Exclude padding files
- if (($f['attr'] ?? null) === 'p') {
+ if (isset($f['attr']) && $f['attr'] === 'p') {
continue;
}
array_deep($f['path'], 'clean_tor_dirname');
diff --git a/styles/images/magnet_v2.png b/styles/images/magnet_v2.png
new file mode 100644
index 000000000..f587bf795
Binary files /dev/null and b/styles/images/magnet_v2.png differ
diff --git a/styles/templates/default/tpl_config.php b/styles/templates/default/tpl_config.php
index 3b160d694..267ecb60d 100644
--- a/styles/templates/default/tpl_config.php
+++ b/styles/templates/default/tpl_config.php
@@ -72,6 +72,7 @@ $images['folder_dl_hot_new'] = $_main . 'folder_dl_hot_new.gif';
$images['icon_clip'] = $_img . 'icon_clip.gif';
$images['icon_dn'] = $_img . 'icon_dn.gif';
$images['icon_magnet'] = $_img . 'magnet.png';
+$images['icon_magnet_v2'] = $_img . 'magnet_v2.png';
// posting_icons
$images['post_new'] = $_lang . 'post.gif';