From a593e2b8e09325c0d1f704da7e2aeeff08bc15fb Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Mon, 28 Oct 2024 03:13:10 +0800 Subject: [PATCH] update --- class/core/mw.py | 5 +- panel_task.py | 156 ++++++++++-------- plugins/simpleping/index.py | 2 +- web/admin/__init__.py | 18 +- web/admin/logs/__init__.py | 2 +- web/admin/model/__init__.py | 1 + web/admin/model/initdb.py | 8 +- web/admin/model/task.py | 19 +++ web/admin/{control => monitor}/__init__.py | 4 +- web/admin/{config => setting}/__init__.py | 13 +- web/admin/submodules.py | 8 +- web/app.py | 8 +- web/{setting.py => config.py} | 0 web/core/mw.py | 10 +- web/static/app/config.js | 62 +++---- web/templates/default/layout.html | 4 +- .../default/{control.html => monitor.html} | 0 .../default/{config.html => setting.html} | 0 18 files changed, 185 insertions(+), 135 deletions(-) create mode 100644 web/admin/model/task.py rename web/admin/{control => monitor}/__init__.py (85%) rename web/admin/{config => setting}/__init__.py (71%) rename web/{setting.py => config.py} (100%) rename web/templates/default/{control.html => monitor.html} (100%) rename web/templates/default/{config.html => setting.html} (100%) diff --git a/class/core/mw.py b/class/core/mw.py index 5925c5fec..a4441260e 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -593,8 +593,11 @@ def writeLog(stype, msg, args=()): if 'uid' in session: uid = session['uid'] except Exception as e: - pass + print('writeL:',e) + # pass # writeFileLog(getTracebackInfo()) + + print(stype, msg) return writeDbLog(stype, msg, args, uid) diff --git a/panel_task.py b/panel_task.py index ca3b86915..363276993 100755 --- a/panel_task.py +++ b/panel_task.py @@ -28,9 +28,13 @@ web_dir = os.getcwd() + "/web" os.chdir(web_dir) sys.path.append(web_dir) +from admin import app +from admin import model + import core.mw as mw import core.db as db + print(mw.getPanelDir()) # print sys.path @@ -47,18 +51,18 @@ timeoutCount = 0 isCheck = 0 oldEdate = None -logPath = os.getcwd() + '/tmp/panelExec.log' -isTask = os.getcwd() + '/tmp/panelTask.pl' +g_log_file = mw.getMWLogs() + '/panelExec.log' +isTask = mw.getMWLogs() + '/panelTask.pl' if not os.path.exists(os.getcwd() + "/tmp"): os.system('mkdir -p ' + os.getcwd() + "/tmp") -if not os.path.exists(logPath): - os.system("touch " + logPath) +if not os.path.exists(g_log_file): + os.system("touch " + g_log_file) def execShell(cmdstring, cwd=None, timeout=None, shell=True): try: - global logPath + global g_log_file import shlex import datetime import subprocess @@ -66,9 +70,8 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True): if timeout: end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout) - cmd = cmdstring + ' > ' + logPath + ' 2>&1' - sub = subprocess.Popen( - cmd, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096) + cmd = cmdstring + ' > ' + g_log_file + ' 2>&1' + sub = subprocess.Popen(cmd, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096) while sub.poll() is None: time.sleep(0.1) @@ -140,14 +143,12 @@ def downloadFile(url, filename): import socket socket.setdefaulttimeout(300) - headers = ( - 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36') + headers = ('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36') opener = urllib.request.build_opener() opener.addheaders = [headers] urllib.request.install_opener(opener) - urllib.request.urlretrieve( - url, filename=filename, reporthook=downloadHook) + urllib.request.urlretrieve(url, filename=filename, reporthook=downloadHook) if not mw.isAppleSystem(): os.system('chown www.www ' + filename) @@ -155,6 +156,7 @@ def downloadFile(url, filename): writeLogs('done') except Exception as e: writeLogs(str(e)) + return True def downloadHook(count, blockSize, totalSize): @@ -168,61 +170,66 @@ def downloadHook(count, blockSize, totalSize): writeLogs(json.dumps(speed)) -def writeLogs(logMsg): +def writeLogs(data): # 写输出日志 try: - global logPath - fp = open(logPath, 'w+') - fp.write(logMsg) + fp = open(g_log_file, 'w+') + fp.write(data) fp.close() except: pass def runTask(): - global isTask - try: - if os.path.exists(isTask): - sql = db.Sql() - sql.table('tasks').where( - "status=?", ('-1',)).setField('status', '0') - taskArr = sql.table('tasks').where("status=?", ('0',)).field( - 'id,type,execstr').order("id asc").select() - for value in taskArr: - start = int(time.time()) - if not sql.table('tasks').where("id=?", (value['id'],)).count(): - continue - sql.table('tasks').where("id=?", (value['id'],)).save( - 'status,start', ('-1', start)) - if value['type'] == 'download': - argv = value['execstr'].split('|mw|') - downloadFile(argv[0], argv[1]) - elif value['type'] == 'execshell': - execShell(value['execstr']) - end = int(time.time()) - sql.table('tasks').where("id=?", (value['id'],)).save( - 'status,end', ('1', end)) - - if(sql.table('tasks').where("status=?", ('0')).count() < 1): - os.system('rm -f ' + isTask) - - sql.close() - except Exception as e: - print(str(e)) + + + mw.writeLog("后台任务", "运行") + + print(model.getTaskCount()) + # global isTask + # try: + + # if os.path.exists(isTask): + # sql = db.Sql() + # sql.table('tasks').where( + # "status=?", ('-1',)).setField('status', '0') + # taskArr = sql.table('tasks').where("status=?", ('0',)).field( + # 'id,type,execstr').order("id asc").select() + # for value in taskArr: + # start = int(time.time()) + # if not sql.table('tasks').where("id=?", (value['id'],)).count(): + # continue + # sql.table('tasks').where("id=?", (value['id'],)).save('status,start', ('-1', start)) + # if value['type'] == 'download': + # argv = value['execstr'].split('|mw|') + # downloadFile(argv[0], argv[1]) + # elif value['type'] == 'execshell': + # execShell(value['execstr']) + # end = int(time.time()) + # sql.table('tasks').where("id=?", (value['id'],)).save( + # 'status,end', ('1', end)) + + # if(sql.table('tasks').where("status=?", ('0')).count() < 1): + # os.system('rm -f ' + isTask) + + # sql.close() + # except Exception as e: + # print(str(e)) # 站点过期检查 - siteEdate() + # siteEdate() -def startTask(): +def startPanelTask(): # 任务队列 try: while True: runTask() - time.sleep(2) + time.sleep(1) except Exception as e: - time.sleep(60) - startTask() + print(str(e)) + time.sleep(10) + startPanelTask() def siteEdate(): @@ -605,33 +612,38 @@ def setDaemon(t): t.setDaemon(True) return t -if __name__ == "__main__": +def run(): + # # 系统监控 + # sysTask = threading.Thread(target=systemTask) + # sysTask = setDaemon(sysTask) + # sysTask.start() - # 系统监控 - sysTask = threading.Thread(target=systemTask) - sysTask = setDaemon(sysTask) - sysTask.start() + # # PHP 502错误检查线程 + # php502 = threading.Thread(target=check502Task) + # php502 = setDaemon(php502) + # php502.start() - # PHP 502错误检查线程 - php502 = threading.Thread(target=check502Task) - php502 = setDaemon(php502) - php502.start() + # # OpenResty Restart At Once Start + # oraos = threading.Thread(target=openrestyRestartAtOnce) + # oraos = setDaemon(oraos) + # oraos.start() - # OpenResty Restart At Once Start - oraos = threading.Thread(target=openrestyRestartAtOnce) - oraos = setDaemon(oraos) - oraos.start() + # # OpenResty Auto Restart Start + # oar = threading.Thread(target=openrestyAutoRestart) + # oar = setDaemon(oar) + # oar.start() - # OpenResty Auto Restart Start - oar = threading.Thread(target=openrestyAutoRestart) - oar = setDaemon(oar) - oar.start() + # # Panel Restart Start + # rps = threading.Thread(target=restartPanelService) + # rps = setDaemon(rps) + # rps.start() - # Panel Restart Start - rps = threading.Thread(target=restartPanelService) - rps = setDaemon(rps) - rps.start() + # 面板后台任务 + startPanelTask() - startTask() +if __name__ == "__main__": + with app.app_context(): + run() + diff --git a/plugins/simpleping/index.py b/plugins/simpleping/index.py index f27b2b3c2..6565cf2f4 100755 --- a/plugins/simpleping/index.py +++ b/plugins/simpleping/index.py @@ -268,7 +268,7 @@ def runLog(): def ipList(): config = getServerDir() + '/conf/app.conf' content = mw.readFile(config) - rep = 'ip\s*=\s*(.*)' + rep = r'ip\s*=\s*(.*)' tmp = re.search(rep, content) if not tmp: return '' diff --git a/web/admin/__init__.py b/web/admin/__init__.py index ce34a9057..a819cc369 100644 --- a/web/admin/__init__.py +++ b/web/admin/__init__.py @@ -28,7 +28,7 @@ from admin.model import db as sys_db from admin import setup import core.mw as mw -import setting +import config import utils.config as utils_config root_dir = mw.getRunDir() @@ -56,7 +56,7 @@ app.config['SESSION_COOKIE_NAME'] = "MW_VER_1" app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31) # db的配置 -app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+setting.SQLITE_PATH # 使用 SQLite 数据库 +app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+config.SQLITE_PATH # 使用 SQLite 数据库 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True @@ -66,7 +66,7 @@ Migrate(app, sys_db) # 检查数据库是否存在。如果没有就创建它。 setup_db_required = False -if not os.path.isfile(setting.SQLITE_PATH): +if not os.path.isfile(config.SQLITE_PATH): setup_db_required = True # with app.app_context(): @@ -98,8 +98,8 @@ def requestCheck(): @app.after_request def requestAfter(response): - response.headers['soft'] = setting.APP_NAME - response.headers['mw-version'] = setting.APP_VERSION + response.headers['soft'] = config.APP_NAME + response.headers['mw-version'] = config.APP_VERSION return response @@ -111,17 +111,17 @@ def page_unauthorized(error): # 设置模板全局变量 @app.context_processor def inject_global_variables(): - ver = setting.APP_VERSION; + ver = config.APP_VERSION; if mw.isDebugMode(): ver = ver + str(time.time()) data = utils_config.getGlobalVar() - config = { + g_config = { 'version': ver, 'title' : '面板', 'ip' : '127.0.0.1' } - return dict(config=config, data=data) + return dict(config=g_config, data=data) # from flasgger import Swagger @@ -172,7 +172,7 @@ def inject_global_variables(): # Log the startup app.logger.info('########################################################') -app.logger.info('Starting %s v%s...', setting.APP_NAME, setting.APP_VERSION) +app.logger.info('Starting %s v%s...', config.APP_NAME, config.APP_VERSION) app.logger.info('########################################################') app.logger.debug("Python syspath: %s", sys.path) diff --git a/web/admin/logs/__init__.py b/web/admin/logs/__init__.py index 4dc255dab..fa210411b 100644 --- a/web/admin/logs/__init__.py +++ b/web/admin/logs/__init__.py @@ -37,7 +37,7 @@ def get_log_list(): if search != '': pagination = Logs.query.filter_by(Logs.type.like(search) or Logs.log.like(search)).paginate(page=int(p), per_page=int(size)) else: - pagination = Logs.query.filter_by().paginate(page=int(p), per_page=int(size)) + pagination = Logs.query.filter_by().order_by(Logs.id.desc()).paginate(page=int(p), per_page=int(size)) rows = [] for item in pagination.items: diff --git a/web/admin/model/__init__.py b/web/admin/model/__init__.py index ffa69ece7..ebd9c90c4 100644 --- a/web/admin/model/__init__.py +++ b/web/admin/model/__init__.py @@ -13,6 +13,7 @@ from .initdb import * from .logs import addLog from .option import getOption,getOptionByJson,setOption from .sites import getSitesCount +from .task import getTaskCount diff --git a/web/admin/model/initdb.py b/web/admin/model/initdb.py index bbf9e8a3e..3555ed667 100644 --- a/web/admin/model/initdb.py +++ b/web/admin/model/initdb.py @@ -11,15 +11,15 @@ from flask_sqlalchemy import SQLAlchemy # from flask_security import UserMixin, RoleMixin -import setting +import config SCHEMA_VERSION = 1 db = SQLAlchemy( engine_options={ - 'pool_size': setting.CONFIG_DATABASE_CONNECTION_POOL_SIZE, - 'max_overflow': setting.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW + 'pool_size': config.CONFIG_DATABASE_CONNECTION_POOL_SIZE, + 'max_overflow': config.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW } ) @@ -82,7 +82,7 @@ class Logs(db.Model): """定义日志""" __tablename__ = 'logs' id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID") - uid = db.Column(db.Integer(), unique=True, nullable=False, comment="用户ID") + uid = db.Column(db.Integer(), unique=False, nullable=False, comment="用户ID") type = db.Column(db.String(128), unique=False, nullable=False, comment="日志类型") log = db.Column(db.TEXT, unique=False, nullable=True, comment="日志内容") add_time = db.Column(db.TEXT, nullable=False, comment="添加时间") diff --git a/web/admin/model/task.py b/web/admin/model/task.py new file mode 100644 index 000000000..933367f81 --- /dev/null +++ b/web/admin/model/task.py @@ -0,0 +1,19 @@ +# coding:utf-8 + +# --------------------------------------------------------------------------------- +# MW-Linux面板 +# --------------------------------------------------------------------------------- +# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved. +# --------------------------------------------------------------------------------- +# Author: midoks +# --------------------------------------------------------------------------------- + +from admin.model import db, Tasks + + + +def getTaskCount( + status: str | None = None + ) -> int: + + return Tasks.query.filter_by().count() \ No newline at end of file diff --git a/web/admin/control/__init__.py b/web/admin/monitor/__init__.py similarity index 85% rename from web/admin/control/__init__.py rename to web/admin/monitor/__init__.py index 7ca57b102..c8258caef 100644 --- a/web/admin/control/__init__.py +++ b/web/admin/monitor/__init__.py @@ -11,7 +11,7 @@ from flask import Blueprint, render_template -blueprint = Blueprint('control', __name__, url_prefix='/control', template_folder='../../templates/default') +blueprint = Blueprint('monitor', __name__, url_prefix='/monitor', template_folder='../../templates/default') @blueprint.route('/index', endpoint='index') def index(): - return render_template('control.html',) \ No newline at end of file + return render_template('monitor.html',) \ No newline at end of file diff --git a/web/admin/config/__init__.py b/web/admin/setting/__init__.py similarity index 71% rename from web/admin/config/__init__.py rename to web/admin/setting/__init__.py index 5baa4844f..39f6f0784 100644 --- a/web/admin/config/__init__.py +++ b/web/admin/setting/__init__.py @@ -16,10 +16,10 @@ from admin import model import core.mw as mw # 默认页面 -blueprint = Blueprint('config', __name__, url_prefix='/config', template_folder='../../templates') +blueprint = Blueprint('setting', __name__, url_prefix='/setting', template_folder='../../templates') @blueprint.route('/index', endpoint='index') def index(): - return render_template('default/config.html') + return render_template('default/setting.html') @@ -37,3 +37,12 @@ def set_webname(): model.setOption('title', webname) return mw.returnData(True, '面板别名保存成功!') +@blueprint.route('/set_ip', endpoint='set_ip', methods=['POST']) +def set_ip(): + host_ip = request.form.get('host_ip', '') + src_host_ip = model.getOption('server_ip') + if host_ip != src_host_ip: + model.setOption('server_ip', host_ip) + return mw.returnJson(True, 'IP保存成功!') + + \ No newline at end of file diff --git a/web/admin/submodules.py b/web/admin/submodules.py index 29954e7f7..62b7277d8 100644 --- a/web/admin/submodules.py +++ b/web/admin/submodules.py @@ -12,14 +12,14 @@ from .dashboard import blueprint as DashboardModule from .site import blueprint as SiteModule from .task import blueprint as TaskModule -from .config import blueprint as ConfigModule +from .setting import blueprint as SettingModule from .logs import blueprint as LogsModule from .files import blueprint as FilesModule from .soft import blueprint as SoftModule from .plugins import blueprint as PluginsModule from .crontab import blueprint as CrontabModule from .firewall import blueprint as FirewallModule -from .control import blueprint as ControlModule +from .monitor import blueprint as MonitorModule from .system import blueprint as SystemModule def get_submodules(): @@ -33,7 +33,7 @@ def get_submodules(): PluginsModule, CrontabModule, FirewallModule, - ControlModule, + MonitorModule, SystemModule, - ConfigModule, + SettingModule, ] diff --git a/web/app.py b/web/app.py index 1e833ce89..ae86bc4a2 100644 --- a/web/app.py +++ b/web/app.py @@ -22,17 +22,17 @@ if sys.path[0] != os.path.dirname(os.path.realpath(__file__)): # print(sys.path) -import setting +import config from admin import app, socketio -# print(setting.DEFAULT_SERVER,setting.DEFAULT_SERVER_PORT) +# print(config.DEFAULT_SERVER,config.DEFAULT_SERVER_PORT) # app = create_app() def main(): socketio.run( app, - debug=setting.DEBUG, + debug=config.DEBUG, allow_unsafe_werkzeug=True, - host=setting.DEFAULT_SERVER, + host=config.DEFAULT_SERVER, port=7201, ) diff --git a/web/setting.py b/web/config.py similarity index 100% rename from web/setting.py rename to web/config.py diff --git a/web/core/mw.py b/web/core/mw.py index 4968c9b24..77f1eab85 100644 --- a/web/core/mw.py +++ b/web/core/mw.py @@ -310,6 +310,12 @@ def getFileSuffix(file): def getPathSuffix(path): return os.path.splitext(path)[-1] +def getHostAddr(): + ip_text = getPanelDataDir() + '/iplist.txt' + if os.path.exists(ip_text): + return readFile(ip_text).strip() + return '127.0.0.1' + def getSqitePrefix(): WIN = sys.platform.startswith('win') if WIN: # 如果是 Windows 系统,使用三个斜线 @@ -498,13 +504,13 @@ def isNumber(s): def writeLog(stype, msg, args=()): # 写日志 - uid = 1 + uid = 0 try: from flask import session if 'uid' in session: uid = session['uid'] except Exception as e: - print(str(e)) + print("writeLog:"+str(e)) # pass # writeFileLog(getTracebackInfo()) return writeDbLog(stype, msg, args, uid) diff --git a/web/static/app/config.js b/web/static/app/config.js index 31f8b2077..063bb03c4 100755 --- a/web/static/app/config.js +++ b/web/static/app/config.js @@ -17,7 +17,7 @@ $('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){ + $.post('/setting/set_webname','webname='+webname, function(rdata){ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); },'json'); }); @@ -28,7 +28,7 @@ $('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){ + $.post('/setting/set_ip','host_ip='+host_ip, function(rdata){ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); },'json'); }); @@ -39,7 +39,7 @@ $('input[name="port"]').change(function(){ var old_port = $(this).data('port'); $('.btn_port').removeAttr('disabled'); $('.btn_port').unbind().click(function(){ - $.post('/config/set_port','port='+port, function(rdata){ + $.post('/setting/set_port','port='+port, function(rdata){ showMsg(rdata.msg,function(){ window.location.href = window.location.href.replace(old_port,port); // window.location.reload(); @@ -52,7 +52,7 @@ $('input[name="sites_path"]').change(function(){ var sites_path = $(this).val(); $('.btn_sites_path').removeAttr('disabled'); $('.btn_sites_path').unbind().click(function(){ - $.post('/config/set_www_dir','sites_path='+sites_path, function(rdata){ + $.post('/setting/set_www_dir','sites_path='+sites_path, function(rdata){ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); },'json'); }); @@ -63,7 +63,7 @@ $('input[name="backup_path"]').change(function(){ var backup_path = $(this).val(); $('.btn_backup_path').removeAttr('disabled'); $('.btn_backup_path').unbind().click(function(){ - $.post('/config/set_backup_dir','backup_path='+backup_path, function(rdata){ + $.post('/setting/set_backup_dir','backup_path='+backup_path, function(rdata){ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000); },'json'); }); @@ -74,7 +74,7 @@ $('input[name="bind_domain"]').change(function(){ var domain = $(this).val(); $('.btn_bind_domain').removeAttr('disabled'); $('.btn_bind_domain').unbind().click(function(){ - $.post('/config/set_panel_domain','domain='+domain, function(rdata){ + $.post('/setting/set_panel_domain','domain='+domain, function(rdata){ showMsg(rdata.msg,function(){ window.location.href = rdata.data; },{icon:rdata.status?1:2},5000); @@ -126,7 +126,7 @@ $('input[name="bind_ssl"]').click(function(){ yes: function(){ var cert_type = $('select[name=cert_type]').val(); - $.post('/config/set_panel_local_ssl',{'cert_type':cert_type}, function(rdata){ + $.post('/setting/set_panel_local_ssl',{'cert_type':cert_type}, function(rdata){ // console.log(rdata); var to_https = window.location.href.replace('http','https'); showMsg(rdata.msg,function(){ @@ -163,7 +163,7 @@ $('input[name="bind_ssl"]').click(function(){ return; } - $.post('/config/close_panel_ssl',{}, function(rdata){ + $.post('/setting/close_panel_ssl',{}, function(rdata){ var to_http = window.location.href.replace('https','http'); showMsg(rdata.msg,function(){ if (rdata.status){ @@ -234,7 +234,7 @@ function closePanel(){ layer.confirm('关闭面板会导致您无法访问面板 ,您真的要关闭Linux面板吗?',{title:'关闭面板',closeBtn:2,icon:13,cancel:function(){ $("#closePl").prop("checked",false); }}, function() { - $.post('/config/close_panel','',function(rdata){ + $.post('/setting/close_panel','',function(rdata){ layer.msg(rdata.msg,{icon:rdata.status?1:2}); setTimeout(function(){ window.location.reload(); @@ -248,7 +248,7 @@ function closePanel(){ //开发模式 function debugMode(){ var loadT = layer.msg('正在发送请求,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post('/config/open_debug', {}, function (rdata) { + $.post('/setting/open_debug', {}, function (rdata) { layer.close(loadT); showMsg(rdata.msg, function(){ window.location.reload(); @@ -339,7 +339,7 @@ function setPassword(a) { layer.msg('两次输入的密码不一致', {icon: 2}); return; } - $.post("/config/set_password", "password1=" + encodeURIComponent(p1) + "&password2=" + encodeURIComponent(p2), function(b) { + $.post("/setting/set_password", "password1=" + encodeURIComponent(p1) + "&password2=" + encodeURIComponent(p2), function(b) { if(b.status) { layer.closeAll(); layer.msg(b.msg, {icon: 1}); @@ -394,7 +394,7 @@ function setUserName(a) { layer.msg('两次输入的用户名不一致', {icon: 2}); return; } - $.post("/config/set_name", "name1=" + encodeURIComponent(p1) + "&name2=" + encodeURIComponent(p2), function(b) { + $.post("/setting/set_name", "name1=" + encodeURIComponent(p1) + "&name2=" + encodeURIComponent(p2), function(b) { if(b.status) { layer.closeAll(); layer.msg(b.msg, {icon: 1}); @@ -463,7 +463,7 @@ function setTimezone(){ yes:function(index){ var loadT = layer.msg("正在设置时区...", { icon: 16, time: 0, shade: [0.3, '#000'] }); var timezone = $('select[name="timezone"]').val(); - $.post('/config/set_timezone', { timezone: timezone }, function (rdata) { + $.post('/setting/set_timezone', { timezone: timezone }, function (rdata) { showMsg(rdata.msg, function(){ layer.close(index); layer.close(loadT); @@ -473,7 +473,7 @@ function setTimezone(){ }, btn3:function(){ var loadT = layer.msg('正在同步时间...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/sync_date','',function(rdata){ + $.post('/setting/sync_date','',function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:2}); setTimeout(function(){window.location.reload();},1500); @@ -485,7 +485,7 @@ function setTimezone(){ function setIPv6() { var loadT = layer.msg('正在配置,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post('/config/set_ipv6_status', {}, function (rdata) { + $.post('/setting/set_ipv6_status', {}, function (rdata) { layer.close(loadT); layer.msg(rdata.msg, {icon:rdata.status?1:2}); setTimeout(function(){window.location.reload();},5000); @@ -513,7 +513,7 @@ function setPanelSSL(){ } } var loadT = layer.msg('正在安装并设置SSL组件,这需要几分钟时间...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/set_panel_ssl','',function(rdata){ + $.post('/setting/set_panel_ssl','',function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:5}); if(rdata.status === true){ @@ -538,7 +538,7 @@ function setPanelSSL(){ function setNotifyApi(tag, obj){ var enable = $(obj).prop("checked"); // console.log(tag,obj,enable); - $.post('/config/set_notify_enable', {'tag':tag, 'enable':enable},function(rdata){ + $.post('/setting/set_notify_enable', {'tag':tag, 'enable':enable},function(rdata){ showMsg(rdata.msg, function(){ if (rdata.status){} } ,{icon:rdata.status?1:2}, 1000); @@ -547,7 +547,7 @@ function setNotifyApi(tag, obj){ function getTgbot(){ var loadT = layer.msg('正在获取TgBot信息...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/get_notify',{},function(data){ + $.post('/setting/get_notify',{},function(data){ layer.close(loadT); var app_token = ''; @@ -593,7 +593,7 @@ function getTgbot(){ return false; } - $.post('/config/set_notify',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){ + $.post('/setting/set_notify',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){ showMsg(rdata.msg, function(){ if (rdata.status){ layer.close(index); @@ -617,7 +617,7 @@ function getTgbot(){ return false; } - $.post('/config/set_notify_test',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){ + $.post('/setting/set_notify_test',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){ showMsg(rdata.msg, function(){ if (rdata.status){ layer.close(index); @@ -632,7 +632,7 @@ function getTgbot(){ function getEmailCfg(){ var loadT = layer.msg('正在获取邮件配置信息...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/get_notify',{},function(data){ + $.post('/setting/get_notify',{},function(data){ layer.close(loadT); var smtp_host = 'smtp.163.com'; @@ -801,7 +801,7 @@ function getEmailCfg(){ function getPanelSSL(){ var loadT = layer.msg('正在获取证书信息...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/get_panel_ssl',{},function(cert){ + $.post('/setting/get_panel_ssl',{},function(cert){ layer.close(loadT); // console.log(cert); @@ -943,7 +943,7 @@ function getPanelSSL(){ var data = {}; data['choose'] = 'local'; var loadT = layer.msg('正在删除面板SSL【本地】...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config/del_panel_ssl',data,function(rdata){ + $.post('/setting/del_panel_ssl',data,function(rdata){ console.log(rdata); layer.close(loadT); showMsg(rdata.msg, function(){ @@ -998,7 +998,7 @@ function getPanelSSL(){ function removeTempAccess(id){ - $.post('/config/remove_temp_login', {id:id}, function(rdata){ + $.post('/setting/remove_temp_login', {id:id}, function(rdata){ showMsg(rdata.msg, function(){ setTempAccessReq(); },{ icon: rdata.status ? 1 : 2 }, 2000); @@ -1006,7 +1006,7 @@ function removeTempAccess(id){ } function getTempAccessLogsReq(id){ - $.post('/config/get_temp_login_logs', {id:id}, function(rdata){ + $.post('/setting/get_temp_login_logs', {id:id}, function(rdata){ var tbody = ''; for (var i = 0; i < rdata.data.length; i++) { @@ -1054,7 +1054,7 @@ function setTempAccessReq(page){ page = 1; } - $.post('/config/get_temp_login', {page:page}, function(rdata){ + $.post('/setting/get_temp_login', {page:page}, function(rdata){ if ( typeof(rdata.status) !='undefined' && !rdata.status){ showMsg(rdata.msg,function(){ layer.closeAll(); @@ -1228,7 +1228,7 @@ function setTempAccess(){ //二次验证 function setAuthBind(){ - $.post('/config/get_auth_secret', {}, function(rdata){ + $.post('/setting/get_auth_secret', {}, function(rdata){ console.log(rdata); var tip = layer.open({ area: ['500px', '355px'], @@ -1275,7 +1275,7 @@ function setAuthBind(){ function setAuthSecretApi(){ var cfg_panel_auth = $('#cfg_panel_auth').prop("checked"); - $.post('/config/set_auth_secret', {'op_type':"2"},function(rdata){ + $.post('/setting/set_auth_secret', {'op_type':"2"},function(rdata){ showMsg(rdata.msg, function(){ if (rdata.data == 1){ setAuthBind(); @@ -1374,7 +1374,7 @@ function setBasicAuth(){ {btn: ['确定', '取消'], title: "是否关闭BasicAuth认证?", icon:13}, function (index) { var basic_user = ''; var basic_pwd = ''; - $.post('/config/set_basic_auth', {'is_open':'false'},function(rdata){ + $.post('/setting/set_basic_auth', {'is_open':'false'},function(rdata){ showMsg(rdata.msg, function(){ layer.close(index); window.location.reload(); @@ -1387,7 +1387,7 @@ function setBasicAuth(){ } function showPanelApi(){ - $.post('/config/get_panel_token', '', function(rdata){ + $.post('/setting/get_panel_token', '', function(rdata){ var tip = layer.open({ area: ['500px', '355px'], title: '配置面板API', @@ -1447,7 +1447,7 @@ function showPanelApi(){ function setPanelApi(){ var cfg_panel_api = $('#cfg_panel_api').prop("checked"); - $.post('/config/set_panel_token', {'op_type':"2"},function(rdata){ + $.post('/setting/set_panel_token', {'op_type':"2"},function(rdata){ showMsg(rdata.msg, function(){ if (rdata.status){ showPanelApi(); diff --git a/web/templates/default/layout.html b/web/templates/default/layout.html index 15e9e65b6..98ac32a4c 100755 --- a/web/templates/default/layout.html +++ b/web/templates/default/layout.html @@ -41,7 +41,7 @@
diff --git a/web/templates/default/control.html b/web/templates/default/monitor.html similarity index 100% rename from web/templates/default/control.html rename to web/templates/default/monitor.html diff --git a/web/templates/default/config.html b/web/templates/default/setting.html similarity index 100% rename from web/templates/default/config.html rename to web/templates/default/setting.html