11<?php
22
33/**
4- * The Kinsmen File Manager v2.5
4+ * The Kinsmen File Manager v2.6
55 *
66 * A comprehensive, modern file manager with cPanel styling and all essential features:
77 * - File Tree Navigation
1919 * - Sorting and filtering
2020 */
2121
22- $ username = "" ; //username
23- $ root_path = "" ; // root path
22+ $ username = "" ; // user
23+ $ root_path = "" ; // path
2424
2525// Configuration
2626$ config = [
@@ -1056,6 +1056,11 @@ function extract7Zip($source, $destination)
10561056
10571057 foreach ($ items as $ item ) {
10581058 $ itemPath = $ currentPath . DIRECTORY_SEPARATOR . $ item ;
1059+ if ($ item == ".fm-config " ) {
1060+ $ status = false ;
1061+ $ messages [] = "Cannot delete 'fm-config' file " ;
1062+ continue ;
1063+ }
10591064
10601065 if (moveToTrash ($ itemPath , $ currentPath , $ config )) {
10611066 $ movedCount ++;
@@ -1079,53 +1084,40 @@ function extract7Zip($source, $destination)
10791084
10801085 case "delete " :
10811086 $ items = isset ($ _POST ["items " ]) ? $ _POST ["items " ] : [];
1082- $ permanent = isset ($ _POST ["permanent " ])
1083- ? $ _POST ["permanent " ] === "true "
1084- : false ;
1087+ $ permanent = isset ($ _POST ["permanent " ]) ? $ _POST ["permanent " ] == true : false ;
10851088 $ status = true ;
10861089 $ messages = [];
10871090
1088- $ stop = [];
10891091 foreach ($ items as $ item ) {
1090- if (str_contains ($ item , "fm-config " )) {
1091- $ stop [] = $ item ;
1092- }
1093- }
1092+ $ itemPath = $ currentPath . DIRECTORY_SEPARATOR . $ item ;
10941093
1095- if (count ($ stop ) > 0 ) {
1096- $ response = [
1097- "status " => "error " ,
1098- "message " => "Cannot delete 'fm-config' file: " . implode (", " , $ stop ),
1099- ];
1100- header ('Content-Type: application/json ' );
1101- echo json_encode ($ response );
1102- exit ;
1103- }
1104- if (!$ permanent && $ action === "delete " ) {
1105- $ formData = new FormData ();
1106- $ formData . append ("action " , "trash " );
1107- $ formData . append ("path " , $ currentPath );
1094+ if ($ item == ".fm-config " ) {
1095+ $ status = false ;
1096+ $ messages [] = "Cannot delete 'fm-config' file " ;
1097+ continue ;
1098+ }
11081099
1109- foreach ($ items as $ item ) {
1110- $ formData . append ("items[] " , $ item );
1100+ if (!file_exists ($ itemPath )) {
1101+ $ status = false ;
1102+ $ messages [] = "Item not found: " . $ item ;
1103+ continue ;
11111104 }
1112- } else {
1113- foreach ($ items as $ item ) {
1114- $ itemPath = $ currentPath . DIRECTORY_SEPARATOR . $ item ;
1115- $ result = deleteItem ($ itemPath );
11161105
1117- if ($ result ["status " ] != "success " ) {
1118- $ status = false ;
1119- }
1106+ $ result = deleteItem ($ itemPath );
11201107
1121- $ messages [] = $ result ["message " ];
1108+ if ($ result ["status " ] !== "success " ) {
1109+ $ status = false ;
11221110 }
11231111
1124- $ response = [
1125- "status " => $ status ? "success " : "error " ,
1126- "message " => implode (", " , $ messages ),
1127- ];
1112+ $ messages [] = $ result ["message " ];
11281113 }
1114+
1115+ $ response = [
1116+ "status " => $ status ? "success " : "error " ,
1117+ "message " => implode (", " , $ messages ),
1118+ ];
1119+
1120+
11291121 break ;
11301122
11311123 case "restore " :
0 commit comments