mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 04:34:17 +00:00
remove torrent file limits
This commit is contained in:
parent
e591fe36a1
commit
b25cc173c5
2
.env
2
.env
@ -63,6 +63,4 @@ APP_PAGE_TITLE_LENGTH_MIN=10
|
||||
APP_PAGE_TITLE_LENGTH_MAX=255
|
||||
APP_PAGE_DESCRIPTION_LENGTH_MIN=0
|
||||
APP_PAGE_DESCRIPTION_LENGTH_MAX=10000
|
||||
APP_PAGE_TORRENT_FILE_QUANTITY_MIN=1
|
||||
APP_PAGE_TORRENT_FILE_QUANTITY_MAX=100
|
||||
APP_TORRENT_FILE_SIZE_MAX=1024000
|
@ -16,8 +16,6 @@ parameters:
|
||||
app.page.title.length.max: '%env(APP_PAGE_TITLE_LENGTH_MAX)%'
|
||||
app.page.description.length.min: '%env(APP_PAGE_DESCRIPTION_LENGTH_MIN)%'
|
||||
app.page.description.length.max: '%env(APP_PAGE_DESCRIPTION_LENGTH_MAX)%'
|
||||
app.page.torrent.file.quantity.min: '%env(APP_PAGE_TORRENT_FILE_QUANTITY_MIN)%'
|
||||
app.page.torrent.file.quantity.max: '%env(APP_PAGE_TORRENT_FILE_QUANTITY_MAX)%'
|
||||
app.torrent.size.max: '%env(APP_TORRENT_FILE_SIZE_MAX)%'
|
||||
|
||||
services:
|
||||
|
@ -120,11 +120,7 @@ class PageController extends AbstractController
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'placeholder' => sprintf(
|
||||
$translator->trans('Append %s-%s torrent files'),
|
||||
$this->getParameter('app.page.torrent.file.quantity.min'),
|
||||
$this->getParameter('app.page.torrent.file.quantity.max')
|
||||
)
|
||||
'placeholder' => $translator->trans('Select torrent file')
|
||||
]
|
||||
],
|
||||
'sensitive' =>
|
||||
@ -170,35 +166,30 @@ class PageController extends AbstractController
|
||||
}
|
||||
|
||||
/// Torrents
|
||||
$total = 0;
|
||||
$torrents = [];
|
||||
|
||||
if ($files = $request->files->get('torrents'))
|
||||
{
|
||||
foreach ($files as $file)
|
||||
{
|
||||
//// Quantity
|
||||
$total++;
|
||||
|
||||
//// File size
|
||||
if (filesize($file->getPathName()) > $this->getParameter('app.torrent.size.max'))
|
||||
/// Torrent
|
||||
if ($file = $request->files->get('torrent'))
|
||||
{
|
||||
$form['torrents']['error'][] = $translator->trans('Torrent file out of size limit');
|
||||
//// Validate torrent file
|
||||
if (filesize($file->getPathName()) > $this->getParameter('app.torrent.size.max'))
|
||||
{
|
||||
$form['torrents']['error'][] = $translator->trans('Torrent file out of size limit');
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//// Validate torrent format
|
||||
try
|
||||
{
|
||||
\Rhilip\Bencode\TorrentFile::load(
|
||||
$file->getPathName()
|
||||
);
|
||||
}
|
||||
//// Validate torrent format
|
||||
if (!$torrentService->readTorrentFileByFilepath($file->getPathName()))
|
||||
{
|
||||
$form['torrents']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
|
||||
catch (ParseException $e)
|
||||
{
|
||||
$form['torrents']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//// Content
|
||||
@ -206,7 +197,7 @@ class PageController extends AbstractController
|
||||
$file->getPathName(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
(array) $locales,
|
||||
[$request->get('locale')],
|
||||
(bool) $request->get('sensitive'),
|
||||
$user->isApproved()
|
||||
);
|
||||
@ -215,17 +206,6 @@ class PageController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
if ($total < $this->getParameter('app.page.torrent.file.quantity.min') ||
|
||||
$total > $this->getParameter('app.page.torrent.file.quantity.max'))
|
||||
{
|
||||
$form['torrents']['error'][] = sprintf(
|
||||
$translator->trans('Torrents quantity out of %s-%s range'),
|
||||
number_format($this->getParameter('app.page.torrent.file.quantity.min')),
|
||||
number_format($this->getParameter('app.page.torrent.file.quantity.max'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (empty($form['locale']['error']) &&
|
||||
empty($form['title']['error']) &&
|
||||
empty($form['description']['error']) &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user