Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeinrich committed Jan 9, 2023
2 parents 3db137e + efa0bf6 commit 6c642aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions phpthumb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function setSourceImageResource($gdimg) {
public function setParameter($param, $value) {
if ($param == 'src') {
$this->setSourceFilename($this->ResolveFilenameToAbsolute($value));
} elseif (@is_array($this->$param)) {
} elseif (isset($this->$param) && is_array($this->$param)) {
if (is_array($value)) {
foreach ($value as $arraykey => $arrayvalue) {
array_push($this->$param, $arrayvalue);
Expand Down Expand Up @@ -3731,7 +3731,7 @@ public function SetCacheFilename() {
} elseif (!$this->config_cache_source_filemtime_ignore_remote && preg_match('#^(f|ht)tps?\://#i', $this->src)) {
$this->cache_filename .= '_dat'. (int) phpthumb_functions::filedate_remote($this->src);
} elseif (!$this->config_cache_source_filemtime_ignore_local && $this->src && !$this->rawImageData) {
$this->cache_filename .= '_dat'. (int) (@filemtime($this->sourceFilename));
$this->cache_filename .= '_dat'. (int) (file_exists($this->sourceFilename) ? filemtime($this->sourceFilename) : 0);
}

$this->cache_filename .= '.'.strtolower($this->thumbnailFormat);
Expand Down
8 changes: 5 additions & 3 deletions phpthumb.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function exif_info() {


public static function ImageTypeToMIMEtype($imagetype) {
if (function_exists('image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 18)) {
if (function_exists('image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 19)) {
// PHP v4.3.0+
return image_type_to_mime_type($imagetype);
}
Expand All @@ -196,6 +196,7 @@ public static function ImageTypeToMIMEtype($imagetype) {
16 => 'image/xbm', // IMAGETYPE_XBM
17 => 'image/x-icon', // IMAGETYPE_ICO
18 => 'image/webp', // IMAGETYPE_WEBP
19 => 'image/avif', // IMAGETYPE_AVIF

'gif' => 'image/gif', // IMAGETYPE_GIF
'jpg' => 'image/jpeg', // IMAGETYPE_JPEG
Expand All @@ -204,6 +205,7 @@ public static function ImageTypeToMIMEtype($imagetype) {
'bmp' => 'image/bmp', // IMAGETYPE_BMP
'ico' => 'image/x-icon', // IMAGETYPE_ICO
'webp' => 'image/webp', // IMAGETYPE_WEBP
'avif' => 'image/avif', // IMAGETYPE_AVIF
);

return (isset($image_type_to_mime_type[$imagetype]) ? $image_type_to_mime_type[$imagetype] : false);
Expand Down Expand Up @@ -1047,8 +1049,8 @@ function preg_quote($string, $delimiter='\\') {
if (!function_exists('file_get_contents')) {
// included in PHP v4.3.0+
function file_get_contents($filename) {
if (preg_match('#^(f|ht)tp\://#i', $filename)) {
return SafeURLread($filename, $error);
if (preg_match('#^(ftp|https?)\://#i', $filename)) {
return phpthumb_functions::SafeURLread($filename, $error);
}
if ($fp = @fopen($filename, 'rb')) {
$rawData = '';
Expand Down

0 comments on commit 6c642aa

Please sign in to comment.