mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Transfer from array to ArrayObject data type (#1019)
This commit is contained in:
parent
3ba3b5a8db
commit
79116b2c27
4 changed files with 8 additions and 6 deletions
|
@ -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)) . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue