Bump fileuploader to v9.32
This commit is contained in:
@@ -84,9 +84,9 @@ class UploadHandler
|
|||||||
const IMAGETYPE_PNG = 3;
|
const IMAGETYPE_PNG = 3;
|
||||||
|
|
||||||
protected $image_objects = array();
|
protected $image_objects = array();
|
||||||
|
protected $response = array();
|
||||||
|
|
||||||
public function __construct($options = null, $initialize = true, $error_messages = null) {
|
public function __construct($options = null, $initialize = true, $error_messages = null) {
|
||||||
$this->response = array();
|
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
|
'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
|
||||||
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
|
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
|
||||||
@@ -418,7 +418,11 @@ class UploadHandler
|
|||||||
public function get_config_bytes($val) {
|
public function get_config_bytes($val) {
|
||||||
$val = trim($val);
|
$val = trim($val);
|
||||||
$last = strtolower($val[strlen($val)-1]);
|
$last = strtolower($val[strlen($val)-1]);
|
||||||
|
if (is_numeric($val)) {
|
||||||
$val = (int)$val;
|
$val = (int)$val;
|
||||||
|
} else {
|
||||||
|
$val = (int)substr($val, 0, -1);
|
||||||
|
}
|
||||||
switch ($last) {
|
switch ($last) {
|
||||||
case 'g':
|
case 'g':
|
||||||
$val *= 1024;
|
$val *= 1024;
|
||||||
@@ -492,7 +496,7 @@ class UploadHandler
|
|||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($img_width)) {
|
if (!empty($img_width) && !empty($img_height)) {
|
||||||
if ($max_width && $img_width > $max_width) {
|
if ($max_width && $img_width > $max_width) {
|
||||||
$file->error = $this->get_error_message('max_width');
|
$file->error = $this->get_error_message('max_width');
|
||||||
return false;
|
return false;
|
||||||
@@ -836,9 +840,10 @@ class UploadHandler
|
|||||||
// Handle transparency in GIF and PNG images:
|
// Handle transparency in GIF and PNG images:
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'gif':
|
case 'gif':
|
||||||
|
imagecolortransparent($new_img, imagecolorallocate($new_img, 0, 0, 0));
|
||||||
|
break;
|
||||||
case 'png':
|
case 'png':
|
||||||
imagecolortransparent($new_img, imagecolorallocate($new_img, 0, 0, 0));
|
imagecolortransparent($new_img, imagecolorallocate($new_img, 0, 0, 0));
|
||||||
case 'png':
|
|
||||||
imagealphablending($new_img, false);
|
imagealphablending($new_img, false);
|
||||||
imagesavealpha($new_img, true);
|
imagesavealpha($new_img, true);
|
||||||
break;
|
break;
|
||||||
@@ -868,7 +873,12 @@ class UploadHandler
|
|||||||
$image->setResourceLimit($type, $limit);
|
$image->setResourceLimit($type, $limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
$image->readImage($file_path);
|
$image->readImage($file_path);
|
||||||
|
} catch (ImagickException $e) {
|
||||||
|
error_log($e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$this->image_objects[$file_path] = $image;
|
$this->image_objects[$file_path] = $image;
|
||||||
}
|
}
|
||||||
return $this->image_objects[$file_path];
|
return $this->image_objects[$file_path];
|
||||||
@@ -925,6 +935,7 @@ class UploadHandler
|
|||||||
$file_path,
|
$file_path,
|
||||||
!empty($options['crop']) || !empty($options['no_cache'])
|
!empty($options['crop']) || !empty($options['no_cache'])
|
||||||
);
|
);
|
||||||
|
if (is_null($image)) return false;
|
||||||
if ($image->getImageFormat() === 'GIF') {
|
if ($image->getImageFormat() === 'GIF') {
|
||||||
// Handle animated GIFs:
|
// Handle animated GIFs:
|
||||||
$images = $image->coalesceImages();
|
$images = $image->coalesceImages();
|
||||||
@@ -938,11 +949,9 @@ class UploadHandler
|
|||||||
if (!empty($options['auto_orient'])) {
|
if (!empty($options['auto_orient'])) {
|
||||||
$image_oriented = $this->imagick_orient_image($image);
|
$image_oriented = $this->imagick_orient_image($image);
|
||||||
}
|
}
|
||||||
|
|
||||||
$image_resize = false;
|
$image_resize = false;
|
||||||
$new_width = $max_width = $img_width = $image->getImageWidth();
|
$new_width = $max_width = $img_width = $image->getImageWidth();
|
||||||
$new_height = $max_height = $img_height = $image->getImageHeight();
|
$new_height = $max_height = $img_height = $image->getImageHeight();
|
||||||
|
|
||||||
// use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
|
// use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
|
||||||
if (isset($options['max_width'])) {
|
if (isset($options['max_width'])) {
|
||||||
$image_resize = true;
|
$image_resize = true;
|
||||||
@@ -952,9 +961,7 @@ class UploadHandler
|
|||||||
$image_resize = true;
|
$image_resize = true;
|
||||||
$new_height = $max_height = $options['max_height'];
|
$new_height = $max_height = $options['max_height'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$image_strip = (isset($options['strip']) ? $options['strip'] : false);
|
$image_strip = (isset($options['strip']) ? $options['strip'] : false);
|
||||||
|
|
||||||
if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) {
|
if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) {
|
||||||
if ($file_path !== $new_file_path) {
|
if ($file_path !== $new_file_path) {
|
||||||
return copy($file_path, $new_file_path);
|
return copy($file_path, $new_file_path);
|
||||||
@@ -1360,8 +1367,7 @@ class UploadHandler
|
|||||||
$json = json_encode($content);
|
$json = json_encode($content);
|
||||||
$redirect = stripslashes($this->get_post_param('redirect'));
|
$redirect = stripslashes($this->get_post_param('redirect'));
|
||||||
if ($redirect && preg_match($this->options['redirect_allow_target'], $redirect)) {
|
if ($redirect && preg_match($this->options['redirect_allow_target'], $redirect)) {
|
||||||
$this->header('Location: '.sprintf($redirect, rawurlencode($json)));
|
return $this->header('Location: '.sprintf($redirect, rawurlencode($json)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->head();
|
$this->head();
|
||||||
if ($this->get_server_var('HTTP_CONTENT_RANGE')) {
|
if ($this->get_server_var('HTTP_CONTENT_RANGE')) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user