mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Handle & show upload_max_filesize occurences (#1241)
This commit is contained in:
parent
e9fec26e7d
commit
0525597a15
4 changed files with 19 additions and 6 deletions
|
@ -30,7 +30,7 @@ if (!file_exists($filename) || !$file_contents = file_get_contents($filename)) {
|
|||
|
||||
try {
|
||||
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||
} catch (Exception) {
|
||||
} catch (\Exception) {
|
||||
$this->response['html'] = $lang['TORFILE_INVALID'];
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ if ($bb_cfg['flist_max_files']) {
|
|||
|
||||
try {
|
||||
$torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||
} catch (Exception) {
|
||||
} catch (\Exception) {
|
||||
http_response_code(410);
|
||||
die($lang['TORFILE_INVALID']);
|
||||
}
|
||||
|
|
|
@ -734,9 +734,22 @@ class Attach
|
|||
$file = $_FILES['fileupload']['tmp_name'];
|
||||
$this->type = $_FILES['fileupload']['type'];
|
||||
|
||||
if (isset($_FILES['fileupload']['size']) && $_FILES['fileupload']['size'] == 0) {
|
||||
bb_die('Tried to upload empty file');
|
||||
if (isset($_FILES['fileupload']['error'])) {
|
||||
switch($_FILES['fileupload']['error']) {
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
bb_die('No file content sent');
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
bb_die('upload_max_filesize setting: ' . ini_get('upload_max_filesize'));
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
bb_die('Failed to write file to disk, check permissions');
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
bb_die('The uploaded file was only partially uploaded');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES['fileupload']['size']) && $_FILES['fileupload']['size'] === 0) {
|
||||
bb_die('Tried to upload empty file');
|
||||
}
|
||||
|
||||
$this->type = strtolower($this->type);
|
||||
$this->extension = strtolower(get_extension($this->filename));
|
||||
|
|
|
@ -319,7 +319,7 @@ class Torrent
|
|||
|
||||
try {
|
||||
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||
} catch (Exception) {
|
||||
} catch (\Exception $e) {
|
||||
self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ class Torrent
|
|||
$file_contents = file_get_contents($filename);
|
||||
try {
|
||||
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
|
||||
} catch (Exception) {
|
||||
} catch (\Exception) {
|
||||
bb_die($lang['TORFILE_INVALID']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue