From 10de3b8138c6be5e98ce5bf51b16c46ad69dc4fb Mon Sep 17 00:00:00 2001 From: djmaze Date: Mon, 22 Mar 2021 13:51:38 +0100 Subject: [PATCH] Added PHP 8 str_contains fallback Clear cache folder on version change Secure data folder with .htaccess --- snappymail/v/0.0.0/include.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/snappymail/v/0.0.0/include.php b/snappymail/v/0.0.0/include.php index 739d41f07..00d97c038 100644 --- a/snappymail/v/0.0.0/include.php +++ b/snappymail/v/0.0.0/include.php @@ -14,6 +14,14 @@ unset($load); } + // PHP 8 + if (!\function_exists('str_contains')) { + function str_contains(string $haystack, string $needle) : bool + { + return false !== \strpos($haystack, $needle); + } + } + ini_set('register_globals', 0); ini_set('zend.ze1_compatibility_mode', 0); @@ -152,6 +160,17 @@ if (!is_dir(APP_PRIVATE_DATA)) { mkdir(APP_PRIVATE_DATA, 0755, true); + file_put_contents(APP_PRIVATE_DATA.'.htaccess', 'Require all denied'); + } + + else if (is_dir(APP_PRIVATE_DATA.'cache')) + { + foreach (new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(APP_PRIVATE_DATA.'cache', FilesystemIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST) as $value) { + $value->isDir() ? rmdir($value) : unlink($value); + } + clearstatcache(); } foreach (array('logs', 'cache', 'configs', 'plugins', 'storage') as $sName)