From 1312f10ff2370897af3b4c7c5e4bb39097af56dc Mon Sep 17 00:00:00 2001 From: Alexey Kalnov Date: Thu, 21 Apr 2016 23:32:02 +0300 Subject: [PATCH] cot_rmdir() improve --- system/functions.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/system/functions.php b/system/functions.php index a2e4edf33..ae62cdbf7 100644 --- a/system/functions.php +++ b/system/functions.php @@ -1022,28 +1022,27 @@ function cot_rmdir($dir) static $cnt = 0; if (is_dir($dir)) { - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $f) { - $path = $dir . DIRECTORY_SEPARATOR . $f; - if ($f != "." && $f != "..") + $objects = scandir($dir); + foreach ($objects as $f) { + $path = $dir . DIRECTORY_SEPARATOR . $f; + if ($f != "." && $f != "..") + { + if (filetype($path) == "dir") + { + cot_rmdir($path); + } + else { - if (filetype($path) == "dir") - { - cot_rmdir($path); - } - else - { - unlink($path); - $cnt++; - } + unlink($path); + $cnt++; } } - reset($objects); - rmdir($dir); - $cnt++; } + reset($objects); + rmdir($dir); + $cnt++; } + return $cnt; }