Transfer from array to ArrayObject data type (#1019)

This commit is contained in:
Cønstantine Kovalensky 2023-11-03 14:11:45 +04:00 committed by GitHub
commit 79116b2c27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View file

@ -48,11 +48,14 @@ preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_arra
$info_hashes = []; $info_hashes = [];
foreach ($info_hash_array[1] as $hash) { 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]; $torrents['files'][$info_key = array_key_first($scrape_cache)] = $scrape_cache[$info_key];
} }
else{ else{
$info_hashes[] = '\''. DB()->escape((urldecode($hash))) . '\''; $info_hashes[] = '\''. DB()->escape(($decoded_hash)) . '\'';
} }
} }

View file

@ -37,7 +37,7 @@ if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents)) {
} }
$torrent = new TorrentPier\Legacy\TorrentFileList($tor); $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 $tor_filelist = $torrent->fileTreeList($tor['info']['file tree'], $tor['info']['name'] ?? ''); // v2
} else { } else {
$tor_filelist = $torrent->get_filelist(); // v1 $tor_filelist = $torrent->get_filelist(); // v1

View file

@ -386,7 +386,6 @@ class Torrent
} }
$totallen = 0; $totallen = 0;
if (isset($info['length'])) { if (isset($info['length'])) {
$totallen = (float)$info['length']; $totallen = (float)$info['length'];
} elseif ($bt_v1 && isset($info['files']) && \is_array($info['files'])) { } elseif ($bt_v1 && isset($info['files']) && \is_array($info['files'])) {
@ -397,7 +396,7 @@ class Torrent
} }
} }
} elseif ($bt_v2) { } elseif ($bt_v2) {
$fileTreeSize = function (array $array, string $name = '') use (&$fileTreeSize) { $fileTreeSize = function ($array, string $name = '') use (&$fileTreeSize) {
$size = 0; $size = 0;
foreach ($array as $key => $value) { foreach ($array as $key => $value) {

View file

@ -132,7 +132,7 @@ class TorrentFileList
* @param string $name * @param string $name
* @return string * @return string
*/ */
public function fileTreeList(array $array, string $name = ''): string public function fileTreeList($array, string $name = ''): string
{ {
$folders = []; $folders = [];
$rootFiles = []; $rootFiles = [];