Browse Source

Enforce file limits

merge-requests/3/head
Mike Koch 6 years ago
parent
commit
1eeb477577
  1. 7
      inc/common.inc.php
  2. 17
      inc/view_attachment_functions.inc.php
  3. 4
      language/en/text.php

7
inc/common.inc.php

@ -1836,4 +1836,11 @@ function mfh_log_warning($location, $message, $user) {
function mfh_log_error($location, $message, $user) {
mfh_log($location, $message, 3, $user);
}
function mfh_bytesToUnits($size) {
$bytes_in_megabyte = 1048576;
$quotient = $size / $bytes_in_megabyte;
return intval($quotient);
}

17
inc/view_attachment_functions.inc.php

@ -211,6 +211,8 @@ function display_dropzone_field($url, $id = 'filedrop') {
output_attachment_id_holder_container($id);
$acceptedFiles = implode(',', $hesk_settings['attachments']['allowed_types']);
$size = mfh_bytesToUnits($hesk_settings['attachments']['max_size']);
$max_files = $hesk_settings['attachments']['max_number'];
echo "
<script type=\"text/javascript\">
@ -224,22 +226,29 @@ function display_dropzone_field($url, $id = 'filedrop') {
file['databaseId'] = response;
});
this.on('removedfile', function(file) {
// Remove the attachment from the database and the filesystem.
removeAttachment(file['databaseId']);
});
this.on('queuecomplete', function(progress) {
// Stop animating if complete.
$('#total-progress').removeClass('active');
});
},
paramName: 'attachment',
url: '" . $url . "',
parallelUploads: 1,
uploadMultiple: false,
maxFiles: 1,
parallelUploads: ".$max_files.",
uploadMultiple: true,
maxFiles: ".$max_files.",
acceptedFiles: '".json_encode($acceptedFiles)."',
maxFilesize: 2, // MB
maxFilesize: ".$size.", // MB
dictDefaultMessage: ".json_encode($hesklang['attachment_viewer_message']).",
dictFallbackMessage: '',
dictInvalidFileType: ".json_encode($hesklang['attachment_invalid_type_message']).",
dictResponseError: ".json_encode($hesklang['attachment_upload_error']).",
dictFileTooBig: ".json_encode($hesklang['attachment_too_large']).",
dictCancelUpload: ".json_encode($hesklang['attachment_cancel']).",
dictCancelUploadConfirmation: ".json_encode($hesklang['attachment_confirm_cancel']).",
dictRemoveFile: ".json_encode($hesklang['attachment_remove']).",
previewTemplate: $('#previews').html()
};
</script>

4
language/en/text.php

@ -35,6 +35,10 @@ $hesklang['can_view_logs'] = 'Can view message logs';
$hesklang['attachment_viewer_message'] = 'Drag or click here to select files to upload.';
$hesklang['attachment_invalid_type_message'] = 'Sorry, but the file type you tried to upload is not allowed.';
$hesklang['attachment_upload_error'] = 'An error occurred when trying to upload. Please try again later.';
$hesklang['attachment_too_large'] = 'This attachment is larger than the max filesize permitted.';
$hesklang['attachment_cancel'] = 'Cancel';
$hesklang['attachment_confirm_cancel'] = 'Are you sure you want to cancel this upload?';
$hesklang['attachment_remove'] = 'Remove attachment';
// ADDED OR MODIFIED IN Mods for HESK 2.5.2
$hesklang['manage_statuses'] = 'Manage Statuses';

Loading…
Cancel
Save