public static function delete_dir($path = '', $encode = true) { $done = false; if ($path == '') { return true; } if (($dp = opendir($path)) !== false) { while (($el = readdir($dp)) !== false) { if ($el == '.' || $el == '..') { continue; } $obj = $path . DS . $el; if (is_file($obj)) { FileManager::delete_file($obj); continue; } if (is_dir($obj)) { FileManager::delete_dir($obj); } } closedir($dp); rmdir($path); $done = true; } return $done; }
function run($location) { if (isset($_POST['userdir']) && strlen($_POST['userdir']) > 0) { if ($location->uploadAllowed() && GateKeeper::isUserLoggedIn() && GateKeeper::isAccessAllowed() && GateKeeper::isNewdirAllowed()) { $this->newFolder($location, $_POST['userdir']); } } if (isset($_FILES['userfile']['name']) && strlen($_FILES['userfile']['name']) > 0) { if ($location->uploadAllowed() && GateKeeper::isUserLoggedIn() && GateKeeper::isAccessAllowed() && GateKeeper::isUploadAllowed()) { $this->uploadFile($location, $_FILES['userfile']); } } if (isset($_GET['del'])) { if (GateKeeper::isUserLoggedIn() && GateKeeper::isAccessAllowed() && GateKeeper::isDeleteAllowed()) { $split_path = Location::splitPath($_GET['del']); $path = ""; for ($i = 0; $i < count($split_path); $i++) { $path .= $split_path[$i]; if ($i + 1 < count($split_path)) { $path .= "/"; } } if ($path == "" || $path == "/" || $path == "\\" || $path == ".") { return; } if (is_dir($path)) { FileManager::delete_dir($path); } else { if (is_file($path)) { FileManager::delete_file($path); } } } } }
<?php /** * Cyber Image Manager * * * @package Cyber Image Manager * @author Radik * @copyright Copyright (c) 2010, Cyber Applications. * @link http://www.cyberapp.ru/ * @since Version 1.1 * @file /includes/tasks/del_dir.php */ /* Защита от прямой загрузки */ defined('ACCESS') or die; echo json_encode(array('done' => FileManager::delete_dir(FileManager::convertToFileSystem(FileManager::clear_path(Manager::$conf['filesystem.files_abs_path'] . DS . $_REQUEST['path'])))));