From 3b90209c4c853da351bc14e1fb57806af763dd5f Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 14 Oct 2018 17:37:43 +0800 Subject: [PATCH] u --- app.py | 11 +- data/default.db | Bin 17408 -> 17408 bytes static/js/files.js | 1609 ------------------------------------------- static/js/index.js | 4 +- static/js/soft.js | 176 ++--- templates/default/site.html | 26 +- views/__init__.py | 6 +- views/dashboard.py | 27 - views/database.py | 17 + views/plugins.py | 25 +- views/site.py | 10 +- views/system.py | 159 +++++ 12 files changed, 322 insertions(+), 1748 deletions(-) delete mode 100755 static/js/files.js create mode 100644 views/database.py create mode 100644 views/system.py diff --git a/app.py b/app.py index b93619b90..5ccc83942 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,11 @@ -from flask import Flask -import views import sys import io import os +import views +from flask import Flask +from datetime import timedelta + sys.path.append("class/") app = Flask(__name__) @@ -18,12 +20,17 @@ DEFAULT_MODULES = ( (views.config, "/config"), (views.plugins, "/plugins"), (views.task, "/task"), + (views.system, "/system"), + (views.database, "/database") ) import time # print "time.time(): %f " % time.time() app.config.version = "0.0.1" + str(time.time()) +app.config['SECRET_KEY'] = os.urandom(24) +app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) + def setting_modules(app, modules): for module, url_prefix in modules: diff --git a/data/default.db b/data/default.db index 966364cdcaec43b48c33b1a9baf32fb250c7db2e..1145da3e2b1593d3e714010e2d2cd711bbad4018 100755 GIT binary patch delta 78 zcmZqZU~K4MoFL68IZ?)$QF3EK4L2j#=DXbL3KCol{}`AzGp8|2GM! 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 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 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 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 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 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 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 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"+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 GetFiles(Path) { - var searchtype = Path; - if(isNaN(Path)){ - var p = '1'; - Path = encodeURIComponent(Path) - }else{ - var p = Path; - Path = getCookie('Path'); - } - - var search = ''; - var searchV = $("#SearchValue").val(); - if(searchV.length > 1 && searchtype == "1"){ - search = "&search="+searchV; - } - var showRow = getCookie('showRow'); - if(!showRow) showRow = '100'; - var Body = ''; - var data = 'path=' + Path; - var loadT = layer.load(); - var totalSize = 0; - $.post('/files?action=GetDir&tojs=GetFiles&p=' + p + '&showRow=' + showRow + search, data, function(rdata) { - layer.close(loadT); - - var rows = ['100','200','500','1000','2000']; - var rowOption = ''; - for(var i=0;i'+rows[i]+''; - } - - $("#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 timetext ='--'; - if(getCookie("rank") == "a"){ - $("#set_list").addClass("active"); - $("#set_icon").removeClass("active"); - Body += "\ - \ - " + cnametext + "\ - "+ToSize(fmp[1])+"\ - "+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"){ - Body += "\ - " + cnametext + "\ - " + (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.DIR.length+'')+''+(ToSize(totalSize))+''+lan.files.get+')'; - $("#DirInfo").html(dirInfo); - if(getCookie("rank")=="a"){ - var tablehtml = '\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - '+Body+'\ -
'+lan.files.file_name+''+lan.files.file_size+''+lan.files.file_etime+''+lan.files.file_auth+''+lan.files.file_own+''+lan.files.file_act+'
'; - $("#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 = '
\ - \ - \ -
'; - if (rdata.PATH != '/') { - BarTools += ' '; - } - setCookie('Path',rdata.PATH); - BarTools += ' '; - 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); - - $("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() - }); - - $("#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()); - GetFiles(p); - }); - PathPlaceBtn(rdata.PATH); - }); - //setTimeout(function(){getCookie('path');},200); -} -//统计选择数量 -function totalFile(){ - var el = $("input[name='id']"); - var len = el.length; - var count = 0; - for(var i=0;i 1){ - BatchTools = '\ - \ - \ - \ - ' - $("#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(); - IsDiskWidth() -} - -//批量操作 -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"+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'+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','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 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('/files/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.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - if(rdata.status){ - GetFiles($("#DirPathPlace input").val()); - OnlineEditFile(0,path + '/' + fileName); - } - }); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 2, - area: '320px', - title: lan.files.new_empty_file, - content: '
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
' - }); - $("#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.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - GetFiles($("#DirPathPlace input").val()); - }); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 2, - area: '320px', - title: lan.files.new_dir, - content: '
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
' - }); - $("#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(){ - layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files?action=DeleteFile', 'path=' + encodeURIComponent(fileName), function(rdata) { - layer.closeAll(); - 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(){ - layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files?action=DeleteDir', 'path=' + encodeURIComponent(dirName), function(rdata) { - layer.closeAll(); - 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(){ - 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.closeAll(); - 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()); - layer.closeAll(); - 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.closeAll(); - GetFiles(fpath); - GetTaskCount(); - layer.msg(rdata.msg,{icon:rdata.status?1:2}); - }); - return; - } - var path = $("#DirPathPlace input").val(); - 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+':\ -
\ -
\ - \ - \ -
\ -
' - }); - 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(); - } - 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; -//取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 - }); - GetFiles(path); - }); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 2, - area: '320px', - title: lan.files.file_menu_rename, - content: '
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
' - }); - $("#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 - }); - 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: 1 - }); - 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'+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()); - layer.closeAll(); - layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); - $.post('/files?action=Zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) { - layer.closeAll(); - 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) GetFiles(path); - }); - 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: '
' - +'
' - +'' - +''+lan.files.zip_to+'' - +'
' - +'
' - +'' - +'' - +'
' - +'
' - }); - - 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}); - GetFiles(path); - }); - return - } - - type = (type == 1) ? 'tar':'zip' - var umpass = ''; - if(type == 'zip'){ - umpass = '
'+lan.files.zip_pass_title+'
' - } - 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+'' - +'
' - +'
' - +'' - +'' - +'
' - +'
' - }); -} - -//是否压缩文件 -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' - }); - $(".layui-layer").css("top", "30%"); -} - -//获取文件数据 -function GetFileBytes(fileName, fileSize){ - window.open('/download?filename='+encodeURIComponent(fileName)); -} - - -//上传文件 -function UploadFiles(){ - var path = $("#DirPathPlace input").val()+"/"; - 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 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(); - GetFiles(path) - }); - return; - } - - var toExec = fileName == lan.files.all?'Batch(3,1)':'SetChmod(1,\''+fileName+'\')'; - - $.post('/files?action=GetFileAccess','filename='+encodeURIComponent(fileName),function(rdata){ - 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+'\ -
    \ -
    \ - \ - \ -
    \ -
    ' - }); - - onAccess(); - $("#access").keyup(function(){ - onAccess(); - }); - - $("input[type=checkbox]").change(function(){ - var idName = ['owner','group','public']; - var onacc = ''; - for(var n=0;n 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)}}, - {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(isText(type)){ - 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)}}); - } - 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)}}); - } - 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 = ''; - var Dpath = path; - if(path == '/'){ - html ='
  • '+lan.files.path_root+'
  • '; - } - else{ - Dpath = path.split("/"); - for(var i = 0; i'+Dpath[i]+''; - } - } - html = '
      '+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) - } -} -//路径快捷点击 -$("#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(); -}); diff --git a/static/js/index.js b/static/js/index.js index 2446b4c69..824c7c6d8 100755 --- a/static/js/index.js +++ b/static/js/index.js @@ -135,7 +135,7 @@ function GetPercent(num, total) { function GetDiskInfo() { - $.get('/system?action=GetDiskInfo', function(rdata) { + $.get('/system/disknfo', function(rdata) { var dBody for (var i = 0; i < rdata.length; i++) { if (rdata[i].path == '/' || rdata[i].path == '/www') { @@ -233,7 +233,7 @@ function getNet() { var down; $.ajax({ type: "get", - url: "/system?action=GetNetWork", + url: "/system/network", async: true, success: function(net) { $("#InterfaceSpeed").html(lan.index.interfacespeed + ": 1.0Gbps"); diff --git a/static/js/soft.js b/static/js/soft.js index 5120258e7..350496f12 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -1597,96 +1597,96 @@ function phpmyadmin(msg) { }); } //首页软件列表 -function indexsoft() { - var loadT = layer.msg(lan.soft.get_list, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post('/plugin?action=getPluginList', 'display=1', function(rdata) { - layer.close(loadT); - var con = ''; - for (var i = 0; i < rdata['data'].length - 1; i++) { - var len = rdata.data[i].versions.length; - var version_info = ''; - for (var j = 0; j < len; j++) { - if (rdata.data[i].versions[j].status) continue; - version_info += rdata.data[i].versions[j].version + '|'; - } - if (version_info != '') { - version_info = version_info.substring(0, version_info.length - 1); - } - if (rdata.data[i].display) { - var isDisplay = false; - if (rdata.data[i].name != 'php') { - for (var n = 0; n < len; n++) { - if (rdata.data[i].versions[n].status == true) { - isDisplay = true; - var version = rdata.data[i].versions[n].version; - if (rdata.data[i].versions[n].run == true) { - state = '' - } else { - state = '' - } - } - } - if (isDisplay) { - var clickName = 'SoftMan'; - if (rdata.data[i].tip == 'lib') { - clickName = 'PluginMan'; - version_info = rdata.data[i].title; - } +// function indexsoft() { +// var loadT = layer.msg(lan.soft.get_list, { icon: 16, time: 0, shade: [0.3, '#000'] }); +// $.post('/plugin?action=getPluginList', 'display=1', function(rdata) { +// layer.close(loadT); +// var con = ''; +// for (var i = 0; i < rdata['data'].length - 1; i++) { +// var len = rdata.data[i].versions.length; +// var version_info = ''; +// for (var j = 0; j < len; j++) { +// if (rdata.data[i].versions[j].status) continue; +// version_info += rdata.data[i].versions[j].version + '|'; +// } +// if (version_info != '') { +// version_info = version_info.substring(0, version_info.length - 1); +// } +// if (rdata.data[i].display) { +// var isDisplay = false; +// if (rdata.data[i].name != 'php') { +// for (var n = 0; n < len; n++) { +// if (rdata.data[i].versions[n].status == true) { +// isDisplay = true; +// var version = rdata.data[i].versions[n].version; +// if (rdata.data[i].versions[n].run == true) { +// state = '' +// } else { +// state = '' +// } +// } +// } +// if (isDisplay) { +// var clickName = 'SoftMan'; +// if (rdata.data[i].tip == 'lib') { +// clickName = 'PluginMan'; +// version_info = rdata.data[i].title; +// } - con += '
    \ - \ -
    \ -
    \ -
    ' + rdata.data[i].title + ' ' + version + state + '
    \ -
    \ -
    ' - } - } else { - for (var n = 0; n < len; n++) { - if (rdata.data[i].versions[n].status == true) { - var version = rdata.data[i].versions[n].version; - if (rdata.data[i].versions[n].run == true) { - state = '' - } else { - state = '' - } - } - if (rdata.data[i].versions[n].display == true) { - con += '
    \ - \ -
    \ -
    \ -
    ' + rdata.data[i].title + ' ' + rdata.data[i].versions[n].version + state + '
    \ -
    \ -
    ' - } - } - } - } - } - $("#indexsoft").html(con); - //软件位置移动 - var softboxlen = $("#indexsoft > div").length; - var softboxsum = 12; - var softboxcon = ''; - var softboxn = softboxlen; - if (softboxlen <= softboxsum) { - for (var i = 0; i < softboxsum - softboxlen; i++) { - softboxn += 1000; - softboxcon += '
    ' - } - $("#indexsoft").append(softboxcon); - } - $("#indexsoft").dragsort({ dragSelector: ".spanmove", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "
    " }); +// con += '
    \ +// \ +//
    \ +//
    \ +//
    ' + rdata.data[i].title + ' ' + version + state + '
    \ +//
    \ +//
    ' +// } +// } else { +// for (var n = 0; n < len; n++) { +// if (rdata.data[i].versions[n].status == true) { +// var version = rdata.data[i].versions[n].version; +// if (rdata.data[i].versions[n].run == true) { +// state = '' +// } else { +// state = '' +// } +// } +// if (rdata.data[i].versions[n].display == true) { +// con += '
    \ +// \ +//
    \ +//
    \ +//
    ' + rdata.data[i].title + ' ' + rdata.data[i].versions[n].version + state + '
    \ +//
    \ +//
    ' +// } +// } +// } +// } +// } +// $("#indexsoft").html(con); +// //软件位置移动 +// var softboxlen = $("#indexsoft > div").length; +// var softboxsum = 12; +// var softboxcon = ''; +// var softboxn = softboxlen; +// if (softboxlen <= softboxsum) { +// for (var i = 0; i < softboxsum - softboxlen; i++) { +// softboxn += 1000; +// softboxcon += '
    ' +// } +// $("#indexsoft").append(softboxcon); +// } +// $("#indexsoft").dragsort({ dragSelector: ".spanmove", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "
    " }); - function saveOrder() { - var data = $("#indexsoft > div").map(function() { return $(this).attr("data-id"); }).get(); - var ssort = data.join("|"); - $("input[name=list1SortOrder]").val(ssort); - $.post("/plugin?action=savePluginSort", 'ssort=' + ssort, function(rdata) {}); - }; - }); -} +// function saveOrder() { +// var data = $("#indexsoft > div").map(function() { return $(this).attr("data-id"); }).get(); +// var ssort = data.join("|"); +// $("input[name=list1SortOrder]").val(ssort); +// $.post("/plugin?action=savePluginSort", 'ssort=' + ssort, function(rdata) {}); +// }; +// }); +// } //插件设置菜单 function PluginMan(name, title) { diff --git a/templates/default/site.html b/templates/default/site.html index fc657a27d..9597cab23 100755 --- a/templates/default/site.html +++ b/templates/default/site.html @@ -6,7 +6,7 @@
    - $tData['lan']['H1']/$tData['lan']['H2'] + 首页/网站
    -

    $tData['lan']['PS']

    +

    使用MDWEB Linux面板创建站点时会自动创建权限配置,统一使用www用户。

    -   - - +   + +
    @@ -32,14 +32,14 @@ - $tData['lan']['TH1'] - $tData['lan']['TH2'] - $tData['lan']['TH3'] - $tData['lan']['TH4'] - $tData['lan']['TH5'] - $tData['lan']['TH6'] + 域名 + 网站状态 + 备份 + 网站目录 + 到期日期 + 备注 防火墙 - $tData['lan']['TH7'] + 操作 diff --git a/views/__init__.py b/views/__init__.py index 2f1792da6..6c715c9f9 100644 --- a/views/__init__.py +++ b/views/__init__.py @@ -1,9 +1,9 @@ - - from dashboard import * from site import * from files import * from soft import * from config import * -from plugins import * from task import * +from system import * +from plugins import * +from database import * diff --git a/views/dashboard.py b/views/dashboard.py index c7d82ce06..1d92623e7 100644 --- a/views/dashboard.py +++ b/views/dashboard.py @@ -13,30 +13,3 @@ dashboard = Blueprint('dashboard', __name__, template_folder='templates') @dashboard.route("/") def index(): return render_template('default/index.html') - - -@dashboard.route("getnetwork") -def getNetWork(): - # 取网络流量信息 - networkIo = psutil.net_io_counters()[:4] - # if not hasattr(web.ctx.session,'otime'): - # web.ctx.session.up = networkIo[0] - # web.ctx.session.down = networkIo[1] - # web.ctx.session.otime = time.time(); - - ntime = time.time() - networkInfo = {} - networkInfo['upTotal'] = networkIo[0] - networkInfo['downTotal'] = networkIo[1] - # networkInfo['up'] = round(float(networkIo[0] - web.ctx.session.up) / 1024 / (ntime - web.ctx.session.otime),2) - # networkInfo['down'] = round(float(networkIo[1] - web.ctx.session.down) / 1024 / (ntime - web.ctx.session.otime),2) - networkInfo['downPackets'] = networkIo[3] - networkInfo['upPackets'] = networkIo[2] - - # web.ctx.session.up = networkIo[0] - # web.ctx.session.down = networkIo[1] - # web.ctx.session.otime = ntime; - - # networkInfo['cpu'] = self.GetCpuInfo() - # networkInfo['load'] = self.GetLoadAverage(get); - return jsonify(networkInfo) diff --git a/views/database.py b/views/database.py new file mode 100644 index 000000000..61d7847d2 --- /dev/null +++ b/views/database.py @@ -0,0 +1,17 @@ +# coding:utf-8 + +from flask import Flask +from flask import Blueprint, render_template + + +database = Blueprint('database', __name__, template_folder='templates') + + +@database.route("/") +def index(): + return render_template('default/database.html') + + +@database.route("/count") +def count(): + return "0" diff --git a/views/plugins.py b/views/plugins.py index 73c8be38d..6392b962f 100644 --- a/views/plugins.py +++ b/views/plugins.py @@ -8,11 +8,10 @@ import psutil import time import sys import os - +import json sys.path.append("class/") import public -import json plugins = Blueprint('plugins', __name__, template_folder='templates') @@ -96,3 +95,25 @@ def install(): @plugins.route('/uninstall', methods=['POST']) def uninstall(): pass + + +@plugins.route('/installed', methods=['POST']) +def installed(): + + rundir = public.getRunDir() + name = request.form.get('name', '') + + if name.strip() == '': + return public.retJson(-1, "缺少name数据!", ()) + + infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json' + + if not os.path.exists(infoJsonPos): + return public.retJson(-1, "info.json数据不存在!", ()) + + pluginInfo = json.loads(public.readFile(infoJsonPos)) + + sh = __plugin_name + '/' + name + '/' + pluginInfo['shell'] + os.system('/bin/bash ' + sh + ' install') + print request.args + return '' diff --git a/views/site.py b/views/site.py index b9059240a..6ddc86d92 100644 --- a/views/site.py +++ b/views/site.py @@ -1,11 +1,17 @@ # coding:utf-8 from flask import Flask -from flask import Blueprint,render_template +from flask import Blueprint, render_template site = Blueprint('site', __name__, template_folder='templates') + @site.route("/") def index(): - return render_template('default/site.html') \ No newline at end of file + return render_template('default/site.html') + + +# @site.route("/list") +# def list(): +# SQL = public.M('site') diff --git a/views/system.py b/views/system.py new file mode 100644 index 000000000..8c405a62d --- /dev/null +++ b/views/system.py @@ -0,0 +1,159 @@ +# coding:utf-8 + +import time +import psutil +import os +import sys + +from flask import Flask, session +from flask import Blueprint, render_template +from flask import jsonify + +sys.path.append("class/") +import public + + +system = Blueprint('system', __name__, template_folder='templates') + + +def GetCpuInfo(interval=1): + # 取CPU信息 + cpuCount = psutil.cpu_count() + used = psutil.cpu_percent(interval=interval) + return used, cpuCount + + +def GetLoadAverage(): + c = os.getloadavg() + data = {} + data['one'] = float(c[0]) + data['five'] = float(c[1]) + data['fifteen'] = float(c[2]) + data['max'] = psutil.cpu_count() * 2 + data['limit'] = data['max'] + data['safe'] = data['max'] * 0.75 + return data + + +def GetMemInfo(): + # 取内存信息 + mem = psutil.virtual_memory() + memInfo = {'memTotal': mem.total / 1024 / 1024, + 'memFree': mem.free / 1024 / 1024, + # 'memBuffers': mem.buffers / 1024 / 1024, + # 'memCached': mem.cached / 1024 / 1024 + } + + memInfo['memRealUsed'] = memInfo['memTotal'] - \ + memInfo['memFree'] + #- memInfo['memBuffers'] - memInfo['memCached'] + return memInfo + + +def GetBootTime(): + conf = public.readFile('/proc/uptime').split() + tStr = float(conf[0]) + min = tStr / 60 + hours = min / 60 + days = math.floor(hours / 24) + hours = math.floor(hours - (days * 24)) + min = math.floor(min - (days * 60 * 24) - (hours * 60)) + return public.getMsg('SYS_BOOT_TIME', (str(int(days)), str(int(hours)), str(int(min)))) + + +def GetSystemVersion(): + # 取操作系统版本 + version = public.readFile('/etc/redhat-release') + if not version: + version = public.readFile( + '/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip() + else: + version = version.replace('release ', '').strip() + return version + + +@system.route("/network") +def network(): + # 取网络流量信息 + networkIo = psutil.net_io_counters()[:4] + if not hasattr(session, 'otime'): + session['up'] = networkIo[0] + session['down'] = networkIo[1] + session['otime'] = time.time() + + ntime = time.time() + networkInfo = {} + networkInfo['upTotal'] = networkIo[0] + networkInfo['downTotal'] = networkIo[1] + networkInfo['up'] = round(float( + networkIo[0] - session['up']) / 1024 / (ntime - session['otime']), 2) + networkInfo['down'] = round( + float(networkIo[1] - session['down']) / 1024 / (ntime - session['otime']), 2) + networkInfo['downPackets'] = networkIo[3] + networkInfo['upPackets'] = networkIo[2] + + session['up'] = networkIo[0] + session['down'] = networkIo[1] + session['otime'] = time.time() + + networkInfo['cpu'] = GetCpuInfo() + networkInfo['load'] = GetLoadAverage() + return jsonify(networkInfo) + + +@system.route("/diskinfo") +def diskinfo(): + # 取磁盘分区信息 + temp = public.ExecShell("df -h -P|grep '/'|grep -v tmpfs")[0] + tempInodes = public.ExecShell("df -i -P|grep '/'|grep -v tmpfs")[0] + temp1 = temp.split('\n') + tempInodes1 = tempInodes.split('\n') + diskInfo = [] + n = 0 + cuts = ['/mnt/cdrom', '/boot', '/boot/efi', '/dev', + '/dev/shm', '/run/lock', '/run', '/run/shm', '/run/user'] + for tmp in temp1: + n += 1 + inodes = tempInodes1[n - 1].split() + disk = tmp.split() + if len(disk) < 5: + continue + if disk[1].find('M') != -1: + continue + if disk[1].find('K') != -1: + continue + if len(disk[5].split('/')) > 4: + continue + if disk[5] in cuts: + continue + arr = {} + arr['path'] = disk[5] + tmp1 = [disk[1], disk[2], disk[3], disk[4]] + arr['size'] = tmp1 + arr['inodes'] = [inodes[1], inodes[2], inodes[3], inodes[4]] + if disk[5] == '/': + bootLog = '/tmp/panelBoot.pl' + if disk[2].find('M') != -1: + if os.path.exists(bootLog): + os.system('rm -f ' + bootLog) + else: + pass + if not os.path.exists(bootLog): + os.system('sleep 1 &') + # print arr + diskInfo.append(arr) + return jsonify(diskInfo) + + +@system.route("/systemtotal") +def systemtotal(): + # 取系统统计信息 + data = GetMemInfo() + cpu = GetCpuInfo(1) + data['cpuNum'] = cpu[1] + data['cpuRealUsed'] = cpu[0] + # data['time'] = GetBootTime() + # data['system'] = GetSystemVersion() + data['isuser'] = public.M('users').where('username=?', ('admin',)).count() + data['version'] = '0.0.1' + return jsonify(data)