diff --git a/class/core/config_api.py b/class/core/config_api.py index 33bac5a0d..1b69459e7 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -122,6 +122,42 @@ class config_api: session['username'] = name1 return mw.returnJson(True, '用户修改成功!') + def setWebnameApi(self): + webname = request.form.get('webname', '') + if webname != mw.getConfig('title'): + mw.setConfig('title', webname) + return mw.returnJson(True, '面板别名保存成功!') + + def setPortApi(self): + port = request.form.get('port', '') + if port != mw.getHostPort(): + import system_api + import firewall_api + + if os.path.exists("/lib/systemd/system/firewalld.service"): + if not firewall_api.firewall_api().getFwStatus(): + return mw.returnJson(False, 'firewalld必须先启动!') + + mw.setHostPort(port) + + msg = mw.getInfo('放行端口[{1}]成功', (port,)) + mw.writeLog("防火墙管理", msg) + addtime = time.strftime('%Y-%m-%d %X', time.localtime()) + mw.M('firewall').add('port,ps,addtime', (port, "配置修改", addtime)) + + firewall_api.firewall_api().addAcceptPort(port) + firewall_api.firewall_api().firewallReload() + + system_api.system_api().restartMw() + + return mw.returnJson(True, '端口保存成功!') + + def setIpApi(self): + host_ip = request.form.get('host_ip', '') + if host_ip != mw.getHostAddr(): + mw.setHostAddr(host_ip) + return mw.returnJson(True, 'IP保存成功!') + def setApi(self): webname = request.form.get('webname', '') port = request.form.get('port', '') diff --git a/route/static/app/config.js b/route/static/app/config.js index 121e470fa..5430f85fb 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -3,7 +3,7 @@ // console.log(rdata); // },'json'); - +/** op **/ $(".set-submit").click(function(){ var data = $("#set_config").serialize(); layer.msg('正在保存配置...',{icon:16,time:0,shade: [0.3, '#000']}); @@ -18,6 +18,41 @@ $(".set-submit").click(function(){ },'json'); }); +$('input[name="webname"]').change(function(){ + var webname = $(this).val(); + $('.btn_webname').removeAttr('disabled'); + $('.btn_webname').unbind().click(function(){ + $.post('/config/set_webname','webname='+webname, function(rdata){ + showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); + },'json'); + }); +}); + + +$('input[name="host_ip"]').change(function(){ + var host_ip = $(this).val(); + $('.btn_host_ip').removeAttr('disabled'); + $('.btn_host_ip').unbind().click(function(){ + $.post('/config/set_ip','host_ip='+host_ip, function(rdata){ + showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); + },'json'); + }); +}); + +$('input[name="port"]').change(function(){ + var port = $(this).val(); + $('.btn_port').removeAttr('disabled'); + $('.btn_port').unbind().click(function(){ + $.post('/config/set_port','port='+port, function(rdata){ + showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); + },'json'); + }); +}); + + + +/** op **/ + //关闭面板 function closePanel(){ diff --git a/route/templates/default/config.html b/route/templates/default/config.html index 987442437..18c1180b2 100755 --- a/route/templates/default/config.html +++ b/route/templates/default/config.html @@ -56,11 +56,23 @@

别名 - 面板名称 + + + 面板名称

+ +

+ 服务器IP + + + 默认为外网IP,若您在本地虚拟机测试,请填写虚拟机内网IP! +

+

面板端口 - 建议端口范围7200 - 65535 + + + 建议端口范围7200 - 65535

@@ -91,12 +103,6 @@

- 服务器IP - - 默认为外网IP,若您在本地虚拟机测试,请填写虚拟机内网IP! -

- -

服务器时间