diff --git a/src/Mind.php b/src/Mind.php index 485f08b..5f02d10 100755 --- a/src/Mind.php +++ b/src/Mind.php @@ -3,7 +3,7 @@ /** * * @package Mind - * @version Release: 5.9.7 + * @version Release: 5.9.8 * @license GPL3 * @author Ali YILMAZ * @category Php Framework, Design pattern builder for PHP. @@ -5898,32 +5898,25 @@ public function captcha($level=3, $length=8, $width=320, $height=60){ * @return bool */ public function rm_r($paths) { - - if(!is_array($paths)){ - $paths = array($paths); - } - - foreach ($paths as $path) { - - if(is_file($path)){ - return unlink($path); + if (is_array($paths)) { + foreach ($paths as $path) { + $this->rm_r($path); } - - if(is_dir($path)){ - - $files = array_diff(scandir($path), array('.','..')); - foreach ($files as $file) { - $this->rm_r($path.'/'.$file); + } else { + if (is_file($paths)) { + unlink($paths); + $dirPath = dirname($paths); + while (is_dir($dirPath)) { + $files = scandir($dirPath); + if (count($files) === 2 && in_array('.', $files) && in_array('..', $files)) { + rmdir($dirPath); + $dirPath = dirname($dirPath); + } else { + break; + } } - return rmdir($path); - - } else { - return false; } - } - - return true; } /**