diff --git a/ifm.php b/ifm.php index 3214f2c..e7f0d75 100644 --- a/ifm.php +++ b/ifm.php @@ -1,24 +1,28 @@ 1, // allow uploads? + "upload" => 1, // allow uploads "remoteupload" => 1, // allow remote uploads using cURL - "delete" => 1, // allow deletions? - "rename" => 1, // allow renamings? - "edit" => 1, // allow editing? - "chmod" => 1, // allow to change rights? - "extract" => 1, // allow extracting zip archives? - "download" => 1, // allow to download files and skripts (even php-Skripts!!) + "delete" => 1, // allow deletions + "rename" => 1, // allow renamings + "edit" => 1, // allow editing + "chmod" => 1, // allow to change rights + "extract" => 1, // allow extracting zip archives + "download" => 1, // allow to download files and skripts (even php-Skripts!) "selfdownload" => 1, // allow to download this skript itself "createdir" => 1, // allow to create directorys "createfile" => 1, // allow to create files "zipnload" => 1, // allow to zip and download directorys // view controls + "multiselect" => 1, // implement multiselect of files and directories "showlastmodified" => 0, // show the last modified date? "showfilesize" => 1, // show filesize? "showowner" => 1, // show file owner? @@ -73,6 +77,7 @@ if(isset($_POST["api"])) { case "changePermissions": changePermissions($_POST); break; case "zipnload": zipnload($_POST); break; case "remoteUpload": remoteUpload($_POST); break; + case "deleteMultipleFiles": deleteMultipleFiles($_POST); break; default: echo json_encode(array("status"=>"ERROR", "message"=>"No valid api action given")); break; } } else echo json_encode(array("status"=>"ERROR", "message"=>"No valid working directory")); @@ -224,6 +229,35 @@ function deleteFile(array $d) { } } } +// deletes a bunch of files or directories +function deleteMultipleFiles(array $d) { + global $config; + if($config["delete"] != 1||$config["multiselect"] != 1) echo json_encode(array("status"=>"ERROR", "message"=>"No permission to delete multiple files")); + else { + chDirIfNecessary($d['dir']); + $err = array(); $errFLAG = -1; // -1 -> no files deleted; 0 -> at least some files deleted; 1 -> all files deleted + foreach($d['filenames'] as $file) { + if(is_dir($file)){ + $res = rec_rmdir($file); + if($res != 0) array_push($err, $file); else $errFLAG = 0; + } + else { + if(@unlink($file)) { $errFLAG = 0; } + else array_push($err, $file); + } + } + if(empty($err)) { + echo json_encode(array("status"=>"OK", "message"=>"Files deleted successfully", "errflag"=>"1")); + } + else { + $errmsg = "The following files could not be deleted: