mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:39:25 +08:00
update
This commit is contained in:
@@ -18,10 +18,11 @@ from utils.crontab import crontab as MwCrontab
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
blueprint = Blueprint('crontab', __name__, url_prefix='/crontab', template_folder='../../templates/default')
|
||||
blueprint = Blueprint('crontab', __name__, url_prefix='/crontab', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
def index():
|
||||
return render_template('crontab.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/crontab.html' % name)
|
||||
|
||||
# 计划任务列表
|
||||
@blueprint.route('/list', endpoint='list', methods=['POST'])
|
||||
|
||||
@@ -30,7 +30,8 @@ blueprint = Blueprint('dashboard', __name__, url_prefix='/', template_folder='..
|
||||
@blueprint.route('/')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('default/index.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/index.html' % name)
|
||||
|
||||
# 安全路径
|
||||
@blueprint.route('/<path>',endpoint='admin_safe_path',methods=['GET'])
|
||||
|
||||
@@ -21,12 +21,14 @@ from werkzeug.utils import secure_filename
|
||||
from admin.user_login_check import panel_login_required
|
||||
import core.mw as mw
|
||||
import utils.file as file
|
||||
import thisdb
|
||||
|
||||
blueprint = Blueprint('files', __name__, url_prefix='/files', template_folder='../../templates/default')
|
||||
blueprint = Blueprint('files', __name__, url_prefix='/files', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('files.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/files.html' % name)
|
||||
|
||||
# 获取文件内容
|
||||
@blueprint.route('/get_body', endpoint='get_file_body', methods=['POST'])
|
||||
|
||||
@@ -17,12 +17,14 @@ from admin.user_login_check import panel_login_required
|
||||
from utils.firewall import Firewall as MwFirewall
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
blueprint = Blueprint('firewall', __name__, url_prefix='/firewall', template_folder='../../templates/default')
|
||||
blueprint = Blueprint('firewall', __name__, url_prefix='/firewall', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('firewall.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/firewall.html' % name)
|
||||
|
||||
|
||||
# 防火墙列表
|
||||
|
||||
@@ -23,8 +23,8 @@ blueprint = Blueprint('logs', __name__, url_prefix='/logs', template_folder='../
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('default/logs.html')
|
||||
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/logs.html' % name)
|
||||
|
||||
# 日志列表
|
||||
@blueprint.route('/get_log_list', endpoint='get_log_list', methods=['POST'])
|
||||
|
||||
@@ -13,8 +13,11 @@ from flask import Blueprint, render_template
|
||||
|
||||
from admin.user_login_check import panel_login_required
|
||||
|
||||
blueprint = Blueprint('monitor', __name__, url_prefix='/monitor', template_folder='../../templates/default')
|
||||
import thisdb
|
||||
|
||||
blueprint = Blueprint('monitor', __name__, url_prefix='/monitor', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('monitor.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/monitor.html' % name)
|
||||
@@ -23,11 +23,12 @@ import utils.config as utils_config
|
||||
import thisdb
|
||||
|
||||
|
||||
blueprint = Blueprint('plugins', __name__, url_prefix='/plugins', template_folder='../../templates/default')
|
||||
blueprint = Blueprint('plugins', __name__, url_prefix='/plugins', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('plugins.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/plugins.html' % name)
|
||||
|
||||
# 初始化检查,首页提示选择安装
|
||||
@blueprint.route('/init', endpoint='init', methods=['POST'])
|
||||
|
||||
@@ -29,7 +29,8 @@ blueprint = Blueprint('setting', __name__, url_prefix='/setting', template_folde
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('default/setting.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/setting.html' % name)
|
||||
|
||||
@blueprint.route('/get_panel_list', endpoint='get_panel_list', methods=['POST'])
|
||||
@panel_login_required
|
||||
|
||||
@@ -18,7 +18,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
@@ -136,6 +135,13 @@ def get_site_php_version():
|
||||
siteName = request.form.get('siteName', '')
|
||||
return MwSites.instance().getSitePhpVersion(siteName)
|
||||
|
||||
# 获取站点PHP版本
|
||||
@blueprint.route('/get_site_domains', endpoint='get_site_domains',methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_site_domains():
|
||||
site_id = request.form.get('id', '')
|
||||
data = thisdb.getSitesDomainById(site_id)
|
||||
return mw.returnData(True, 'OK', data)
|
||||
|
||||
# 设置站点PHP版本
|
||||
@blueprint.route('/set_php_version', endpoint='set_php_version',methods=['POST'])
|
||||
@@ -287,3 +293,4 @@ def set_default_site():
|
||||
return MwSites.instance().setDefaultSite(name)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
|
||||
@@ -18,14 +18,13 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from utils.site import sites as MwSites
|
||||
import utils.site as site
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
from .site import blueprint
|
||||
|
||||
|
||||
# 删除代理配置
|
||||
# 获取证书信息
|
||||
@blueprint.route('/get_ssl', endpoint='get_ssl', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_ssl():
|
||||
@@ -33,6 +32,12 @@ def get_ssl():
|
||||
ssl_type = request.form.get('ssl_type', '')
|
||||
return MwSites.instance().getSsl(site_name, ssl_type)
|
||||
|
||||
# 获取证书列表
|
||||
@blueprint.route('/get_cert_list', endpoint='get_cert_list', methods=['GET','POST'])
|
||||
@panel_login_required
|
||||
def get_cert_list():
|
||||
return MwSites.instance().getCertList()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,11 @@ from flask import Blueprint, render_template
|
||||
|
||||
from admin.user_login_check import panel_login_required
|
||||
|
||||
import thisdb
|
||||
|
||||
blueprint = Blueprint('soft', __name__, url_prefix='/soft', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@panel_login_required
|
||||
def index():
|
||||
return render_template('default/soft.html')
|
||||
name = thisdb.getOption('template', default='default')
|
||||
return render_template('%s/soft.html' % name)
|
||||
@@ -19,6 +19,22 @@ def getSitesCount():
|
||||
def getSitesById(site_id):
|
||||
return mw.M('sites').field(__FIELD).where("id=?", (site_id,)).find()
|
||||
|
||||
def getSitesByName(site_name):
|
||||
return mw.M('sites').field(__FIELD).where("name=?", (site_name,)).find()
|
||||
|
||||
def getSitesDomainById(site_id):
|
||||
data = {}
|
||||
domains = mw.M('domain').where('pid=?', (site_id,)).field('name,id').select()
|
||||
binding = mw.M('binding').where('pid=?', (site_id,)).field('domain,id').select()
|
||||
for b in binding:
|
||||
t = {}
|
||||
t['name'] = b['domain']
|
||||
t['id'] = b['id']
|
||||
domains.append(t)
|
||||
data['domains'] = domains
|
||||
data['email'] = mw.M('users').getField('email')
|
||||
return data
|
||||
|
||||
def addSites(name, path):
|
||||
now_time = mw.getDateFromNow()
|
||||
insert_data = {
|
||||
|
||||
+43
-6
@@ -1318,8 +1318,8 @@ location ^~ {from} {\n\
|
||||
|
||||
to_https = self.isToHttps(site_name)
|
||||
|
||||
sid = mw.M('sites').where("name=?", (site_name,)).getField('id')
|
||||
domains = mw.M('domain').where("pid=?", (sid,)).field('name').select()
|
||||
info = thisdb.getSitesByName(site_name)
|
||||
domains = mw.M('domain').where("pid=?", (info['id'],)).field('name').select()
|
||||
|
||||
csr_path = path + '/fullchain.pem' # 生成证书路径
|
||||
key_path = path + '/privkey.pem' # 密钥文件路径
|
||||
@@ -1330,11 +1330,19 @@ location ^~ {from} {\n\
|
||||
key_path = self.sslLetsDir + '/' + site_name + '/privkey.pem' # 密钥文件路径
|
||||
elif ssl_type == 'acme':
|
||||
acme_dir = mw.getAcmeDomainDir(site_name)
|
||||
csr_path = acme_dir + '/fullchain.cer' # 生成证书路径
|
||||
key_path = acme_dir + '/' + site_name + '.key' # 密钥文件路径
|
||||
csr_path = acme_dir + '/fullchain.cer' # ACME生成证书路径
|
||||
key_path = acme_dir + '/' + site_name + '.key' # ACME密钥文件路径
|
||||
|
||||
if os.path.exists(key_path):
|
||||
key = mw.readFile(key_path)
|
||||
else:
|
||||
key = ''
|
||||
|
||||
if os.path.exists(csr_path):
|
||||
csr = mw.readFile(csr_path)
|
||||
else:
|
||||
csr = ''
|
||||
|
||||
key = mw.readFile(key_path)
|
||||
csr = mw.readFile(csr_path)
|
||||
cert_data = mw.getCertName(csr_path)
|
||||
data = {
|
||||
'status': status,
|
||||
@@ -1347,6 +1355,35 @@ location ^~ {from} {\n\
|
||||
}
|
||||
return mw.returnData(True, 'OK', data)
|
||||
|
||||
def getCertList(self):
|
||||
try:
|
||||
vpath = self.sslDir
|
||||
if not os.path.exists(vpath):
|
||||
os.system('mkdir -p ' + vpath)
|
||||
data = []
|
||||
for d in os.listdir(vpath):
|
||||
|
||||
# keyPath = self.sslDir + siteName + '/privkey.pem'
|
||||
# certPath = self.sslDir + siteName + '/fullchain.pem'
|
||||
|
||||
keyPath = vpath + '/' + d + '/privkey.pem'
|
||||
certPath = vpath + '/' + d + '/fullchain.pem'
|
||||
if os.path.exists(keyPath) and os.path.exists(certPath):
|
||||
self.saveCert(keyPath, certPath)
|
||||
|
||||
mpath = vpath + '/' + d + '/info.json'
|
||||
if not os.path.exists(mpath):
|
||||
continue
|
||||
|
||||
tmp = mw.readFile(mpath)
|
||||
if not tmp:
|
||||
continue
|
||||
tmp1 = json.loads(tmp)
|
||||
data.append(tmp1)
|
||||
return mw.returnData(True, 'OK', data)
|
||||
except:
|
||||
return mw.returnData(True, 'OK', [])
|
||||
|
||||
|
||||
def setPhpVersion(self, siteName, version):
|
||||
# nginx
|
||||
|
||||
Reference in New Issue
Block a user