diff --git a/class/class.modules.php b/class/class.modules.php index 764db25..a62b9fa 100644 --- a/class/class.modules.php +++ b/class/class.modules.php @@ -596,37 +596,36 @@ } - public function moduleRemove ($dir) - { - global $AVE_Template; +public function moduleRemove ($dir) +{ + global $AVE_Template; - $directory = BASE_DIR . '/modules/' . $dir; + $directory = BASE_DIR . '/modules/' . $dir; - $files = glob($directory . '*', GLOB_MARK); + clearstatcache(); - foreach ($files as $file) - { - if (substr($file, -1) == '/') - { - $this->moduleRemove($file); - } - elseif (!is_dir($file)) - { - unlink($file); - } + if (is_dir($directory)) { + $objects = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach($objects as $name => $object){ + if ($object->isDir()){ + @rmdir($name); + } else { + @unlink($name); + } } + @rmdir($directory); + } - rrmdir ($directory); + $this->clearModulesCache(); + reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_REMOVE') . ' (' . $dir . ')'); - $this->clearModulesCache(); - - // Сохраняем системное сообщение в журнал - reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_REMOVE') . ' (' . $dir . ')'); - - // Выполняем обновление страницы со списком модулей - header('Location:index.php?do=modules&cp=' . SESSION); - exit; - } + header('Location:index.php?do=modules&cp=' . SESSION); + exit; +} /**