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