diff --git a/class/core/public.py b/class/core/public.py index 7830d1356..8436cdcb0 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -54,6 +54,10 @@ def getServerDir(): return getRootDir() + '/server' +def getWwwDir(): + return getRootDir() + '/wwwroot' + + def getOs(): os = execShell('uname') return os[0].lower().strip() diff --git a/route/site.py b/route/site.py index 3a8c82b7e..3c5ac10a0 100644 --- a/route/site.py +++ b/route/site.py @@ -31,6 +31,13 @@ def getPhpVersion(): return site_api.site_api().getPhpVersion() +@site.route('get_root_dir', methods=['POST']) +def getRootDir(): + data = {} + data['dir'] = public.getWwwDir() + return public.getJson(data) + + @site.route('add', methods=['POST']) def add(): webname = request.form.get('webinfo', '').encode('utf-8') diff --git a/static/app/public.js b/static/app/public.js index 4e6e7b6b9..b5661444d 100755 --- a/static/app/public.js +++ b/static/app/public.js @@ -68,6 +68,21 @@ function mwsPost(path, args, callback){ },'json'); } +function syncPost(path, args){ + var retData; + $.ajax({ + type : 'post', + url : path, + data : args, + async : false, + dataType:'json', + success : function(data){ + retData = data; + } + }); + return retData; +} + function repeatPwd(a) { $("#MyPassword").val(RandomStrPwd(a)) } @@ -125,9 +140,7 @@ function getLocalTime(a) { } - - -function ChangePath(d) { +function changePath(d) { setCookie("SetId", d); setCookie("SetName", ""); var c = layer.open({ @@ -151,18 +164,18 @@ function ChangePath(d) { setCookie("SetName", tmp[tmp.length - 1]) } b = b.replace(/\/\//g, "/"); - GetDiskList(b); - ActiveDisk() + getDiskList(b); + activeDisk(); } -function GetDiskList(b) { +function getDiskList(b) { var d = ""; var a = ""; var c = "path=" + b + "&disk=True"; - $.post("/files?action=GetDir", c, function(h) { + $.post("/files/get_dir", c, function(h) { if(h.DISK != undefined) { for(var f = 0; f < h.DISK.length; f++) { - a += "
 " + h.DISK[f].path + "
" + a += "
 " + h.DISK[f].path + "
" } $("#changecomlist").html(a) } @@ -177,7 +190,7 @@ function GetDiskList(b) { e = e.substring(0, 10) + "..." } } - d += "" + e + "" + getLocalTime(g[2]) + "" + g[3] + "" + g[4] + "X" + d += "" + e + "" + getLocalTime(g[2]) + "" + g[3] + "" + g[4] + "X" } if(h.FILES != null && h.FILES != "") { for(var f = 0; f < h.FILES.length; f++) { @@ -201,9 +214,9 @@ function GetDiskList(b) { h.PATH += "/" } $("#PathPlace").find("span").html(h.PATH); - ActiveDisk(); + activeDisk(); return - }) + },'json'); } function CreateFolder() { @@ -229,7 +242,7 @@ function CreateFolder() { icon: 2 }) } - GetDiskList(b) + getDiskList(b) }) }); $("#nameNOk").click(function() { @@ -251,11 +264,11 @@ function NewDelFile(c) { icon: 2 }) } - GetDiskList(a) + getDiskList(a) }) } -function ActiveDisk() { +function activeDisk() { var a = $("#PathPlace").find("span").text().substring(0, 1); switch(a) { case "C": @@ -285,7 +298,7 @@ function BackMyComputer() { $(".default").show(); $(".file-list").hide(); $("#PathPlace").find("span").html(""); - ActiveDisk() + activeDisk() } function BackFile() { @@ -300,7 +313,7 @@ function BackFile() { for(var b = 0; b < e; b++) { a += d[b] + "/" } - GetDiskList(a.replace("//", "/")) + getDiskList(a.replace("//", "/")) } else { a = d[0] } @@ -566,7 +579,7 @@ function isChineseChar(b) { return a.test(b) } -function SafeMessage(j, h, g, f) { +function safeMessage(j, h, g, f) { if(f == undefined) { f = "" } diff --git a/static/app/site.js b/static/app/site.js index 2d406c6db..746505f2e 100755 --- a/static/app/site.js +++ b/static/app/site.js @@ -152,8 +152,6 @@ function webAdd(type) { var loadT = layer.msg(lan.public.the_get,{icon:16,time:0,shade: [0.3, "#000"]}) var data = $("#addweb").serialize()+"&port="+webport+"&webinfo="+domain; - console.log(data); - $.post('/site/add', data, function(ret) { if(ret.status === false){ layer.msg(ret.msg,{icon:ret.status?1:2}) @@ -204,12 +202,15 @@ function webAdd(type) { for(var i=rdata.length-1;i>=0;i--){ php_version += ""; } + + var www = syncPost('/site/get_root_dir'); + php_version += ""; layer.open({ type: 1, skin: 'demo-class', area: '640px', - title: lan.site.site_add, + title: '添加网站', closeBtn: 2, shift: 0, shadeClose: false, @@ -221,15 +222,15 @@ function webAdd(type) { \ \
\ - "+lan.site.note+"\ + 备注\
\ \
\
\
\ - "+lan.site.root_dir+"\ + 根目录\
\ - \ + \
\
\ "+php_version+"\ @@ -266,6 +267,27 @@ function webAdd(type) { $('#php_w').text(''); } }) + + $('#mainDomain').on('input', function() { + // var array; + // var res,ress; + // var str = $(this).val().replace('http://','').replace('https://',''); + // var len = str.replace(/[^\x00-\xff]/g, "**").length; + // array = str.split("\n"); + // ress =array[0].split(":")[0]; + // res = ress.replace(new RegExp(/([-.])/g), '_'); + // if(res.length > 15) res = res.substr(0,15); + // if($("#inputPath").val().substr(0,defaultPath.length) == defaultPath) $("#inputPath").val(defaultPath+'/'+ress); + // if(!isNaN(res.substr(0,1))) res = "sql"+res; + // if(res.length > 15) res = res.substr(0,15); + // $("#Wbeizhu").val(ress); + // $("#ftp-user").val(res); + // $("#data-user").val(res); + // if(isChineseChar(str)) $('.btn-zhm').show(); + // else $('.btn-zhm').hide(); + console.log('123'); + }) + //备注 $('#Wbeizhu').on('input', function() { var str = $(this).val(); @@ -306,7 +328,7 @@ function webPathEdit(id){
\ "+lan.site.web_dir+"\ \ - \ + \ \
\
\ @@ -321,7 +343,7 @@ function webPathEdit(id){ +'
' +''+lan.soft.pma_pass+'' +'' - +'' + +'' +'' +'
' +'
' @@ -350,7 +372,7 @@ function webPathEdit(id){ } //是否设置访问密码 -function PathSafe(id){ +function pathSafe(id){ var isPass = $('#pathSafe').prop('checked'); if(!isPass){ $(".user_pw").show(); @@ -491,23 +513,16 @@ function webStart(wid, wname) { */ function webDelete(wid, wname){ var thtml = "
\ - \ - \ \
"; - SafeMessage(lan.site.site_del_title+"["+wname+"]",lan.site.site_del_info,function(){ - var ftp='',data='',path=''; - if($("#delftp").is(":checked")){ - ftp='&ftp=1'; - } - if($("#deldata").is(":checked")){ - data='&database=1'; - } + var info = '是否要删除同名根目录'; + safeMessage('删除站点'+"["+wname+"]",info, function(){ + var path=''; if($("#delpath").is(":checked")){ path='&path=1'; } var loadT = layer.msg(lan.public.the,{icon:16,time:10000,shade: [0.3, '#000']}); - $.post("/site?action=DeleteSite","id=" + wid + "&webname=" + wname+ftp+data+path, function(ret){ + $.post("/site?action=DeleteSite","id=" + wid + "&webname=" + wname+path, function(ret){ layer.closeAll(); layer.msg(ret.msg,{icon:ret.status?1:2}) getWeb(1);