);
foreach ($files as $fileInfo) {
- $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink');
- $todo($fileInfo->getRealPath());
+ $filename = $fileInfo->getFilename();
+ if (!$filename[0] == '.') {
+ $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink');
+ $todo($fileInfo->getRealPath());
+ }
}
Tools::logm('empty cache');
if (isset($_GET['clean'])) {
if (is_dir('install')){
- delTree('install');
+ delTree('install', true);
header('Location: index.php');
}
if (is_dir('cache')) {
- delTree('cache', false);
+ delTree('cache', false, false);
header('Location: index.php');
}
}
* Here in case of .gitignore files
*/
-function delTree($dir, $withdirectory="true") {
- $files = array_diff(scandir($dir), array('.','..'));
- foreach ($files as $file) {
- (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
+function delTree($dir, $withdirectory=true, $hiddenfiles = true) {
+ if ($hiddenfiles) {
+ $files = array_diff(scandir($dir), array('.','..'));
+ foreach ($files as $file) {
+ (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
+ }
}
if ($withdirectory) {
return rmdir($dir);