pull/632/head
Mr Chen 5 months ago
parent 1da7d08887
commit d00da44fcb
  1. 18
      panel_tools.py
  2. 6
      scripts/init.d/mw.tpl
  3. 7
      web/admin/__init__.py
  4. 18
      web/admin/dashboard/login.py
  5. 4
      web/admin/setting/setting.py

@ -57,6 +57,8 @@ def mwcli(mw_input=0):
print("(11) 修改面板密码") print("(11) 修改面板密码")
print("(12) 修改面板用户名") print("(12) 修改面板用户名")
print("(13) 显示面板错误日志") print("(13) 显示面板错误日志")
print("(14) 关闭面板访问")
print("(15) 开启面板访问")
print("(20) 关闭BasicAuth认证") print("(20) 关闭BasicAuth认证")
print("(21) 解除域名绑定") print("(21) 解除域名绑定")
print("(22) 解除面板SSL绑定") print("(22) 解除面板SSL绑定")
@ -80,7 +82,7 @@ def mwcli(mw_input=0):
mw_input = 0 mw_input = 0
nums = [ nums = [
1, 2, 3, 4, 5, 10, 11, 12, 13, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15,
20, 21, 22, 23, 24, 25, 26, 27, 28, 20, 21, 22, 23, 24, 25, 26, 27, 28,
100, 101, 100, 101,
200, 201 200, 201
@ -123,6 +125,20 @@ def mwcli(mw_input=0):
set_panel_username(input_user.strip()) set_panel_username(input_user.strip())
elif mw_input == 13: elif mw_input == 13:
os.system('tail -100 ' + panel_dir + '/logs/panel_error.log') os.system('tail -100 ' + panel_dir + '/logs/panel_error.log')
elif mw_input == 14:
admin_close = thisdb.getOption('admin_close')
if admin_close == 'no':
thisdb.setOption('admin_close', 'yes')
print("|-关闭面板访问成功!")
else:
print("|-已关闭面板访问!")
elif mw_input == 15:
admin_close = thisdb.getOption('admin_close')
if admin_close == 'yes':
thisdb.setOption('admin_close', 'no')
print("|-开启面板访问成功!")
else:
print("|-已开启面板访问!")
elif mw_input == 20: elif mw_input == 20:
basic_auth = thisdb.getOptionByJson('basic_auth', default={'open':False}) basic_auth = thisdb.getOptionByJson('basic_auth', default={'open':False})
if basic_auth['open']: if basic_auth['open']:

@ -206,14 +206,12 @@ mw_reload()
} }
mw_close(){ mw_close(){
echo 'True' > ${PANEL_DIR}/data/close.pl cd ${PANEL_DIR} && python3 panel_tools.py cli 14
} }
mw_open() mw_open()
{ {
if [ -f ${PANEL_DIR}/data/close.pl ];then cd ${PANEL_DIR} && python3 panel_tools.py cli 15
rm -rf ${PANEL_DIR}/data/close.pl
fi
} }
mw_unbind_domain() mw_unbind_domain()

@ -19,6 +19,7 @@ from datetime import timedelta
from flask import Flask from flask import Flask
from flask import request from flask import request
from flask import redirect
from flask import Response from flask import Response
from flask import Flask, abort, current_app, session, url_for from flask import Flask, abort, current_app, session, url_for
from flask import Blueprint, render_template from flask import Blueprint, render_template
@ -93,6 +94,12 @@ def sendAuthenticated():
@app.before_request @app.before_request
def requestCheck(): def requestCheck():
admin_close = thisdb.getOption('admin_close')
if admin_close == 'yes':
if not request.path.startswith('/close'):
return redirect('/close')
config.APP_START_TIME=time.time() config.APP_START_TIME=time.time()
# 自定义basic auth认证 # 自定义basic auth认证
if app.config['BASIC_AUTH_OPEN']: if app.config['BASIC_AUTH_OPEN']:

@ -88,6 +88,7 @@ def login_temp_user(token):
# 登录页: 当设置了安全路径,本页失效。 # 登录页: 当设置了安全路径,本页失效。
@blueprint.route('/login') @blueprint.route('/login')
def login(): def login():
name = thisdb.getOption('template', default='default')
# 临时登录功能 # 临时登录功能
token = request.args.get('tmp_token', '').strip() token = request.args.get('tmp_token', '').strip()
@ -103,13 +104,22 @@ def login():
db_path = thisdb.getOption('admin_path') db_path = thisdb.getOption('admin_path')
if db_path == '': if db_path == '':
return render_template('default/login.html') return render_template('%s/login.html' % name)
else: else:
unauthorized_status = thisdb.getOption('unauthorized_status') unauthorized_status = thisdb.getOption('unauthorized_status')
if unauthorized_status == '0': if unauthorized_status == '0':
return render_template('default/path.html') return render_template('%s/path.html' % name)
return Response(status=int(unauthorized_status)) return Response(status=int(unauthorized_status))
@blueprint.route('/close')
def close():
name = thisdb.getOption('template', default='default')
admin_close = thisdb.getOption('admin_close')
if admin_close == 'no':
return redirect('/', code=302)
return render_template('%s/close.html' % name)
# 验证码 # 验证码
@blueprint.route('/code') @blueprint.route('/code')
def code(): def code():
@ -179,7 +189,7 @@ def do_login():
if login_cache_limit >= login_cache_count: if login_cache_limit >= login_cache_count:
thisdb.setOption('admin_close', 'yes') thisdb.setOption('admin_close', 'yes')
return mw.returnJson(False, '面板已经关闭!') return mw.returnData(False, '面板已经关闭!')
cache.set('login_cache_limit', login_cache_limit, timeout=10000) cache.set('login_cache_limit', login_cache_limit, timeout=10000)
login_cache_limit = cache.get('login_cache_limit') login_cache_limit = cache.get('login_cache_limit')
@ -218,4 +228,4 @@ def do_login():
session['overdue'] = int(time.time()) + 7 * 24 * 60 * 60 session['overdue'] = int(time.time()) + 7 * 24 * 60 * 60
thisdb.updateUserLoginTime() thisdb.updateUserLoginTime()
return mw.returnJson(1, '登录成功,正在跳转...') return mw.returnData(1, '登录成功,正在跳转...')

@ -177,9 +177,9 @@ def close_panel():
admin_close = thisdb.getOption('admin_close',default='no') admin_close = thisdb.getOption('admin_close',default='no')
if admin_close == 'no': if admin_close == 'no':
thisdb.setOption('admin_close','yes') thisdb.setOption('admin_close','yes')
return mw.returnData(True, '开启面板成功!')
thisdb.setOption('admin_close','no')
return mw.returnData(True, '关闭面板成功!') return mw.returnData(True, '关闭面板成功!')
thisdb.setOption('admin_close','no')
return mw.returnData(True, '开启面板成功!')
# 设置IPV6状态 # 设置IPV6状态
@blueprint.route('/set_ipv6_status', endpoint='set_ipv6_status', methods=['POST']) @blueprint.route('/set_ipv6_status', endpoint='set_ipv6_status', methods=['POST'])

Loading…
Cancel
Save