CMD_FILE_MANAGER action=json_dirs action=json_files action=json_all

Version 1.51

Feature
Finished

json_dirs: generate a json output for the list of directories in the current path json_files: generate a json output for the list of files in the current path Note, if "linkpath" is not empty, eg: "", then the file or folder is a link. Command: CMD_FILE_MANAGER path=/ or path=/some/path or CMD_FILE_MANAGER/some/path GET action=json_dirs|json_files optional: api_flags=0|1 default for this function is 1. (CMD_API_FILEMANAGER default is 0, but can use api_flags=1 in the GET for more info in the API result) The api_flags variable is a bitmask for the following options: #define FM_F_PROTECTABLE 1 #define FM_F_RENAME 2 #define FM_F_COPY 4 #define FM_F_RESET_OWNER 16 #define FM_F_RESET_OWNER_RECURSIVE 32 #define FM_F_HIDE_CHECKBOX 64 #define FM_F_EDITABLE 128 #define FM_F_EXTRACTABLE 256 so to figure out which action a folder can have, check the the bitwise & for the given item. Example, to determine if a folder is protectable, check: if (api_flags & 1) console.log("folder is protectable"); The json_files can use the ipp=10&page=4 method to limit the output, just like tables. All table search/sorting/filtering is available, same as Advanced Search for tables. But the "sub_directories" and "files" variables are not search/sort-able, as they're appended to the data afterwards. Page/row info is added to the "info" data item at the end of the list. There shouldn't be any conflicts with /filenames as all files/paths start with a forward slash, and "info" does not. ======================================== SEARCH / SORTING The json_dirs/json_files output is actually all run by the existing table class. So anything you can do with a table, you should be able to do with this output. The difference is the column names and column order is not the same as the Enhanced "Advanced Search" so the column numbers won't be the same. Note that the columns of json_dirs and json_files ARE NOT THE SAME, so please see the samples for the column number you want. If we add colums in the future, I'll make sure they're appended to the end, so the numbers for existing columns remains the same. Use the sample output below for json_dirs / json_files column numbers, below. api_flags is column 1, and count up from there. Eg: for json_dirs, to search for a .txt file, you'd want column 6 (path), eg: comparison6=contains&value6=.txt You can specify single rules on multiple columns at the same time, if you want to execute a boolean "AND" comparsion. For example: comparison6=contains&value6=.txt&comparison9=atleast&value9=1024000 will show all files that have .txt in their name, and who's size is 1MB or larger. ---- So when searching, the comparisonX values can be: equals atleast atmost contains startswith with the given valueX set to what you're looking for. Make sure the atleast/atmost are only searching on number type columns, else you'd be doing it on strings, eg: a<=b which isn't as useful. ---- You can then sort, and sub-sort at desired, eg: sort1dir=1&sort1=6 where sort1dir is either 1 (ascending) or -1 (descending) And sort1 is the column to sort. ---- You can then do a sub-sort if you want, eg: sort2dir=1&sort2=9 which is the sorting done when a row in sort1 matches. (usually not required) ---- PAGES Json "info" output sample for json_dirs: "info": { "columns": { "api_flags": "1", "date": "2", "gid": "3", "linkpath": "4", "name": "5", "permission": "6", "showsize": "7", "size": "8", "truepath": "9", "uid": "10" }, "current_page": "1", "ipp": "50", "rows": "10", "total_pages": "1" } columns: is a sub-set showing which column each item is at, useful for figureout out which comparison row to work on. (json_dirs != json_files column #s) Items per page: If you want to control how many items are returns, set a value: ipp=50 but usually isn't required. DA has an internal default of 50. rows shows the total number of items in the table. You can pass: page=2 to see page 2, and then you'd see current_page=2 total_pages shows the number of pages available for the given ipp values (internal default, skin.conf value, or get ipp override) An override recomputes the total number of pages, so would affect the current page, etc.. ======================================== Sample output for / path: ---------------------------------------- { "/محمود": { "api_flags": "6", "date": "1474348180", "gid": "admin", "islink": "0", "linkpath": "", "name": "محمود" "permission": "755", "showsize": "4.06k", "size": "4155", "truepath": "/محمود", "uid": "admin", "sub_directories": "1", "files": "1" } , "/.php": { "api_flags": "54", "date": "1476144611", "gid": "apache", "islink": "0", "linkpath": "", "name": ".php" "permission": "770", "showsize": "4.00k", "size": "4096", "truepath": "/.php", "uid": "admin", "sub_directories": "0", "files": "10" } , "/Maildir": { "api_flags": "6", "date": "1475065659", "gid": "mail", "islink": "0", "linkpath": "", "name": "Maildir" "permission": "770", "showsize": "1.34M", "size": "1409098", "truepath": "/Maildir", "uid": "admin", "sub_directories": "6", "files": "5" } , "/admin_backups": { "api_flags": "6", "date": "1476075968", "gid": "admin", "islink": "0", "linkpath": "", "name": "admin_backups" "permission": "711", "showsize": "711.5M", "size": "746046021", "truepath": "/admin_backups", "uid": "admin", "sub_directories": "20", "files": "15" } , "/domains": { "api_flags": "6", "date": "1475246669", "gid": "1003", "islink": "0", "linkpath": "", "name": "domains" "permission": "750", "showsize": "298k", "size": "304861", "truepath": "/domains", "uid": "admin", "sub_directories": "9", "files": "0" } , "/imap": { "api_flags": "6", "date": "1475246669", "gid": "mail", "islink": "0", "linkpath": "", "name": "imap" "permission": "770", "showsize": "4.32k", "size": "4428", "truepath": "/imap", "uid": "admin", "sub_directories": "5", "files": "0" } , "/public_html": { "api_flags": "6", "date": "1475246669", "gid": "admin", "islink": "1", "linkpath": "./domains/testing2domain.com/public_html", "name": "public_html" "permission": "777", "showsize": "0.04k", "size": "40", "truepath": "/public_html", "uid": "admin", "sub_directories": "1", "files": "10" } , "/user_backups": { "api_flags": "6", "date": "1463077334", "gid": "admin", "islink": "0", "linkpath": "", "name": "user_backups" "permission": "711", "showsize": "355.8M", "size": "373067818", "truepath": "/user_backups", "uid": "admin", "sub_directories": "0", "files": "2" } , "info": { "columns": { "api_flags": "1", "date": "2", "gid": "3", "linkpath": "4", "name": "5", "permission": "6", "showsize": "7", "size": "8", "truepath": "9", "uid": "10" }, "current_page": "1", "total_pages": "2", "rows": "15", "ipp": "8" } } ----------------- sample json_files: { "/.bashrc": { "api_flags": "6", "date": "1430061718", "gid": "admin", "linkpath": "", "name": ".bashrc" "permission": "644", "showsize": "0.09k", "size": "89", "truepath": "/.bashrc", "uid": "admin" , "info": { "current_page": "1", "total_pages": "1", "rows": "1", "ipp": "50" } } ----------------- sample json_all: exactly the same as json_dirs, except each file/folder entry has one of: type: "file" type: "directory" and where type=file won't provide extra files/sub_directories values.

Interested to try DirectAdmin? Get a 30-day Free Trial!