mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-69028 repository: Put a rate limit on draft file uploads
This commit is contained in:
parent
5b7d2a1992
commit
c4e993d546
7 changed files with 168 additions and 1 deletions
|
@ -334,6 +334,11 @@ case 'download':
|
|||
unlink($thefile['path']);
|
||||
print_error('maxareabytes');
|
||||
}
|
||||
// Ensure the user does not upload too many draft files in a short period.
|
||||
if (file_is_draft_areas_limit_reached($USER->id)) {
|
||||
unlink($thefile['path']);
|
||||
print_error('maxdraftitemids');
|
||||
}
|
||||
try {
|
||||
$info = repository::move_to_filepool($thefile['path'], $record);
|
||||
redirect($home_url, get_string('downloadsucc', 'repository'));
|
||||
|
|
|
@ -309,6 +309,10 @@ switch ($action) {
|
|||
if (file_is_draft_area_limit_reached($itemid, $areamaxbytes, filesize($downloadedfile['path']))) {
|
||||
throw new file_exception('maxareabytes');
|
||||
}
|
||||
// Ensure the user does not upload too many draft files in a short period.
|
||||
if (file_is_draft_areas_limit_reached($USER->id)) {
|
||||
throw new file_exception('maxdraftitemids');
|
||||
}
|
||||
|
||||
$info = repository::move_to_filepool($downloadedfile['path'], $record);
|
||||
if (empty($info)) {
|
||||
|
|
|
@ -199,6 +199,10 @@ class repository_upload extends repository {
|
|||
if (file_is_draft_area_limit_reached($record->itemid, $areamaxbytes, filesize($_FILES[$elname]['tmp_name']))) {
|
||||
throw new file_exception('maxareabytes');
|
||||
}
|
||||
// Ensure the user does not upload too many draft files in a short period.
|
||||
if (file_is_draft_areas_limit_reached($USER->id)) {
|
||||
throw new file_exception('maxdraftitemids');
|
||||
}
|
||||
|
||||
$record->contextid = $context->id;
|
||||
$record->userid = $USER->id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue