X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FFileUtils.php;h=3f940751ccdcc9f7b2f720ee7f04eedc40d83920;hb=refs%2Fpull%2F1604%2Fhead;hp=b89ea12bcc26cb7e67b09eaa60f11abf9b0c552a;hpb=39ee93925b66b527c4386647001fadc898c52a2c;p=github%2Fshaarli%2FShaarli.git diff --git a/application/FileUtils.php b/application/FileUtils.php index b89ea12b..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; + } }