Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP warning : is_readable() open_basedir restriction in effect. #73

Open
wants to merge 2 commits into
base: pThumb-dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/components/phpthumbof/model/phpthumbof.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down