From 6cc3ce7f0595091dc6dc8cbab6773b08577c770e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 21 Feb 2019 23:05:09 +0800 Subject: [PATCH] update --- .gitignore | 1 + class/core/common.py | 11 +++++++++++ class/core/config_api.py | 4 ++++ class/core/plugins_api.py | 1 + route/__init__.py | 11 ++++++++++- route/static/app/config.js | 5 +++++ route/templates/default/close.html | 13 +++++++++++++ 7 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 route/templates/default/close.html diff --git a/.gitignore b/.gitignore index bba9efecb..6a929076a 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,4 @@ data/json/index.json data/json/config.json data/site.pl data/admin_path.pl +data/close.pl diff --git a/class/core/common.py b/class/core/common.py index 4c4effdd4..668147f36 100755 --- a/class/core/common.py +++ b/class/core/common.py @@ -16,13 +16,24 @@ from random import Random import public import db +from flask import redirect + def init(): + + checkClose() + initDB() initInitD() initUserInfo() +# 检查面板是否关闭 +def checkClose(): + if os.path.exists('data/close.pl'): + return redirect('/close') + + def initDB(): try: sql = db.Sql().dbfile('default') diff --git a/class/core/config_api.py b/class/core/config_api.py index aff1d8065..74c37dc5a 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -144,6 +144,10 @@ class config_api: public.execShell("chown root.root " + filename) return public.returnJson(True, '面板已关闭!') + def getApi(self): + data = {} + + return public.getJson(data) ##### ----- end ----- ### def getVersion(self): diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 90f6a0823..d31fe71ea 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -683,6 +683,7 @@ class plugins_api: if not os.path.exists(path): return ('', '') data = public.execShell(py_cmd) + # data = os.popen(py_cmd).read() if public.isAppleSystem(): print py_cmd diff --git a/route/__init__.py b/route/__init__.py index 189bcc7e7..97aba6fdf 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -112,6 +112,15 @@ def test(): return public.getLocalIp() +@app.route('/close') +def close(): + if not os.path.exists('data/close.pl'): + return redirect('/') + data = {} + data['cmd'] = 'rm -rf ' + public.getRunDir() + '/data/close.pl' + return render_template('close.html', data=data) + + @app.route("/code") def code(): import vilidate @@ -140,7 +149,7 @@ def checkLogin(): @app.route("/login") def login(): - print session + # print session dologin = request.args.get('dologin', '') if dologin == 'True': session.clear() diff --git a/route/static/app/config.js b/route/static/app/config.js index 9383b3cde..b26357f58 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -1,4 +1,9 @@ +$.post('/config/get','',function(rdata){ + console.log(rdata); +},'json'); + + $(".set-submit").click(function(){ var data = $("#set_config").serialize(); layer.msg('正在保存配置...',{icon:16,time:0,shade: [0.3, '#000']}); diff --git a/route/templates/default/close.html b/route/templates/default/close.html new file mode 100755 index 000000000..de6e90fb9 --- /dev/null +++ b/route/templates/default/close.html @@ -0,0 +1,13 @@ + + + + + 抱歉,管理员已关闭面板 + + +

开启命令

+

{{data['cmd']}}

+
+ + + \ No newline at end of file