You've already forked EasyImages2.0
mirror of
https://github.com/icret/EasyImages2.0.git
synced 2025-12-16 11:53:58 +08:00
v2.6.8
- 上传组件支持到 PHP 8.2 - 修复下载任意文件漏洞 [#75](https://github.com/icret/EasyImages2.0/issues/75) - 增加自定义底部信息 - 增加自定义管理提示 - 增加图床模式 - 危险:除图片外不验证文件是否正常,也代表可以上传任意指定格式! - 增加上传时生成缩略图(仅设置直链缩略图时生效),低配vps负载较大,影响前端上传速度! - 其他一些优化
This commit is contained in:
@@ -500,6 +500,14 @@ class Upload {
|
||||
*/
|
||||
var $file_max_size;
|
||||
|
||||
/**
|
||||
* Max file size, from php.ini
|
||||
*
|
||||
* @access private
|
||||
* @var double
|
||||
*/
|
||||
var $file_max_size_raw;
|
||||
|
||||
/**
|
||||
* Set this variable to true to resize the file if it is an image
|
||||
*
|
||||
@@ -2109,7 +2117,7 @@ class Upload {
|
||||
*/
|
||||
function upload($file, $lang = 'en_GB') {
|
||||
|
||||
$this->version = '13/06/2022';
|
||||
$this->version = '30/08/2022';
|
||||
|
||||
$this->file_src_name = '';
|
||||
$this->file_src_name_body = '';
|
||||
@@ -2926,6 +2934,7 @@ class Upload {
|
||||
* @return resource Container image
|
||||
*/
|
||||
function imagecreatenew($x, $y, $fill = true, $trsp = false) {
|
||||
$x = (int) $x; $y = (int) $y;
|
||||
if ($x < 1) $x = 1; if ($y < 1) $y = 1;
|
||||
if ($this->gdversion() >= 2 && !$this->image_is_palette) {
|
||||
// create a true color image
|
||||
@@ -3913,6 +3922,8 @@ class Upload {
|
||||
|
||||
// resize the image
|
||||
if ($this->image_dst_x != $this->image_src_x || $this->image_dst_y != $this->image_src_y) {
|
||||
$this->image_dst_x = (int) $this->image_dst_x;
|
||||
$this->image_dst_y = (int) $this->image_dst_y;
|
||||
$tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);
|
||||
|
||||
if ($gd_version >= 2) {
|
||||
@@ -4077,8 +4088,9 @@ class Upload {
|
||||
$p_new['red'] = (abs($p_orig['red'] - $p_blur['red']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'])) : $p_orig['red'];
|
||||
$p_new['green'] = (abs($p_orig['green'] - $p_blur['green']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'])) : $p_orig['green'];
|
||||
$p_new['blue'] = (abs($p_orig['blue'] - $p_blur['blue']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'])) : $p_orig['blue'];
|
||||
$p_new['alpha'] = max(-127, min(127, $p_orig['alpha']));
|
||||
if (($p_orig['red'] != $p_new['red']) || ($p_orig['green'] != $p_new['green']) || ($p_orig['blue'] != $p_new['blue'])) {
|
||||
$color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']);
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $p_new['red'], (int) $p_new['green'], (int) $p_new['blue'], (int) $p_new['alpha']);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
}
|
||||
}
|
||||
@@ -4094,7 +4106,8 @@ class Upload {
|
||||
if ($p_new['green']>255) { $p_new['green']=255; } elseif ($p_new['green']<0) { $p_new['green']=0; }
|
||||
$p_new['blue'] = ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'];
|
||||
if ($p_new['blue']>255) { $p_new['blue']=255; } elseif ($p_new['blue']<0) { $p_new['blue']=0; }
|
||||
$color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']);
|
||||
$p_new['alpha'] = round(max(-127, min(127, $p_orig['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $p_new['red'], (int) $p_new['green'], (int) $p_new['blue'], (int) $p_new['alpha']);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
}
|
||||
}
|
||||
@@ -4125,7 +4138,8 @@ class Upload {
|
||||
if ($this->image_greyscale) {
|
||||
$pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));
|
||||
$r = $g = $b = round((0.2125 * $pixel['red']) + (0.7154 * $pixel['green']) + (0.0721 * $pixel['blue']));
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4133,7 +4147,8 @@ class Upload {
|
||||
$pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));
|
||||
$c = (round($pixel['red'] + $pixel['green'] + $pixel['blue']) / 3) - 127;
|
||||
$r = $g = $b = ($c > $this->image_threshold ? 255 : 0);
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4142,7 +4157,8 @@ class Upload {
|
||||
$r = max(min(round($pixel['red'] + (($this->image_brightness * 2))), 255), 0);
|
||||
$g = max(min(round($pixel['green'] + (($this->image_brightness * 2))), 255), 0);
|
||||
$b = max(min(round($pixel['blue'] + (($this->image_brightness * 2))), 255), 0);
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4151,7 +4167,8 @@ class Upload {
|
||||
$r = max(min(round(($this->image_contrast + 128) * $pixel['red'] / 128), 255), 0);
|
||||
$g = max(min(round(($this->image_contrast + 128) * $pixel['green'] / 128), 255), 0);
|
||||
$b = max(min(round(($this->image_contrast + 128) * $pixel['blue'] / 128), 255), 0);
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4160,7 +4177,8 @@ class Upload {
|
||||
$r = min(round($tint_red * $pixel['red'] / 169), 255);
|
||||
$g = min(round($tint_green * $pixel['green'] / 169), 255);
|
||||
$b = min(round($tint_blue * $pixel['blue'] / 169), 255);
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4169,7 +4187,8 @@ class Upload {
|
||||
$r = round(255 - $pixel['red']);
|
||||
$g = round(255 - $pixel['green']);
|
||||
$b = round(255 - $pixel['blue']);
|
||||
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
|
||||
$alpha = round(max(-127, min(127, $pixel['alpha'])));
|
||||
$color = imagecolorallocatealpha($image_dst, (int) $r, (int) $g, (int) $b, (int) $alpha);
|
||||
imagesetpixel($image_dst, $x, $y, $color);
|
||||
unset($color); unset($pixel);
|
||||
}
|
||||
@@ -4330,7 +4349,7 @@ class Upload {
|
||||
// add watermark image
|
||||
if ($this->image_watermark!='' && file_exists($this->image_watermark)) {
|
||||
$this->log .= '- add watermark<br />';
|
||||
$this->image_watermark_position = strtolower($this->image_watermark_position);
|
||||
$this->image_watermark_position = strtolower((string) $this->image_watermark_position);
|
||||
$watermark_info = getimagesize($this->image_watermark);
|
||||
$watermark_type = (array_key_exists(2, $watermark_info) ? $watermark_info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG
|
||||
$watermark_checked = false;
|
||||
@@ -4404,8 +4423,8 @@ class Upload {
|
||||
// if watermark is too large/tall, resize it first
|
||||
if ((!$this->image_watermark_no_zoom_out && ($watermark_dst_width > $this->image_dst_x || $watermark_dst_height > $this->image_dst_y))
|
||||
|| (!$this->image_watermark_no_zoom_in && $watermark_dst_width < $this->image_dst_x && $watermark_dst_height < $this->image_dst_y)) {
|
||||
$canvas_width = $this->image_dst_x - abs($this->image_watermark_x);
|
||||
$canvas_height = $this->image_dst_y - abs($this->image_watermark_y);
|
||||
$canvas_width = $this->image_dst_x - abs((int) $this->image_watermark_x);
|
||||
$canvas_height = $this->image_dst_y - abs((int) $this->image_watermark_y);
|
||||
if (($watermark_src_width/$canvas_width) > ($watermark_src_height/$canvas_height)) {
|
||||
$watermark_dst_width = $canvas_width;
|
||||
$watermark_dst_height = intval($watermark_src_height*($canvas_width / $watermark_src_width));
|
||||
@@ -4527,9 +4546,9 @@ class Upload {
|
||||
if (!is_numeric($this->image_text_line_spacing)) $this->image_text_line_spacing = 0;
|
||||
if (!is_numeric($this->image_text_padding_x)) $this->image_text_padding_x = $this->image_text_padding;
|
||||
if (!is_numeric($this->image_text_padding_y)) $this->image_text_padding_y = $this->image_text_padding;
|
||||
$this->image_text_position = strtolower($this->image_text_position);
|
||||
$this->image_text_direction = strtolower($this->image_text_direction);
|
||||
$this->image_text_alignment = strtolower($this->image_text_alignment);
|
||||
$this->image_text_position = strtolower((string) $this->image_text_position);
|
||||
$this->image_text_direction = strtolower((string) $this->image_text_direction);
|
||||
$this->image_text_alignment = strtolower((string) $this->image_text_alignment);
|
||||
|
||||
$font_type = 'gd';
|
||||
|
||||
@@ -4596,8 +4615,8 @@ class Upload {
|
||||
$maxX = max(array($rect[0],$rect[2],$rect[4],$rect[6]));
|
||||
$minY = min(array($rect[1],$rect[3],$rect[5],$rect[7]));
|
||||
$maxY = max(array($rect[1],$rect[3],$rect[5],$rect[7]));
|
||||
$text_offset_x = abs($minX) - 1;
|
||||
$text_offset_y = abs($minY) - 1;
|
||||
$text_offset_x = abs($minX);
|
||||
$text_offset_y = abs($minY);
|
||||
$text_width = $maxX - $minX + (2 * $this->image_text_padding_x);
|
||||
$text_height = $maxY - $minY + (2 * $this->image_text_padding_y);
|
||||
}
|
||||
@@ -4670,15 +4689,15 @@ class Upload {
|
||||
if ($this->image_text_direction == 'v') {
|
||||
imagestringup($filter,
|
||||
$this->image_text_font,
|
||||
$k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
|
||||
$text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))) ,
|
||||
(int) ($k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0))),
|
||||
(int) ($text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2)))),
|
||||
$v,
|
||||
$text_color);
|
||||
} else {
|
||||
imagestring($filter,
|
||||
$this->image_text_font,
|
||||
($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))),
|
||||
$k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
|
||||
(int) ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))),
|
||||
(int) ($k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0))),
|
||||
$v,
|
||||
$text_color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user