mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
+12
-14
@@ -100,13 +100,12 @@ setup.init_db_system()
|
||||
|
||||
|
||||
app.config['BASIC_AUTH_OPEN'] = False
|
||||
with app.app_context():
|
||||
try:
|
||||
basic_auth = model.getOptionByJson('basic_auth', default={'open':False})
|
||||
if basic_auth['open']:
|
||||
app.config['BASIC_AUTH_OPEN'] = True
|
||||
except Exception as e:
|
||||
pass
|
||||
try:
|
||||
basic_auth = model.getOptionByJson('basic_auth', default={'open':False})
|
||||
if basic_auth['open']:
|
||||
app.config['BASIC_AUTH_OPEN'] = True
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +126,7 @@ def sendAuthenticated():
|
||||
|
||||
@app.before_request
|
||||
def requestCheck():
|
||||
config.APP_START_TIME=time.time()
|
||||
# 自定义basic auth认证
|
||||
if app.config['BASIC_AUTH_OPEN']:
|
||||
basic_auth = model.getOptionByJson('basic_auth', default={'open':False})
|
||||
@@ -152,6 +152,8 @@ def requestCheck():
|
||||
def requestAfter(response):
|
||||
response.headers['soft'] = config.APP_NAME
|
||||
response.headers['mw-version'] = config.APP_VERSION
|
||||
if mw.isDebugMode():
|
||||
response.headers['mw-debug-cos'] = time.time() - config.APP_START_TIME
|
||||
return response
|
||||
|
||||
|
||||
@@ -163,20 +165,16 @@ def page_unauthorized(error):
|
||||
# 设置模板全局变量
|
||||
@app.context_processor
|
||||
def inject_global_variables():
|
||||
start_t = time.time()
|
||||
ver = config.APP_VERSION;
|
||||
app_ver = config.APP_VERSION
|
||||
if mw.isDebugMode():
|
||||
ver = ver + str(time.time())
|
||||
app_ver = app_ver + str(time.time())
|
||||
|
||||
data = utils_config.getGlobalVar()
|
||||
g_config = {
|
||||
'version': ver,
|
||||
'version': app_ver,
|
||||
'title' : 'MW面板',
|
||||
'ip' : '127.0.0.1'
|
||||
}
|
||||
|
||||
end_t = time.time()
|
||||
print("cos:"+str(end_t-start_t))
|
||||
return dict(config=g_config, data=data)
|
||||
|
||||
|
||||
|
||||
@@ -23,40 +23,82 @@ blueprint = Blueprint('crontab', __name__, url_prefix='/crontab', template_folde
|
||||
def index():
|
||||
return render_template('crontab.html')
|
||||
|
||||
# 插件列表
|
||||
@blueprint.route('/list', endpoint='list', methods=['GET','POST'])
|
||||
# 计划任务列表
|
||||
@blueprint.route('/list', endpoint='list', methods=['POST'])
|
||||
@panel_login_required
|
||||
def list():
|
||||
page = request.args.get('p', '1').strip()
|
||||
limit = request.args.get('limit', '10').strip()
|
||||
return MwCrontab.instance().getCrontabList(page=int(page),size=int(limit))
|
||||
|
||||
# 插件列表
|
||||
@blueprint.route('/logs', endpoint='logs', methods=['GET','POST'])
|
||||
def logs(self):
|
||||
sid = request.form.get('id', '')
|
||||
echo = mw.M('crontab').where("id=?", (sid,)).field('echo').find()
|
||||
logFile = mw.getServerDir() + '/cron/' + echo['echo'] + '.log'
|
||||
if not os.path.exists(logFile):
|
||||
return mw.returnData(False, '当前日志为空!')
|
||||
log = mw.getLastLine(logFile, 500)
|
||||
return mw.returnData(True, log)
|
||||
# 计划任务日志
|
||||
@blueprint.route('/logs', endpoint='logs', methods=['POST'])
|
||||
def logs():
|
||||
cron_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().cronLog(cron_id)
|
||||
|
||||
# 获取计划任务
|
||||
@blueprint.route('/del', endpoint='del', methods=['GET','POST'])
|
||||
# 删除计划任务
|
||||
@blueprint.route('/del', endpoint='del', methods=['POST'])
|
||||
def crontab_del():
|
||||
task_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().delete(task_id)
|
||||
cron_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().delete(cron_id)
|
||||
|
||||
# 删除计划任务日志
|
||||
@blueprint.route('/del_logs', endpoint='del_logs', methods=['POST'])
|
||||
def del_logs():
|
||||
cron_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().delLogs(cron_id)
|
||||
|
||||
|
||||
# 设置计划任务状态
|
||||
@blueprint.route('/set_cron_status', endpoint='set_cron_status', methods=['POST'])
|
||||
def set_cron_status():
|
||||
cron_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().setCronStatus(cron_id)
|
||||
|
||||
# 设置计划任务状态
|
||||
@blueprint.route('/get_data_list', endpoint='get_data_list', methods=['POST'])
|
||||
def get_data_list():
|
||||
stype = request.form.get('type', '')
|
||||
return MwCrontab.instance().getDataList(stype)
|
||||
|
||||
|
||||
# 获取计划任务
|
||||
@blueprint.route('/get_crond_find', endpoint='get_crond_find', methods=['GET','POST'])
|
||||
@blueprint.route('/get_crond_find', endpoint='get_crond_find', methods=['POST'])
|
||||
def get_crond_find():
|
||||
sid = request.form.get('id', '')
|
||||
data = MwCrontab.instance().getCrondFind(sid)
|
||||
cron_id = request.form.get('id', '')
|
||||
data = MwCrontab.instance().getCrondFind(cron_id)
|
||||
return data
|
||||
|
||||
# 修改计划任务
|
||||
@blueprint.route('/modify_crond', endpoint='modify_crond', methods=['POST'])
|
||||
def modify_crond():
|
||||
request_data = {}
|
||||
|
||||
request_data['name'] = request.form.get('name', '')
|
||||
request_data['type'] = request.form.get('type', '')
|
||||
request_data['week'] = request.form.get('week', '')
|
||||
request_data['where1'] = request.form.get('where1', '')
|
||||
request_data['hour'] = request.form.get('hour', '')
|
||||
request_data['minute'] = request.form.get('minute', '')
|
||||
request_data['save'] = request.form.get('save', '')
|
||||
request_data['backup_to'] = request.form.get('backupTo', '')
|
||||
request_data['stype'] = request.form.get('stype', '')
|
||||
request_data['sname'] = request.form.get('sname', '')
|
||||
request_data['sbody'] = request.form.get('sbody', '')
|
||||
request_data['url_address'] = request.form.get('urladdress', '')
|
||||
cron_id = request.form.get('id', '')
|
||||
data = MwCrontab.instance().modifyCrond(cron_id,request_data)
|
||||
return data
|
||||
|
||||
# 执行计划任务
|
||||
@blueprint.route('/start_task', endpoint='start_task', methods=['POST'])
|
||||
def start_task():
|
||||
cron_id = request.form.get('id', '')
|
||||
return MwCrontab.instance().startTask(cron_id)
|
||||
|
||||
# 添加计划任务
|
||||
@blueprint.route('/add', endpoint='add', methods=['GET','POST'])
|
||||
@blueprint.route('/add', endpoint='add', methods=['POST'])
|
||||
@panel_login_required
|
||||
def add():
|
||||
request_data = {}
|
||||
|
||||
@@ -33,25 +33,7 @@ def index():
|
||||
def get_list():
|
||||
p = request.form.get('p', '1').strip()
|
||||
limit = request.form.get('limit', '10').strip()
|
||||
|
||||
count = Firewall.query.filter_by().count()
|
||||
pagination = Firewall.query.filter_by().paginate(page=int(p), per_page=int(limit))
|
||||
|
||||
rows = []
|
||||
for item in pagination.items:
|
||||
t = {}
|
||||
t['id'] = item.id
|
||||
t['port'] = item.port
|
||||
t['protocol'] = item.protocol
|
||||
t['ps'] = item.ps
|
||||
t['add_time'] = item.add_time
|
||||
t['update_time'] = item.update_time
|
||||
rows.append(t)
|
||||
|
||||
data = {}
|
||||
data['data'] = rows
|
||||
data['page'] = mw.getPage({'count':count,'tojs':'getLogs','p':p,'row':limit})
|
||||
return data
|
||||
return MwFirewall.instance().getList(p,limit)
|
||||
|
||||
# 获取站点日志目录
|
||||
@blueprint.route('/get_www_path', endpoint='get_www_path', methods=['POST'])
|
||||
@@ -64,8 +46,7 @@ def get_www_path():
|
||||
@blueprint.route('/get_ssh_info', endpoint='get_ssh_info', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_ssh_info():
|
||||
mf = MwFirewall.instance()
|
||||
return mf.getSshInfo()
|
||||
return MwFirewall.instance().getSshInfo()
|
||||
|
||||
|
||||
# 切换ping开关
|
||||
@@ -88,8 +69,7 @@ def add_accept_port():
|
||||
protocol = request.form.get('protocol', '').strip()
|
||||
stype = request.form.get('type', '').strip()
|
||||
|
||||
data = mf.addAcceptPort(port, ps, stype, protocol=protocol)
|
||||
return mw.getJson(data)
|
||||
return mf.addAcceptPort(port, ps, stype, protocol=protocol)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user