X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FFileUtils.php;h=3f940751ccdcc9f7b2f720ee7f04eedc40d83920;hb=e6215a2ad97182efcf88ef532ec6bd65ae35fd19;hp=b8ad897029f7f0318feaf91fd76b728dc4d4ea12;hpb=77de24876ff542e3770aa2845e993c58f87e37df;p=github%2Fshaarli%2FShaarli.git diff --git a/application/FileUtils.php b/application/FileUtils.php index b8ad8970..3f940751 100644 --- a/application/FileUtils.php +++ b/application/FileUtils.php @@ -1,6 +1,8 @@ isDot()) { + continue; + } + + if (in_array($file->getBasename(), $exclude, true)) { + $skipped = true; + continue; + } + + if ($file->isFile()) { + unlink($file->getPathname()); + } elseif($file->isDir()) { + $skipped = static::clearFolder($file->getRealPath(), true, $exclude) || $skipped; + } + } + + if ($selfDelete && !$skipped) { + rmdir($path); + } + + return $skipped; + } + + /** + * Checks that the given path is inside Shaarli directory. + */ + public static function isPathInShaarliFolder(string $path): bool + { + $rootDirectory = dirname(dirname(__FILE__)); + + return strpos(realpath($path), $rootDirectory) !== false; } }