function IsDiskWidth() { var comlistWidth = $("#comlist").width(); var bodyWidth = $(".file-box").width(); if (comlistWidth + 530 > bodyWidth) { $("#comlist").css({ "width": bodyWidth - 530 + "px", "height": "34px", "overflow": "auto" }); } else { $("#comlist").removeAttr("style"); } } function Recycle_bin(type) { $.post('/files?action=Get_Recycle_bin','',function (rdata) { var body = ''; switch (type) { case 1: for (var i = 0; i < rdata.dirs.length; i++) { var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'"); var shortpath = rdata.dirs[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.dirs[i].size) + '\ '+ getLocalTime(rdata.dirs[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ '; } for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname.replace('BTDB_', '') + '\ mysql://' + shortpath.replace('BTDB_', '') + '\ -\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' continue; } var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 2: for (var i = 0; i < rdata.dirs.length; i++) { var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'"); var shortpath = rdata.dirs[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.dirs[i].size) + '\ '+ getLocalTime(rdata.dirs[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 3: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) continue; var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 4: for (var i = 0; i < rdata.files.length; i++) { if (ReisImage(getFileName(rdata.files[i].name))) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; break; case 5: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) continue; if (!(ReisImage(getFileName(rdata.files[i].name)))) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; case 6: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname.replace('BTDB_', '') + '\ mysql://' + shortpath.replace('BTDB_', '') + '\ -\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; break; } var tablehtml = '
\
\ '+ lan.files.recycle_bin_on + '\
\ \ \
\ '+ lan.files.recycle_bin_on_db + '\
\ \ \
\
\ '+ lan.files.recycle_bin_ps + '\ \
\
\
\

'+ lan.files.recycle_bin_type1 + '

\

'+ lan.files.recycle_bin_type2 + '

\

'+ lan.files.recycle_bin_type3 + '

\

'+ lan.files.recycle_bin_type4 + '

\

'+ lan.files.recycle_bin_type5 + '

\

'+ lan.files.recycle_bin_type6 + '

\
\
\
\ \ \ \ \ \ \ \ \ \ \ '+ body + '\
'+ lan.files.recycle_bin_th1 + ''+ lan.files.recycle_bin_th2 + ''+ lan.files.recycle_bin_th3 + ''+ lan.files.recycle_bin_th4 + ''+ lan.files.recycle_bin_th5 + '
'; if (type == "open") { layer.open({ type: 1, shift: 5, closeBtn: 2, area: ['80%', '606px'], title: lan.files.recycle_bin_title, content: tablehtml }); if (window.location.href.indexOf("database") != -1) { Recycle_bin(6); $(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on"); } else { Recycle_bin(1); } } $(".re-con-menu p").click(function () { $(this).addClass("on").siblings().removeClass("on"); }) }); } function getFileName(name) { var text = name.split("."); var n = text.length - 1; text = text[n]; return text; } function ReisImage(fileName) { var exts = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff', 'ico']; for (var i = 0; i < exts.length; i++) { if (fileName == exts[i]) return true } return false; } function ReRecycleBin(path, obj) { layer.confirm(lan.files.recycle_bin_re_msg, { title: lan.files.recycle_bin_re_title, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg(lan.files.recycle_bin_re_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=Re_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); $(obj).parents('tr').remove(); }); }); } function DelRecycleBin(path, obj) { layer.confirm(lan.files.recycle_bin_del_msg, { title: lan.files.recycle_bin_del_title, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg(lan.files.recycle_bin_del_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=Del_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); $(obj).parents('tr').remove(); }); }); } function CloseRecycleBin() { layer.confirm(lan.files.recycle_bin_close_msg, { title: lan.files.recycle_bin_close, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg("
" + lan.files.recycle_bin_close_the + "
", { icon: 16, time: 0, shade: [0.3, '#000'] }); setTimeout(function () { getSpeed('.myspeed'); }, 1000); $.post('/files?action=Close_Recycle_bin', '', function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); $("#RecycleBody").html(''); }); }); } function Set_Recycle_bin(db) { var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); var data = {} if (db == 1) { data = { db: db }; } $.post('/files?action=Recycle_bin', data, function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); }); } function get_path_size(path) { var loadT = layer.msg('正在计算目录大小,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=get_path_size', { path: path }, function (rdata) { layer.close(loadT); var myclass = '.' + rdata.path.replace(/[^\w]/g, '-'); console.log(myclass) console.log($(myclass).text()) $(myclass).text(ToSize(rdata.size)); }); } function path_check(path) { if (path == '/') return path; path = path.replace(/[\/]{2,}/g, '/'); path = path.replace(/[\/]+$/g, ''); return path; } function GetFiles(Path, sort) { var searchtype = Path; var p = '1'; if (!isNaN(Path)) { p = Path; Path = getCookie('Path'); } Path = path_check(Path); var data = {}; var search = ''; var searchV = $("#SearchValue").val(); if (searchV.length > 0 && searchtype == "1") { data['search'] = searchV; if ($("#search_all")[0].checked) { data['all'] = 'True' } } var old_scroll_top = 0; if (getCookie('Path') === Path) { old_scroll_top = $(".oldTable").scrollTop(); } var sorted = ''; var reverse = ''; if (!sort) { sort = getCookie('files_sort'); reverse = getCookie(sort + '_reverse'); } else { reverse = getCookie(sort + '_reverse'); if (reverse === 'True') { reverse = 'False'; } else { reverse = 'True'; } } if (sort) { data['sort'] = sort; data['reverse'] = reverse; setCookie(sort + '_reverse', reverse); setCookie('files_sort', sort); } var showRow = getCookie('showRow'); if (!showRow) showRow = '200'; var Body = ''; data['path'] = Path; if (searchV) { var loadT = layer.msg('正在搜索,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); } var totalSize = 0; $.post('/files?action=GetDir&tojs=GetFiles&p=' + p + '&showRow=' + showRow + search, data, function (rdata) { if (searchV) layer.close(loadT); if (rdata.status === false) { layer.msg(rdata.msg, { icon: 2 }); return; } var rows = ['10', '50', '100', '200', '500', '1000', '2000']; var rowOption = ''; for (var i = 0; i < rows.length; i++) { var rowSelected = ''; if (showRow == rows[i]) rowSelected = 'selected'; rowOption += ''; } $("#filePage").html(rdata.PAGE); $("#filePage div").append("每页"); $("#filePage .Pcount").css("left", "16px"); if (rdata.DIR == null) rdata.DIR = []; for (var i = 0; i < rdata.DIR.length; i++) { var fmp = rdata.DIR[i].split(";"); var cnametext = fmp[0] + fmp[5]; fmp[0] = fmp[0].replace(/'/, "\\'"); if (cnametext.length > 20) { cnametext = cnametext.substring(0, 20) + '...' } if (isChineseChar(cnametext)) { if (cnametext.length > 10) { cnametext = cnametext.substring(0, 10) + '...' } } var fileMsg = ''; if (fmp[0].indexOf('Recycle_bin') != -1) { fileMsg = 'PS: 回收站目录,勿动!'; } if (fileMsg != '') { fileMsg = '' + fileMsg + ''; } var timetext = '--'; if (getCookie("rank") == "a") { $("#set_list").addClass("active"); $("#set_icon").removeClass("active"); Body += "\ \ " + cnametext + fileMsg + "\ 点击计算\ "+ getLocalTime(fmp[2]) + "\ "+ fmp[3] + "\ "+ fmp[4] + "\ \ " + lan.files.file_menu_copy + " | \ " + lan.files.file_menu_mv + " | \ " + lan.files.file_menu_rename + " | \ " + lan.files.file_menu_auth + " | \ " + lan.files.file_menu_zip + " | \ " + lan.files.file_menu_del + "\ "; } else { $("#set_icon").addClass("active"); $("#set_list").removeClass("active"); Body += ""; } } for (var i = 0; i < rdata.FILES.length; i++) { if (rdata.FILES[i] == null) continue; var fmp = rdata.FILES[i].split(";"); var displayZip = isZip(fmp[0]); var bodyZip = ''; var download = ''; var cnametext = fmp[0] + fmp[5]; fmp[0] = fmp[0].replace(/'/, "\\'"); if (cnametext.length > 48) { cnametext = cnametext.substring(0, 48) + '...' } if (isChineseChar(cnametext)) { if (cnametext.length > 16) { cnametext = cnametext.substring(0, 16) + '...' } } if (displayZip != -1) { bodyZip = "" + lan.files.file_menu_unzip + " | "; } if (isText(fmp[0])) { bodyZip = "" + lan.files.file_menu_edit + " | "; } if (isImage(fmp[0])) { download = "" + lan.files.file_menu_img + " | "; } else { download = "" + lan.files.file_menu_down + " | "; } totalSize += parseInt(fmp[1]); if (getCookie("rank") == "a") { var fileMsg = ''; switch (fmp[0]) { case '.user.ini': fileMsg = 'PS: PHP用户配置文件(防跨站)!'; break; case '.htaccess': fileMsg = 'PS: Apache用户配置文件(伪静态)'; break; case 'swap': fileMsg = 'PS: 宝塔默认设置的SWAP交换分区文件'; break; } if (fmp[0].indexOf('.upload.tmp') != -1) { fileMsg = 'PS: 宝塔文件上传临时文件,重新上传从断点续传,可删除'; } if (fileMsg != '') { fileMsg = '' + fileMsg + ''; } Body += "\ " + cnametext + fileMsg + "\ " + (ToSize(fmp[1])) + "\ " + ((fmp[2].length > 11) ? fmp[2] : getLocalTime(fmp[2])) + "\ "+ fmp[3] + "\ "+ fmp[4] + "\ \ " + lan.files.file_menu_copy + " | \ " + lan.files.file_menu_mv + " | \ " + lan.files.file_menu_rename + " | \ " + lan.files.file_menu_auth + " | \ " + lan.files.file_menu_zip + " | \ "+ bodyZip + download + "\ " + lan.files.file_menu_del + "\ "; } else { Body += ""; } } var dirInfo = '(' + lan.files.get_size.replace('{1}', rdata.DIR.length + '').replace('{2}', rdata.FILES.length + '') + '' + lan.files.get + ')'; $("#DirInfo").html(dirInfo); if (getCookie("rank") === "a") { var sort_icon = ''; var tablehtml = '
\ \ \ \ \ \ \ \ \ \ \ \ \
' + lan.files.file_name + ((data['sort'] === 'name' || !data['sort']) ? sort_icon : '') + '' + lan.files.file_size + ((data['sort'] === 'size') ? sort_icon : '') + '' + lan.files.file_etime + ((data['sort'] === 'mtime') ? sort_icon : '') + '' + lan.files.file_auth + ((data['sort'] === 'accept') ? sort_icon : '') + '' + lan.files.file_own + ((data['sort'] === 'user') ? sort_icon : '') + ''+ lan.files.file_act + '
\
\
\
\ \ \ \ \ \ \ \ \ \ \ \ '+ Body + '\
' + lan.files.file_name + ((data['sort'] === 'name' || !data['sort']) ? sort_icon : '') + '' + lan.files.file_size + ((data['sort'] === 'size') ? sort_icon : '') + '' + lan.files.file_etime + ((data['sort'] === 'mtime') ? sort_icon : '') + '' + lan.files.file_auth + ((data['sort'] === 'accept') ? sort_icon : '') + '' + lan.files.file_own + ((data['sort'] === 'user') ? sort_icon : '') + ''+ lan.files.file_act + '
'; $("#fileCon").removeClass("fileList").html(tablehtml); $("#tipTools").width($("#fileCon")[0].clientWidth - 30); } else { $("#fileCon").addClass("fileList").html(Body); $("#tipTools").width($("#fileCon")[0].clientWidth - 30); } $("#DirPathPlace input").val(rdata.PATH); var BarTools = '
\ \ \
'; if (rdata.PATH != '/') { BarTools += ' '; } setCookie('Path', rdata.PATH); BarTools += ' '; // 收藏夹 var shtml = '
\ \
' BarTools += shtml; var copyName = getCookie('copyFileName'); var cutName = getCookie('cutFileName'); var isPaste = (copyName == 'null') ? cutName : copyName; if (isPaste != 'null' && isPaste != undefined) { BarTools += ' '; } $("#Batch").html(''); var BatchTools = ''; var isBatch = getCookie('BatchSelected'); if (isBatch == 1 || isBatch == '1') { BatchTools += ' '; } $("#Batch").html(BatchTools); $("#setBox").prop("checked", false); $("#BarTools").html(BarTools); $(".oldTable").scrollTop(old_scroll_top); $("input[name=id]").click(function () { if ($(this).prop("checked")) { $(this).prop("checked", true); $(this).parents("tr").addClass("ui-selected"); } else { $(this).prop("checked", false); $(this).parents("tr").removeClass("ui-selected"); } showSeclect() }); // // 鼠标移入移出事件 // $('.file-types').hover(function () { // // 鼠标移入时添加hover类 // $('.dropdown-menu-li').hide(); // $(this).find('.dropdown-menu-li').show(); // }, function () { // $('.dropdown-menu-li').hide(); // // 鼠标移出时移出hover类 // }); $("#setBox").click(function () { if ($(this).prop("checked")) { $("input[name=id]").prop("checked", true); $("#filesBody > tr").addClass("ui-selected"); } else { $("input[name=id]").prop("checked", false); $("#filesBody > tr").removeClass("ui-selected"); } showSeclect(); }); $("#filesBody .btlink").click(function (e) { e.stopPropagation(); }); $("input[name=id]").dblclick(function (e) { e.stopPropagation(); }); $("#filesBody").bind("contextmenu", function (e) { return false; }); bindselect(); $("#filesBody").mousedown(function (e) { var count = totalFile(); if (e.which == 3) { if (count > 1) { RClickAll(e); } else { return } } }); $(".folderBox,.folderBoxTr").mousedown(function (e) { var count = totalFile(); if (e.which == 3) { if (count <= 1) { var a = $(this); a.contextify(RClick(a.attr("filetype"), a.attr("data-path"), a.find("input").val(), rdata)); } else { RClickAll(e); } } }); $(".showRow").change(function () { setCookie('showRow', $(this).val()); GetFiles(p); }); PathPlaceBtn(rdata.PATH); auto_table_width(); }); } function auto_table_width() { var oldTable = $(window).height() - $('#tipTools')[0].getBoundingClientRect().height - $('#filePage')[0].getBoundingClientRect().height - $('.footer')[0].getBoundingClientRect().height - 111; var oldTable_heigth = $('.oldTable table').height(); $('.oldTable thead th').each(function (index, el) { var table_th = $('.oldTable thead th').length; $('.newTable thead th').eq(index).attr('width', el.offsetWidth); if (index == (table_th - 1)) $('.newTable thead th').eq(table_th).attr('width', '10').css('padding', '0'); }); if (oldTable_heigth > oldTable) { $('.oldTableShadow,.newTableShadow').show(); $('.oldTable').css('marginTop', '0') } else { $('.oldTableShadow,.newTableShadow').hide(); $('.oldTable').css('marginTop', '0') } $('.oldTable').height(oldTable); $('.oldTable table').css({ 'marginTop': '-36px' }) } function totalFile() { var el = $("input[name='id']"); var len = el.length; var count = 0; for (var i = 0; i < len; i++) { if (el[i].checked == true) { count++; } } return count; } function bindselect() { $("#filesBody").selectable({ autoRefresh: false, filter: "tr,.folderBox", cancel: "a,span,input,.ico-folder", selecting: function (e) { $(".ui-selecting").find("input").prop("checked", true); showSeclect(); }, selected: function (e) { $(".ui-selectee").find("input").prop("checked", false); $(".ui-selected", this).each(function () { $(this).find("input").prop("checked", true); showSeclect(); }); }, unselecting: function (e) { $(".ui-selectee").find("input").prop("checked", false); $(".ui-selecting").find("input").prop("checked", true); showSeclect(); $("#rmenu").hide() } }); $("#filesBody").selectable("refresh"); $(".ico-folder").click(function () { $(this).parent().addClass("ui-selected").siblings().removeClass("ui-selected"); $(".ui-selectee").find("input").prop("checked", false); $(this).prev("input").prop("checked", true); showSeclect(); }) } function showSeclect() { var count = totalFile(); var BatchTools = ''; if (count > 1) { BatchTools = '\ \ \ \ ' $("#Batch").html(BatchTools); } else { $("#Batch").html(BatchTools); } } $("#tipTools").width($(".file-box")[0].clientWidth-30); $("#PathPlaceBtn").width($(".file-box").width() - 700); $("#DirPathPlace input").width($(".file-box").width() - 700); if ($(window).width() < 1160) { $("#PathPlaceBtn").width(290); } window.onresize = function () { $("#tipTools").width($(".file-box")[0].clientWidth-30); $("#PathPlaceBtn").width($(".file-box").width() - 700); $("#DirPathPlace input").width($(".file-box").width() - 700); if ($(window).width() < 1160) { $("#PathPlaceBtn,#DirPathPlace input").width(290); } PathLeft(); IsDiskWidth() auto_table_width(); } function Batch(type, access) { var path = $("#DirPathPlace input").val(); var el = document.getElementsByTagName('input'); var len = el.length; var data = 'path=' + path + '&type=' + type; var name = 'data'; var datas = [] var oldType = getCookie('BatchPaste'); for (var i = 0; i < len; i++) { if (el[i].checked == true && el[i].value != 'on') { datas.push(el[i].value) } } data += "&data=" + encodeURIComponent(JSON.stringify(datas)) if (type == 3 && access == undefined) { SetChmod(0, lan.files.all); return; } if (type < 3) setCookie('BatchSelected', '1'); setCookie('BatchPaste', type); if (access == 1) { var access = $("#access").val(); var chown = $("#chown").val(); var all = $("#accept_all").prop("checked") ? 'True' : 'False'; data += '&access=' + access + '&user=' + chown + "&all=" + all; layer.closeAll(); } if (type == 4) { AllDeleteFileSub(data, path); setCookie('BatchPaste', oldType); return; } if (type == 5) { var names = ''; for (var i = 0; i < len; i++) { if (el[i].checked == true && el[i].value != 'on') { names += el[i].value + ','; } } Zip(names); return; } myloadT = layer.msg("
" + lan.public.the + "
", { icon: 16, time: 0, shade: [0.3, '#000'] }); setTimeout(function () { getSpeed('.myspeed'); }, 1000); $.post('/files?action=SetBatchData', data, function (rdata) { layer.close(myloadT); GetFiles(path); layer.msg(rdata.msg, { icon: 1 }); }); } function BatchPaste() { var path = $("#DirPathPlace input").val(); var type = getCookie('BatchPaste'); var data = 'type=' + type + '&path=' + path; $.post('/files?action=CheckExistsFiles', { dfile: path }, function (result) { if (result.length > 0) { var tbody = ''; for (var i = 0; i < result.length; i++) { tbody += '' + result[i].filename + '' + ToSize(result[i].size) + '' + getLocalTime(result[i].mtime) + ''; } var mbody = '
\ '+ tbody + '\
文件名大小最后修改时间
'; SafeMessage('即将覆盖以下文件', mbody, function () { BatchPasteTo(data, path); }); $(".layui-layer-page").css("width", "500px"); } else { BatchPasteTo(data, path); } }); } function BatchPasteTo(data, path) { myloadT = layer.msg("
" + lan.public.the + "
", { icon: 16, time: 0, shade: [0.3, '#000'] }); setTimeout(function () { getSpeed('.myspeed'); }, 1000); $.post('files?action=BatchPaste', data, function (rdata) { layer.close(myloadT); setCookie('BatchSelected', null); GetFiles(path); layer.msg(rdata.msg, { icon: 1 }); }); } function GetExtName(fileName) { var extArr = fileName.split("."); var exts = ['folder', 'folder-unempty', 'sql', 'c', 'cpp', 'cs', 'flv', 'css', 'js', 'htm', 'html', 'java', 'log', 'mht', 'php', 'url', 'xml', 'ai', 'bmp', 'cdr', 'gif', 'ico', 'jpeg', 'jpg', 'JPG', 'png', 'psd', 'webp', 'ape', 'avi', 'flv', 'mkv', 'mov', 'mp3', 'mp4', 'mpeg', 'mpg', 'rm', 'rmvb', 'swf', 'wav', 'webm', 'wma', 'wmv', 'rtf', 'docx', 'fdf', 'potm', 'pptx', 'txt', 'xlsb', 'xlsx', '7z', 'cab', 'iso', 'bz2', 'rar', 'zip', 'gz', 'bt', 'file', 'apk', 'bookfolder', 'folder', 'folder-empty', 'folder-unempty', 'fromchromefolder', 'documentfolder', 'fromphonefolder', 'mix', 'musicfolder', 'picturefolder', 'videofolder', 'sefolder', 'access', 'mdb', 'accdb', 'sql', 'c', 'cpp', 'cs', 'js', 'fla', 'flv', 'htm', 'html', 'java', 'log', 'mht', 'php', 'url', 'xml', 'ai', 'bmp', 'cdr', 'gif', 'ico', 'jpeg', 'jpg', 'JPG', 'png', 'psd', 'webp', 'ape', 'avi', 'flv', 'mkv', 'mov', 'mp3', 'mp4', 'mpeg', 'mpg', 'rm', 'rmvb', 'swf', 'wav', 'webm', 'wma', 'wmv', 'doc', 'docm', 'dotx', 'dotm', 'dot', 'rtf', 'docx', 'pdf', 'fdf', 'ppt', 'pptm', 'pot', 'potm', 'pptx', 'txt', 'xls', 'csv', 'xlsm', 'xlsb', 'xlsx', '7z', 'gz', 'cab', 'iso', 'rar', 'zip', 'bt', 'file', 'apk', 'css']; var extLastName = extArr[extArr.length - 1]; for (var i = 0; i < exts.length; i++) { if (exts[i] == extLastName) { return exts[i]; } } return 'file'; } function ShowEditMenu() { $("#filesBody > tr").hover(function () { $(this).addClass("hover"); }, function () { $(this).removeClass("hover"); }).click(function () { $(this).addClass("on").siblings().removeClass("on"); }) } function GetFileName(fileNameFull) { var pName = fileNameFull.split('/'); return pName[pName.length - 1]; } function GetDisk() { var LBody = ''; $.get('/system?action=GetDiskInfo', function (rdata) { for (var i = 0; i < rdata.length; i++) { LBody += " " + (rdata[i].path == '/' ? lan.files.path_root : rdata[i].path) + "(" + rdata[i].size[2] + ")"; } var trash = ' ' + lan.files.recycle_bin_title + ''; $("#comlist").html(LBody + trash); IsDiskWidth(); }); } function BackDir() { var str = $("#DirPathPlace input").val().replace('//', '/'); if (str.substr(str.length - 1, 1) == '/') { str = str.substr(0, str.length - 1); } var Path = str.split("/"); var back = '/'; if (Path.length > 2) { var count = Path.length - 1; for (var i = 0; i < count; i++) { back += Path[i] + '/'; } if (back.substr(back.length - 1, 1) == '/') { back = back.substr(0, back.length - 1); } GetFiles(back); } else { back += Path[0]; GetFiles(back); } setTimeout('PathPlaceBtn(getCookie("Path"));', 200); } function CreateFile(type, path) { if (type == 1) { var fileName = $("#newFileName").val(); layer.msg(lan.public.the, { icon: 16, time: 10000 }); $.post('/files?action=CreateFile', 'path=' + encodeURIComponent(path + '/' + fileName), function (rdata) { layer.close(getCookie('layers')); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); if (rdata.status) { GetFiles($("#DirPathPlace input").val()); openEditorView(0, path + '/' + fileName); } }); return; } var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '320px', title: lan.files.new_empty_file, content: '
\
\ \
\
\ \ \
\
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index); }); } }); setCookie('layers', layers); $("#newFileName").focus().keyup(function (e) { if (e.keyCode == 13) $("#CreateFileBtn").click(); }); } function CreateDir(type, path) { if (type == 1) { var dirName = $("#newDirName").val(); layer.msg(lan.public.the, { icon: 16, time: 10000 }); $.post('/files?action=CreateDir', 'path=' + encodeURIComponent(path + '/' + dirName), function (rdata) { layer.close(getCookie('layers')); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles($("#DirPathPlace input").val()); }); return; } var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '320px', title: lan.files.new_dir, content: '
\
\ \
\
\ \ \
\
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index); }); } }); setCookie('layers', layers); $("#newDirName").focus().keyup(function (e) { if (e.keyCode == 13) $("#CreateDirBtn").click(); }); } // 删除文件 function DeleteFile(fileName) { layer.confirm(lan.get('recycle_bin_confirm', [fileName]), { title: lan.files.del_file, closeBtn: 2, icon: 3 }, function (index) { layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=DeleteFile', 'path=' + encodeURIComponent(fileName), function (rdata) { layer.close(index); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles($("#DirPathPlace input").val()); }); }); } function DeleteDir(dirName) { layer.confirm(lan.get('recycle_bin_confirm_dir', [dirName]), { title: lan.files.del_dir, closeBtn: 2, icon: 3 }, function (index) { layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=DeleteDir', 'path=' + encodeURIComponent(dirName), function (rdata) { layer.close(index); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles($("#DirPathPlace input").val()); }); }); } function AllDeleteFileSub(data, path) { layer.confirm(lan.files.del_all_msg, { title: lan.files.del_all_file, closeBtn: 2, icon: 3 }, function (index) { layer.msg("
" + lan.public.the + "
", { icon: 16, time: 0, shade: [0.3, '#000'] }); setTimeout(function () { getSpeed('.myspeed'); }, 1000); $.post('files?action=SetBatchData', data, function (rdata) { layer.close(index); GetFiles(path); layer.msg(rdata.msg, { icon: 1 }); }); }); } function ReloadFiles() { setInterval(function () { var path = $("#DirPathPlace input").val(); GetFiles(path); }, 3000); } function DownloadFile(action) { if (action == 1) { var fUrl = $("#mUrl").val(); fUrl = encodeURIComponent(fUrl); fpath = $("#dpath").val(); fname = encodeURIComponent($("#dfilename").val()); if (!fname) { durl = $("#mUrl").val() tmp = durl.split('/') $("#dfilename").val(tmp[tmp.length - 1]) fname = encodeURIComponent($("#dfilename").val()); if (!fname) { layer.msg('文件名不能为空!'); return; } } layer.close(getCookie('layers')) layer.msg(lan.files.down_task, { time: 0, icon: 16, shade: [0.3, '#000'] }); $.post('/files?action=DownloadFile', 'path=' + fpath + '&url=' + fUrl + '&filename=' + fname, function (rdata) { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles(fpath); GetTaskCount(); task_stat(); }); return; } var path = $("#DirPathPlace input").val(); var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '500px', title: lan.files.down_title, content: '
\
\ '+ lan.files.down_url + ':\
\
\ '+ lan.files.down_to + ':\
\
\ '+ lan.files.file_name + ':\
\
\ \ \
\
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index) }); } }); setCookie('layers', layers); //fly("dlok"); $("#mUrl").change(function () { durl = $(this).val() tmp = durl.split('/') $("#dfilename").val(tmp[tmp.length - 1]) }); } function ExecShell(action) { if (action == 1) { var path = $("#DirPathPlace input").val(); var exec = encodeURIComponent($("#mExec").val()); $.post('/files?action=ExecShell', 'path=' + path + '&shell=' + exec, function (rdata) { if (rdata.status) { $("#mExec").val(''); GetShellEcho(); } else { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); } }); return; } layer.open({ type: 1, shift: 5, closeBtn: 2, area: ['70%', '600px'], title: lan.files.shell_title, content: '
\
\
\ ' + lan.files.shell_go + '\
\
' }); setTimeout(function () { outTimeGet(); }, 1000); } var outTime = null; function outTimeGet() { outTime = setInterval(function () { if (!$("#mExec").attr('name')) { clearInterval(outTime); return; } GetShellEcho(); }, 1000); } function GetShellEcho() { $.post('/files?action=GetExecShellMsg', '', function (rdata) { $("#Result").html(rdata); $(".shellcode").scrollTop($(".shellcode")[0].scrollHeight); }); } function ReName(type, fileName) { if (type == 1) { var path = $("#DirPathPlace input").val(); var newFileName = encodeURIComponent(path + '/' + $("#newFileName").val()); var oldFileName = encodeURIComponent(path + '/' + fileName); layer.msg(lan.public.the, { icon: 16, time: 10000 }); $.post('/files?action=MvFile', 'sfile=' + oldFileName + '&dfile=' + newFileName + '&rename=true', function (rdata) { layer.close(getCookie('layers')); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles(path); }); return; } var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '320px', title: lan.files.file_menu_rename, content: '
\
\ \
\
\ \ \
\
', success: function (layers, index) { $('.layers_close').click(function () { layer.close(index); }); } }); setCookie('layers', layers); $("#newFileName").focus().keyup(function (e) { if (e.keyCode == 13) $("#ReNameBtn").click(); }); } function CutFile(fileName) { var path = $("#DirPathPlace input").val(); setCookie('cutFileName', fileName); setCookie('copyFileName', null); layer.msg(lan.files.mv_ok, { icon: 1, time: 1000 }); GetFiles(path); } function CopyFile(fileName) { var path = $("#DirPathPlace input").val(); setCookie('copyFileName', fileName); setCookie('cutFileName', null); layer.msg(lan.files.copy_ok, { icon: 1, time: 1000 }); GetFiles(path); } function PasteFile(fileName) { var path = $("#DirPathPlace input").val(); var copyName = getCookie('copyFileName'); var cutName = getCookie('cutFileName'); var filename = copyName; if (cutName != 'null' && cutName != undefined) filename = cutName; filename = filename.split('/').pop(); $.post('/files?action=CheckExistsFiles', { dfile: path, filename: filename }, function (result) { if (result.length > 0) { var tbody = ''; for (var i = 0; i < result.length; i++) { tbody += '' + result[i].filename + '' + ToSize(result[i].size) + '' + getLocalTime(result[i].mtime) + ''; } var mbody = '
\ '+ tbody + '\
文件名大小最后修改时间
'; SafeMessage('即将覆盖以下文件', mbody, function () { PasteTo(path, copyName, cutName, fileName); }); } else { PasteTo(path, copyName, cutName, fileName); } }); } function PasteTo(path, copyName, cutName, fileName) { if (copyName != 'null' && copyName != undefined) { layer.msg(lan.files.copy_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=CopyFile', 'sfile=' + encodeURIComponent(copyName) + '&dfile=' + encodeURIComponent(path + '/' + fileName), function (rdata) { layer.closeAll(); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles(path); }); setCookie('copyFileName', null); setCookie('cutFileName', null); return; } if (cutName != 'null' && cutName != undefined) { layer.msg(lan.files.mv_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=MvFile', 'sfile=' + encodeURIComponent(cutName) + '&dfile=' + encodeURIComponent(path + '/' + fileName), function (rdata) { layer.closeAll(); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); GetFiles(path); }); setCookie('copyFileName', null); setCookie('cutFileName', null); } } // 压缩文件 function Zip(dirName, submits) { var path = $("#DirPathPlace input").val(); if (submits != undefined) { if (dirName.indexOf(',') == -1) { tmp = $("#sfile").val().split('/'); sfile = encodeURIComponent(tmp[tmp.length - 1]); } else { sfile = encodeURIComponent(dirName); } dfile = encodeURIComponent($("#dfile").val()); var z_type = $("select[name='z_type']").val(); if (!z_type) z_type = 'tar.gz'; layer.close(getCookie('layers')); var layers = layer.msg(lan.files.zip_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=Zip', 'sfile=' + sfile + '&dfile=' + dfile + '&z_type=' + z_type + '&path=' + encodeURIComponent(path), function (rdata) { layer.close(layers); if (rdata == null || rdata == undefined) { layer.msg(lan.files.zip_ok, { icon: 1 }); GetFiles(path) ReloadFiles(); return; } layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); if (rdata.status) { task_stat() GetFiles(path); } }); return } param = dirName; if (dirName.indexOf(',') != -1) { tmp = path.split('/') dirName = path + '/' + tmp[tmp.length - 1] } var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '650px', title: lan.files.zip_title, content: '
' + '
' + '' + '

