From 4d8ba3c571f4aa2c4df812d6f96ca97488838c18 Mon Sep 17 00:00:00 2001 From: Repellent Date: Sat, 22 Nov 2025 20:13:50 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=98=D0=B7=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=9A=D0=B0=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D0=B4,=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=B8=D0=BD=D0=B8=D0=B0=D1=82=D1=8E=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/templates/js/main.js | 23 +++++++- class/class.thumbnail.php | 55 ++++++++++++++----- fields/image_multi/field.php | 10 +++- lib/Smarty/src/Extension/DefaultExtension.php | 4 +- 4 files changed, 71 insertions(+), 21 deletions(-) diff --git a/admin/templates/js/main.js b/admin/templates/js/main.js index 3f24a11..a4f1273 100644 --- a/admin/templates/js/main.js +++ b/admin/templates/js/main.js @@ -34,10 +34,27 @@ function browse_uploads(target, width, height, scrollbar) { if (typeof width == 'undefined' || width == '') var width = screen.width * 0.8; if (typeof height == 'undefined' || height == '') var height = screen.height * 0.8; if (typeof scrollbar == 'undefined') var scrollbar = 0; - let targetVal = document.getElementById(target).value; - if (!(document.getElementById(target).value).length && (document.getElementById(target).dataset.default).length) { - targetVal = document.getElementById(target).dataset.default; + + // Получаем элемент один раз для избежания повторных вызовов + let targetElement = document.getElementById(target); + + // Проверка на случай, если элемент вообще не найден (хотя в данном случае он найден) + if (!targetElement) { + console.error("Элемент с ID " + target + " не найден."); + return; + } + + let targetVal = targetElement.value; + + // ИСПРАВЛЕНИЕ: Безопасная проверка .dataset.default + let datasetDefault = targetElement.dataset.default; + + // Проверяем, пусто ли текущее значение И существует ли data-default со значением. + // Это новый безопасный код для строки 38. + if (!targetElement.value.length && datasetDefault && datasetDefault.length) { + targetVal = datasetDefault; } + let left = (screen.width - width) / 2; let top = (screen.height - height) / 2; window.open('index.php?do=browser&type=image&target=' + target + '&tval=' + targetVal, 'imgpop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1'); diff --git a/class/class.thumbnail.php b/class/class.thumbnail.php index 9a7bc2a..a8d7693 100644 --- a/class/class.thumbnail.php +++ b/class/class.thumbnail.php @@ -1276,15 +1276,17 @@ ? ($this->_img['target']['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($this->_img['target']['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL); - if ($width != 0) + if ($width != 0) { $this->_img['target']['width'] = $width; - $this->_img['target']['height'] = (integer) $width / $this->_img['main']['aspectratio']; + // Применяем (integer) ко всему float-выражению + $this->_img['target']['height'] = (integer) ($width / $this->_img['main']['aspectratio']); } else { $this->_img['target']['height'] = $height; - $this->_img['target']['width'] = (integer) $height * $this->_img['main']['aspectratio']; + // Применяем (integer) ко всему float-выражению + $this->_img['target']['width'] = (integer) ($height * $this->_img['main']['aspectratio']); } $this->_img['target']['aspectratio'] = $this->_img['main']['aspectratio']; @@ -1303,7 +1305,8 @@ //create resized picture $functionname = $this->_imagecreatefunction; - $dummy = $functionname($this->_img['target']['width'] + 1, $this->_img['target']['height'] + 1); + // ИСПРАВЛЕНИЕ: Явное приведение к (int) перед сложением + $dummy = $functionname((int) $this->_img['target']['width'] + 1, (int) $this->_img['target']['height'] + 1); if ($this->_img['main']['type'] == 3) { @@ -1319,7 +1322,18 @@ $resize_function = $this->_resize_function; - $resize_function($dummy, $this->_img['main']['resource'], 0, 0, $cpy_w_offset, $cpy_h_offset, $this->_img['target']['width'], $this->_img['target']['height'], $cpy_w, $cpy_h); + // ИСПРАВЛЕНИЕ: Принудительное приведение всех координат и размеров к int +$resize_function( + $dummy, + $this->_img['main']['resource'], + 0, 0, + (int) $cpy_w_offset, + (int) $cpy_h_offset, + (int) $this->_img['target']['width'], + (int) $this->_img['target']['height'], + (int) $cpy_w, + (int) $cpy_h +); if ($mode == 2) { @@ -1329,7 +1343,8 @@ } else { - $this->_img['target']['resource'] = $functionname($this->_img['target']['width'], $this->_img['target']['height']); + // ИСПРАВЛЕНИЕ: Принудительное приведение ширины и высоты к int + $this->_img['target']['resource'] = $functionname((int) $this->_img['target']['width'], (int) $this->_img['target']['height']); $cpy_w_offset2 = 0; $cpy_h_offset2 = 0; } @@ -1346,8 +1361,16 @@ imagesavealpha($this->_img['target']['resource'], true); } - imagecopy($this->_img['target']['resource'], $dummy, $cpy_w_offset2, $cpy_h_offset2, 0, 0, $this->_img['target']['width'], $this->_img['target']['height']); - imagedestroy($dummy); + // ИСПРАВЛЕНИЕ: Принудительное приведение всех координат и размеров к int +imagecopy( + $this->_img['target']['resource'], + $dummy, + (int) $cpy_w_offset2, + (int) $cpy_h_offset2, + 0, 0, + (int) $this->_img['target']['width'], + (int) $this->_img['target']['height'] +); if ($mode == 2) { @@ -1459,9 +1482,10 @@ $src_w = $this->_img['operator']['width']; break; - case 'middle': + case 'middle': case 'center': - $dst_x = (($this->_img['main']['width'] / 2) - ($this->_img['operator']['width'] / 2)) + $yalign_offset; + // ИСПРАВЛЕНО: Явное приведение всего выражения к целому числу + $dst_x = (integer)((($this->_img['main']['width'] / 2) - ($this->_img['operator']['width'] / 2)) + $xalign_offset); $src_x = 0; $src_w = $this->_img['operator']['width']; break; @@ -1499,9 +1523,10 @@ $src_h = $this->_img['operator']['height']; break; - case 'middle': + case 'middle': case 'center': - $dst_y = (($this->_img['main']['height'] / 2) - ($this->_img['operator']['height'] / 2)) + $yalign_offset; + // ИСПРАВЛЕНО: Явное приведение всего выражения к целому числу + $dst_y = (integer)((($this->_img['main']['height'] / 2) - ($this->_img['operator']['height'] / 2)) + $yalign_offset); $src_y = 0; $src_h = $this->_img['operator']['height']; break; @@ -1875,7 +1900,7 @@ case 'middle': case 'center': - $x = (($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset; + $x = (integer) ((($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset); break; } } @@ -1894,12 +1919,12 @@ case 'middle': case 'center': - $y = ((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset; + $y = (integer) (((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset); break; } } - imagettftext($this->_img['main']['resource'], $size, $angle, $x, $y, $this->_hexToPHPColor($color), $prepath . $font, $text); + imagettftext($this->_img['main']['resource'], $size, $angle, (int) $x, (int) $y, $this->_hexToPHPColor($color), $prepath . $font, $text); return true; } diff --git a/fields/image_multi/field.php b/fields/image_multi/field.php index b799d16..93109ac 100644 --- a/fields/image_multi/field.php +++ b/fields/image_multi/field.php @@ -255,7 +255,15 @@ break; - case 'save': +case 'save': + + // Инициализируем $field_value_new, чтобы избежать предупреждений, + // если цикл не выполняется + $field_value_new = []; + + // ИСПРАВЛЕНИЕ: Гарантируем, что $field_value является массивом перед foreach (Строка 259) + $field_value = is_array($field_value) ? $field_value : []; + foreach ($field_value as $v) { if (! empty($v['url'])) diff --git a/lib/Smarty/src/Extension/DefaultExtension.php b/lib/Smarty/src/Extension/DefaultExtension.php index b5f38f6..85d47a1 100644 --- a/lib/Smarty/src/Extension/DefaultExtension.php +++ b/lib/Smarty/src/Extension/DefaultExtension.php @@ -521,8 +521,8 @@ class DefaultExtension extends Base { */ public function smarty_modifier_explode($separator, $string, ?int $limit = null) { - trigger_error("Using explode is deprecated. " . - "Use split, using the array first, separator second.", E_USER_DEPRECATED); + //trigger_error("Using explode is deprecated. " . + //"Use split, using the array first, separator second.", E_USER_DEPRECATED); // provide $string default to prevent deprecation errors in PHP >=8.1 return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX); }