diff --git a/bt/scrape.php b/bt/scrape.php index eaaa90e59..5717b6ae1 100644 --- a/bt/scrape.php +++ b/bt/scrape.php @@ -48,11 +48,14 @@ preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_arra $info_hashes = []; foreach ($info_hash_array[1] as $hash) { - if ($scrape_cache = CACHE('tr_cache')->get(SCRAPE_LIST_PREFIX . bin2hex(urldecode($hash)))) { + + $decoded_hash = urldecode($hash); + + if ($scrape_cache = CACHE('tr_cache')->get(SCRAPE_LIST_PREFIX . bin2hex($decoded_hash))) { $torrents['files'][$info_key = array_key_first($scrape_cache)] = $scrape_cache[$info_key]; } else{ - $info_hashes[] = '\''. DB()->escape((urldecode($hash))) . '\''; + $info_hashes[] = '\''. DB()->escape(($decoded_hash)) . '\''; } } diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index 0a0dbf7f1..46ac44b8a 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -37,7 +37,7 @@ if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents)) { } $torrent = new TorrentPier\Legacy\TorrentFileList($tor); -if (($tor['info']['meta version'] ?? null) == 2 && is_array($tor['info']['file tree'] ?? null)) { +if (($tor['info']['meta version'] ?? null) == 2) { $tor_filelist = $torrent->fileTreeList($tor['info']['file tree'], $tor['info']['name'] ?? ''); // v2 } else { $tor_filelist = $torrent->get_filelist(); // v1 diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index 6f3cd17ec..d6d770f3e 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -386,7 +386,6 @@ class Torrent } $totallen = 0; - if (isset($info['length'])) { $totallen = (float)$info['length']; } elseif ($bt_v1 && isset($info['files']) && \is_array($info['files'])) { @@ -397,7 +396,7 @@ class Torrent } } } elseif ($bt_v2) { - $fileTreeSize = function (array $array, string $name = '') use (&$fileTreeSize) { + $fileTreeSize = function ($array, string $name = '') use (&$fileTreeSize) { $size = 0; foreach ($array as $key => $value) { diff --git a/src/Legacy/TorrentFileList.php b/src/Legacy/TorrentFileList.php index fc294e465..2f9d91190 100644 --- a/src/Legacy/TorrentFileList.php +++ b/src/Legacy/TorrentFileList.php @@ -132,7 +132,7 @@ class TorrentFileList * @param string $name * @return string */ - public function fileTreeList(array $array, string $name = ''): string + public function fileTreeList($array, string $name = ''): string { $folders = []; $rootFiles = [];