pull/109/head
midoks 6 years ago
parent e62c536046
commit 909e7497da
  1. 21
      class/core/site_api.py
  2. 2
      route/static/app/site.js

@ -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

@ -339,7 +339,7 @@ function webPathEdit(id){
});
$("#logs").change(function(){
$.post('/site?action=logsOpen','id='+id,function(userini){
$.post('/site/logs_open','id='+id,function(userini){
layer.msg(userini.msg,{icon:userini.status?1:2});
},'josn');
});

Loading…
Cancel
Save