diff --git a/src/phpFastCache/Util/OpenBaseDir.php b/src/phpFastCache/Util/OpenBaseDir.php new file mode 100644 index 000000000..9ca5dfb14 --- /dev/null +++ b/src/phpFastCache/Util/OpenBaseDir.php @@ -0,0 +1,33 @@ +".$tmp[0]." = ".$path." BY {$allowed_path}"; + self::$stores[$index] = true; + return true; + } + + } + } else { + return self::$stores[$index]; + } + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/phpFastCache/phpFastCache.php b/src/phpFastCache/phpFastCache.php index 88e73ec25..fd557bb07 100644 --- a/src/phpFastCache/phpFastCache.php +++ b/src/phpFastCache/phpFastCache.php @@ -13,15 +13,17 @@ */ use phpFastCache\CacheManager; +use phpFastCache\Util\OpenBaseDir; define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); - +require_once __DIR__."/Util/OpenBaseDir.php"; /** * Register Autoload */ spl_autoload_register(function ($entity) { // Explode is faster than substr & strstr also more control $module = explode('\\',$entity,2); - if ($module[0] !== 'phpFastCache') { + if ($module[0] !== 'phpFastCache' + || !OpenBaseDir::checkBaseDir(__DIR__)) { /** * Not a part of phpFastCache file * then we return here. @@ -30,7 +32,6 @@ } $entity = str_replace('\\', '/', $module[1]); - $path = __DIR__ . '/' . $entity . '.' . PHP_EXT; if (is_readable($path)) { require_once $path;