mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Tighten registration requirements for torrent files (#1165)
This commit is contained in:
parent
3c7f3cf7d0
commit
c3b9a781eb
3 changed files with 14 additions and 14 deletions
|
@ -20,7 +20,7 @@ if ($bb_cfg['bt_disable_dht'] && IS_GUEST) {
|
|||
|
||||
$topic_id = !empty($_GET['topic']) ? (int)$_GET['topic'] : (http_response_code(404) && die($lang['INVALID_TOPIC_ID']));
|
||||
|
||||
$sql = 'SELECT t.attach_id, t.info_hash_v2, ad.physical_filename
|
||||
$sql = 'SELECT t.attach_id, t.info_hash_v2, t.size, ad.physical_filename
|
||||
FROM ' . BB_BT_TORRENTS . ' t
|
||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . ' ad
|
||||
ON t.attach_id = ad.attach_id
|
||||
|
@ -58,18 +58,18 @@ if (isset($torrent['info']['private']) && IS_GUEST) {
|
|||
die($lang['BT_PRIVATE_TORRENT']);
|
||||
}
|
||||
|
||||
header('Cache-Control: public, max-age=3600');
|
||||
|
||||
$files = (new TorrentPier\Legacy\TorrentFileList($torrent)) -> fileTreeTable($torrent['info']['file tree']);
|
||||
|
||||
$data = [
|
||||
'name' => htmlCHR($torrent['info']['name'] ?? ''),
|
||||
'client' => htmlCHR(substr($torrent['created by'] ?? 'unknown client', 0, 20)),
|
||||
'size' => humn_size($files['size']),
|
||||
'name' => isset($torrent['info']['name']) ? htmlCHR(substr($torrent['info']['name'], 0, 255)) : 'undefined',
|
||||
'client' => isset($torrent['created by']) ? htmlCHR(substr($torrent['created by'], 0, 20)) : 'unknown client',
|
||||
'date' => (isset($torrent['creation date']) && is_numeric($torrent['creation date'])) ? delta_time($torrent['creation date']) : 'unknown',
|
||||
'size' => humn_size($row['size']),
|
||||
'site_url' => FULL_URL
|
||||
];
|
||||
|
||||
header('Cache-Control: public, max-age=3600');
|
||||
|
||||
echo <<<EOF
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
@ -390,22 +390,23 @@ 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']) && !isset($bt_v2) && \is_array($info['files'])) {
|
||||
foreach ($info['files'] as $fn => $f) {
|
||||
// Exclude padding files
|
||||
if (($f['attr'] ?? null) !== 'p') {
|
||||
$totallen += (float)$f['length'];
|
||||
$totallen += (isset($f['length']) && is_numeric($f['length'])) ? (float)$f['length'] : self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||
}
|
||||
}
|
||||
} elseif (isset($bt_v2)) {
|
||||
$fileTreeSize = function (array $array, string $name = '') use (&$fileTreeSize) {
|
||||
$size = 0;
|
||||
global $lang;
|
||||
|
||||
$size = 0;
|
||||
foreach ($array as $key => $value) {
|
||||
if (!isset($value[''])) {
|
||||
$size += $fileTreeSize($value);
|
||||
} else {
|
||||
$size += (int)$value['']['length'];
|
||||
$size += (isset($value['']['length']) && is_numeric($value['']['length'])) ? (float)$value['']['length'] : self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class TorrentFileList
|
|||
$html_v2 = $this->fileTreeList($value);
|
||||
$allItems .= "<li><span class=\"b\">$key</span><ul>$html_v2</ul></li>";
|
||||
} else {
|
||||
$length = (int)$value['']['length'];
|
||||
$length = (float)$value['']['length'];
|
||||
$root = bin2hex($value['']['pieces root'] ?? '');
|
||||
$allItems .= "<li><span>$key<i>$length</i><p>$root</p></span></li>";
|
||||
}
|
||||
|
@ -165,16 +165,15 @@ class TorrentFileList
|
|||
*/
|
||||
public function fileTreeTable(array $array, string $parent = ''): array
|
||||
{
|
||||
static $filesList = ['list' => '', 'size' => 0, 'count' => 0];
|
||||
static $filesList = ['list' => '', 'count' => 0];
|
||||
foreach ($array as $key => $value) {
|
||||
$key = htmlCHR($key);
|
||||
$current = "$parent/$key";
|
||||
if (!isset($value[''])) {
|
||||
$this->fileTreeTable($value, $current);
|
||||
} else {
|
||||
$length = (int)$value['']['length'];
|
||||
$length = (float)$value['']['length'];
|
||||
$root = bin2hex($value['']['pieces root'] ?? '');
|
||||
$filesList['size'] += $length;
|
||||
$filesList['list'] .= '<tr><td>' . $current . '</td><td>' . humn_size($length, 2) . '</td><td>' . $root . '</td></tr><tr>';
|
||||
$filesList['count']++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue