pull/628/head
Mr Chen 6 months ago
parent 5394dd329a
commit a593e2b8e0
  1. 5
      class/core/mw.py
  2. 156
      panel_task.py
  3. 2
      plugins/simpleping/index.py
  4. 18
      web/admin/__init__.py
  5. 2
      web/admin/logs/__init__.py
  6. 1
      web/admin/model/__init__.py
  7. 8
      web/admin/model/initdb.py
  8. 19
      web/admin/model/task.py
  9. 4
      web/admin/monitor/__init__.py
  10. 13
      web/admin/setting/__init__.py
  11. 8
      web/admin/submodules.py
  12. 8
      web/app.py
  13. 0
      web/config.py
  14. 10
      web/core/mw.py
  15. 62
      web/static/app/config.js
  16. 4
      web/templates/default/layout.html
  17. 0
      web/templates/default/monitor.html
  18. 0
      web/templates/default/setting.html

@ -593,8 +593,11 @@ def writeLog(stype, msg, args=()):
if 'uid' in session: if 'uid' in session:
uid = session['uid'] uid = session['uid']
except Exception as e: except Exception as e:
pass print('writeL:',e)
# pass
# writeFileLog(getTracebackInfo()) # writeFileLog(getTracebackInfo())
print(stype, msg)
return writeDbLog(stype, msg, args, uid) return writeDbLog(stype, msg, args, uid)

@ -28,9 +28,13 @@ web_dir = os.getcwd() + "/web"
os.chdir(web_dir) os.chdir(web_dir)
sys.path.append(web_dir) sys.path.append(web_dir)
from admin import app
from admin import model
import core.mw as mw import core.mw as mw
import core.db as db import core.db as db
print(mw.getPanelDir()) print(mw.getPanelDir())
# print sys.path # print sys.path
@ -47,18 +51,18 @@ timeoutCount = 0
isCheck = 0 isCheck = 0
oldEdate = None oldEdate = None
logPath = os.getcwd() + '/tmp/panelExec.log' g_log_file = mw.getMWLogs() + '/panelExec.log'
isTask = os.getcwd() + '/tmp/panelTask.pl' isTask = mw.getMWLogs() + '/panelTask.pl'
if not os.path.exists(os.getcwd() + "/tmp"): if not os.path.exists(os.getcwd() + "/tmp"):
os.system('mkdir -p ' + os.getcwd() + "/tmp") os.system('mkdir -p ' + os.getcwd() + "/tmp")
if not os.path.exists(logPath): if not os.path.exists(g_log_file):
os.system("touch " + logPath) os.system("touch " + g_log_file)
def execShell(cmdstring, cwd=None, timeout=None, shell=True): def execShell(cmdstring, cwd=None, timeout=None, shell=True):
try: try:
global logPath global g_log_file
import shlex import shlex
import datetime import datetime
import subprocess import subprocess
@ -66,9 +70,8 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True):
if timeout: if timeout:
end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout) end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout)
cmd = cmdstring + ' > ' + logPath + ' 2>&1' cmd = cmdstring + ' > ' + g_log_file + ' 2>&1'
sub = subprocess.Popen( sub = subprocess.Popen(cmd, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096)
cmd, cwd=cwd, stdin=subprocess.PIPE, shell=shell, bufsize=4096)
while sub.poll() is None: while sub.poll() is None:
time.sleep(0.1) time.sleep(0.1)
@ -140,14 +143,12 @@ def downloadFile(url, filename):
import socket import socket
socket.setdefaulttimeout(300) socket.setdefaulttimeout(300)
headers = ( 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')
'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 = urllib.request.build_opener()
opener.addheaders = [headers] opener.addheaders = [headers]
urllib.request.install_opener(opener) urllib.request.install_opener(opener)
urllib.request.urlretrieve( urllib.request.urlretrieve(url, filename=filename, reporthook=downloadHook)
url, filename=filename, reporthook=downloadHook)
if not mw.isAppleSystem(): if not mw.isAppleSystem():
os.system('chown www.www ' + filename) os.system('chown www.www ' + filename)
@ -155,6 +156,7 @@ def downloadFile(url, filename):
writeLogs('done') writeLogs('done')
except Exception as e: except Exception as e:
writeLogs(str(e)) writeLogs(str(e))
return True
def downloadHook(count, blockSize, totalSize): def downloadHook(count, blockSize, totalSize):
@ -168,61 +170,66 @@ def downloadHook(count, blockSize, totalSize):
writeLogs(json.dumps(speed)) writeLogs(json.dumps(speed))
def writeLogs(logMsg): def writeLogs(data):
# 写输出日志 # 写输出日志
try: try:
global logPath fp = open(g_log_file, 'w+')
fp = open(logPath, 'w+') fp.write(data)
fp.write(logMsg)
fp.close() fp.close()
except: except:
pass pass
def runTask(): def runTask():
global isTask
try:
if os.path.exists(isTask): mw.writeLog("后台任务", "运行")
sql = db.Sql()
sql.table('tasks').where( print(model.getTaskCount())
"status=?", ('-1',)).setField('status', '0') # global isTask
taskArr = sql.table('tasks').where("status=?", ('0',)).field( # try:
'id,type,execstr').order("id asc").select()
for value in taskArr: # if os.path.exists(isTask):
start = int(time.time()) # sql = db.Sql()
if not sql.table('tasks').where("id=?", (value['id'],)).count(): # sql.table('tasks').where(
continue # "status=?", ('-1',)).setField('status', '0')
sql.table('tasks').where("id=?", (value['id'],)).save( # taskArr = sql.table('tasks').where("status=?", ('0',)).field(
'status,start', ('-1', start)) # 'id,type,execstr').order("id asc").select()
if value['type'] == 'download': # for value in taskArr:
argv = value['execstr'].split('|mw|') # start = int(time.time())
downloadFile(argv[0], argv[1]) # if not sql.table('tasks').where("id=?", (value['id'],)).count():
elif value['type'] == 'execshell': # continue
execShell(value['execstr']) # sql.table('tasks').where("id=?", (value['id'],)).save('status,start', ('-1', start))
end = int(time.time()) # if value['type'] == 'download':
sql.table('tasks').where("id=?", (value['id'],)).save( # argv = value['execstr'].split('|mw|')
'status,end', ('1', end)) # downloadFile(argv[0], argv[1])
# elif value['type'] == 'execshell':
if(sql.table('tasks').where("status=?", ('0')).count() < 1): # execShell(value['execstr'])
os.system('rm -f ' + isTask) # end = int(time.time())
# sql.table('tasks').where("id=?", (value['id'],)).save(
sql.close() # 'status,end', ('1', end))
except Exception as e:
print(str(e)) # 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: try:
while True: while True:
runTask() runTask()
time.sleep(2) time.sleep(1)
except Exception as e: except Exception as e:
time.sleep(60) print(str(e))
startTask() time.sleep(10)
startPanelTask()
def siteEdate(): def siteEdate():
@ -605,33 +612,38 @@ def setDaemon(t):
t.setDaemon(True) t.setDaemon(True)
return t return t
if __name__ == "__main__": def run():
# # 系统监控
# sysTask = threading.Thread(target=systemTask)
# sysTask = setDaemon(sysTask)
# sysTask.start()
# 系统监控 # # PHP 502错误检查线程
sysTask = threading.Thread(target=systemTask) # php502 = threading.Thread(target=check502Task)
sysTask = setDaemon(sysTask) # php502 = setDaemon(php502)
sysTask.start() # php502.start()
# PHP 502错误检查线程 # # OpenResty Restart At Once Start
php502 = threading.Thread(target=check502Task) # oraos = threading.Thread(target=openrestyRestartAtOnce)
php502 = setDaemon(php502) # oraos = setDaemon(oraos)
php502.start() # 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) startPanelTask()
rps = setDaemon(rps)
rps.start() if __name__ == "__main__":
with app.app_context():
run()
startTask()

@ -268,7 +268,7 @@ def runLog():
def ipList(): def ipList():
config = getServerDir() + '/conf/app.conf' config = getServerDir() + '/conf/app.conf'
content = mw.readFile(config) content = mw.readFile(config)
rep = 'ip\s*=\s*(.*)' rep = r'ip\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
return '' return ''

@ -28,7 +28,7 @@ from admin.model import db as sys_db
from admin import setup from admin import setup
import core.mw as mw import core.mw as mw
import setting import config
import utils.config as utils_config import utils.config as utils_config
root_dir = mw.getRunDir() root_dir = mw.getRunDir()
@ -56,7 +56,7 @@ app.config['SESSION_COOKIE_NAME'] = "MW_VER_1"
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31) app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31)
# db的配置 # 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 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
@ -66,7 +66,7 @@ Migrate(app, sys_db)
# 检查数据库是否存在。如果没有就创建它。 # 检查数据库是否存在。如果没有就创建它。
setup_db_required = False setup_db_required = False
if not os.path.isfile(setting.SQLITE_PATH): if not os.path.isfile(config.SQLITE_PATH):
setup_db_required = True setup_db_required = True
# with app.app_context(): # with app.app_context():
@ -98,8 +98,8 @@ def requestCheck():
@app.after_request @app.after_request
def requestAfter(response): def requestAfter(response):
response.headers['soft'] = setting.APP_NAME response.headers['soft'] = config.APP_NAME
response.headers['mw-version'] = setting.APP_VERSION response.headers['mw-version'] = config.APP_VERSION
return response return response
@ -111,17 +111,17 @@ def page_unauthorized(error):
# 设置模板全局变量 # 设置模板全局变量
@app.context_processor @app.context_processor
def inject_global_variables(): def inject_global_variables():
ver = setting.APP_VERSION; ver = config.APP_VERSION;
if mw.isDebugMode(): if mw.isDebugMode():
ver = ver + str(time.time()) ver = ver + str(time.time())
data = utils_config.getGlobalVar() data = utils_config.getGlobalVar()
config = { g_config = {
'version': ver, 'version': ver,
'title' : '面板', 'title' : '面板',
'ip' : '127.0.0.1' 'ip' : '127.0.0.1'
} }
return dict(config=config, data=data) return dict(config=g_config, data=data)
# from flasgger import Swagger # from flasgger import Swagger
@ -172,7 +172,7 @@ def inject_global_variables():
# Log the startup # Log the startup
app.logger.info('########################################################') 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.info('########################################################')
app.logger.debug("Python syspath: %s", sys.path) app.logger.debug("Python syspath: %s", sys.path)

@ -37,7 +37,7 @@ def get_log_list():
if search != '': if search != '':
pagination = Logs.query.filter_by(Logs.type.like(search) or Logs.log.like(search)).paginate(page=int(p), per_page=int(size)) pagination = Logs.query.filter_by(Logs.type.like(search) or Logs.log.like(search)).paginate(page=int(p), per_page=int(size))
else: 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 = [] rows = []
for item in pagination.items: for item in pagination.items:

@ -13,6 +13,7 @@ from .initdb import *
from .logs import addLog from .logs import addLog
from .option import getOption,getOptionByJson,setOption from .option import getOption,getOptionByJson,setOption
from .sites import getSitesCount from .sites import getSitesCount
from .task import getTaskCount

@ -11,15 +11,15 @@
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
# from flask_security import UserMixin, RoleMixin # from flask_security import UserMixin, RoleMixin
import setting import config
SCHEMA_VERSION = 1 SCHEMA_VERSION = 1
db = SQLAlchemy( db = SQLAlchemy(
engine_options={ engine_options={
'pool_size': setting.CONFIG_DATABASE_CONNECTION_POOL_SIZE, 'pool_size': config.CONFIG_DATABASE_CONNECTION_POOL_SIZE,
'max_overflow': setting.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW 'max_overflow': config.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW
} }
) )
@ -82,7 +82,7 @@ class Logs(db.Model):
"""定义日志""" """定义日志"""
__tablename__ = 'logs' __tablename__ = 'logs'
id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID") 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="日志类型") type = db.Column(db.String(128), unique=False, nullable=False, comment="日志类型")
log = db.Column(db.TEXT, unique=False, nullable=True, comment="日志内容") log = db.Column(db.TEXT, unique=False, nullable=True, comment="日志内容")
add_time = db.Column(db.TEXT, nullable=False, comment="添加时间") add_time = db.Column(db.TEXT, nullable=False, comment="添加时间")

@ -0,0 +1,19 @@
# coding:utf-8
# ---------------------------------------------------------------------------------
# MW-Linux面板
# ---------------------------------------------------------------------------------
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
# ---------------------------------------------------------------------------------
# Author: midoks <midoks@163.com>
# ---------------------------------------------------------------------------------
from admin.model import db, Tasks
def getTaskCount(
status: str | None = None
) -> int:
return Tasks.query.filter_by().count()

@ -11,7 +11,7 @@
from flask import Blueprint, render_template 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') @blueprint.route('/index', endpoint='index')
def index(): def index():
return render_template('control.html',) return render_template('monitor.html',)

@ -16,10 +16,10 @@ from admin import model
import core.mw as mw 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') @blueprint.route('/index', endpoint='index')
def 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) model.setOption('title', webname)
return mw.returnData(True, '面板别名保存成功!') 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保存成功!')

@ -12,14 +12,14 @@
from .dashboard import blueprint as DashboardModule from .dashboard import blueprint as DashboardModule
from .site import blueprint as SiteModule from .site import blueprint as SiteModule
from .task import blueprint as TaskModule 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 .logs import blueprint as LogsModule
from .files import blueprint as FilesModule from .files import blueprint as FilesModule
from .soft import blueprint as SoftModule from .soft import blueprint as SoftModule
from .plugins import blueprint as PluginsModule from .plugins import blueprint as PluginsModule
from .crontab import blueprint as CrontabModule from .crontab import blueprint as CrontabModule
from .firewall import blueprint as FirewallModule from .firewall import blueprint as FirewallModule
from .control import blueprint as ControlModule from .monitor import blueprint as MonitorModule
from .system import blueprint as SystemModule from .system import blueprint as SystemModule
def get_submodules(): def get_submodules():
@ -33,7 +33,7 @@ def get_submodules():
PluginsModule, PluginsModule,
CrontabModule, CrontabModule,
FirewallModule, FirewallModule,
ControlModule, MonitorModule,
SystemModule, SystemModule,
ConfigModule, SettingModule,
] ]

@ -22,17 +22,17 @@ if sys.path[0] != os.path.dirname(os.path.realpath(__file__)):
# print(sys.path) # print(sys.path)
import setting import config
from admin import app, socketio from admin import app, socketio
# print(setting.DEFAULT_SERVER,setting.DEFAULT_SERVER_PORT) # print(config.DEFAULT_SERVER,config.DEFAULT_SERVER_PORT)
# app = create_app() # app = create_app()
def main(): def main():
socketio.run( socketio.run(
app, app,
debug=setting.DEBUG, debug=config.DEBUG,
allow_unsafe_werkzeug=True, allow_unsafe_werkzeug=True,
host=setting.DEFAULT_SERVER, host=config.DEFAULT_SERVER,
port=7201, port=7201,
) )

@ -310,6 +310,12 @@ def getFileSuffix(file):
def getPathSuffix(path): def getPathSuffix(path):
return os.path.splitext(path)[-1] 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(): def getSqitePrefix():
WIN = sys.platform.startswith('win') WIN = sys.platform.startswith('win')
if WIN: # 如果是 Windows 系统,使用三个斜线 if WIN: # 如果是 Windows 系统,使用三个斜线
@ -498,13 +504,13 @@ def isNumber(s):
def writeLog(stype, msg, args=()): def writeLog(stype, msg, args=()):
# 写日志 # 写日志
uid = 1 uid = 0
try: try:
from flask import session from flask import session
if 'uid' in session: if 'uid' in session:
uid = session['uid'] uid = session['uid']
except Exception as e: except Exception as e:
print(str(e)) print("writeLog:"+str(e))
# pass # pass
# writeFileLog(getTracebackInfo()) # writeFileLog(getTracebackInfo())
return writeDbLog(stype, msg, args, uid) return writeDbLog(stype, msg, args, uid)

