diff --git a/assets/snippets/phpthumb/composer.lock b/assets/snippets/phpthumb/composer.lock index 1596e443d4..73673f04a3 100644 --- a/assets/snippets/phpthumb/composer.lock +++ b/assets/snippets/phpthumb/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "james-heinrich/phpthumb", - "version": "v1.7.20", + "version": "v1.7.21", "source": { "type": "git", "url": "https://github.com/JamesHeinrich/phpThumb.git", - "reference": "6c642aad3fa33ce88fe1307feaa6316edfc9ed76" + "reference": "7ee966b38ddd7eb4d8091389aa514604710711c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/6c642aad3fa33ce88fe1307feaa6316edfc9ed76", - "reference": "6c642aad3fa33ce88fe1307feaa6316edfc9ed76", + "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/7ee966b38ddd7eb4d8091389aa514604710711c8", + "reference": "7ee966b38ddd7eb4d8091389aa514604710711c8", "shasum": "" }, "require": { @@ -59,9 +59,9 @@ ], "support": { "issues": "https://github.com/JamesHeinrich/phpThumb/issues", - "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.20" + "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.21" }, - "time": "2023-01-09T14:23:26+00:00" + "time": "2023-07-14T21:25:25+00:00" } ], "packages-dev": [], diff --git a/assets/snippets/phpthumb/vendor/composer/installed.json b/assets/snippets/phpthumb/vendor/composer/installed.json index 2fc7d175e3..08003c3788 100644 --- a/assets/snippets/phpthumb/vendor/composer/installed.json +++ b/assets/snippets/phpthumb/vendor/composer/installed.json @@ -2,17 +2,17 @@ "packages": [ { "name": "james-heinrich/phpthumb", - "version": "v1.7.20", - "version_normalized": "1.7.20.0", + "version": "v1.7.21", + "version_normalized": "1.7.21.0", "source": { "type": "git", "url": "https://github.com/JamesHeinrich/phpThumb.git", - "reference": "6c642aad3fa33ce88fe1307feaa6316edfc9ed76" + "reference": "7ee966b38ddd7eb4d8091389aa514604710711c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/6c642aad3fa33ce88fe1307feaa6316edfc9ed76", - "reference": "6c642aad3fa33ce88fe1307feaa6316edfc9ed76", + "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/7ee966b38ddd7eb4d8091389aa514604710711c8", + "reference": "7ee966b38ddd7eb4d8091389aa514604710711c8", "shasum": "" }, "require": { @@ -22,7 +22,7 @@ "ext-gd": "PHP GD library", "ext-imagick": "PHP ImageMagick" }, - "time": "2023-01-09T14:23:26+00:00", + "time": "2023-07-14T21:25:25+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -56,11 +56,11 @@ ], "support": { "issues": "https://github.com/JamesHeinrich/phpThumb/issues", - "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.20" + "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.21" }, "install-path": "../james-heinrich/phpthumb" } ], - "dev": false, + "dev": true, "dev-package-names": [] } diff --git a/assets/snippets/phpthumb/vendor/composer/installed.php b/assets/snippets/phpthumb/vendor/composer/installed.php index c2a1972844..3c6e08ed6a 100644 --- a/assets/snippets/phpthumb/vendor/composer/installed.php +++ b/assets/snippets/phpthumb/vendor/composer/installed.php @@ -1,28 +1,28 @@ array( 'name' => '__root__', - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => NULL, + 'pretty_version' => '1.4.x-dev', + 'version' => '1.4.9999999.9999999-dev', + 'reference' => 'd1b46408a166eff5588bebd00018f671b111c8c4', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'dev' => false, + 'dev' => true, ), 'versions' => array( '__root__' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => NULL, + 'pretty_version' => '1.4.x-dev', + 'version' => '1.4.9999999.9999999-dev', + 'reference' => 'd1b46408a166eff5588bebd00018f671b111c8c4', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'james-heinrich/phpthumb' => array( - 'pretty_version' => 'v1.7.20', - 'version' => '1.7.20.0', - 'reference' => '6c642aad3fa33ce88fe1307feaa6316edfc9ed76', + 'pretty_version' => 'v1.7.21', + 'version' => '1.7.21.0', + 'reference' => '7ee966b38ddd7eb4d8091389aa514604710711c8', 'type' => 'library', 'install_path' => __DIR__ . '/../james-heinrich/phpthumb', 'aliases' => array(), diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/demo/phpThumb.demo.demo.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/demo/phpThumb.demo.demo.php index e2cc406678..b23c335c33 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/demo/phpThumb.demo.demo.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/demo/phpThumb.demo.demo.php @@ -99,7 +99,8 @@ $img['anigif'] = 'images/animaple.gif'; $img['alpha'] = 'images/alpha.png'; //$img['alpha'] = 'images/North15.gif'; -$img['whitespace'] = 'images/whitespace.jpg'; +// $img['whitespace'] = 'images/whitespace.jpg'; // missing +$img['whitespace'] = 'images/bunnies.jpg'; $img['mask1'] = 'images/mask04.png'; $img['mask2'] = 'images/mask05.png'; @@ -135,7 +136,7 @@ $Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&q=10&sia=custom-filename'), 'description' => 'width=300px, JPEGquality=10%, SaveImageAs=custom-filename'); $Examples[] = array('getstrings' => array('src='.$img['watermark'].'&w=400&aoe=1&bg=ffffff'), 'description' => 'width=400px, AllowOutputEnlargement enabled'); $Examples[] = array('getstrings' => array('src='.$img['square'].'&w=250&sx=600&sy=5&sw=100&sh=100&aoe=1'), 'description' => 'section from (600x5 - 700x105) cropped and enlarged by 250%, AllowOutputEnlargement enabled'); -$Examples[] = array('getstrings' => array('src='.urlencode('http://www.silisoftware.com/images/SiliSoft.gif').'&w=100'), 'description' => 'HTTP source image'.$only_gd); +$Examples[] = array('getstrings' => array('src='.urlencode('https://www.silisoftware.com/images/SiliSoft.gif').'&w=100'), 'description' => 'HTTP source image'.$only_gd); $Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|BL'), 'description' => 'width=300px, watermark (bottom-left, 75% opacity)'.$only_gd); $Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|*|25'), 'description' => 'width=300px, watermark (tiled, 25% opacity)'.$only_gd); $Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|75x50|80|75|75|45'), 'description' => 'width=300px, watermark (absolute position (75x50), rotation (45), scaling (75x75)))'.$only_gd); diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt index 263ff09aa0..b17ec0d477 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt @@ -7,6 +7,15 @@ ยค = structure change or important new feature * = less important new feature or change +v1.7.21-202307141720 + * [bugfix: #215] PHP 8.2 compatibility + * [bugfix: #214] PHP 8.2 compatibility (Dynamic Properties are deprecated) + * [bugfix: #213] PHP 8.2 compatibility + * [bugfix: #212] PHP 8.2 compatibility + * [bugfix: #211] quality parameter fix for ImageMagick processing + * [bugfix: #208] PHP 8.2 compatibility + * [bugfix: #207] PHP 8.2 compatibility + v1.7.20-202212091316 * [bugfix: #203] Support https in file_get_contents polyfill * [bugfix: #202] Test if property is set when testing array (@ operator fix) diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default index 82001ec38c..0819c275f6 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default @@ -242,6 +242,10 @@ $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = false; // if true, GETstring parameters w //$PHPTHUMB_DEFAULTS['fltr'] = array('blur|10'); //$PHPTHUMB_DEFAULTS['q'] = 90; +// benchmark by https://www.industrialempathy.com/posts/avif-webp-quality-settings/ suggests: +// JPEG quality 50 60 70 80 +// AVIF quality 48 51 56 64 +// WebP quality 55 64 72 82 /* END DEFAULT PARAMETERS SECTION */ diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php index 08717f18ad..bce7c8de1f 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php @@ -41,7 +41,7 @@ function SendSaveAsFileHeaderIfNeeded($getimagesize=false) { //if (empty($_GET['sia']) && empty($_GET['down']) && !empty($phpThumb->thumbnail_image_width) && !empty($phpThumb->thumbnail_image_height)) { if (empty($_GET['sia']) && empty($_GET['down']) && !empty($getimagesize[0]) && !empty($getimagesize[1])) { // if we know the output image dimensions we can generate a better default filename - $downloadfilename = phpthumb_functions::SanitizeFilename((!empty($phpThumb->src) ? basename($phpThumb->src) : md5($phpThumb->rawImageData)).'-'.intval($getimagesize[0]).'x'.intval($getimagesize[1]).'.'.(!empty($_GET['f']) ? $_GET['f'] : 'jpg')); + $downloadfilename = phpthumb_functions::SanitizeFilename((!empty($phpThumb->src) ? basename($phpThumb->src) : md5((string)$phpThumb->rawImageData)).'-'.intval($getimagesize[0]).'x'.intval($getimagesize[1]).'.'.(!empty($_GET['f']) ? $_GET['f'] : 'jpg')); } if (!empty($downloadfilename)) { $phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: '.(!empty($_GET['down']) ? 'attachment' : 'inline').'; filename="'.$downloadfilename.'"', __FILE__, __LINE__); @@ -286,7 +286,7 @@ function RedirectToCachedFile() { $phpThumb->ErrorImage('config_nooffsitelink_require_refer enabled and '.(@$parsed_url_referer['host'] ? '"'.$parsed_url_referer['host'].'" is not an allowed referer' : 'no HTTP_REFERER exists')); } $parsed_url_src = phpthumb_functions::ParseURLbetter(@$_GET['src']); -if ($phpThumb->config_nohotlink_enabled && $phpThumb->config_nohotlink_erase_image && preg_match('#^(f|ht)tps?://#i', @$_GET['src']) && !in_array(@$parsed_url_src['host'], $phpThumb->config_nohotlink_valid_domains)) { +if ($phpThumb->config_nohotlink_enabled && $phpThumb->config_nohotlink_erase_image && preg_match('#^(f|ht)tps?://#i', (string)@$_GET['src']) && !in_array(@$parsed_url_src['host'], $phpThumb->config_nohotlink_valid_domains)) { $phpThumb->ErrorImage($phpThumb->config_nohotlink_text_message); } @@ -391,6 +391,8 @@ function RedirectToCachedFile() { if (!empty($PHPTHUMB_DEFAULTS_DISABLEGETPARAMS) && ($key != 'src')) { // disabled, do not set parameter $phpThumb->DebugMessage('ignoring $_GET['.$key.'] because of $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS', __FILE__, __LINE__); + } elseif ($key == 'hash') { + // "hash" is for use in phpThumb.phpdoes only, should not be set on object } elseif (in_array($key, $allowedGETparameters)) { $phpThumb->DebugMessage('setParameter('.$key.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__); $phpThumb->setParameter($key, $value); @@ -435,9 +437,9 @@ function RedirectToCachedFile() { $CanPassThroughDirectly = true; if ($phpThumb->rawImageData) { // data from SQL, should be fine -} elseif (preg_match('#^https?\\://[^\\?&]+\\.(jpe?g|gif|png|webp|avif)$#i', $phpThumb->src)) { +} elseif (preg_match('#^https?\\://[^\\?&]+\\.(jpe?g|gif|png|webp|avif)$#i', (string)$phpThumb->src)) { // assume is ok to passthru if no other parameters specified -} elseif (preg_match('#^(f|ht)tps?\\://#i', $phpThumb->src)) { +} elseif (preg_match('#^(f|ht)tps?\\://#i', (string)$phpThumb->src)) { $phpThumb->DebugMessage('$CanPassThroughDirectly=false because preg_match("#^(f|ht)tps?://#i", '.$phpThumb->src.')', __FILE__, __LINE__); $CanPassThroughDirectly = false; } elseif (!@is_readable($phpThumb->sourceFilename)) { @@ -456,7 +458,7 @@ function RedirectToCachedFile() { case 'w': case 'h': // might be OK if exactly matches original - if (preg_match('#^https?\\://[^\\?&]+\\.(jpe?g|gif|png|webp|avif)$#i', $phpThumb->src)) { + if (preg_match('#^https?\\://[^\\?&]+\\.(jpe?g|gif|png|webp|avif)$#i', (string)$phpThumb->src)) { // assume it is not ok for direct-passthru of remote image $CanPassThroughDirectly = false; } diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php index 9cb5b39376..bc6ee7f979 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php @@ -265,7 +265,7 @@ class phpthumb { public $issafemode = null; public $php_memory_limit = null; - public $phpthumb_version = '1.7.20-202212091316'; + public $phpthumb_version = '1.7.21-202307141720'; ////////////////////////////////////////////////////////////////////// @@ -314,6 +314,9 @@ public function __destruct() { $this->purgeTempFiles(); } + public function __set(string $name, $value): void { + } + // public: public function purgeTempFiles() { foreach ($this->tempFilesToDelete as $tempFileToDelete) { @@ -1447,7 +1450,7 @@ public function ResolveFilenameToAbsolute($filename) { $AbsoluteFilename = str_replace(DIRECTORY_SEPARATOR, '/', $AbsoluteFilename); } $resolvedAbsoluteFilename = $this->resolvePath($AbsoluteFilename, $this->config_additional_allowed_dirs); - if (!$this->config_allow_src_above_docroot && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this->realPathSafe($this->config_document_root))).'#', $resolvedAbsoluteFilename)) { + if (!$this->config_allow_src_above_docroot && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this->realPathSafe($this->config_document_root))).'#', (string)$resolvedAbsoluteFilename)) { $this->DebugMessage('!$this->config_allow_src_above_docroot therefore setting "'.$AbsoluteFilename.'" (outside "'.$this->realPathSafe($this->config_document_root).'") to null', __FILE__, __LINE__); return false; } @@ -1492,7 +1495,8 @@ public function ImageMagickWhichConvert() { if (($cachedwhichconvertstring = @file_get_contents($IMwhichConvertCacheFilename)) !== false) { $WhichConvert = $cachedwhichconvertstring; } else { - $WhichConvert = trim(phpthumb_functions::SafeExec('which convert')); + $execResult = phpthumb_functions::SafeExec('which convert'); + $WhichConvert = $execResult !== null ? trim($execResult) : null; @file_put_contents($IMwhichConvertCacheFilename, $WhichConvert); @chmod($IMwhichConvertCacheFilename, $this->getParameter('config_file_create_mask')); } @@ -1800,7 +1804,7 @@ public function ImageMagickThumbnailToGD() { // some (older? around 2002) versions of IM won't accept "-resize 100x" but require "-resize 100x100" $commandline_test = $this->ImageMagickCommandlineBase().' logo: -resize 1x '.phpthumb_functions::escapeshellarg_replacement($IMtempfilename).' 2>&1'; $IMresult_test = phpthumb_functions::SafeExec($commandline_test); - $IMuseExplicitImageOutputDimensions = preg_match('#image dimensions are zero#i', $IMresult_test); + $IMuseExplicitImageOutputDimensions = preg_match('#image dimensions are zero#i', (string)$IMresult_test); $this->DebugMessage('IMuseExplicitImageOutputDimensions = '. (int) $IMuseExplicitImageOutputDimensions, __FILE__, __LINE__); if ($fp_im_temp = @fopen($IMtempfilename, 'wb')) { // erase temp image so ImageMagick logo doesn't get output if other processing fails @@ -1986,8 +1990,8 @@ public function ImageMagickThumbnailToGD() { } } list($nw, $nh) = phpthumb_functions::TranslateWHbyAngle($this->w, $this->h, $this->ra); - $nw = ((round($nw) != 0) ? round($nw) : ''); - $nh = ((round($nh) != 0) ? round($nh) : ''); + $nw = ((isset($nw) && round($nw) != 0) ? round($nw) : ''); + $nh = ((isset($nh) && round($nh) != 0) ? round($nh) : ''); $commandline .= ' -'.$IMresizeParameter.' '.phpthumb_functions::escapeshellarg_replacement($nw.'x'.$nh); } @@ -2019,7 +2023,7 @@ public function ImageMagickThumbnailToGD() { if (($this->ra % 90) != 0) { if (preg_match('#('.implode('|', $this->AlphaCapableFormats).')#i', $outputFormat)) { // alpha-capable format - $commandline .= ' -background rgba(255,255,255,0)'; + $commandline .= ' -background '.phpthumb_functions::escapeshellarg_replacement('rgba(255,255,255,0)'); } else { $commandline .= ' -background '.phpthumb_functions::escapeshellarg_replacement('#'.($this->bg ? $this->bg : 'FFFFFF')); } @@ -2188,9 +2192,9 @@ public function ImageMagickThumbnailToGD() { case 'lvl': @list($band, $method, $threshold) = explode('|', $parameter); - $band = ($band ? preg_replace('#[^RGBA\\*]#', '', strtoupper($band)) : '*'); - $method = ((strlen($method) > 0) ? (int) $method : 2); - $threshold = ((strlen($threshold) > 0) ? min(max((float) $threshold, 0), 100) : 0.1); + $band = ($band ? preg_replace('#[^RGBA\\*]#', '', strtoupper((string)$band)) : '*'); + $method = ((strlen((string)$method) > 0) ? (int) $method : 2); + $threshold = ((strlen((string)$threshold) > 0) ? min(max((float) $threshold, 0), 100) : 0.1); $band = preg_replace('#[^RGBA\\*]#', '', strtoupper($band)); @@ -2395,6 +2399,10 @@ public function ImageMagickThumbnailToGD() { } } } + // ImageMagic also support quality for webp - but only for version 7.0.8-68 and above + if (($outputFormat=='webp') && $this->q && $this->ImageMagickSwitchAvailable(['quality'])) { + $commandline .= ' -quality '.phpthumb_functions::escapeshellarg_replacement($this->thumbnailQuality); + } $commandline .= ' '.$outputFormat.':'.phpthumb_functions::escapeshellarg_replacement($IMtempfilename); if (!$this->iswindows) { $commandline .= ' 2>&1'; @@ -2403,8 +2411,8 @@ public function ImageMagickThumbnailToGD() { $IMresult = phpthumb_functions::SafeExec($commandline); clearstatcache(); if (!@file_exists($IMtempfilename) || !@filesize($IMtempfilename)) { - $this->FatalError('ImageMagick failed with message ('.trim($IMresult).')'); - $this->DebugMessage('ImageMagick failed with message ('.trim($IMresult).')', __FILE__, __LINE__); + $this->FatalError('ImageMagick failed with message ('.trim((string)$IMresult).')'); + $this->DebugMessage('ImageMagick failed with message ('.trim((string)$IMresult).')', __FILE__, __LINE__); if ($this->iswindows && !$IMresult) { $this->DebugMessage('Check to make sure that PHP has read+write permissions to "'.dirname($IMtempfilename).'"', __FILE__, __LINE__); } @@ -2630,7 +2638,7 @@ public function AntiOffsiteLinking() { } } - if ($allow && $this->config_nohotlink_enabled && preg_match('#^(f|ht)tps?\://#i', $this->src)) { + if ($allow && $this->config_nohotlink_enabled && preg_match('#^(f|ht)tps?\://#i', (string)$this->src)) { $parsed_url = phpthumb_functions::ParseURLbetter($this->src); //if (!phpthumb_functions::CaseInsensitiveInArray(@$parsed_url['host'], $this->config_nohotlink_valid_domains)) { if (!$this->OffsiteDomainIsAllowed(@$parsed_url['host'], $this->config_nohotlink_valid_domains)) { @@ -2894,8 +2902,8 @@ public function ApplyFilters() { case 'lvl': // autoLevels @list($band, $method, $threshold) = explode('|', $parameter, 3); $band = ($band ? preg_replace('#[^RGBA\\*]#', '', strtoupper($band)) : '*'); - $method = ((strlen($method) > 0) ? (int) $method : 2); - $threshold = ((strlen($threshold) > 0) ? (float) $threshold : 0.1); + $method = ((strlen((string)$method) > 0) ? (int) $method : 2); + $threshold = ((strlen((string)$threshold) > 0) ? (float) $threshold : 0.1); $phpthumbFilters->HistogramStretch($this->gdimg_output, $band, $method, $threshold); break; @@ -3002,8 +3010,8 @@ public function ApplyFilters() { case 'over': // Overlay @list($filename, $underlay, $margin, $opacity) = explode('|', $parameter, 4); $underlay = (bool) ($underlay ? $underlay : false); - $margin = ((strlen($margin) > 0) ? $margin : ($underlay ? 0.1 : 0.0)); - $opacity = ((strlen($opacity) > 0) ? $opacity : 100); + $margin = ((strlen((string)$margin) > 0) ? $margin : ($underlay ? 0.1 : 0.0)); + $opacity = ((strlen((string)$opacity) > 0) ? $opacity : 100); if (($margin > 0) && ($margin < 1)) { $margin = min(0.499, $margin); } elseif (($margin > -1) && ($margin < 0)) { @@ -3477,15 +3485,15 @@ public function SetOrientationDependantWidthHeight() { public function ExtractEXIFgetImageSize() { $this->DebugMessage('starting ExtractEXIFgetImageSize()', __FILE__, __LINE__); - if (preg_match('#^http:#i', $this->src) && !$this->sourceFilename && $this->rawImageData) { + if (preg_match('#^http:#i', (string)$this->src) && !$this->sourceFilename && $this->rawImageData) { $this->SourceDataToTempFile(); } if (null === $this->getimagesizeinfo) { if ($this->sourceFilename) { if ($this->getimagesizeinfo = @getimagesize($this->sourceFilename)) { - $this->source_width = $this->getimagesizeinfo[0]; - $this->source_height = $this->getimagesizeinfo[1]; - $this->DebugMessage('getimagesize('.$this->sourceFilename.') says image is '.$this->source_width.'x'.$this->source_height, __FILE__, __LINE__); + $this->source_width = $this->getimagesizeinfo[0]; + $this->source_height = $this->getimagesizeinfo[1]; + $this->DebugMessage('getimagesize('.$this->sourceFilename.') says image is '.$this->source_width.'x'.$this->source_height, __FILE__, __LINE__); } else { $this->DebugMessage('getimagesize('.$this->sourceFilename.') failed', __FILE__, __LINE__); } @@ -3682,8 +3690,8 @@ public function SetCacheFilename() { $broad_directory_name = strtolower(md5($this->rawImageData)); $this->cache_filename .= '_raw'.$broad_directory_name; } else { - $this->DebugMessage('SetCacheFilename() _src set from md5($this->sourceFilename) "'.$this->sourceFilename.'" = "'.md5($this->sourceFilename).'"', __FILE__, __LINE__); - $broad_directory_name = strtolower(md5($this->sourceFilename)); + $this->DebugMessage('SetCacheFilename() _src set from md5($this->sourceFilename) "'.$this->sourceFilename.'" = "'.md5((string)$this->sourceFilename).'"', __FILE__, __LINE__); + $broad_directory_name = strtolower(md5((string)$this->sourceFilename)); $this->cache_filename .= '_src'.$broad_directory_name; } if (!empty($_SERVER['HTTP_REFERER']) && $this->config_nooffsitelink_enabled) { @@ -3717,8 +3725,8 @@ public function SetCacheFilename() { $ParametersString .= '_'.$key.substr(md5($this->$key), 0, 4); } } - if ($this->thumbnailFormat == 'jpeg') { - // only JPEG output has variable quality option + if (in_array($this->thumbnailFormat, ['jpeg','webp'])) { + // only JPEG and WEBP output has variable quality option $ParametersString .= '_q'. (int) $this->thumbnailQuality; } $this->DebugMessage('SetCacheFilename() _par set from md5('.$ParametersString.')', __FILE__, __LINE__); diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.filters.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.filters.php index a18b7399de..9606476b45 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.filters.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.filters.php @@ -114,15 +114,15 @@ public function Blur(&$gdimg, $radius=0.5) { // Move copies of the image around one pixel at the time and merge them with weight // according to the matrix. The same matrix is simply repeated for higher radii. for ($i = 0; $i < $radius; $i++) { - imagecopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left - imagecopymerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right - imagecopymerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left - imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right - imagecopymerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left - imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right - imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up - imagecopymerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down - imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center + imagecopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left + imagecopymerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50); // down right + imagecopymerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33); // down left + imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25); // up right + imagecopymerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33); // left + imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25); // right + imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20); // up + imagecopymerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 17); // down + imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50); // center imagecopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h); } return true; @@ -287,8 +287,10 @@ public function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) { if (($bottom > 0) && ($bottom < 1)) { $bottom = round($bottom * $oldH); } $right = min($oldW - $left - 1, $right); $bottom = min($oldH - $top - 1, $bottom); - $newW = $oldW - $left - $right; - $newH = $oldH - $top - $bottom; + $newW = (int)($oldW - $left - $right); + $newH = (int)($oldH - $top - $bottom); + $left = (int)$left; + $top = (int)$top; if ($imgCropped = imagecreatetruecolor($newW, $newH)) { imagecopy($imgCropped, $gdimg, 0, 0, $left, $top, $newW, $newH); @@ -362,8 +364,8 @@ public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha //for ($i = 0; $i < $width; $i++) { for ($i = 0; $i < 1; $i++) { if (!isset($PixelMap[$x][$y]['alpha']) || ($PixelMap[$x][$y]['alpha'] > 0)) { - if (isset($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']) && ($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha'] < 127)) { - $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']); + if (isset($PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha']) && ($PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha'] < 127)) { + $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha']); imagesetpixel($gdimg_dropshadow_temp, $x, $y, $thisColor); } } @@ -1018,7 +1020,7 @@ public function SourceTransparentColorMask(&$gdimg, $hexcolor, $min_limit=5, $ma for ($y = 0; $y < $height; $y++) { $currentPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); $colorDiff = phpthumb_functions::PixelColorDifferencePercent($currentPixel, $targetPixel); - $grayLevel = min($cutoffRange, max(0, -$min_limit + $colorDiff)) * (255 / max(1, $cutoffRange)); + $grayLevel = (int)min($cutoffRange, max(0, -$min_limit + $colorDiff)) * (255 / max(1, $cutoffRange)); $newColor = imagecolorallocate($gdimg_mask, $grayLevel, $grayLevel, $grayLevel); imagesetpixel($gdimg_mask, $x, $y, $newColor); } @@ -1127,16 +1129,20 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 } $lineheight = min(100.0, max(0.01, (float) $lineheight)); - $metaTextArray = array( - '^Fb' => $this->phpThumbObject->getimagesizeinfo['filesize'], - '^Fk' => round($this->phpThumbObject->getimagesizeinfo['filesize'] / 1024), - '^Fm' => round($this->phpThumbObject->getimagesizeinfo['filesize'] / 1048576), - '^X' => $this->phpThumbObject->getimagesizeinfo[0], - '^Y' => $this->phpThumbObject->getimagesizeinfo[1], - '^x' => imagesx($gdimg), - '^y' => imagesy($gdimg), - '^^' => '^', - ); + $metaTextArray = array(); + if (is_array($this->phpThumbObject->getimagesizeinfo)) { + if (array_key_exists('filesize',$this->phpThumbObject->getimagesizeinfo)) { + $metaTextArray['^Fb'] = $this->phpThumbObject->getimagesizeinfo['filesize']; + $metaTextArray['^Fk'] = round($this->phpThumbObject->getimagesizeinfo['filesize'] / 1024); + $metaTextArray['^Fm'] = round($this->phpThumbObject->getimagesizeinfo['filesize'] / 1048576); + } + $metaTextArray['^X'] = $this->phpThumbObject->getimagesizeinfo[0]; + $metaTextArray['^Y'] = $this->phpThumbObject->getimagesizeinfo[1]; + } + $metaTextArray['^x'] = imagesx($gdimg); + $metaTextArray['^y'] = imagesy($gdimg); + $metaTextArray['^^'] = '^'; + $text = strtr($text, $metaTextArray); $text = str_replace(array( @@ -1430,7 +1436,8 @@ public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', $watermark_source_width = imagesx($img_watermark); $watermark_source_height = imagesy($img_watermark); $watermark_opacity_percent = max(0, min(100, $opacity)); - $margin_y = (null === $margin_y ? $margin_x : $margin_y); + $margin_x = (null === $margin_x ? 0 : $margin_y); // if null fill 0 (or 5?) + $margin_y = (null === $margin_y ? $margin_x : $margin_y); $watermark_margin_x = ((($margin_x > 0) && ($margin_x < 1)) ? round((1 - $margin_x) * $img_source_width) : $margin_x); $watermark_margin_y = ((($margin_y > 0) && ($margin_y < 1)) ? round((1 - $margin_y) * $img_source_height) : $margin_y); $watermark_destination_x = 0; diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.functions.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.functions.php index d8bc70670e..acde62d10f 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.functions.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.functions.php @@ -232,13 +232,13 @@ public static function HexCharDisplay($string) { public static function IsHexColor($HexColorString) { - return preg_match('#^[0-9A-F]{6}$#i', $HexColorString); + return preg_match('#^[0-9A-F]{6}$#i', (string)$HexColorString); } public static function ImageColorAllocateAlphaSafe(&$gdimg_hexcolorallocate, $R, $G, $B, $alpha=false) { if (self::version_compare_replacement(PHP_VERSION, '4.3.2', '>=') && ($alpha !== false)) { - return imagecolorallocatealpha($gdimg_hexcolorallocate, $R, $G, $B, (int) $alpha); + return imagecolorallocatealpha($gdimg_hexcolorallocate, round($R), round($G), round($B), (int) $alpha); } else { return imagecolorallocate($gdimg_hexcolorallocate, $R, $G, $B); } @@ -706,7 +706,7 @@ public static function CleanUpURLencoding($url, $queryseperator='&') { return $url; } $parsed_url = self::ParseURLbetter($url); - $pathelements = explode('/', $parsed_url['path']); + $pathelements = explode('/', (string)$parsed_url['path']); $CleanPathElements = array(); $TranslationMatrix = array(' '=>'%20'); foreach ($pathelements as $key => $pathelement) { @@ -718,7 +718,7 @@ public static function CleanUpURLencoding($url, $queryseperator='&') { } } - $queries = explode($queryseperator, $parsed_url['query']); + $queries = explode($queryseperator, (string)$parsed_url['query']); $CleanQueries = array(); foreach ($queries as $key => $query) { @list($param, $value) = explode('=', $query); @@ -862,6 +862,16 @@ public static function EnsureDirectoryExists($dirname, $mask=0755) { $delimiter = ':'; $case_insensitive_pathname = false; } + do { + /* + \\3930K\WEBROOT\trainspotted.com\phpThumb/_cache/\6\6f // starts off with mismatched directory separators + \\3930K\WEBROOT\trainspotted.com\phpThumb\_cache\\6\6f // gets multiple directory separators in a row that we want to strip out (being sure not to replace the UNC double-slash at the beginning) + */ + if ($doubleslash_offset = strpos($dirname, DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, 1)) { + $dirname = substr($dirname, 0, $doubleslash_offset).substr($dirname, $doubleslash_offset + 1); + } + } while ($doubleslash_offset !== false); + $open_basedirs = explode($delimiter, $config_open_basedir); foreach ($open_basedirs as $key => $open_basedir) { if (preg_match('#^'.preg_quote($open_basedir).'#'.($case_insensitive_pathname ? 'i' : ''), $dirname) && (strlen($dirname) > strlen($open_basedir))) { @@ -878,12 +888,23 @@ public static function EnsureDirectoryExists($dirname, $mask=0755) { continue; } if (!@is_dir($test_directory)) { + if (substr($test_directory, 0, 2) == '\\\\') { + // UNC path + if (count(explode('\\', $test_directory)) <= 4) { + // 1,2 = UNC starting slashes + // 3 = hostname; skip further checks + // 4 = sharename; skip further checks + // 5+ = real subdiretories + continue; + } + } if (@file_exists($test_directory)) { // directory name already exists as a file return false; } @mkdir($test_directory, $mask); @chmod($test_directory, $mask); + clearstatcache(); if (!@is_dir($test_directory) || !@is_writable($test_directory)) { return false; } diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.unsharp.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.unsharp.php index a5c454ee1f..3802e8bf90 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.unsharp.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.unsharp.php @@ -110,9 +110,9 @@ public static function applyUnsharpMask(&$img, $amount, $radius, $threshold) { // When the masked pixels differ less from the original // than the threshold specifies, they are set to their original value. - $rNew = ((abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig); - $gNew = ((abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig); - $bNew = ((abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig); + $rNew = (int)((abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig); + $gNew = (int)((abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig); + $bNew = (int)((abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig); if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = imagecolorallocate($img, $rNew, $gNew, $bNew);