This commit is contained in:
midoks
2019-02-17 22:10:14 +08:00
parent f7b3fbc249
commit 8b6bdd25d9
2 changed files with 22 additions and 1 deletions
+21
View File
@@ -22,6 +22,7 @@ class site_api:
setupPath = None # 安装路径
vhostPath = None
logsPath = None
rewritePath = None
sslDir = None # ssl目录
@@ -35,6 +36,8 @@ class site_api:
if not os.path.exists(rw):
public.execShell("mkdir -p " + rw + " && chmod -R 755 " + rw)
self.logsPath = public.getRootDir() + '/wwwlogs'
# ssl conf
if public.isAppleSystem():
self.sslDir = self.setupPath + '/letsencrypt/'
@@ -166,6 +169,24 @@ class site_api:
public.execShell("which chattr && chattr +i " + filename)
return public.returnJson(True, '已打开防跨站设置!')
def logsOpenApi(self):
mid = request.form.get('id', '').encode('utf-8')
name = public.M('sites').where("id=?", (mid,)).getField('name')
# NGINX
filename = self.getHostConf(name)
if os.path.exists(filename):
conf = public.readFile(filename)
rep = self.logsPath + "/" + name + ".log"
if conf.find(rep) != -1:
conf = conf.replace(rep, "off")
else:
conf = conf.replace('access_log off', 'access_log ' + rep)
public.writeFile(filename, conf)
public.restartWeb()
return public.returnJson(True, '操作成功!')
def getCertListApi(self):
try:
vpath = self.sslDir