|
|
@ -120,11 +120,7 @@ class PageController extends AbstractController |
|
|
|
'error' => [], |
|
|
|
'error' => [], |
|
|
|
'attribute' => |
|
|
|
'attribute' => |
|
|
|
[ |
|
|
|
[ |
|
|
|
'placeholder' => sprintf( |
|
|
|
'placeholder' => $translator->trans('Select torrent file') |
|
|
|
$translator->trans('Append %s-%s torrent files'), |
|
|
|
|
|
|
|
$this->getParameter('app.page.torrent.file.quantity.min'), |
|
|
|
|
|
|
|
$this->getParameter('app.page.torrent.file.quantity.max') |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
] |
|
|
|
] |
|
|
|
], |
|
|
|
], |
|
|
|
'sensitive' => |
|
|
|
'sensitive' => |
|
|
@ -170,35 +166,30 @@ class PageController extends AbstractController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Torrents |
|
|
|
/// Torrents |
|
|
|
$total = 0; |
|
|
|
|
|
|
|
$torrents = []; |
|
|
|
$torrents = []; |
|
|
|
|
|
|
|
|
|
|
|
if ($files = $request->files->get('torrents')) |
|
|
|
if ($files = $request->files->get('torrents')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach ($files as $file) |
|
|
|
foreach ($files as $file) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//// Quantity |
|
|
|
/// Torrent |
|
|
|
$total++; |
|
|
|
if ($file = $request->files->get('torrent')) |
|
|
|
|
|
|
|
|
|
|
|
//// File size |
|
|
|
|
|
|
|
if (filesize($file->getPathName()) > $this->getParameter('app.torrent.size.max')) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$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 |
|
|
|
//// Validate torrent format |
|
|
|
try |
|
|
|
if (!$torrentService->readTorrentFileByFilepath($file->getPathName())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
\Rhilip\Bencode\TorrentFile::load( |
|
|
|
$form['torrents']['error'][] = $translator->trans('Could not parse torrent file'); |
|
|
|
$file->getPathName() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (ParseException $e) |
|
|
|
continue; |
|
|
|
{ |
|
|
|
} |
|
|
|
$form['torrents']['error'][] = $translator->trans('Could not parse torrent file'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// Content |
|
|
|
//// Content |
|
|
@ -206,7 +197,7 @@ class PageController extends AbstractController |
|
|
|
$file->getPathName(), |
|
|
|
$file->getPathName(), |
|
|
|
$user->getId(), |
|
|
|
$user->getId(), |
|
|
|
time(), |
|
|
|
time(), |
|
|
|
(array) $locales, |
|
|
|
[$request->get('locale')], |
|
|
|
(bool) $request->get('sensitive'), |
|
|
|
(bool) $request->get('sensitive'), |
|
|
|
$user->isApproved() |
|
|
|
$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']) && |
|
|
|
if (empty($form['locale']['error']) && |
|
|
|
empty($form['title']['error']) && |
|
|
|
empty($form['title']['error']) && |
|
|
|
empty($form['description']['error']) && |
|
|
|
empty($form['description']['error']) && |
|
|
|