diff --git a/core/components/phpthumbof/model/phpthumbof.class.php b/core/components/phpthumbof/model/phpthumbof.class.php index 4e1141d..e6fcfc0 100644 --- a/core/components/phpthumbof/model/phpthumbof.class.php +++ b/core/components/phpthumbof/model/phpthumbof.class.php @@ -257,7 +257,20 @@ public function createThumbnail($src, $options) { } } else { // it's a local file - if (is_readable($src)) { // if we've already got an existing file, keep going + // see if open_basedir is active - avoid calling is_readable in PHP >= 8.x + $openBasedirIniSetting = ini_get('open_basedir'); + $isOpenBasedirSafe = true; + if (is_string($openBasedirIniSetting)) { + $isOpenBasedirSafe = false; + $openBasedirPaths = explode(":", $openBasedirIniSetting); + foreach($openBasedirPaths as $path) { + if (substr($src, 0, strlen($path)) == $path) { + $isOpenBasedirSafe = true; + break; + } + } + } + if ($isOpenBasedirSafe && is_readable($src)) { // if we've already got an existing file, keep going $file = $src; } else { // otherwise prepend base_path and try again