update
This commit is contained in:
parent
e994cd80f1
commit
881facdfa8
|
|
@ -76,6 +76,31 @@ def get_root_dir():
|
|||
data['dir'] = mw.getWwwDir()
|
||||
return data
|
||||
|
||||
# 获取站点配置
|
||||
@blueprint.route('/get_host_conf', endpoint='get_host_conf',methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_host_conf():
|
||||
siteName = request.form.get('siteName', '')
|
||||
host = MwSites.instance().getHostConf(siteName)
|
||||
return {'host': host}
|
||||
|
||||
|
||||
# 获取站点PHP版本
|
||||
@blueprint.route('/get_site_php_version', endpoint='get_site_php_version',methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_site_php_version():
|
||||
siteName = request.form.get('siteName', '')
|
||||
return MwSites.instance().getSitePhpVersion(siteName)
|
||||
|
||||
|
||||
# 设置站点PHP版本
|
||||
@blueprint.route('/set_php_version', endpoint='set_php_version',methods=['POST'])
|
||||
@panel_login_required
|
||||
def set_php_version():
|
||||
siteName = request.form.get('siteName', '')
|
||||
version = request.form.get('version', '')
|
||||
return MwSites.instance().setPhpVersion(siteName,version)
|
||||
|
||||
# 检查OpenResty安装/启动状态
|
||||
@blueprint.route('/check_web_status', endpoint='check_web_status',methods=['POST'])
|
||||
@panel_login_required
|
||||
|
|
@ -123,6 +148,14 @@ def set_ps():
|
|||
def get_default_site():
|
||||
return MwSites.instance().getDefaultSite()
|
||||
|
||||
# 站点删除
|
||||
@blueprint.route('/get_domain', endpoint='get_domain',methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_domain():
|
||||
site_id = request.form.get('id', '')
|
||||
return MwSites.instance().getDomain(site_id)
|
||||
|
||||
|
||||
@blueprint.route('/set_default_site', endpoint='set_default_site',methods=['POST'])
|
||||
@panel_login_required
|
||||
def set_default_site():
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from .user import *
|
|||
|
||||
from .sites import *
|
||||
from .domain import *
|
||||
from .binding import *
|
||||
|
||||
from .tasks import *
|
||||
from .logs import *
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ def addDomain(pid, name, port):
|
|||
}
|
||||
return mw.M('domain').insert(insert_data)
|
||||
|
||||
def getDomainByPid(pid):
|
||||
return mw.M('domain').where("pid=?", (pid,)).field(__FIELD).select()
|
||||
|
||||
|
||||
def deleteDomainId(domain_id):
|
||||
return mw.M('domain').where("id=?", (domain_id,)).delete()
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ class sites(object):
|
|||
|
||||
def delete(self, site_id, path):
|
||||
info = thisdb.getSitesById(site_id)
|
||||
print(info)
|
||||
webname = info['name']
|
||||
self.deleteWSLogs(webname)
|
||||
|
||||
|
|
@ -239,7 +240,8 @@ class sites(object):
|
|||
return mw.returnData(True, '站点【%s】删除成功!' % webname)
|
||||
|
||||
def nginxAddConf(self):
|
||||
source_tpl = mw.getRunDir() + '/data/tpl/nginx.conf'
|
||||
source_tpl = mw.getPanelDir() + '/data/tpl/nginx.conf'
|
||||
print(source_tpl)
|
||||
vhost_file = self.vhostPath + '/' + self.siteName + '.conf'
|
||||
content = mw.readFile(source_tpl)
|
||||
|
||||
|
|
@ -276,6 +278,43 @@ class sites(object):
|
|||
data['default_site'] = thisdb.getOption('default_site', default='')
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
# 获取域名列表
|
||||
def getDomain(self, pid):
|
||||
return thisdb.getDomainByPid(pid)
|
||||
|
||||
|
||||
def getSitePhpVersion(self, siteName):
|
||||
conf = mw.readFile(self.getHostConf(siteName))
|
||||
rep = r"enable-php-(.*)\.conf"
|
||||
find_php_cnf = re.search(rep, conf)
|
||||
|
||||
def_pver = '00'
|
||||
if find_php_cnf:
|
||||
tmp = find_php_cnf.groups()
|
||||
def_pver = tmp[0]
|
||||
|
||||
data = {}
|
||||
data['phpversion'] = def_pver
|
||||
return data
|
||||
|
||||
|
||||
def setPhpVersion(self, siteName, version):
|
||||
# nginx
|
||||
file = self.getHostConf(siteName)
|
||||
conf = mw.readFile(file)
|
||||
if conf:
|
||||
rep = r"enable-php-(.*)\.conf"
|
||||
tmp = re.search(rep, conf).group()
|
||||
conf = conf.replace(tmp, 'enable-php-' + version + '.conf')
|
||||
mw.writeFile(file, conf)
|
||||
|
||||
msg = mw.getInfo('成功切换网站[{1}]的PHP版本为PHP-{2}', (siteName, version))
|
||||
mw.writeLog("网站管理", msg)
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, msg)
|
||||
|
||||
|
||||
def setDefaultSite(self, name):
|
||||
# 清理旧的
|
||||
default_site = thisdb.getOption('default_site', default='')
|
||||
|
|
|
|||
Loading…
Reference in New Issue