mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -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']));
|
$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
|
FROM ' . BB_BT_TORRENTS . ' t
|
||||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . ' ad
|
LEFT JOIN ' . BB_ATTACHMENTS_DESC . ' ad
|
||||||
ON t.attach_id = ad.attach_id
|
ON t.attach_id = ad.attach_id
|
||||||
|
@ -58,18 +58,18 @@ if (isset($torrent['info']['private']) && IS_GUEST) {
|
||||||
die($lang['BT_PRIVATE_TORRENT']);
|
die($lang['BT_PRIVATE_TORRENT']);
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Cache-Control: public, max-age=3600');
|
|
||||||
|
|
||||||
$files = (new TorrentPier\Legacy\TorrentFileList($torrent)) -> fileTreeTable($torrent['info']['file tree']);
|
$files = (new TorrentPier\Legacy\TorrentFileList($torrent)) -> fileTreeTable($torrent['info']['file tree']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => htmlCHR($torrent['info']['name'] ?? ''),
|
'name' => isset($torrent['info']['name']) ? htmlCHR(substr($torrent['info']['name'], 0, 255)) : 'undefined',
|
||||||
'client' => htmlCHR(substr($torrent['created by'] ?? 'unknown client', 0, 20)),
|
'client' => isset($torrent['created by']) ? htmlCHR(substr($torrent['created by'], 0, 20)) : 'unknown client',
|
||||||
'size' => humn_size($files['size']),
|
|
||||||
'date' => (isset($torrent['creation date']) && is_numeric($torrent['creation date'])) ? delta_time($torrent['creation date']) : 'unknown',
|
'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
|
'site_url' => FULL_URL
|
||||||
];
|
];
|
||||||
|
|
||||||
|
header('Cache-Control: public, max-age=3600');
|
||||||
|
|
||||||
echo <<<EOF
|
echo <<<EOF
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
@ -390,22 +390,23 @@ class Torrent
|
||||||
|
|
||||||
if (isset($info['length'])) {
|
if (isset($info['length'])) {
|
||||||
$totallen = (float)$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) {
|
foreach ($info['files'] as $fn => $f) {
|
||||||
// Exclude padding files
|
// Exclude padding files
|
||||||
if (($f['attr'] ?? null) !== 'p') {
|
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)) {
|
} elseif (isset($bt_v2)) {
|
||||||
$fileTreeSize = function (array $array, string $name = '') use (&$fileTreeSize) {
|
$fileTreeSize = function (array $array, string $name = '') use (&$fileTreeSize) {
|
||||||
$size = 0;
|
global $lang;
|
||||||
|
|
||||||
|
$size = 0;
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (!isset($value[''])) {
|
if (!isset($value[''])) {
|
||||||
$size += $fileTreeSize($value);
|
$size += $fileTreeSize($value);
|
||||||
} else {
|
} 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);
|
$html_v2 = $this->fileTreeList($value);
|
||||||
$allItems .= "<li><span class=\"b\">$key</span><ul>$html_v2</ul></li>";
|
$allItems .= "<li><span class=\"b\">$key</span><ul>$html_v2</ul></li>";
|
||||||
} else {
|
} else {
|
||||||
$length = (int)$value['']['length'];
|
$length = (float)$value['']['length'];
|
||||||
$root = bin2hex($value['']['pieces root'] ?? '');
|
$root = bin2hex($value['']['pieces root'] ?? '');
|
||||||
$allItems .= "<li><span>$key<i>$length</i><p>$root</p></span></li>";
|
$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
|
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) {
|
foreach ($array as $key => $value) {
|
||||||
$key = htmlCHR($key);
|
$key = htmlCHR($key);
|
||||||
$current = "$parent/$key";
|
$current = "$parent/$key";
|
||||||
if (!isset($value[''])) {
|
if (!isset($value[''])) {
|
||||||
$this->fileTreeTable($value, $current);
|
$this->fileTreeTable($value, $current);
|
||||||
} else {
|
} else {
|
||||||
$length = (int)$value['']['length'];
|
$length = (float)$value['']['length'];
|
||||||
$root = bin2hex($value['']['pieces root'] ?? '');
|
$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['list'] .= '<tr><td>' . $current . '</td><td>' . humn_size($length, 2) . '</td><td>' . $root . '</td></tr><tr>';
|
||||||
$filesList['count']++;
|
$filesList['count']++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue