Handle & show upload_max_filesize occurences (#1241)

This commit is contained in:
Cønstantine Kovalensky 2023-12-20 22:47:32 +04:00 committed by GitHub
commit 0525597a15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View file

@ -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;
}

View file

@ -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']);
}

View file

@ -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));

View file

@ -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']);
}