pull/109/head
midoks 6 years ago
parent 6dc702a941
commit 12dbdc3659
  1. 18
      class/core/site_api.py
  2. 6
      route/static/app/site.js

@ -36,9 +36,9 @@ class site_api:
self.rewritePath = rw = self.setupPath + '/nginx/rewrite'
if not os.path.exists(rw):
public.execShell("mkdir -p " + rw + " && chmod -R 755 " + rw)
self.passPath = pp = self.setupPath + '/nginx/pass'
if not os.path.exists(rw):
public.execShell("mkdir -p " + rw + " && chmod -R 755 " + rw)
self.passPath = self.setupPath + '/nginx/pass'
# if not os.path.exists(pp):
# public.execShell("mkdir -p " + rw + " && chmod -R 755 " + rw)
self.logsPath = public.getRootDir() + '/wwwlogs'
# ssl conf
@ -822,6 +822,7 @@ class site_api:
password = request.form.get('password', '').encode('utf-8')
siteName = request.form.get('siteName', '').encode('utf-8')
mid = request.form.get('id', '')
if len(username.strip()) == 0 or len(password.strip()) == 0:
return public.returnJson(False, '用户名或密码不能为空!')
@ -829,10 +830,11 @@ class site_api:
siteName = public.M('sites').where('id=?', (mid,)).getField('name')
# self.closeHasPwd(get)
filename = self.passPath + siteName + '.pass'
filename = self.passPath + '/' + siteName + '.pass'
print filename
passconf = username + ':' + public.hasPwd(password)
if get.siteName == 'phpmyadmin':
if siteName == 'phpmyadmin':
configFile = self.setupPath + '/openresty/nginx/conf/nginx.conf'
else:
configFile = self.setupPath + '/openresty/nginx/vhost/' + siteName + '.conf'
@ -854,7 +856,7 @@ class site_api:
# 写密码配置
passDir = self.passPath
if not os.path.exists(passDir):
public.ExecShell('mkdir -p ' + passDir)
public.execShell('mkdir -p ' + passDir)
public.writeFile(filename, passconf)
public.restartWeb()
@ -879,8 +881,8 @@ class site_api:
# conf = re.sub(rep, '', conf)
# public.writeFile(get.configFile, conf)
# public.serviceReload()
# public.WriteLog("TYPE_SITE", "SITE_AUTH_CLOSE_SUCCESS",
# public.restartWeb()
# public.WriteLog("网站管理", "SITE_AUTH_CLOSE_SUCCESS",
# (get.siteName,))
# return public.returnMsg(True, 'SET_SUCCESS')

@ -356,8 +356,7 @@ function pathSafe(id){
var loadT = layer.msg(lan.public.the,{icon:16,time:10000,shade: [0.3, '#000']});
$.post('/site?action=CloseHasPwd',{id:id},function(rdata){
layer.close(loadT);
var ico = rdata.status?1:2;
layer.msg(rdata.msg,{icon:ico});
layer.msg(rdata.msg,{icon:rdata.status?1:2});
$(".user_pw").hide();
},'json');
}
@ -375,8 +374,7 @@ function setPathSafe(id){
var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:10000,shade: [0.3, '#000']});
$.post('/site/set_has_pwd',{id:id,username:username,password:pass1},function(rdata){
layer.close(loadT);
var ico = rdata.status?1:2;
layer.msg(rdata.msg,{icon:ico});
layer.msg(rdata.msg,{icon:rdata.status?1:2});
},'json');
}

Loading…
Cancel
Save