@ -17,7 +17,7 @@ $('input[name="webname"]').change(function(){
var webname = $(this).val(); var webname = $(this).val();
$('.btn_webname').removeAttr('disabled'); $('.btn_webname').removeAttr('disabled');
$('.btn_webname').unbind().click(function(){ $('.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); showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json'); },'json');
}); });
@ -28,7 +28,7 @@ $('input[name="host_ip"]').change(function(){
var host_ip = $(this).val(); var host_ip = $(this).val();
$('.btn_host_ip').removeAttr('disabled'); $('.btn_host_ip').removeAttr('disabled');
$('.btn_host_ip').unbind().click(function(){ $('.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); showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json'); },'json');
}); });
@ -39,7 +39,7 @@ $('input[name="port"]').change(function(){
var old_port = $(this).data('port'); var old_port = $(this).data('port');
$('.btn_port').removeAttr('disabled'); $('.btn_port').removeAttr('disabled');
$('.btn_port').unbind().click(function(){ $('.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(){ showMsg(rdata.msg,function(){
window.location.href = window.location.href.replace(old_port,port); window.location.href = window.location.href.replace(old_port,port);
// window.location.reload(); // window.location.reload();
@ -52,7 +52,7 @@ $('input[name="sites_path"]').change(function(){
var sites_path = $(this).val(); var sites_path = $(this).val();
$('.btn_sites_path').removeAttr('disabled'); $('.btn_sites_path').removeAttr('disabled');
$('.btn_sites_path').unbind().click(function(){ $('.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); showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json'); },'json');
}); });
@ -63,7 +63,7 @@ $('input[name="backup_path"]').change(function(){
var backup_path = $(this).val(); var backup_path = $(this).val();
$('.btn_backup_path').removeAttr('disabled'); $('.btn_backup_path').removeAttr('disabled');
$('.btn_backup_path').unbind().click(function(){ $('.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); showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json'); },'json');
}); });
@ -74,7 +74,7 @@ $('input[name="bind_domain"]').change(function(){
var domain = $(this).val(); var domain = $(this).val();
$('.btn_bind_domain').removeAttr('disabled'); $('.btn_bind_domain').removeAttr('disabled');
$('.btn_bind_domain').unbind().click(function(){ $('.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(){ showMsg(rdata.msg,function(){
window.location.href = rdata.data; window.location.href = rdata.data;
},{icon:rdata.status?1:2},5000); },{icon:rdata.status?1:2},5000);
@ -126,7 +126,7 @@ $('input[name="bind_ssl"]').click(function(){
yes: function(){ yes: function(){
var cert_type = $('select[name=cert_type]').val(); 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); // console.log(rdata);
var to_https = window.location.href.replace('http','https'); var to_https = window.location.href.replace('http','https');
showMsg(rdata.msg,function(){ showMsg(rdata.msg,function(){
@ -163,7 +163,7 @@ $('input[name="bind_ssl"]').click(function(){
return; return;
} }
$.post('/config/close_panel_ssl',{}, function(rdata){ $.post('/setting/close_panel_ssl',{}, function(rdata){
var to_http = window.location.href.replace('https','http'); var to_http = window.location.href.replace('https','http');
showMsg(rdata.msg,function(){ showMsg(rdata.msg,function(){
if (rdata.status){ if (rdata.status){
@ -234,7 +234,7 @@ function closePanel(){
layer.confirm('关闭面板会导致您无法访问面板 ,您真的要关闭Linux面板吗?',{title:'关闭面板',closeBtn:2,icon:13,cancel:function(){ layer.confirm('关闭面板会导致您无法访问面板 ,您真的要关闭Linux面板吗?',{title:'关闭面板',closeBtn:2,icon:13,cancel:function(){
$("#closePl").prop("checked",false); $("#closePl").prop("checked",false);
}}, function() { }}, function() {
$.post('/config/close_panel','',function(rdata){ $.post('/setting/close_panel','',function(rdata){
layer.msg(rdata.msg,{icon:rdata.status?1:2}); layer.msg(rdata.msg,{icon:rdata.status?1:2});
setTimeout(function(){ setTimeout(function(){
window.location.reload(); window.location.reload();
@ -248,7 +248,7 @@ function closePanel(){
//开发模式 //开发模式
function debugMode(){ function debugMode(){
var loadT = layer.msg('正在发送请求,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); 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); layer.close(loadT);
showMsg(rdata.msg, function(){ showMsg(rdata.msg, function(){
window.location.reload(); window.location.reload();
@ -339,7 +339,7 @@ function setPassword(a) {
layer.msg('两次输入的密码不一致', {icon: 2}); layer.msg('两次输入的密码不一致', {icon: 2});
return; 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) { if(b.status) {
layer.closeAll(); layer.closeAll();
layer.msg(b.msg, {icon: 1}); layer.msg(b.msg, {icon: 1});
@ -394,7 +394,7 @@ function setUserName(a) {
layer.msg('两次输入的用户名不一致', {icon: 2}); layer.msg('两次输入的用户名不一致', {icon: 2});
return; 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) { if(b.status) {
layer.closeAll(); layer.closeAll();
layer.msg(b.msg, {icon: 1}); layer.msg(b.msg, {icon: 1});
@ -463,7 +463,7 @@ function setTimezone(){
yes:function(index){ yes:function(index){
var loadT = layer.msg("正在设置时区...", { icon: 16, time: 0, shade: [0.3, '#000'] }); var loadT = layer.msg("正在设置时区...", { icon: 16, time: 0, shade: [0.3, '#000'] });
var timezone = $('select[name="timezone"]').val(); 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(){ showMsg(rdata.msg, function(){
layer.close(index); layer.close(index);
layer.close(loadT); layer.close(loadT);
@ -473,7 +473,7 @@ function setTimezone(){
}, },
btn3:function(){ btn3:function(){
var loadT = layer.msg('正在同步时间...',{icon:16,time:0,shade: [0.3, '#000']}); 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.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:2}); layer.msg(rdata.msg,{icon:rdata.status?1:2});
setTimeout(function(){window.location.reload();},1500); setTimeout(function(){window.location.reload();},1500);
@ -485,7 +485,7 @@ function setTimezone(){
function setIPv6() { function setIPv6() {
var loadT = layer.msg('正在配置,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); 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.close(loadT);
layer.msg(rdata.msg, {icon:rdata.status?1:2}); layer.msg(rdata.msg, {icon:rdata.status?1:2});
setTimeout(function(){window.location.reload();},5000); 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']}); 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.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:5}); layer.msg(rdata.msg,{icon:rdata.status?1:5});
if(rdata.status === true){ if(rdata.status === true){
@ -538,7 +538,7 @@ function setPanelSSL(){
function setNotifyApi(tag, obj){ function setNotifyApi(tag, obj){
var enable = $(obj).prop("checked"); var enable = $(obj).prop("checked");
// console.log(tag,obj,enable); // 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(){ showMsg(rdata.msg, function(){
if (rdata.status){} if (rdata.status){}
} ,{icon:rdata.status?1:2}, 1000); } ,{icon:rdata.status?1:2}, 1000);
@ -547,7 +547,7 @@ function setNotifyApi(tag, obj){
function getTgbot(){ function getTgbot(){
var loadT = layer.msg('正在获取TgBot信息...',{icon:16,time:0,shade: [0.3, '#000']}); 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); layer.close(loadT);
var app_token = ''; var app_token = '';
@ -593,7 +593,7 @@ function getTgbot(){
return false; 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(){ showMsg(rdata.msg, function(){
if (rdata.status){ if (rdata.status){
layer.close(index); layer.close(index);
@ -617,7 +617,7 @@ function getTgbot(){
return false; 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(){ showMsg(rdata.msg, function(){
if (rdata.status){ if (rdata.status){
layer.close(index); layer.close(index);
@ -632,7 +632,7 @@ function getTgbot(){
function getEmailCfg(){ function getEmailCfg(){
var loadT = layer.msg('正在获取邮件配置信息...',{icon:16,time:0,shade: [0.3, '#000']}); 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); layer.close(loadT);
var smtp_host = 'smtp.163.com'; var smtp_host = 'smtp.163.com';
@ -801,7 +801,7 @@ function getEmailCfg(){
function getPanelSSL(){ function getPanelSSL(){
var loadT = layer.msg('正在获取证书信息...',{icon:16,time:0,shade: [0.3, '#000']}); 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); layer.close(loadT);
// console.log(cert); // console.log(cert);
@ -943,7 +943,7 @@ function getPanelSSL(){
var data = {}; var data = {};
data['choose'] = 'local'; data['choose'] = 'local';
var loadT = layer.msg('正在删除面板SSL【本地】...',{icon:16,time:0,shade: [0.3, '#000']}); 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); console.log(rdata);
layer.close(loadT); layer.close(loadT);
showMsg(rdata.msg, function(){ showMsg(rdata.msg, function(){
@ -998,7 +998,7 @@ function getPanelSSL(){
function removeTempAccess(id){ 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(){ showMsg(rdata.msg, function(){
setTempAccessReq(); setTempAccessReq();
},{ icon: rdata.status ? 1 : 2 }, 2000); },{ icon: rdata.status ? 1 : 2 }, 2000);
@ -1006,7 +1006,7 @@ function removeTempAccess(id){
} }
function getTempAccessLogsReq(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 = ''; var tbody = '';
for (var i = 0; i < rdata.data.length; i++) { for (var i = 0; i < rdata.data.length; i++) {
@ -1054,7 +1054,7 @@ function setTempAccessReq(page){
page = 1; 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){ if ( typeof(rdata.status) !='undefined' && !rdata.status){
showMsg(rdata.msg,function(){ showMsg(rdata.msg,function(){
layer.closeAll(); layer.closeAll();
@ -1228,7 +1228,7 @@ function setTempAccess(){
//二次验证 //二次验证
function setAuthBind(){ function setAuthBind(){
$.post('/config/get_auth_secret', {}, function(rdata){ $.post('/setting/get_auth_secret', {}, function(rdata){
console.log(rdata); console.log(rdata);
var tip = layer.open({ var tip = layer.open({
area: ['500px', '355px'], area: ['500px', '355px'],
@ -1275,7 +1275,7 @@ function setAuthBind(){
function setAuthSecretApi(){ function setAuthSecretApi(){
var cfg_panel_auth = $('#cfg_panel_auth').prop("checked"); 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(){ showMsg(rdata.msg, function(){
if (rdata.data == 1){ if (rdata.data == 1){
setAuthBind(); setAuthBind();
@ -1374,7 +1374,7 @@ function setBasicAuth(){
{btn: ['确定', '取消'], title: "是否关闭BasicAuth认证?", icon:13}, function (index) { {btn: ['确定', '取消'], title: "是否关闭BasicAuth认证?", icon:13}, function (index) {
var basic_user = ''; var basic_user = '';
var basic_pwd = ''; 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(){ showMsg(rdata.msg, function(){
layer.close(index); layer.close(index);
window.location.reload(); window.location.reload();
@ -1387,7 +1387,7 @@ function setBasicAuth(){
} }
function showPanelApi(){ function showPanelApi(){
$.post('/config/get_panel_token', '', function(rdata){ $.post('/setting/get_panel_token', '', function(rdata){
var tip = layer.open({ var tip = layer.open({
area: ['500px', '355px'], area: ['500px', '355px'],
title: '配置面板API', title: '配置面板API',
@ -1447,7 +1447,7 @@ function showPanelApi(){
function setPanelApi(){ function setPanelApi(){
var cfg_panel_api = $('#cfg_panel_api').prop("checked"); 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(){ showMsg(rdata.msg, function(){
if (rdata.status){ if (rdata.status){
showPanelApi(); showPanelApi();

@ -41,7 +41,7 @@
<ul class="menu"> <ul class="menu">
<li id="memuA"><a class="menu_home" href="/">首页</a></li> <li id="memuA"><a class="menu_home" href="/">首页</a></li>
<li id="memuAsite"><a class="menu_web" href="/site/index">网站</a></li> <li id="memuAsite"><a class="menu_web" href="/site/index">网站</a></li>
<li id="memuAcontrol"><a class="menu_control" href="/control/index">监控</a></li> <li id="memuAcontrol"><a class="menu_control" href="/monitor/index">监控</a></li>
<li id="memuAfirewall"><a class="menu_firewall" href="/firewall/index">安全</a></li> <li id="memuAfirewall"><a class="menu_firewall" href="/firewall/index">安全</a></li>
<li id="memuAfiles"><a class="menu_folder" href="/files/index">文件</a></li> <li id="memuAfiles"><a class="menu_folder" href="/files/index">文件</a></li>
<li id="memuAlogs"><a class="menu_logs" href="/logs/index">日志</a></li> <li id="memuAlogs"><a class="menu_logs" href="/logs/index">日志</a></li>
@ -53,7 +53,7 @@
</li> </li>
{% endfor %} {% endfor %}
<li id="memuAsoft"><a class="menu_soft" href="/soft/index">软件管理</a><span class="softnum">1</span></li> <li id="memuAsoft"><a class="menu_soft" href="/soft/index">软件管理</a><span class="softnum">1</span></li>
<li id="memuAconfig"><a class="menu_set" href="/config/index">面板设置</a></li> <li id="memuAconfig"><a class="menu_set" href="/setting/index">面板设置</a></li>
<li><a class="menu_exit" href="javascript:;" id="signout">退出</a></li> <li><a class="menu_exit" href="javascript:;" id="signout">退出</a></li>
</ul> </ul>
<div id="newbtpc"></div> <div id="newbtpc"></div>

Loading…
Cancel
Save