From 9e087cb157b6cd8d176bd63f7e8e666001b2fdaa Mon Sep 17 00:00:00 2001
From: "bt.cn" <287962566@qq.com>
Date: Fri, 21 Jun 2019 14:24:51 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0BasicAuth=E8=AE=A4=E8=AF=81?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=AE=E6=AD=A3apache2.2=E4=B8=8B?=
=?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=EF=BC=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BTPanel.pyproj | 172 ++++++++++++++++++++++++++
BTPanel/__init__.py | 52 ++++++--
BTPanel/static/js/config.js | 63 ++++++++++
BTPanel/static/js/idown_index.js | 3 -
BTPanel/static/js/soft.js | 13 +-
BTPanel/templates/default/config.html | 1 +
class/config.py | 31 +++++
class/panelPlugin.py | 3 +-
class/plugin_deployment.py | 3 +-
class/public.py | 14 ++-
tools.py | 12 +-
11 files changed, 342 insertions(+), 25 deletions(-)
delete mode 100644 BTPanel/static/js/idown_index.js
diff --git a/BTPanel.pyproj b/BTPanel.pyproj
index 17519136..d4114035 100644
--- a/BTPanel.pyproj
+++ b/BTPanel.pyproj
@@ -79,6 +79,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -240,6 +250,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -934,6 +965,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BTPanel/__init__.py b/BTPanel/__init__.py
index 3e45d0ea..bfee4684 100644
--- a/BTPanel/__init__.py
+++ b/BTPanel/__init__.py
@@ -20,12 +20,16 @@
from werkzeug.wrappers import Response
from flask_socketio import SocketIO,emit,send
-#from flask_basicauth import BasicAuth
-#app.config['BASIC_AUTH_USERNAME'] = 'admin'
-#app.config['BASIC_AUTH_PASSWORD'] = '11111'
-#app.config['BASIC_AUTH_FORCE'] = True
-#basic_auth = BasicAuth(app)
-
+#设置BasicAuth
+basic_auth_conf = 'config/basic_auth.json'
+app.config['BASIC_AUTH_OPEN'] = False
+if os.path.exists(basic_auth_conf):
+ try:
+ ba_conf = json.loads(public.readFile(basic_auth_conf))
+ app.config['BASIC_AUTH_USERNAME'] = ba_conf['basic_user']
+ app.config['BASIC_AUTH_PASSWORD'] = ba_conf['basic_pwd']
+ app.config['BASIC_AUTH_OPEN'] = ba_conf['open']
+ except: pass
cache = SimpleCache()
socketio = SocketIO()
@@ -81,6 +85,22 @@
def service_status():
return 'True'
+
+@app.before_request
+def basic_auth_check():
+ if app.config['BASIC_AUTH_OPEN']:
+ if request.path in ['/public']: return;
+ auth = request.authorization
+ if not comm.get_sk(): return;
+ if not auth: return send_authenticated()
+ tips = '_bt.cn'
+ if public.md5(auth.username.strip() + tips) != app.config['BASIC_AUTH_USERNAME'] or public.md5(auth.password.strip() + tips) != app.config['BASIC_AUTH_PASSWORD']:
+ return send_authenticated()
+
+
+def send_authenticated():
+ return Response('', 401,{'WWW-Authenticate': 'Basic realm="Login Required"'})
+
@app.route('/',methods=method_all)
def home():
comReturn = comm.local()
@@ -186,7 +206,7 @@ def ftp(pdata = None):
data['isSetup'] = True;
if os.path.exists(public.GetConfigValue('setup_path') + '/pure-ftpd') == False: data['isSetup'] = False;
data['lan'] = public.GetLan('ftp')
- return render_template( 'ftp.html',data=data)
+ return render_template('ftp.html',data=data)
import ftp
ftpObject = ftp.ftp()
defs = ('AddUser','DeleteUser','SetUserPassword','SetStatus','setPort')
@@ -337,6 +357,7 @@ def config(pdata = None):
if comReturn: return comReturn
if request.method == method_get[0] and not pdata:
import system,wxapp,config
+ c_obj = config.config()
data = system.system().GetConcifInfo()
data['lan'] = public.GetLan('config')
try:
@@ -351,13 +372,15 @@ def config(pdata = None):
if not os.path.exists(workers_p): public.writeFile(workers_p,'1')
data['workers'] = int(public.readFile(workers_p))
data['session_timeout'] = int(public.readFile(sess_out_path))
- if config.config().get_ipv6_listen(None): data['ipv6'] = 'checked'
- if config.config().get_token(None)['open']: data['api'] = 'checked'
+ if c_obj.get_ipv6_listen(None): data['ipv6'] = 'checked'
+ if c_obj.get_token(None)['open']: data['api'] = 'checked'
+ data['basic_auth'] = c_obj.get_basic_auth_stat(None)
+ data['basic_auth']['value'] = '已关闭'
+ if data['basic_auth']['open']: data['basic_auth']['value'] = '已开启'
return render_template( 'config.html',data=data)
import config
- configObject = config.config()
- defs = ('get_cli_php_version','get_tmp_token','set_cli_php_version','DelOldSession', 'GetSessionCount', 'SetSessionConf', 'GetSessionConf','get_ipv6_listen','set_ipv6_status','GetApacheValue','SetApacheValue','GetNginxValue','SetNginxValue','get_token','set_token','set_admin_path','is_pro','get_php_config','get_config','SavePanelSSL','GetPanelSSL','GetPHPConf','SetPHPConf','GetPanelList','AddPanelInfo','SetPanelInfo','DelPanelInfo','ClickPanelInfo','SetPanelSSL','SetTemplates','Set502','setPassword','setUsername','setPanel','setPathInfo','setPHPMaxSize','getFpmConfig','setFpmConfig','setPHPMaxTime','syncDate','setPHPDisable','SetControl','ClosePanel','AutoUpdatePanel','SetPanelLock')
- return publicObject(configObject,defs,None,pdata);
+ defs = ('get_basic_auth_stat','set_basic_auth','get_cli_php_version','get_tmp_token','set_cli_php_version','DelOldSession', 'GetSessionCount', 'SetSessionConf', 'GetSessionConf','get_ipv6_listen','set_ipv6_status','GetApacheValue','SetApacheValue','GetNginxValue','SetNginxValue','get_token','set_token','set_admin_path','is_pro','get_php_config','get_config','SavePanelSSL','GetPanelSSL','GetPHPConf','SetPHPConf','GetPanelList','AddPanelInfo','SetPanelInfo','DelPanelInfo','ClickPanelInfo','SetPanelSSL','SetTemplates','Set502','setPassword','setUsername','setPanel','setPathInfo','setPHPMaxSize','getFpmConfig','setFpmConfig','setPHPMaxTime','syncDate','setPHPDisable','SetControl','ClosePanel','AutoUpdatePanel','SetPanelLock')
+ return publicObject(config.config(),defs,None,pdata);
@app.route('/ajax',methods=method_all)
def ajax(pdata = None):
@@ -455,7 +478,12 @@ def plugin(pdata = None):
def panel_public():
get = get_input();
get.client_ip = public.GetClientIp();
+
if get.fun in ['scan_login','login_qrcode','set_login','is_scan_ok','blind']:
+ #检查是否验证过安全入口
+ if get.fun in ['login_qrcode','is_scan_ok']:
+ global admin_check_auth,admin_path,route_path,admin_path_file
+ if admin_path != '/bt' and os.path.exists(admin_path_file) and not 'admin_auth' in session: return 'False'
import wxapp
pluwx = wxapp.wxapp()
checks = pluwx._check(get)
diff --git a/BTPanel/static/js/config.js b/BTPanel/static/js/config.js
index c37707c4..a11f3fc0 100644
--- a/BTPanel/static/js/config.js
+++ b/BTPanel/static/js/config.js
@@ -519,4 +519,67 @@ function SetIPv6() {
layer.close(loadT);
bt.msg(rdata);
});
+}
+
+
+function modify_basic_auth_to() {
+ var pdata = {
+ open: $("select[name='open']").val(),
+ basic_user: $("input[name='basic_user']").val(),
+ basic_pwd: $("input[name='basic_pwd']").val()
+ }
+ var loadT = layer.msg('正在配置BasicAuth服务,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] });
+ $.post('/config?action=set_basic_auth', pdata, function (rdata) {
+ layer.close(loadT);
+ if (rdata.status) {
+ layer.closeAll();
+ setTimeout(function () { window.location.reload(); }, 3000);
+ }
+ layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ });
+
+}
+
+function modify_basic_auth() {
+ var loadT = layer.msg('正在获取配置,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] });
+ $.post('/config?action=get_basic_auth_stat', {}, function (rdata) {
+ layer.close(loadT);
+ layer.open({
+ type: 1,
+ area: "500px",
+ title: "配置BasicAuth认证",
+ closeBtn: 2,
+ shift: 5,
+ shadeClose: false,
+ content: '
'
+ })
+ });
}
\ No newline at end of file
diff --git a/BTPanel/static/js/idown_index.js b/BTPanel/static/js/idown_index.js
deleted file mode 100644
index 5522985f..00000000
--- a/BTPanel/static/js/idown_index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var idown_version="1.0";$(".layui-layer-page").css({"width":"900px"});$(".bt-w-menu p").click(function(){console.log("点击了菜单");var i=$(this).index();$(this).addClass("bgw").siblings().removeClass("bgw");$(".plugin_body > div").hide().eq(i).show();switch(i){case 0:idown.get_down_index();break;case 1:idown.get_down_new();break;case 2:idown.get_down_active();break;case 3:idown.get_down_stop();break}});var idown={get_down_index:function(){request_plugin("idown","get_panel_indexinfo",{},function(rdata){if(rdata["idown_status"]=="run"){$("#idown_status").prop("checked",true)}else{$("#idown_status").prop("checked",false)}$("#idown_rpc_token").val(rdata["idown_rpc_token"]);$("#webapi_token").val(rdata["idown_webapi_token"]);$("#api_url").val("http://"+rdata["idown_serverip"]+":8001/api");$("#api_help").attr("src","http://"+rdata["idown_serverip"]+":8001/help")})},get_down_new:function(){$("#download_new_link").val("");var obj=document.getElementById("download_new_bt_link");obj.outerHTML=obj.outerHTML;$("#download_textarea_placeholder").show();console.log("显示了下载地址的遮罩层")},get_down_active:function(){request_plugin("idown","download_list_active",{},function(rdata){var num_active=count_array(rdata["Active"]["result"]);var num_wait=count_array(rdata["Wait"]["result"]);var HtmlTable="";if(num_active==0&&num_wait==0){var HtmlTable='没有找到相关任务! |
'}else{for(var i=0;i35){filename=filename.substr(0,35);filename=filename+"..."}}catch(err){filename="[METADATA]"+rdata["Active"]["result"][i]["infoHash"]}var size=rdata["Active"]["result"][i]["totalLength"];size=getsize(size,3);var speed=rdata["Active"]["result"][i]["downloadSpeed"];speed=getsize(speed,1);var percent=(rdata["Active"]["result"][i]["completedLength"]/rdata["Active"]["result"][i]["totalLength"]*100).toFixed(3);HtmlTable=HtmlTable+""+filename+' | |
';HtmlTable=HtmlTable+'Size:'+size+" Speed:"+speed+" Percent:"+percent+"% State:"+'正在下载'+" |
"}for(var i=0;i35){filename=filename.substr(0,35);filename=filename+"..."}}catch(err){filename="[METADATA]"+rdata["Wait"]["result"][i]["infoHash"]}var size=rdata["Wait"]["result"][i]["totalLength"];size=getsize(size,3);var speed=rdata["Wait"]["result"][i]["downloadSpeed"];speed=getsize(speed,1);var percent=(rdata["Wait"]["result"][i]["completedLength"]/rdata["Wait"]["result"][i]["totalLength"]*100).toFixed(3);HtmlTable=HtmlTable+""+filename+' | |
';HtmlTable=HtmlTable+'Size:'+size+" Speed:"+speed+" Percent:"+percent+"% State:"+'下载暂停'+" |
"}}$("#table_list_active").html(HtmlTable)})},get_down_stop:function(){request_plugin("idown","download_list_stop",{},function(rdata){var num=count_array(rdata["result"]);var HtmlTable="";if(num==0){var HtmlTable='没有找到相关任务! |
'}else{for(var i=0;i35){filename=filename.substr(0,35);filename=filename+"..."}var size=rdata["result"][i]["totalLength"];size=getsize(size,3);var speed=rdata["result"][i]["downloadSpeed"];speed=getsize(speed,1);var percent=(rdata["result"][i]["completedLength"]/rdata["result"][i]["totalLength"]*100).toFixed(3);HtmlTable=HtmlTable+""+filename+' | |
';HtmlTable=HtmlTable+'Size:'+size+" Speed:"+speed+" Percent:"+percent+"% State:"+'下载完成'+" |
"}}$("#table_list_stop").html(HtmlTable)})},button_newdownload:function(){var loadT=layer.msg("正在添加新的下载任务...",{icon:16,time:0,shade:[0.3,"#000"]});
-var txt=$("#download_new_link").val();if(txt!=""){var regex=true;_link=txt;if(_link!=""&®ex){var regex_http=/^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;var regex_ftp=/^ftp:\/\/(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)((d|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))$)|^ftp:\/\/([a-zA-Z0-9_-])+:([a-zA-Z0-9_-])+@(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)((d|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))$)/;var regex_magnet=/^(magnet:\?xt=urn:btih:)[0-9a-zA-Z]{32,}.*$/;if(!regex_http.test(_link)&&!regex_ftp.test(_link)&&!regex_magnet.test(_link)){layer.close(loadT);layer.msg("您输入的下载地址有误,请输入正确的下载地址,支持http/https/ftp/magnet格式的链接",{icon:5});idown.get_down_new();regex=false}}if(regex==true){data="link="+_link;request_plugin("idown","download_addnew_link",data,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("新建下载 任务成功",{icon:1})}else{layer.close(loadT);layer.msg("新建下载任务失败"+rdata["mes"],{icon:5})}idown.get_down_new()})}}else{var bt_link=$("#download_new_bt_link").val();if(bt_link==""){layer.close(loadT);layer.msg("请输入需要下载的文件链接地址或者上传种子文件",{icon:5});idown.get_down_new()}else{var name=$("#download_new_bt_link")[0].files[0].name;var _name=name.split(".");var i=_name.length;if(_name[i-1]!="torrent"&&_name[i-1]!="TORRENT"){layer.close(loadT);layer.msg("仅支持torrent格式的种子文件",{icon:5});idown.get_down_new()}else{var formData=new FormData();formData.append("file",$("#download_new_bt_link")[0].files[0]);request_plugin("idown","download_addnew_bt",formData,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("新建BT下载 任务成功",{icon:1})}else{layer.close(loadT);layer.msg("新建BT下载任务失败"+rdata["mes"],{icon:5})}idown.get_down_new()},true)}}}},aria2c_server:function(){if($("#idown_status").prop("checked")){var loadT=layer.msg("正在关闭远程下载服务...",{icon:16,time:0,shade:[0.3,"#000"]});request_plugin("idown","server_stop",{},function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("关闭远程下载服务成功",{icon:1})}else{layer.close(loadT);layer.msg("关闭远程下载服务失败"+rdata["mes"],{icon:5})}})}else{var loadT=layer.msg("正在启动远程下载服务...",{icon:16,time:0,shade:[0.3,"#000"]});request_plugin("idown","server_start",{},function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("启动远程下载服务成功",{icon:1})}else{layer.close(loadT);layer.msg("启动远程下载服务失败"+rdata["mes"],{icon:5})}})}},hide_placeholder:function(){$("#download_textarea_placeholder").hide();console.log("隐藏下载地址的遮罩层")},button_start:function(button){var loadT=layer.msg("正在启动任务...",{icon:16,time:0,shade:[0.3,"#000"]});var gid=button.getAttribute("gid");var post="gid="+gid;request_plugin("idown","download_start_alone",post,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("启动任务成功...",{icon:1});idown.get_down_active()}else{layer.close(loadT);layer.msg("启动任务失败..."+rdata["mes"],{icon:5})}})},button_pause:function(button){var loadT=layer.msg("正在删除任务...",{icon:16,time:0,shade:[0.3,"#000"]});var gid=button.getAttribute("gid");var post="gid="+gid;request_plugin("idown","download_pause_alone",post,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("删除任务成功...",{icon:1});idown.get_down_active()}else{layer.close(loadT);layer.msg("删除任务失败..."+rdata["mes"],{icon:5})}})},button_del_downing:function(button){var loadT=layer.msg("正在删除任务...",{icon:16,time:0,shade:[0.3,"#000"]});var gid=button.getAttribute("gid");var post="gid="+gid;request_plugin("idown","download_del_doing_alone",post,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("删除任务成功...",{icon:1});idown.get_down_active()}else{layer.close(loadT);layer.msg("删除任务失败..."+rdata["mes"],{icon:5})}})},button_del_over:function(button,file){var loadT=layer.msg("正在启动任务...",{icon:16,time:0,shade:[0.3,"#000"]});var gid=button.getAttribute("gid");var action;if(file==0){action="deldown"}else{action="delfile"}var post={gid:gid,delaction:action};request_plugin("idown","download_del_over_alone",post,function(rdata){if(rdata["server_result"]=="success"){layer.close(loadT);layer.msg("删除任务成功...",{icon:1});idown.get_down_stop()}else{layer.close(loadT);layer.msg("删除任务失败..."+rdata["mes"],{icon:5})}})},};function request_plugin(plugin_name,function_name,args,callback,isfile,timeout){if(!timeout){timeout=3600}if(!isfile){$.ajax({type:"POST",url:"/plugin?action=a&s="+function_name+"&name="+plugin_name,data:args,timeout:timeout,success:function(rdata){if(!callback){layer.msg(rdata.msg,{icon:rdata.status?1:2});return}return callback(rdata)},error:function(ex){if(!callback){layer.msg("请求过程发现错误!",{icon:2});return}return callback(ex)}})}else{$.ajax({type:"POST",url:"/plugin?action=a&s="+function_name+"&name="+plugin_name,data:args,timeout:timeout,cache:false,processData:false,contentType:false,success:function(rdata){if(!callback){layer.msg(rdata.msg,{icon:rdata.status?1:2});return}return callback(rdata)},error:function(ex){if(!callback){layer.msg("请求过程发现错误!",{icon:2});
-return}return callback(ex)}})}}function count_array(o){var t=typeof o;if(t=="string"){return o.length}else{if(t=="object"){var n=0;for(var i in o){n++}return n}}return false}function getsize(size,num){if(size<=1048576){size=(size/1024).toFixed(num)+"KB"}else{if(size>=1048576&&size<1073741824){size=(size/1048576).toFixed(num)+"MB"}else{if(size>=1073741824){size=(size/1073741824).toFixed(num)+"GB"}}}return size}idown.get_down_index();setInterval("idown.get_down_index()",2000);setInterval("idown.get_down_active()",2000);setInterval("idown.get_down_stop()",2000);
\ No newline at end of file
diff --git a/BTPanel/static/js/soft.js b/BTPanel/static/js/soft.js
index 9249b5b5..225c90fc 100644
--- a/BTPanel/static/js/soft.js
+++ b/BTPanel/static/js/soft.js
@@ -572,9 +572,16 @@ var soft = {
bt.soft.get_soft_find('apache', function (rdata) {
if (rdata.setup) {
if (rdata.version.indexOf('2.2') >= 0) {
- $(".apache24").hide();
- $(".bt_server").remove();
- $(".bt-w-menu p:eq(0)").trigger("click");
+ if (name.indexOf('php-') != -1) {
+ $(".apache24").hide();
+ $(".bt_server").remove();
+ $(".bt-w-menu p:eq(0)").trigger("click");
+ }
+
+ if (name.indexOf('apache') != -1) {
+ $(".bt-soft-menu p:eq(3)").remove()
+ $(".bt-soft-menu p:eq(3)").remove()
+ }
}
}
})
diff --git a/BTPanel/templates/default/config.html b/BTPanel/templates/default/config.html
index 66409f0c..b551225e 100644
--- a/BTPanel/templates/default/config.html
+++ b/BTPanel/templates/default/config.html
@@ -55,6 +55,7 @@ {{data['lan']['C1']}}
并发线程除非每秒有超过10人访问面板,建议值不要超过2,注意:>1时会导致宝塔终端插件异常
超时时间秒, 若用户在{{data['session_timeout']}}秒内没有任何操作,将自动退出面板
安全入口{{data['lan']['CY10']}}面板管理入口,设置后只能通过指定安全入口登录面板,如: /www_bt_cn
+ BasicAuth认证配置为面板增加一道基于BasicAuth的认证服务,有效防止面板被扫
{{data['lan']['CT3']}}{{data['lan']['CY3']}}
{{data['lan']['CT4']}}{{data['lan']['CY4']}}
{{data['lan']['CT5']}}{{data['lan']['CY5']}}
diff --git a/class/config.py b/class/config.py
index e95fd7e0..61a4c538 100644
--- a/class/config.py
+++ b/class/config.py
@@ -859,4 +859,35 @@ def set_cli_php_version(self,get):
if is_chattr != -1: public.ExecShell('chattr +i /usr/bin')
return public.returnMsg(True,'设置成功!')
+
+ #获取BasicAuth状态
+ def get_basic_auth_stat(self,get):
+ path = 'config/basic_auth.json'
+ is_install = True
+ if not os.path.exists(path): return {"basic_user":"","basic_pwd":"","open":False,"is_install":is_install}
+ ba_conf = json.loads(public.readFile(path))
+ ba_conf['is_install'] = is_install
+ return ba_conf
+
+ #设置BasicAuth
+ def set_basic_auth(self,get):
+ is_open = False
+ if get.open == 'True': is_open = True
+ tips = '_bt.cn'
+ path = 'config/basic_auth.json'
+ ba_conf = None
+ if os.path.exists(path):
+ ba_conf = json.loads(public.readFile(path))
+
+ if not ba_conf:
+ ba_conf = {"basic_user":public.md5(get.basic_user.strip() + tips),"basic_pwd":public.md5(get.basic_pwd.strip() + tips),"open":is_open}
+ else:
+ if get.basic_user: ba_conf['basic_user'] = public.md5(get.basic_user.strip() + tips)
+ if get.basic_pwd: ba_conf['basic_pwd'] = public.md5(get.basic_pwd.strip() + tips)
+ ba_conf['open'] = is_open
+
+ public.writeFile(path,json.dumps(ba_conf))
+ os.chmod(path,384)
+ public.writeFile('data/reload.pl','True')
+ return public.returnMsg(True,"设置成功!")
\ No newline at end of file
diff --git a/class/panelPlugin.py b/class/panelPlugin.py
index b6107aac..684e3892 100644
--- a/class/panelPlugin.py
+++ b/class/panelPlugin.py
@@ -603,8 +603,9 @@ def check_status(self,softInfo):
self.get_icon(softInfo['name'])
if softInfo['name'].find('php-') != -1:
v2= softInfo['versions'][0]['m_version'].replace('.','')
- softInfo['fpm'] = os.path.exists('/etc/init.d/php-fpm-' + v2)
+ softInfo['fpm'] = os.path.exists('/www/server/php/' + v2 + '/sbin/php-fpm')
softInfo['status'] = os.path.exists('/tmp/php-cgi-'+v2+'.sock')
+ if not softInfo['fpm']: softInfo['status'] = True
if softInfo['name'] == 'mysql': softInfo['status'] = self.process_exists('mysqld')
if softInfo['name'] == 'phpmyadmin': softInfo['status'] = self.get_phpmyadmin_stat()
return softInfo
diff --git a/class/plugin_deployment.py b/class/plugin_deployment.py
index 2c033b26..98b37734 100644
--- a/class/plugin_deployment.py
+++ b/class/plugin_deployment.py
@@ -308,7 +308,7 @@ def SetupPackage(self,get):
#执行额外shell进行依赖安装
self.WriteLogs(json.dumps({'name':'执行额外SHELL','total':0,'used':0,'pre':0,'speed':0}));
if os.path.exists(path+'/install.sh'):
- os.system('cd '+path+' && bash ' + 'install.sh ' + find['name']);
+ os.system('cd '+path+' && bash ' + 'install.sh ' + find['name'] + " &> install.log");
os.system('rm -f ' + path+'/install.sh')
#是否执行Composer
@@ -369,6 +369,7 @@ def SetupPackage(self,get):
public.writeFile(siteConfigFile,siteConfig)
#清理文件和目录
+ self.WriteLogs(json.dumps({'name':'清理多余的文件','total':0,'used':0,'pre':0,'speed':0}));
for f_path in pinfo['remove_file']:
filename = (path + '/' + f_path).replace('//','/')
if os.path.exists(filename):
diff --git a/class/public.py b/class/public.py
index 211b4cb4..954c6450 100644
--- a/class/public.py
+++ b/class/public.py
@@ -1211,4 +1211,16 @@ def write_request_log():
log_data['uri'] = request.full_path
log_data['user-agent'] = request.headers.get('User-Agent')
WriteFile(log_path + '/' + log_file,json.dumps(log_data) + "\n",'a+')
- except: pass
\ No newline at end of file
+ except: pass
+
+#重载模块
+def mod_reload(mode):
+ if not mode: return False
+ try:
+ if sys.version_info[0] == 2:
+ reload(mode)
+ else:
+ import imp
+ imp.reload(module)
+ return True
+ except: return False
\ No newline at end of file
diff --git a/tools.py b/tools.py
index da7fad71..62706ac9 100644
--- a/tools.py
+++ b/tools.py
@@ -414,14 +414,15 @@ def bt_cli(u_input = 0):
print("(6) 修改面板用户名 (13) 取消IP访问限制")
print("(7) 强制修改MySQL密码 (14) 查看面板默认信息")
print("(22) 显示面板错误日志 (15) 清理系统垃圾")
- print("(0) 取消 (16) 修复面板(检查错误并更新面板文件到最新版)")
+ print("(23) 关闭BasicAuth认证 (16) 修复面板(检查错误并更新面板文件到最新版)")
+ print("(0) 取消 ")
print(raw_tip)
try:
u_input = input("请输入命令编号:")
if sys.version_info[0] == 3: u_input = int(u_input)
except: u_input = 0
- nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22]
+ nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23]
if not u_input in nums:
print(raw_tip)
print("已取消!")
@@ -533,8 +534,11 @@ def bt_cli(u_input = 0):
os.system("curl http://download.bt.cn/install/update6.sh|bash")
elif u_input == 22:
os.system('tail -100 /www/server/panel/logs/error.log')
-
-
+ elif u_input == 23:
+ filename = '/www/server/panel/config/basic_auth.json'
+ if os.path.exists(filename): os.remove(filename)
+ os.system('bt reload')
+ print("|-已关闭BasicAuth认证")