Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/route/static/app/files.js

1591 lines
59 KiB

7 years ago
console.log(lan);
7 years ago
//判断磁盘数量超出宽度
7 years ago
function isDiskWidth(){
7 years ago
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");
}
}
//打开回收站
6 years ago
function recycleBin(type){
6 years ago
$.post('/files/get_recycle_bin','',function(data){
// console.log(rdata);
var rdata = data['data'];
7 years ago
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 += '<tr>\
<td><span class=\'ico ico-folder\'></span><span class="tname" title="'+rdata.dirs[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.dirs[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.dirs[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.dirs[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.dirs[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.dirs[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
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 += '<tr>\
<td><span class="ico ico-'+(GetExtName(rdata.files[i].name))+'"></span><span class="tname" title="'+rdata.files[i].name+'">'+shortwebname.replace('BTDB_','')+'</span></td>\
<td><span title="'+rdata.files[i].dname+'">mysql://'+shortpath.replace('BTDB_','')+'</span></td>\
<td>-</td>\
<td>'+getLocalTime(rdata.files[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
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 += '<tr>\
<td><span class="ico ico-'+(GetExtName(rdata.files[i].name))+'"></span><span class="tname" title="'+rdata.files[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.files[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.files[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.files[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
$("#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 += '<tr>\
<td><span class=\'ico ico-folder\'></span><span class="tname" title="'+rdata.dirs[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.dirs[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.dirs[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.dirs[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.dirs[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.dirs[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
$("#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 += '<tr>\
<td><span class="ico ico-'+(GetExtName(rdata.files[i].name))+'"></span><span class="tname" title="'+rdata.files[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.files[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.files[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.files[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
$("#RecycleBody").html(body);
return;
break;
case 4:
for(var i=0;i<rdata.files.length;i++){
6 years ago
if(reisImage(getFileName(rdata.files[i].name))){
7 years ago
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 += '<tr>\
<td><span class="ico ico-'+(GetExtName(rdata.files[i].name))+'"></span><span class="tname" title="'+rdata.files[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.files[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.files[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.files[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
}
$("#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;
6 years ago
if(!(reisImage(getFileName(rdata.files[i].name)))){
7 years ago
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 += '<tr>\
<td><span class="ico ico-'+(GetExtName(rdata.files[i].name))+'"></span><span class="tname" title="'+rdata.files[i].name+'">'+shortwebname+'</span></td>\
<td><span title="'+rdata.files[i].dname+'">'+shortpath+'</span></td>\
7 years ago
<td>'+toSize(rdata.files[i].size)+'</td>\
7 years ago
<td>'+getLocalTime(rdata.files[i].time)+'</td>\
<td style="text-align: right;">\
6 years ago
<a class="btlink" href="javascript:;" onclick="reRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_re+'</a>\
6 years ago
| <a class="btlink" href="javascript:;" onclick="delRecycleBin(\'' + rdata.files[i].rname.replace(/'/,"\\'") + '\',this)">'+lan.files.recycle_bin_del+'</a>\
7 years ago
</td>\
</tr>'
}
}
$("#RecycleBody").html(body);
return;
}
var tablehtml = '<div class="re-head">\
<div style="margin-left: 3px;" class="ss-text">\
6 years ago
<em>文件回收站</em>\
7 years ago
<div class="ssh-item">\
6 years ago
<input class="btswitch btswitch-ios" id="setRecycleBin" type="checkbox" '+(rdata.status?'checked':'')+'>\
<label class="btswitch-btn" for="setRecycleBin" onclick="setRecycleBin()"></label>\
7 years ago
</div>\
</div>\
6 years ago
<span style="line-height: 32px; margin-left: 30px;">注意关闭回收站删除的文件无法恢复</span>\
<button style="float: right" class="btn btn-default btn-sm" onclick="closeRecycleBin();">清空回收站</button>\
7 years ago
</div>\
<div class="re-con">\
<div class="re-con-menu">\
6 years ago
<p class="on" onclick="recycleBin(1)">全部</p>\
<p onclick="recycleBin(2)">文件夹</p>\
6 years ago
<p onclick="recycleBin(3)">文件</p>\
<p onclick="recycleBin(4)">图片</p>\
<p onclick="recycleBin(5)">文档</p>\
7 years ago
</div>\
<div class="re-con-con">\
<div style="margin: 15px;" class="divtable">\
<table width="100%" class="table table-hover">\
<thead>\
<tr>\
6 years ago
<th>文件名</th><th></th>\
<th>大小</th><th width="150"></th>\
<th style="text-align: right;" width="110">操作</th>\
7 years ago
</tr>\
</thead>\
<tbody id="RecycleBody" class="list-list">'+body+'</tbody>\
</table></div></div></div>';
6 years ago
if(type == 'open'){
7 years ago
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){
6 years ago
recycleBin(6);
7 years ago
$(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on");
}else{
6 years ago
recycleBin(1);
7 years ago
}
}
$(".re-con-menu p").click(function(){
$(this).addClass("on").siblings().removeClass("on");
})
6 years ago
},'json');
7 years ago
}
//去扩展名不处理
function getFileName(name){
var text = name.split(".");
var n = text.length-1;
text = text[n];
return text;
}
//判断图片文件
7 years ago
function reisImage(fileName){
7 years ago
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;
}
//从回收站恢复文件
7 years ago
function reRecycleBin(path,obj){
7 years ago
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']});
6 years ago
$.post('/files/re_recycle_bin','path='+encodeURIComponent(path),function(rdata){
7 years ago
layer.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:5});
$(obj).parents('tr').remove();
6 years ago
},'json');
7 years ago
});
}
//从回收站删除
7 years ago
function delRecycleBin(path,obj){
7 years ago
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']});
6 years ago
$.post('/files/del_recycle_bin','path='+encodeURIComponent(path),function(rdata){
7 years ago
layer.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:5});
$(obj).parents('tr').remove();
6 years ago
},'json');
7 years ago
});
}
//清空回收站
6 years ago
function closeRecycleBin(){
6 years ago
layer.confirm('清空回收站操作会永久删除回收站中的文件,继续吗?',{title:'清空回收站',closeBtn:2,icon:3},function(){
var loadT = layer.msg("<div class='myspeed'>正在删除,请稍候...</div>",{icon:16,time:0,shade: [0.3, '#000']});
7 years ago
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('');
6 years ago
},'json');
7 years ago
});
}
//回收站开关
6 years ago
function setRecycleBin(db){
var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']});
7 years ago
var data = {}
if(db == 1){
data = {db:db};
}
6 years ago
$.post('/files/recycle_bin',data,function(rdata){
7 years ago
layer.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:5});
6 years ago
},'json');
7 years ago
}
//取数据
7 years ago
function getFiles(Path) {
6 years ago
console.log(Path);
7 years ago
var searchtype = Path;
if(isNaN(Path)){
var p = '1';
6 years ago
Path = encodeURIComponent(Path);
6 years ago
console.log(1,Path);
} else {
var p = '1';
6 years ago
Path = getCookie('open_dir_path');
6 years ago
console.log(2,Path);
7 years ago
}
6 years ago
console.log(Path);
7 years ago
var search = '';
var searchV = $("#SearchValue").val();
6 years ago
if(searchV.length > 1 && searchtype == '1'){
7 years ago
search = "&search="+searchV;
}
var showRow = getCookie('showRow');
6 years ago
if(!showRow) {
showRow = '100';
}
7 years ago
var Body = '';
var data = 'path=' + Path;
var loadT = layer.load();
var totalSize = 0;
7 years ago
$.post('/files/get_dir?p=' + p + '&showRow=' + showRow + search, data, function(rdata) {
7 years ago
layer.close(loadT);
7 years ago
var rows = ['10','50','100','200','500','1000','2000'];
7 years ago
var rowOption = '';
for(var i=0;i<rows.length;i++){
var rowSelected = '';
if(showRow == rows[i]) rowSelected = 'selected';
rowOption += '<option value="'+rows[i]+'" '+rowSelected+'>'+rows[i]+'</option>';
}
$("#filePage").html(rdata.PAGE);
$("#filePage div").append("<span class='Pcount-item'>每页<select style='margin-left: 3px;margin-right: 3px;border:#ddd 1px solid' class='showRow'>"+rowOption+"</select>条</span>");
$("#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 timetext ='--';
6 years ago
if(getCookie('rank') == 'a'){
7 years ago
$("#set_list").addClass("active");
$("#set_icon").removeClass("active");
Body += "<tr class='folderBoxTr' data-path='" + rdata.PATH + "/" + fmp[0] + "' filetype='dir'>\
<td><input type='checkbox' name='id' value='"+fmp[0]+"'></td>\
7 years ago
<td class='column-name'><span class='cursor' onclick=\"getFiles('" + rdata.PATH + "/" + fmp[0] + "')\"><span class='ico ico-folder'></span><a class='text' title='" + fmp[0] + fmp[5] + "'>" + cnametext + "</a></span></td>\
7 years ago
<td>"+toSize(fmp[1])+"</td>\
7 years ago
<td>"+getLocalTime(fmp[2])+"</td>\
<td>"+fmp[3]+"</td>\
<td>"+fmp[4]+"</td>\
<td class='editmenu'><span>\
6 years ago
<a class='btlink' href='javascript:;' onclick=\"CopyFile('" + rdata.PATH +"/"+ fmp[0] + "')\">复制</a> | \
<a class='btlink' href='javascript:;' onclick=\"CutFile('" + rdata.PATH +"/"+ fmp[0]+ "')\">剪切</a> | \
<a class='btlink' href=\"javascript:ReName(0,'" + fmp[0] + "');\">重命名</a> | \
<a class='btlink' href=\"javascript:setChmod(0,'" + rdata.PATH + "/"+fmp[0] + "');\">权限</a> | \
<a class='btlink' href=\"javascript:Zip('" + rdata.PATH +"/" +fmp[0] + "');\">压缩</a> | \
6 years ago
<a class='btlink' href='javascript:;' onclick=\"deleteDir('" + rdata.PATH +"/"+ fmp[0] + "')\">删除</a></span>\
7 years ago
</td></tr>";
6 years ago
} else {
7 years ago
$("#set_icon").addClass("active");
$("#set_list").removeClass("active");
7 years ago
Body += "<div class='file folderBox menufolder' data-path='" + rdata.PATH + "/" + fmp[0] + "' filetype='dir' title='"+lan.files.file_name+":" + fmp[0]+"&#13;"+lan.files.file_size+":" + toSize(fmp[1])+"&#13;"+lan.files.file_etime+":"+getLocalTime(fmp[2])+"&#13;"+lan.files.file_auth+":"+fmp[3]+"&#13;"+lan.files.file_own+":"+fmp[4]+"'>\
7 years ago
<input type='checkbox' name='id' value='"+fmp[0]+"'>\
7 years ago
<div class='ico ico-folder' ondblclick=\"getFiles('" + rdata.PATH + "/" + fmp[0] + "')\"></div>\
<div class='titleBox' onclick=\"getFiles('" + rdata.PATH + "/" + fmp[0] + "')\"><span class='tname'>" + fmp[0] + "</span></div>\
7 years ago
</div>";
}
}
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 = "<a class='btlink' href='javascript:;' onclick=\"UnZip('" + rdata.PATH +"/" +fmp[0] + "'," + displayZip + ")\">"+lan.files.file_menu_unzip+"</a> | ";
}
6 years ago
7 years ago
if(isText(fmp[0])){
7 years ago
bodyZip = "<a class='btlink' href='javascript:;' onclick=\"onlineEditFile(0,'" + rdata.PATH +"/"+ fmp[0] + "')\">编辑</a> | ";
7 years ago
}
6 years ago
7 years ago
if(isImage(fmp[0])){
7 years ago
download = "<a class='btlink' href='javascript:;' onclick=\"getImage('" + rdata.PATH +"/"+ fmp[0] + "')\">预览</a> | ";
6 years ago
} else {
7 years ago
download = "<a class='btlink' href='javascript:;' onclick=\"getFileBytes('" + rdata.PATH +"/"+ fmp[0] + "',"+fmp[1]+")\">下载</a> | ";
7 years ago
}
totalSize += parseInt(fmp[1]);
if(getCookie("rank")=="a"){
Body += "<tr class='folderBoxTr' data-path='" + rdata.PATH +"/"+ fmp[0] + "' filetype='" + fmp[0] + "'><td><input type='checkbox' name='id' value='"+fmp[0]+"'></td>\
<td class='column-name'><span class='ico ico-"+(GetExtName(fmp[0]))+"'></span><a class='text' title='" + fmp[0] + fmp[5] + "'>" + cnametext + "</a></td>\
7 years ago
<td>" + (toSize(fmp[1])) + "</td>\
7 years ago
<td>" + ((fmp[2].length > 11)?fmp[2]:getLocalTime(fmp[2])) + "</td>\
<td>"+fmp[3]+"</td>\
<td>"+fmp[4]+"</td>\
<td class='editmenu'>\
<span><a class='btlink' href='javascript:;' onclick=\"CopyFile('" + rdata.PATH +"/"+ fmp[0] + "')\">"+lan.files.file_menu_copy+"</a> | \
<a class='btlink' href='javascript:;' onclick=\"CutFile('" + rdata.PATH +"/"+ fmp[0] + "')\">"+lan.files.file_menu_mv+"</a> | \
<a class='btlink' href='javascript:;' onclick=\"ReName(0,'" + fmp[0] + "')\">"+lan.files.file_menu_rename+"</a> | \
7 years ago
<a class='btlink' href=\"javascript:setChmod(0,'" + rdata.PATH +"/"+ fmp[0] + "');\">"+lan.files.file_menu_auth+"</a> | \
7 years ago
<a class='btlink' href=\"javascript:Zip('" + rdata.PATH +"/" +fmp[0] + "');\">"+lan.files.file_menu_zip+"</a> | \
"+bodyZip+download+"\
6 years ago
<a class='btlink' href='javascript:;' onclick=\"deleteFile('" + rdata.PATH +"/"+ fmp[0] + "')\">"+lan.files.file_menu_del+"</a>\
7 years ago
</span></td></tr>";
}
else{
7 years ago
Body += "<div class='file folderBox menufile' data-path='" + rdata.PATH +"/"+ fmp[0] + "' filetype='"+fmp[0]+"' title='"+lan.files.file_name+":" + fmp[0]+"&#13;"+lan.files.file_size+":" + toSize(fmp[1])+"&#13;"+lan.files.file_etime+":"+getLocalTime(fmp[2])+"&#13;"+lan.files.file_auth+":"+fmp[3]+"&#13;"+lan.files.file_own+":"+fmp[4]+"'>\
7 years ago
<input type='checkbox' name='id' value='"+fmp[0]+"'>\
<div class='ico ico-"+(GetExtName(fmp[0]))+"'></div>\
<div class='titleBox'><span class='tname'>" + fmp[0] + "</span></div>\
</div>";
}
}
6 years ago
var dirInfo = '('+lan.files.get_size.replace('{1}',rdata.DIR.length+'').replace('{2}',rdata.DIR.length+'')+'<font id="pathSize">'+(toSize(totalSize))+'<a class="btlink ml5" onClick="getPathSize()">获取</a></font>)';
7 years ago
$("#DirInfo").html(dirInfo);
if(getCookie("rank")=="a"){
var tablehtml = '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="table table-hover">\
<thead>\
<tr>\
<th width="30"><input type="checkbox" id="setBox" placeholder=""></th>\
<th>'+lan.files.file_name+'</th>\
<th>'+lan.files.file_size+'</th>\
<th>'+lan.files.file_etime+'</th>\
<th>'+lan.files.file_auth+'</th>\
<th>'+lan.files.file_own+'</th>\
<th style="text-align: right;" width="330">'+lan.files.file_act+'</th>\
</tr>\
</thead>\
<tbody id="filesBody" class="list-list">'+Body+'</tbody>\
</table>';
$("#fileCon").removeClass("fileList").html(tablehtml);
$("#tipTools").width($("#fileCon").width());
}
else{
$("#fileCon").addClass("fileList").html(Body);
$("#tipTools").width($("#fileCon").width());
}
$("#DirPathPlace input").val(rdata.PATH);
var BarTools = '<div class="btn-group">\
<button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\
'+lan.files.new+' <span class="caret"></span>\
</button>\
<ul class="dropdown-menu">\
6 years ago
<li><a href="javascript:createFile(0,\'' + Path + '\');">'+lan.files.new_empty_file+'</a></li>\
<li><a href="javascript:createDir(0,\'' + Path + '\');">'+lan.files.new_dir+'</a></li>\
7 years ago
</ul>\
</div>';
if (rdata.PATH != '/') {
BarTools += ' <button onclick="javascript:BackDir();" class="btn btn-default btn-sm glyphicon glyphicon-arrow-left" title="'+lan.files.return+'"></button>';
}
setCookie('Path',rdata.PATH);
7 years ago
BarTools += ' <button onclick="javascript:getFiles(\'' + rdata.PATH + '\');" class="btn btn-default btn-sm glyphicon glyphicon-refresh" title="'+lan.public.fresh+'"></button> <button onclick="ExecShell()" title="'+lan.files.shell+'" type="button" class="btn btn-default btn-sm"><em class="ico-cmd"></em></button>';
7 years ago
var copyName = getCookie('copyFileName');
var cutName = getCookie('cutFileName');
var isPaste = (copyName == 'null') ? cutName : copyName;
if (isPaste != 'null' && isPaste != undefined) {
6 years ago
BarTools += ' <button onclick="javascript:PasteFile(\'' + (getFileName(isPaste)) + '\');" class="btn btn-Warning btn-sm">'+lan.files.paste+'</button>';
7 years ago
}
$("#Batch").html('');
var BatchTools = '';
var isBatch = getCookie('BatchSelected');
if (isBatch == 1 || isBatch == '1') {
BatchTools += ' <button onclick="javascript:BatchPaste();" class="btn btn-default btn-sm">'+lan.files.paste_all+'</button>';
}
$("#Batch").html(BatchTools);
$("#setBox").prop("checked", false);
$("#BarTools").html(BarTools);
$("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");
}
6 years ago
showSeclect();
7 years ago
});
$("#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();
});
//禁用右键
$("#fileCon").bind("contextmenu",function(e){
return false;
});
bindselect();
//绑定右键
$("#fileCon").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()));
}
else{
RClickAll(e);
}
}
});
//每页行数
$(".showRow").change(function(){
setCookie('showRow',$(this).val());
7 years ago
getFiles(p);
7 years ago
});
PathPlaceBtn(rdata.PATH);
7 years ago
},'json');
7 years ago
//setTimeout(function(){getCookie('path');},200);
}
//统计选择数量
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,#fileCon").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,#fileCon").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 = '<button onclick="javascript:Batch(1);" class="btn btn-default btn-sm">'+lan.files.file_menu_copy+'</button>\
7 years ago
<button onclick="javascript:Batch(2);" class="btn btn-default btn-sm">'+lan.files.file_menu_mv+'</button>\
<button onclick="javascript:Batch(3);" class="btn btn-default btn-sm">'+lan.files.file_menu_auth+'</button>\
<button onclick="javascript:Batch(5);" class="btn btn-default btn-sm">'+lan.files.file_menu_zip+'</button>\
<button onclick="javascript:Batch(4);" class="btn btn-default btn-sm">'+lan.files.file_menu_del+'</button>'
7 years ago
$("#Batch").html(BatchTools);
}else{
$("#Batch").html(BatchTools);
//setCookie('BatchSelected', null);
}
}
//滚动条事件
$(window).scroll(function () {
if($(window).scrollTop() > 16){
$("#tipTools").css({"position":"fixed","top":"0","left":"195px","box-shadow":"0 1px 10px 3px #ccc"});
}else{
$("#tipTools").css({"position":"absolute","top":"0","left":"0","box-shadow":"none"});
}
});
$("#tipTools").width($(".file-box").width());
$("#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").width()-30);
$("#PathPlaceBtn").width($(".file-box").width()-700);
$("#DirPathPlace input").width($(".file-box").width()-700);
if($(window).width()<1160){
$("#PathPlaceBtn,#DirPathPlace input").width(290);
}
PathLeft();
7 years ago
isDiskWidth();
7 years ago
}
//批量操作
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 oldType = getCookie('BatchPaste');
for(var i=0;i<len;i++){
if(el[i].checked == true && el[i].value != 'on'){
data += '&'+name+'='+encodeURIComponent(el[i].value);
}
}
if(type == 3 && access == undefined){
7 years ago
setChmod(0,lan.files.all);
7 years ago
return;
}
if(type < 3) setCookie('BatchSelected', '1');
setCookie('BatchPaste',type);
if(access == 1){
var access = $("#access").val();
var chown = $("#chown").val();
data += '&access='+access+'&user='+chown;
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("<div class='myspeed'>"+lan.public.the+"</div>",{icon:16,time:0,shade: [0.3, '#000']});
setTimeout(function(){getSpeed('.myspeed');},1000);
$.post('files?action=SetBatchData',data,function(rdata){
layer.close(myloadT);
7 years ago
getFiles(path);
7 years ago
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++){
7 years ago
tbody += '<tr><td>'+result[i].filename+'</td><td>'+toSize(result[i].size)+'</td><td>'+getLocalTime(result[i].mtime)+'</td></tr>';
7 years ago
}
var mbody = '<div class="divtable"><table class="table table-hover" width="100%" border="0" cellpadding="0" cellspacing="0"><thead><th>文件名</th><th></th><th></th></thead>\
<tbody>'+tbody+'</tbody>\
</table></div>';
SafeMessage('即将覆盖以下文件',mbody,function(){
BatchPasteTo(data,path);
});
$(".layui-layer-page").css("width","500px");
}else{
BatchPasteTo(data,path);
}
});
}
function BatchPasteTo(data,path){
myloadT = layer.msg("<div class='myspeed'>"+lan.public.the+"</div>",{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);
7 years ago
getFiles(path);
7 years ago
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','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");
})
}
6 years ago
// //取文件名
// function GetFileName(fileNameFull) {
// var pName = fileNameFull.split('/');
// return pName[pName.length - 1];
// }
7 years ago
//取磁盘
7 years ago
function getDisk() {
7 years ago
var LBody = '';
7 years ago
$.get('/system/disk_info', function(rdata) {
7 years ago
for (var i = 0; i < rdata.length; i++) {
7 years ago
LBody += "<span onclick=\"getFiles('" + rdata[i].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;" + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")</span>";
7 years ago
}
6 years ago
var trash = '<span id="recycle_bin" onclick="recycleBin(\'open\')" title="回收站" style="position: absolute; border-color: #ccc; right: 77px;"><span class="glyphicon glyphicon-trash"></span>&nbsp;回收站</span>';
7 years ago
$("#comlist").html(LBody+trash);
7 years ago
isDiskWidth();
7 years ago
},'json');
7 years ago
}
//返回上一级
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);
}
7 years ago
getFiles(back);
7 years ago
} else {
back += Path[0];
7 years ago
getFiles(back);
7 years ago
}
setTimeout('PathPlaceBtn(getCookie("Path"));',200);
}
//新建文件
6 years ago
function createFile(type, path) {
7 years ago
if (type == 1) {
var fileName = $("#newFileName").val();
layer.msg(lan.public.the, {
icon: 16,
time: 10000
});
6 years ago
$.post('/files/create_file', 'path=' + encodeURIComponent(path + '/' + fileName), function(rdata) {
7 years ago
layer.closeAll();
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
if(rdata.status){
7 years ago
getFiles($("#DirPathPlace input").val());
onlineEditFile(0,path + '/' + fileName);
7 years ago
}
6 years ago
},'json');
7 years ago
return;
}
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '320px',
title: lan.files.new_empty_file,
content: '<div class="bt-form pd20 pb70">\
<div class="line">\
6 years ago
<input type="text" class="bt-input-text" name="Name" id="newFileName" value="" placeholder="文件名" style="width:100%" />\
7 years ago
</div>\
<div class="bt-form-submit-btn">\
6 years ago
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">关闭</button>\
<button id="createFileBtn" type="button" class="btn btn-success btn-sm" onclick="createFile(1,\'' + path + '\')">新建</button>\
7 years ago
</div>\
</div>'
});
$("#newFileName").focus().keyup(function(e){
6 years ago
if(e.keyCode == 13) $("#createFileBtn").click();
7 years ago
});
}
//新建目录
6 years ago
function createDir(type, path) {
7 years ago
if (type == 1) {
var dirName = $("#newDirName").val();
layer.msg(lan.public.the, {
icon: 16,
time: 10000
});
6 years ago
$.post('/files/create_dir', 'path=' + encodeURIComponent(path + '/' + dirName), function(rdata) {
7 years ago
layer.closeAll();
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
7 years ago
getFiles($("#DirPathPlace input").val());
6 years ago
},'json');
7 years ago
return;
}
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '320px',
title: lan.files.new_dir,
content: '<div class="bt-form pd20 pb70">\
<div class="line">\
6 years ago
<input type="text" class="bt-input-text" name="Name" id="newDirName" value="" placeholder="目录名称" style="width:100%" />\
7 years ago
</div>\
<div class="bt-form-submit-btn">\
6 years ago
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">关闭</button>\
<button type="button" id="createDirBtn" class="btn btn-success btn-sm btn-title" onclick="createDir(1,\'' + path + '\')">新建</button>\
7 years ago
</div>\
</div>'
});
$("#newDirName").focus().keyup(function(e){
6 years ago
if(e.keyCode == 13) $("#createDirBtn").click();
7 years ago
});
}
//删除文件
6 years ago
function deleteFile(fileName){
7 years ago
layer.confirm(lan.get('recycle_bin_confirm',[fileName]),{title:lan.files.del_file,closeBtn:2,icon:3},function(){
layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']});
7 years ago
$.post('/files/delete', 'path=' + encodeURIComponent(fileName), function(rdata) {
7 years ago
layer.closeAll();
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
7 years ago
getFiles($("#DirPathPlace input").val());
7 years ago
},'json');
7 years ago
});
}
//删除目录
6 years ago
function deleteDir(dirName){
7 years ago
layer.confirm(lan.get('recycle_bin_confirm_dir',[dirName]),{title:lan.files.del_dir,closeBtn:2,icon:3},function(){
layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']});
6 years ago
$.post('/files/delete_dir', 'path=' + encodeURIComponent(dirName), function(rdata) {
7 years ago
layer.closeAll();
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
7 years ago
getFiles($("#DirPathPlace input").val());
6 years ago
},'json');
7 years ago
});
}
//批量删除文件
function AllDeleteFileSub(data,path){
layer.confirm(lan.files.del_all_msg,{title:lan.files.del_all_file,closeBtn:2,icon:3},function(){
layer.msg("<div class='myspeed'>"+lan.public.the+"</div>",{icon:16,time:0,shade: [0.3, '#000']});
setTimeout(function(){getSpeed('.myspeed');},1000);
$.post('files?action=SetBatchData',data,function(rdata){
layer.closeAll();
7 years ago
getFiles(path);
7 years ago
layer.msg(rdata.msg,{icon:1});
});
});
}
//重载文件列表
function ReloadFiles(){
setInterval(function(){
var path = $("#DirPathPlace input").val();
7 years ago
getFiles(path);
7 years ago
},3000);
}
//下载文件
6 years ago
function downloadFile(action){
7 years ago
if(action == 1){
var fUrl = $("#mUrl").val();
fUrl = encodeURIComponent(fUrl);
fpath = $("#dpath").val();
fname = encodeURIComponent($("#dfilename").val());
layer.closeAll();
layer.msg(lan.files.down_task,{time:0,icon:16,shade: [0.3, '#000']});
6 years ago
$.post('/files/download_file','path='+fpath+'&url='+fUrl+'&filename='+fname,function(rdata){
7 years ago
layer.closeAll();
7 years ago
getFiles(fpath);
7 years ago
GetTaskCount();
layer.msg(rdata.msg,{icon:rdata.status?1:2});
6 years ago
},'json');
7 years ago
return;
}
var path = $("#DirPathPlace input").val();
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '500px',
title: lan.files.down_title,
content: '<form class="bt-form pd20 pb70">\
<div class="line">\
6 years ago
<span class="tname">URL地址:</span><input type="text" class="bt-input-text" name="url" id="mUrl" placeholder="URL地址" style="width:330px" />\
7 years ago
</div>\
<div class="line">\
6 years ago
<span class="tname ">下载到:</span><input type="text" class="bt-input-text" name="path" id="dpath" value="'+path+'" placeholder="下载到" style="width:330px" />\
7 years ago
</div>\
<div class="line">\
6 years ago
<span class="tname">文件名:</span><input type="text" class="bt-input-text" name="filename" id="dfilename" value="" placeholder="文件名" style="width:330px" />\
7 years ago
</div>\
<div class="bt-form-submit-btn">\
6 years ago
<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">关闭</button>\
<button type="button" id="dlok" class="btn btn-success btn-sm dlok" onclick="downloadFile(1)">确定</button>\
7 years ago
</div>\
</form>'
});
fly("dlok");
$("#mUrl").keyup(function(){
durl = $(this).val()
tmp = durl.split('/')
$("#dfilename").val(tmp[tmp.length-1])
});
}
//执行SHELL
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();
6 years ago
} else {
7 years ago
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: '<div class="bt-form pd15">\
<div class="shellcode"><pre id="Result"></pre></div>\
<div class="line">\
<input type="text" class="bt-input-text" name="exec" id="mExec" value="" placeholder="'+lan.files.shell_ps+'" onkeydown="if(event.keyCode==13)ExecShell(1);" /><span class="shellbutton btn btn-default btn-sm pull-right" onclick="ExecShell(1)" style="width:10%">'+lan.files.shell_go+'</span>\
</div>\
</div>'
});
setTimeout(function(){
outTimeGet();
},1000);
}
var outTime = null;
//取SHELL输出
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, function(rdata) {
layer.closeAll();
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
7 years ago
getFiles(path);
7 years ago
});
return;
}
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '320px',
title: lan.files.file_menu_rename,
content: '<div class="bt-form pd20 pb70">\
<div class="line">\
<input type="text" class="bt-input-text" name="Name" id="newFileName" value="' + fileName + '" placeholder="'+lan.files.file_name+'" style="width:100%" />\
</div>\
<div class="bt-form-submit-btn">\
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>\
<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="ReName(1,\'' + fileName.replace(/'/,"\\'") + '\')">'+lan.public.save+'</button>\
</div>\
</div>'
});
$("#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: 1
});
7 years ago
getFiles(path);
7 years ago
}
//复制
function CopyFile(fileName) {
var path = $("#DirPathPlace input").val();
setCookie('copyFileName', fileName);
setCookie('cutFileName', null);
layer.msg(lan.files.copy_ok, {
icon: 1,
time: 1
});
7 years ago
getFiles(path);
7 years ago
}
//粘贴
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++){
7 years ago
tbody += '<tr><td>'+result[i].filename+'</td><td>'+toSize(result[i].size)+'</td><td>'+getLocalTime(result[i].mtime)+'</td></tr>';
7 years ago
}
var mbody = '<div class="divtable"><table class="table table-hover" width="100%" border="0" cellpadding="0" cellspacing="0"><thead><th>文件名</th><th></th><th></th></thead>\
<tbody>'+tbody+'</tbody>\
</table></div>';
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
});
7 years ago
getFiles(path);
7 years ago
});
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
});
7 years ago
getFiles(path);
7 years ago
});
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());
layer.closeAll();
layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']});
7 years ago
$.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) {
7 years ago
layer.closeAll();
if(rdata == null || rdata == undefined){
layer.msg(lan.files.zip_ok,{icon:1});
7 years ago
getFiles(path)
7 years ago
ReloadFiles();
return;
}
layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
7 years ago
if(rdata.status) getFiles(path);
7 years ago
},'json');
7 years ago
return
}
param = dirName;
if(dirName.indexOf(',') != -1){
tmp = path.split('/')
dirName = path + '/' + tmp[tmp.length-1]
}
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '650px',
title: lan.files.zip_title,
content: '<div class="bt-form pd20 pb70">'
+'<div class="line noborder">'
+'<input type="text" class="form-control" id="sfile" value="' +param + '" placeholder="" style="display:none" />'
+'<span>'+lan.files.zip_to+'</span><input type="text" class="bt-input-text" id="dfile" value="'+dirName + '.tar.gz" placeholder="'+lan.files.zip_to+'" style="width: 75%; display: inline-block; margin: 0px 10px 0px 20px;" /><span class="glyphicon glyphicon-folder-open cursor" onclick="ChangePath(\'dfile\')"></span>'
+'</div>'
+'<div class="bt-form-submit-btn">'
+'<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>'
+'<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="Zip(\'' + param + '\',1)">'+lan.files.file_menu_zip+'</button>'
+'</div>'
+'</div>'
});
setTimeout(function(){
$("#dfile").change(function(){
var dfile = $(this).val()
tmp = dfile.split('.');
if(tmp[tmp.length-1] != 'gz'){
var path = $("#DirPathPlace input").val();
tmp = path.split('/');
dfile += '/' + tmp[tmp.length-1] + '.tar.gz'
$(this).val(dfile.replace(/\/\//g,'/'))
}
});
},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.closeAll();
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.closeAll();
layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
7 years ago
getFiles(path);
7 years ago
});
return
}
type = (type == 1) ? 'tar':'zip'
var umpass = '';
if(type == 'zip'){
umpass = '<div class="line"><span class="tname">'+lan.files.zip_pass_title+'</span><input type="text" class="bt-input-text" id="unpass" value="" placeholder="'+lan.files.zip_pass_msg+'" style="width:330px" /></div>'
}
layer.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '490px',
title: lan.files.unzip_title,
content: '<div class="bt-form pd20 pb70">'
+'<div class="line unzipdiv">'
+'<span class="tname">'+lan.files.unzip_name+'</span><input type="text" class="bt-input-text" id="sfile" value="' +fileName + '" placeholder="'+lan.files.unzip_name_title+'" style="width:330px" /></div>'
+'<div class="line"><span class="tname">'+lan.files.unzip_to+'</span><input type="text" class="bt-input-text" id="dfile" value="'+path + '" placeholder="'+lan.files.unzip_to+'" style="width:330px" /></div>' + umpass
+'<div class="line"><span class="tname">'+lan.files.unzip_coding+'</span><select class="bt-input-text" name="coding">'
+'<option value="UTF-8">UTF-8</option>'
+'<option value="gb18030">GBK</option>'
+'</select>'
+'</div>'
+'<div class="bt-form-submit-btn">'
+'<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>'
+'<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="UnZip(\'' + fileName + '\',\''+type+'\')">'+lan.files.file_menu_unzip+'</button>'
+'</div>'
+'</div>'
});
}
//是否压缩文件
function isZip(fileName){
var ext = fileName.split('.');
var extName = ext[ext.length-1].toLowerCase();
if( extName == 'zip') return 0;
if( extName == 'gz' || extName == 'tgz') return 1;
return -1;
}
//是否文本文件
function isText(fileName){
var exts = ['rar','zip','tar.gz','gz','iso','xsl','doc','xdoc','jpeg','jpg','png','gif','bmp','tiff','exe','so','7z','bz'];
return isExts(fileName,exts)?false:true;
}
//是否图片文件
function isImage(fileName){
var exts = ['jpg','jpeg','png','bmp','gif','tiff','ico'];
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;
}
//图片预览
7 years ago
function getImage(fileName){
var imgUrl = '/files/download?filename='+fileName;
7 years ago
layer.open({
type:1,
closeBtn: 2,
title:false,
area: '500px',
shadeClose: true,
content: '<div class="showpicdiv"><img width="100%" src="'+imgUrl+'"></div>'
});
$(".layui-layer").css("top", "30%");
}
//获取文件数据
7 years ago
function getFileBytes(fileName, fileSize){
window.open('/files/download?filename='+encodeURIComponent(fileName));
7 years ago
}
//上传文件
function UploadFiles(){
var path = $("#DirPathPlace input").val()+"/";
layer.open({
type:1,
closeBtn: 2,
title:lan.files.up_title,
area: ['500px','500px'],
shadeClose:false,
content:'<div class="fileUploadDiv"><input type="hidden" id="input-val" value="'+path+'" />\
<input type="file" id="file_input" multiple="true" autocomplete="off" />\
<button type="button" id="opt" autocomplete="off">'+lan.files.up_add+'</button>\
<button type="button" id="up" autocomplete="off" >'+lan.files.up_start+'</button>\
<span id="totalProgress" style="position: absolute;top: 7px;right: 147px;"></span>\
<span style="float:right;margin-top: 9px;">\
<font>'+lan.files.up_coding+':</font>\
<select id="fileCodeing" >\
<option value="byte">'+lan.files.up_bin+'</option>\
<option value="utf-8">UTF-8</option>\
<option value="gb18030">GB2312</option>\
</select>\
</span>\
<button type="button" id="filesClose" autocomplete="off" onClick="layer.closeAll()" >'+lan.public.close+'</button>\
<ul id="up_box"></ul></div>'
});
UploadStart();
}
//设置权限
7 years ago
function setChmod(action,fileName){
7 years ago
if(action == 1){
var chmod = $("#access").val();
var chown = $("#chown").val();
var data = 'filename='+ encodeURIComponent(fileName)+'&user='+chown+'&access='+chmod;
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.closeAll();
layer.msg(rdata.msg,{icon:rdata.status?1:2});
var path = $("#DirPathPlace input").val();
7 years ago
getFiles(path)
7 years ago
});
return;
}
7 years ago
var toExec = fileName == lan.files.all?'Batch(3,1)':'setChmod(1,\''+fileName+'\')';
$.post('/files/file_access','filename='+encodeURIComponent(fileName),function(rdata){
console.log(rdata);
7 years ago
layer.open({
type:1,
closeBtn: 2,
title: lan.files.set_auth + '['+fileName+']',
area: '400px',
shadeClose:false,
content:'<div class="setchmod bt-form ptb15 pb70">\
<fieldset>\
<legend>'+lan.files.file_own+'</legend>\
<p><input type="checkbox" id="owner_r" />'+lan.files.file_read+'</p>\
<p><input type="checkbox" id="owner_w" />'+lan.files.file_write+'</p>\
<p><input type="checkbox" id="owner_x" />'+lan.files.file_exec+'</p>\
</fieldset>\
<fieldset>\
<legend>'+lan.files.file_group+'</legend>\
<p><input type="checkbox" id="group_r" />'+lan.files.file_read+'</p>\
<p><input type="checkbox" id="group_w" />'+lan.files.file_write+'</p>\
<p><input type="checkbox" id="group_x" />'+lan.files.file_exec+'</p>\
</fieldset>\
<fieldset>\
<legend>'+lan.files.file_public+'</legend>\
<p><input type="checkbox" id="public_r" />'+lan.files.file_read+'</p>\
<p><input type="checkbox" id="public_w" />'+lan.files.file_write+'</p>\
<p><input type="checkbox" id="public_x" />'+lan.files.file_exec+'</p>\
</fieldset>\
<div class="setchmodnum"><input class="bt-input-text" type="text" id="access" maxlength="3" value="'+rdata.chmod+'">'+lan.files.file_menu_auth+'\
<span>'+lan.files.file_own+'\
<select id="chown" class="bt-input-text">\
<option value="www" '+(rdata.chown=='www'?'selected="selected"':'')+'>www</option>\
<option value="mysql" '+(rdata.chown=='mysql'?'selected="selected"':'')+'>mysql</option>\
<option value="root" '+(rdata.chown=='root'?'selected="selected"':'')+'>root</option>\
</select></span></div>\
<div class="bt-form-submit-btn">\
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>\
<button type="button" class="btn btn-success btn-sm btn-title" onclick="'+toExec+'" >'+lan.public.ok+'</button>\
</div>\
</div>'
});
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);
});
7 years ago
},'json');
7 years ago
}
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){
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)}},
7 years ago
{text: lan.files.file_menu_auth, onclick: function() {setChmod(0,path)}},
7 years ago
{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(isText(type)){
6 years ago
options.items.push({text: lan.files.file_menu_edit, onclick: function() {onlineEditFile(0,path)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}});
7 years ago
}
else if(displayZip != -1){
6 years ago
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)}});
7 years ago
}
else if(isImage(type)){
6 years ago
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)}});
7 years ago
}
else{
6 years ago
options.items.push({text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}});
7 years ago
}
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();
}
//取目录大小
6 years ago
function getPathSize(){
7 years ago
var path = encodeURIComponent($("#DirPathPlace input").val());
6 years ago
layer.msg("正在计算,请稍候...",{icon:16,time:0,shade: [0.3, '#000']})
$.post("/files/get_dir_size","path="+path,function(rdata){
7 years ago
layer.closeAll();
6 years ago
$("#pathSize").text(rdata.msg);
},'json');
7 years ago
}
6 years ago
7 years ago
$("body").not(".def-log").click(function(){
$("#rmenu").hide()
});
//指定路径
$("#DirPathPlace input").keyup(function(e){
if(e.keyCode == 13) {
7 years ago
getFiles($(this).val());
7 years ago
}
});
6 years ago
7 years ago
function PathPlaceBtn(path){
var html = '';
var title = '';
var Dpath = path;
if(path == '/'){
html ='<li><a title="/">'+lan.files.path_root+'</a></li>';
}
else{
Dpath = path.split("/");
for(var i = 0; i<Dpath.length; i++ ){
title += Dpath[i]+'/';
Dpath[0] = lan.files.path_root;
html +='<li><a title="'+title+'">'+Dpath[i]+'</a></li>';
}
}
html = '<div style="width:1200px;height:26px"><ul>'+html+'</ul></div>';
$("#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);
}
}
7 years ago
getFiles(Gopath);
7 years ago
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)
}
}
//路径快捷点击
$("#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();
});