pull/109/head
Mr Chen 6 years ago
parent 2ec60bf8b2
commit db3c29b631
  1. 4
      class/core/public.py
  2. 7
      route/site.py
  3. 47
      static/app/public.js
  4. 55
      static/app/site.js

@ -54,6 +54,10 @@ def getServerDir():
return getRootDir() + '/server' return getRootDir() + '/server'
def getWwwDir():
return getRootDir() + '/wwwroot'
def getOs(): def getOs():
os = execShell('uname') os = execShell('uname')
return os[0].lower().strip() return os[0].lower().strip()

@ -31,6 +31,13 @@ def getPhpVersion():
return site_api.site_api().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']) @site.route('add', methods=['POST'])
def add(): def add():
webname = request.form.get('webinfo', '').encode('utf-8') webname = request.form.get('webinfo', '').encode('utf-8')

@ -68,6 +68,21 @@ function mwsPost(path, args, callback){
},'json'); },'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) { function repeatPwd(a) {
$("#MyPassword").val(RandomStrPwd(a)) $("#MyPassword").val(RandomStrPwd(a))
} }
@ -125,9 +140,7 @@ function getLocalTime(a) {
} }
function changePath(d) {
function ChangePath(d) {
setCookie("SetId", d); setCookie("SetId", d);
setCookie("SetName", ""); setCookie("SetName", "");
var c = layer.open({ var c = layer.open({
@ -151,18 +164,18 @@ function ChangePath(d) {
setCookie("SetName", tmp[tmp.length - 1]) setCookie("SetName", tmp[tmp.length - 1])
} }
b = b.replace(/\/\//g, "/"); b = b.replace(/\/\//g, "/");
GetDiskList(b); getDiskList(b);
ActiveDisk() activeDisk();
} }
function GetDiskList(b) { function getDiskList(b) {
var d = ""; var d = "";
var a = ""; var a = "";
var c = "path=" + b + "&disk=True"; var c = "path=" + b + "&disk=True";
$.post("/files?action=GetDir", c, function(h) { $.post("/files/get_dir", c, function(h) {
if(h.DISK != undefined) { if(h.DISK != undefined) {
for(var f = 0; f < h.DISK.length; f++) { for(var f = 0; f < h.DISK.length; f++) {
a += "<dd onclick=\"GetDiskList('" + h.DISK[f].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;" + h.DISK[f].path + "</dd>" a += "<dd onclick=\"getDiskList('" + h.DISK[f].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;" + h.DISK[f].path + "</dd>"
} }
$("#changecomlist").html(a) $("#changecomlist").html(a)
} }
@ -177,7 +190,7 @@ function GetDiskList(b) {
e = e.substring(0, 10) + "..." e = e.substring(0, 10) + "..."
} }
} }
d += "<tr><td onclick=\"GetDiskList('" + h.PATH + "/" + g[0] + "')\" title='" + g[0] + "'><span class='glyphicon glyphicon-folder-open'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td><span class='delfile-btn' onclick=\"NewDelFile('" + h.PATH + "/" + g[0] + "')\">X</span></td></tr>" d += "<tr><td onclick=\"getDiskList('" + h.PATH + "/" + g[0] + "')\" title='" + g[0] + "'><span class='glyphicon glyphicon-folder-open'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td><span class='delfile-btn' onclick=\"NewDelFile('" + h.PATH + "/" + g[0] + "')\">X</span></td></tr>"
} }
if(h.FILES != null && h.FILES != "") { if(h.FILES != null && h.FILES != "") {
for(var f = 0; f < h.FILES.length; f++) { for(var f = 0; f < h.FILES.length; f++) {
@ -201,9 +214,9 @@ function GetDiskList(b) {
h.PATH += "/" h.PATH += "/"
} }
$("#PathPlace").find("span").html(h.PATH); $("#PathPlace").find("span").html(h.PATH);
ActiveDisk(); activeDisk();
return return
}) },'json');
} }
function CreateFolder() { function CreateFolder() {
@ -229,7 +242,7 @@ function CreateFolder() {
icon: 2 icon: 2
}) })
} }
GetDiskList(b) getDiskList(b)
}) })
}); });
$("#nameNOk").click(function() { $("#nameNOk").click(function() {
@ -251,11 +264,11 @@ function NewDelFile(c) {
icon: 2 icon: 2
}) })
} }
GetDiskList(a) getDiskList(a)
}) })
} }
function ActiveDisk() { function activeDisk() {
var a = $("#PathPlace").find("span").text().substring(0, 1); var a = $("#PathPlace").find("span").text().substring(0, 1);
switch(a) { switch(a) {
case "C": case "C":
@ -285,7 +298,7 @@ function BackMyComputer() {
$(".default").show(); $(".default").show();
$(".file-list").hide(); $(".file-list").hide();
$("#PathPlace").find("span").html(""); $("#PathPlace").find("span").html("");
ActiveDisk() activeDisk()
} }
function BackFile() { function BackFile() {
@ -300,7 +313,7 @@ function BackFile() {
for(var b = 0; b < e; b++) { for(var b = 0; b < e; b++) {
a += d[b] + "/" a += d[b] + "/"
} }
GetDiskList(a.replace("//", "/")) getDiskList(a.replace("//", "/"))
} else { } else {
a = d[0] a = d[0]
} }
@ -566,7 +579,7 @@ function isChineseChar(b) {
return a.test(b) return a.test(b)
} }
function SafeMessage(j, h, g, f) { function safeMessage(j, h, g, f) {
if(f == undefined) { if(f == undefined) {
f = "" f = ""
} }

@ -152,8 +152,6 @@ function webAdd(type) {
var loadT = layer.msg(lan.public.the_get,{icon:16,time:0,shade: [0.3, "#000"]}) var loadT = layer.msg(lan.public.the_get,{icon:16,time:0,shade: [0.3, "#000"]})
var data = $("#addweb").serialize()+"&port="+webport+"&webinfo="+domain; var data = $("#addweb").serialize()+"&port="+webport+"&webinfo="+domain;
console.log(data);
$.post('/site/add', data, function(ret) { $.post('/site/add', data, function(ret) {
if(ret.status === false){ if(ret.status === false){
layer.msg(ret.msg,{icon:ret.status?1:2}) 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--){ for(var i=rdata.length-1;i>=0;i--){
php_version += "<option value='"+rdata[i].version+"'>"+rdata[i].name+"</option>"; php_version += "<option value='"+rdata[i].version+"'>"+rdata[i].name+"</option>";
} }
var www = syncPost('/site/get_root_dir');
php_version += "</select><span id='php_w' style='color:red;margin-left: 10px;'></span></div>"; php_version += "</select><span id='php_w' style='color:red;margin-left: 10px;'></span></div>";
layer.open({ layer.open({
type: 1, type: 1,
skin: 'demo-class', skin: 'demo-class',
area: '640px', area: '640px',
title: lan.site.site_add, title: '添加网站',
closeBtn: 2, closeBtn: 2,
shift: 0, shift: 0,
shadeClose: false, shadeClose: false,
@ -221,15 +222,15 @@ function webAdd(type) {
</div>\ </div>\
</div>\ </div>\
<div class='line'>\ <div class='line'>\
<span class='tname'>"+lan.site.note+"</span>\ <span class='tname'>备注</span>\
<div class='info-r c4'>\ <div class='info-r c4'>\
<input id='Wbeizhu' class='bt-input-text' type='text' name='ps' placeholder='"+lan.site.note_ph+"' style='width:458px' />\ <input id='Wbeizhu' class='bt-input-text' type='text' name='ps' placeholder='"+lan.site.note_ph+"' style='width:458px' />\
</div>\ </div>\
</div>\ </div>\
<div class='line'>\ <div class='line'>\
<span class='tname'>"+lan.site.root_dir+"</span>\ <span class='tname'>根目录</span>\
<div class='info-r c4'>\ <div class='info-r c4'>\
<input id='inputPath' class='bt-input-text mr5' type='text' name='path' value='"+defaultPath+"/' placeholder='"+lan.site.web_root_dir+"' style='width:458px' /><span class='glyphicon glyphicon-folder-open cursor' onclick='ChangePath(\"inputPath\")'></span>\ <input id='inputPath' class='bt-input-text mr5' type='text' name='path' value='"+www['dir']+"/' placeholder='"+www['dir']+"' style='width:458px' /><span class='glyphicon glyphicon-folder-open cursor' onclick='changePath(\"inputPath\")'></span>\
</div>\ </div>\
</div>\ </div>\
"+php_version+"\ "+php_version+"\
@ -266,6 +267,27 @@ function webAdd(type) {
$('#php_w').text(''); $('#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() { $('#Wbeizhu').on('input', function() {
var str = $(this).val(); var str = $(this).val();
@ -306,7 +328,7 @@ function webPathEdit(id){
<div class='line mt10'>\ <div class='line mt10'>\
<span class='mr5'>"+lan.site.web_dir+"</span>\ <span class='mr5'>"+lan.site.web_dir+"</span>\
<input class='bt-input-text mr5' type='text' style='width:50%' placeholder='"+lan.site.web_root_dir+"' value='"+rdata+"' name='webdir' id='inputPath'>\ <input class='bt-input-text mr5' type='text' style='width:50%' placeholder='"+lan.site.web_root_dir+"' value='"+rdata+"' name='webdir' id='inputPath'>\
<span onclick='ChangePath(&quot;inputPath&quot;)' class='glyphicon glyphicon-folder-open cursor mr20'></span>\ <span onclick='changePath(&quot;inputPath&quot;)' class='glyphicon glyphicon-folder-open cursor mr20'></span>\
<button class='btn btn-success btn-sm' onclick='SetSitePath("+id+")'>"+lan.public.save+"</button>\ <button class='btn btn-success btn-sm' onclick='SetSitePath("+id+")'>"+lan.public.save+"</button>\
</div>\ </div>\
<div class='line mtb15'>\ <div class='line mtb15'>\
@ -321,7 +343,7 @@ function webPathEdit(id){
+'<div class="user_pw_tit" style="margin-top: -8px;padding-top: 11px;">' +'<div class="user_pw_tit" style="margin-top: -8px;padding-top: 11px;">'
+'<span class="tit">'+lan.soft.pma_pass+'</span>' +'<span class="tit">'+lan.soft.pma_pass+'</span>'
+'<span class="btswitch-p"><input '+(userini.pass?'checked':'')+' class="btswitch btswitch-ios" id="pathSafe" type="checkbox">' +'<span class="btswitch-p"><input '+(userini.pass?'checked':'')+' class="btswitch btswitch-ios" id="pathSafe" type="checkbox">'
+'<label class="btswitch-btn phpmyadmin-btn" for="pathSafe" onclick="PathSafe('+id+')"></label>' +'<label class="btswitch-btn phpmyadmin-btn" for="pathSafe" onclick="pathSafe('+id+')"></label>'
+'</span>' +'</span>'
+'</div>' +'</div>'
+'<div class="user_pw" style="margin-top: 10px;display:'+(userini.pass?'block;':'none;')+'">' +'<div class="user_pw" style="margin-top: 10px;display:'+(userini.pass?'block;':'none;')+'">'
@ -350,7 +372,7 @@ function webPathEdit(id){
} }
//是否设置访问密码 //是否设置访问密码
function PathSafe(id){ function pathSafe(id){
var isPass = $('#pathSafe').prop('checked'); var isPass = $('#pathSafe').prop('checked');
if(!isPass){ if(!isPass){
$(".user_pw").show(); $(".user_pw").show();
@ -491,23 +513,16 @@ function webStart(wid, wname) {
*/ */
function webDelete(wid, wname){ function webDelete(wid, wname){
var thtml = "<div class='options'>\ var thtml = "<div class='options'>\
<label><input type='checkbox' id='delftp' name='ftp'><span>FTP</span></label>\
<label><input type='checkbox' id='deldata' name='data'><span>"+lan.site.database+"</span></label>\
<label><input type='checkbox' id='delpath' name='path'><span>"+lan.site.root_dir+"</span></label>\ <label><input type='checkbox' id='delpath' name='path'><span>"+lan.site.root_dir+"</span></label>\
</div>"; </div>";
SafeMessage(lan.site.site_del_title+"["+wname+"]",lan.site.site_del_info,function(){ var info = '是否要删除同名根目录';
var ftp='',data='',path=''; safeMessage('删除站点'+"["+wname+"]",info, function(){
if($("#delftp").is(":checked")){ var path='';
ftp='&ftp=1';
}
if($("#deldata").is(":checked")){
data='&database=1';
}
if($("#delpath").is(":checked")){ if($("#delpath").is(":checked")){
path='&path=1'; path='&path=1';
} }
var loadT = layer.msg(lan.public.the,{icon:16,time:10000,shade: [0.3, '#000']}); 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.closeAll();
layer.msg(ret.msg,{icon:ret.status?1:2}) layer.msg(ret.msg,{icon:ret.status?1:2})
getWeb(1); getWeb(1);

Loading…
Cancel
Save