压缩类型

' + '' + lan.files.zip_to + '' + '
' + '
' + '' + '' + '
' + '
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index); }); } }); setCookie('layers', layers); setTimeout(function () { $("select[name='z_type']").change(function () { var z_type = $(this).val(); dirName = dirName.replace("tar.gz", z_type) $("#dfile").val(dirName + '.' + z_type); }); }, 100); } function UnZip(fileName, type) { var path = $("#DirPathPlace input").val(); if (type.length == 3) { var sfile = encodeURIComponent($("#sfile").val()); var dfile = encodeURIComponent($("#dfile").val()); var password = encodeURIComponent($("#unpass").val()); coding = $("select[name='coding']").val(); layer.close(getCookie('layers')); layer.msg(lan.files.unzip_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=UnZip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=' + type + '&coding=' + coding + '&password=' + password, function (rdata) { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); task_stat(); GetFiles(path); }); return } type = (type == 1) ? 'tar' : 'zip' var umpass = ''; if (type == 'zip') { umpass = '
' + lan.files.zip_pass_title + '
' } var layers = layer.open({ type: 1, shift: 5, closeBtn: 2, area: '490px', title: lan.files.unzip_title, content: '
' + '
' + '' + lan.files.unzip_name + '
' + '
' + lan.files.unzip_to + '
' + umpass + '
' + lan.files.unzip_coding + '' + '
' + '
' + '' + '' + '
' + '
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index); }); } }); setCookie('layers', layers); } function isZip(fileName) { var ext = fileName.split('.'); var extName = ext[ext.length - 1].toLowerCase(); if (extName == 'zip' || extName == 'war' || extName == 'rar') return 0; if (extName == 'gz' || extName == 'tgz' || extName == 'bz2') return 1; return -1; } function isText(fileName) { var exts = ['rar', 'war', 'zip', 'tar.gz', 'gz', 'iso', 'xsl', 'doc', 'xdoc', 'jpeg', 'jpg', 'png', 'gif', 'bmp', 'tiff', 'exe', 'so', '7z', 'bz', 'bz2']; return isExts(fileName, exts) ? false : true; } function isImage(fileName) { var exts = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff', 'ico']; return isExts(fileName, exts); } function isVideo(fileName) { var exts = ['mp4', 'mpeg', 'mpg', 'mov', 'avi', 'webm', 'mkv']; return isExts(fileName, exts); } function isExts(fileName, exts) { var ext = fileName.split('.'); if (ext.length < 2) return false; var extName = ext[ext.length - 1].toLowerCase(); for (var i = 0; i < exts.length; i++) { if (extName == exts[i]) return true; } return false; } function GetImage(fileName) { var imgUrl = '/download?filename=' + fileName; layer.open({ type: 1, closeBtn: 2, title: false, area: '500px', shadeClose: true, content: '
' }); $(".layui-layer").css("top", "30%"); } function GetPlay(fileName) { var imgUrl = '/download?filename=' + fileName; layer.open({ type: 1, closeBtn: 2, title: '播放[' + fileName + ']', area: '500px', shadeClose: false, content: '
' }); $(".layui-layer").css("top", "30%"); } function GetFileBytes(fileName, fileSize) { window.open('/download?filename=' + encodeURIComponent(fileName)); } function UploadFiles() { var path = $("#DirPathPlace input").val() + "/"; bt_upload_file.open(path, null, null, function (path) { GetFiles(path); }); return; /* layer.open({ type:1, closeBtn: 2, title:lan.files.up_title, area: ['500px','500px'], shadeClose:false, content:'
\ \ \ \ \ \ '+lan.files.up_coding+':\ \ \ \
' }); UploadStart();*/ } // 设置权限 function SetChmod(action, fileName) { if (action == 1) { var chmod = $("#access").val(); var chown = $("#chown").val(); var all = $("#accept_all").prop("checked") ? 'True' : 'False'; var data = 'filename=' + encodeURIComponent(fileName) + '&user=' + chown + '&access=' + chmod + '&all=' + all; var loadT = layer.msg(lan.public.config, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('files?action=SetFileAccess', data, function (rdata) { layer.close(loadT); if (rdata.status) layer.close(getCookie('layers')); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); var path = $("#DirPathPlace input").val(); GetFiles(path) }); return; } var toExec = fileName == lan.files.all ? 'Batch(3,1)' : 'SetChmod(1,\'' + fileName + '\')'; $.post('/files?action=GetFileAccess', 'filename=' + encodeURIComponent(fileName), function (rdata) { var layers = layer.open({ type: 1, closeBtn: 2, title: lan.files.set_auth + '[' + fileName + ']', area: '400px', shadeClose: false, content: '
\
\ '+ lan.files.file_own + '\

'+ lan.files.file_read + '

\

'+ lan.files.file_write + '

\

'+ lan.files.file_exec + '

\
\
\ '+ lan.files.file_group + '\

'+ lan.files.file_read + '

\

'+ lan.files.file_write + '

\

'+ lan.files.file_exec + '

\
\
\ '+ lan.files.file_public + '\

'+ lan.files.file_read + '

\

'+ lan.files.file_write + '

\

'+ lan.files.file_exec + '

\
\
' + lan.files.file_menu_auth + ',\ '+ lan.files.file_own + '\ \ \
\
\ \ \
\
', success: function (layers, index) { $('.layer_close').click(function () { layer.close(index); }) } }); setCookie('layers', layers); onAccess(); $("#access").keyup(function () { onAccess(); }); $("input[type=checkbox]").change(function () { var idName = ['owner', 'group', 'public']; var onacc = ''; for (var n = 0; n < idName.length; n++) { var access = 0; access += $("#" + idName[n] + "_x").prop('checked') ? 1 : 0; access += $("#" + idName[n] + "_w").prop('checked') ? 2 : 0; access += $("#" + idName[n] + "_r").prop('checked') ? 4 : 0; onacc += access; } $("#access").val(onacc); }); }) } function onAccess() { var access = $("#access").val(); var idName = ['owner', 'group', 'public']; for (var n = 0; n < idName.length; n++) { $("#" + idName[n] + "_x").prop('checked', false); $("#" + idName[n] + "_w").prop('checked', false); $("#" + idName[n] + "_r").prop('checked', false); } for (var i = 0; i < access.length; i++) { var onacc = access.substr(i, 1); if (i > idName.length) continue; if (onacc > 7) $("#access").val(access.substr(0, access.length - 1)); switch (onacc) { case '1': $("#" + idName[i] + "_x").prop('checked', true); break; case '2': $("#" + idName[i] + "_w").prop('checked', true); break; case '3': $("#" + idName[i] + "_x").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); break; case '4': $("#" + idName[i] + "_r").prop('checked', true); break; case '5': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_x").prop('checked', true); break; case '6': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); break; case '7': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); $("#" + idName[i] + "_x").prop('checked', true); break; } } } function RClick(type, path, name, file_store) { var displayZip = isZip(type); var options = { items: [ { text: lan.files.file_menu_copy, onclick: function () { CopyFile(path) } }, { text: lan.files.file_menu_mv, onclick: function () { CutFile(path) } }, { text: lan.files.file_menu_rename, onclick: function () { ReName(0, name) } }, { text: lan.files.file_menu_auth, onclick: function () { SetChmod(0, path) } }, { text: lan.files.file_menu_zip, onclick: function () { Zip(path) } } ] }; if (type == "dir") { options.items.push({ text: lan.files.file_menu_del, onclick: function () { DeleteDir(path) } }); } //else if (isVideo(type)) { // options.items.push({ text: '播放', onclick: function () { GetPlay(path) } }, { text: lan.files.file_menu_down, onclick: function () { GetFileBytes(path) } }, { text: lan.files.file_menu_del, onclick: function () { DeleteFile(path) } }); //} else if (isText(type)) { options.items.push({ text: lan.files.file_menu_edit, onclick: function () { openEditorView(0, path) } }, { text: lan.files.file_menu_down, onclick: function () { GetFileBytes(path) } }, { text: lan.files.file_menu_del, onclick: function () { DeleteFile(path) } }); } else if (displayZip != -1) { options.items.push({ text: lan.files.file_menu_unzip, onclick: function () { UnZip(path, displayZip) } }, { text: lan.files.file_menu_down, onclick: function () { GetFileBytes(path) } }, { text: lan.files.file_menu_del, onclick: function () { DeleteFile(path) } }); } else if (isImage(type)) { options.items.push({ text: lan.files.file_menu_img, onclick: function () { GetImage(path) } }, { text: lan.files.file_menu_down, onclick: function () { GetFileBytes(path) } }, { text: lan.files.file_menu_del, onclick: function () { DeleteFile(path) } }); } else { options.items.push({ text: lan.files.file_menu_down, onclick: function () { GetFileBytes(path) } }, { text: lan.files.file_menu_del, onclick: function () { DeleteFile(path) } }); } options.items.push({ text: "收藏夹", onclick: function () { var loading = bt.load(); bt.send('add_files_store', 'files/add_files_store',{path:path}, function (rRet) { loading.close(); bt.msg(rRet); if (rRet.status) { console.log(file_store.PATH); GetFiles(file_store.PATH) } }); } }) return options; } function RClickAll(e) { var menu = $("#rmenu"); var windowWidth = $(window).width(), windowHeight = $(window).height(), menuWidth = menu.outerWidth(), menuHeight = menu.outerHeight(), x = (menuWidth + e.clientX < windowWidth) ? e.clientX : windowWidth - menuWidth, y = (menuHeight + e.clientY < windowHeight) ? e.clientY : windowHeight - menuHeight; menu.css('top', y) .css('left', x) .css('position', 'fixed') .css("z-index", "1") .show(); } function GetPathSize() { var path = encodeURIComponent($("#DirPathPlace input").val()); layer.msg("正在计算,请稍候", { icon: 16, time: 0, shade: [0.3, '#000'] }) $.post("/files?action=GetDirSize", "path=" + path, function (rdata) { layer.closeAll(); $("#pathSize").text(rdata) }) } $("body").not(".def-log").click(function () { $("#rmenu").hide() }); $("#DirPathPlace input").keyup(function (e) { if (e.keyCode == 13) { GetFiles($(this).val()); } }); function PathPlaceBtn(path) { var html = ''; var title = ''; path = path.replace('//', '/'); var Dpath = path; if (path == '/') { html = '
  • ' + lan.files.path_root + '
  • '; } else { Dpath = path.split("/"); for (var i = 0; i < Dpath.length; i++) { title += Dpath[i] + '/'; Dpath[0] = lan.files.path_root; html += '
  • ' + Dpath[i] + '
  • '; } } html = '
    '; $("#PathPlaceBtn").html(html); $("#PathPlaceBtn ul li a").click(function (e) { var Gopath = $(this).attr("title"); if (Gopath.length > 1) { if (Gopath.substr(Gopath.length - 1, Gopath.length) == '/') { Gopath = Gopath.substr(0, Gopath.length - 1); } } GetFiles(Gopath); e.stopPropagation(); }); PathLeft(); } function PathLeft() { var UlWidth = $("#PathPlaceBtn ul").width(); var SpanPathWidth = $("#PathPlaceBtn").width() - 50; var Ml = UlWidth - SpanPathWidth; if (UlWidth > SpanPathWidth) { $("#PathPlaceBtn ul").css("left", -Ml) } else { $("#PathPlaceBtn ul").css("left", 0) } } var store_type_index = 0 //删除分类或者文件 function del_files_store(path, obj) { var _item = $(obj).parents('tr').data('item') var action = '', msg = ''; var data = {} action = 'del_files_store'; data['path'] = _item.path; msg = "是否确定删除路径【" + _item.path + "】?" bt.confirm({ msg: msg, title: '提示' }, function () { var loading = bt.load(); bt.send(action, 'files/' + action, data, function (rRet) { loading.close(); if (rRet.status) { set_file_store(path) GetFiles(getCookie('Path')) } bt.msg(rRet); }) }) } function set_file_store(path) { var loading = bt.load(); bt.send('get_files_store', 'files/get_files_store', {}, function (rRet) { loading.close(); if ($('#stroe_tab_list').length <= 0) { bt.open({ type: 1, skin: 'demo-class', area: '510px', title: "管理收藏夹", closeBtn: 2, shift: 5, shadeClose: false, content: "
    ", success: function () { $('#btn_data_store_add').click(function () { bt.send('add_files_store_types', 'files/add_files_store_types', { file_type: $(".type_name").val() }, function (rRet) { loading.close(); if (rRet.status) { set_file_store(path) GetFiles(path) } bt.msg(rRet); }) }) reload_sort_data(path) } }); } else { reload_sort_data(path) } function reload_sort_data(path) { var _tab = bt.render({ table: '#stroe_tab_list', columns: [ { field: 'path', title: '路径' }, { field: 'opt', align: 'right', title: '操作', templet: function (item) { return '删除'; } }, ], data: rRet }); } }) } $("#PathPlaceBtn").on("click", function (e) { if ($("#DirPathPlace").is(":hidden")) { $("#DirPathPlace").css("display", "inline"); $("#DirPathPlace input").focus(); $(this).hide(); } else { $("#DirPathPlace").hide(); $(this).css("display", "inline"); } $(document).one("click", function () { $("#DirPathPlace").hide(); $("#PathPlaceBtn").css("display", "inline"); }); e.stopPropagation(); }); $("#DirPathPlace").on("click", function (e) { e.stopPropagation(); });