1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2026-02-18 02:10:54 +00:00

[Web] limit logo file upload

This commit is contained in:
FreddleSpl0it
2024-01-15 16:34:47 +01:00
parent 43bb26f28c
commit 7f6f7e0e9f
4 changed files with 31 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
function customize($_action, $_item, $_data = null) {
global $redis;
global $lang;
global $LOGO_LIMITS;
switch ($_action) {
case 'add':
@@ -35,6 +36,23 @@ function customize($_action, $_item, $_data = null) {
);
return false;
}
if ($_data[$_item]['size'] > $LOGO_LIMITS['max_size']) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_item, $_data),
'msg' => 'img_size_exceeded'
);
return false;
}
list($width, $height) = getimagesize($_data[$_item]['tmp_name']);
if ($width > $LOGO_LIMITS['max_width'] || $height > $LOGO_LIMITS['max_height']) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_item, $_data),
'msg' => 'img_dimensions_exceeded'
);
return false;
}
$image = new Imagick($_data[$_item]['tmp_name']);
if ($image->valid() !== true) {
$_SESSION['return'][] = array(