diff --git a/class/core/site_api.py b/class/core/site_api.py
index f0778a326..66e5e3811 100755
--- a/class/core/site_api.py
+++ b/class/core/site_api.py
@@ -100,6 +100,56 @@ class site_api:
data['email'] = ''
return public.returnJson(True, 'OK', data)
+ def getDirBindingApi(self):
+ mid = request.form.get('id', '').encode('utf-8')
+
+ path = public.M('sites').where('id=?', (mid,)).getField('path')
+ if not os.path.exists(path):
+ checks = ['/', '/usr', '/etc']
+ if path in checks:
+ data = {}
+ data['dirs'] = []
+ data['binding'] = []
+ return public.returnJson(True, 'OK', data)
+ os.system('mkdir -p ' + path)
+ os.system('chmod 755 ' + path)
+ os.system('chown www:www ' + path)
+ siteName = public.M('sites').where(
+ 'id=?', (get.id,)).getField('name')
+ public.writeLog(
+ '网站管理', '站点[' + siteName + '],根目录[' + path + ']不存在,已重新创建!')
+
+ dirnames = []
+ for filename in os.listdir(path):
+ try:
+ filePath = path + '/' + filename
+ if os.path.islink(filePath):
+ continue
+ if os.path.isdir(filePath):
+ dirnames.append(filename)
+ except:
+ pass
+
+ data = {}
+ data['dirs'] = dirnames
+ data['binding'] = public.M('binding').where('pid=?', (mid,)).field(
+ 'id,pid,domain,path,port,addtime').select()
+ return public.returnJson(True, 'OK', data)
+
+ def getDirUserIniApi(self):
+ mid = request.form.get('id', '').encode('utf-8')
+
+ path = public.M('sites').where('id=?', (mid,)).getField('path')
+ name = public.M('sites').where("id=?", (mid,)).getField('name')
+ data = {}
+ data['logs'] = self.getLogsStatus(name)
+ data['userini'] = False
+ if os.path.exists(path + '/.user.ini'):
+ data['userini'] = True
+ data['runPath'] = self.getSiteRunPath(mid)
+ data['pass'] = self.getHasPwd(name)
+ return public.returnJson(True, 'OK', data)
+
def getCertListApi(self):
try:
vpath = self.sslDir
@@ -203,6 +253,54 @@ class site_api:
public.writeLog('TYPE_SITE', '证书已保存!')
return public.returnJson(True, '证书已保存!')
+ def closeSslConfApi(self):
+ siteName = request.form.get('siteName', '').encode('utf-8')
+
+ file = self.getHostConf(siteName)
+ conf = public.readFile(file)
+
+ if conf:
+ rep = "\n\s*#HTTP_TO_HTTPS_START(.|\n){1,300}#HTTP_TO_HTTPS_END"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_certificate\s+.+;\s+ssl_certificate_key\s+.+;"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_protocols\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_ciphers\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_prefer_server_ciphers\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_session_cache\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_session_timeout\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_ecdh_curve\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_session_tickets\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_stapling\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl_stapling_verify\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+add_header\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+add_header\s+.+;\n"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+ssl\s+on;"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+error_page\s497.+;"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+if.+server_port.+\n.+\n\s+\s*}"
+ conf = re.sub(rep, '', conf)
+ rep = "\s+listen\s+443.*;"
+ conf = re.sub(rep, '', conf)
+ public.writeFile(file, conf)
+
+ msg = public.getInfo('网站[{1}]关闭SSL成功!', (siteName,))
+ public.writeLog('TYPE_SITE', msg)
+ public.restartWeb()
+ return public.returnJson(True, 'SSL已关闭!')
+
def createLetApi(self):
siteName = request.form.get('siteName', '').encode('utf-8')
updateOf = request.form.get('updateOf', '')
@@ -589,6 +687,39 @@ class site_api:
return path
return ''
+ # 取当站点前运行目录
+ def getSiteRunPath(self, mid):
+ siteName = public.M('sites').where('id=?', (mid,)).getField('name')
+ sitePath = public.M('sites').where('id=?', (mid,)).getField('path')
+ path = sitePath
+
+ filename = self.getHostConf(siteName)
+ if os.path.exists(filename):
+ conf = public.readFile(filename)
+ rep = '\s*root\s*(.+);'
+ path = re.search(rep, conf).groups()[0]
+
+ data = {}
+ if sitePath == path:
+ data['runPath'] = '/'
+ else:
+ data['runPath'] = path.replace(sitePath, '')
+
+ dirnames = []
+ dirnames.append('/')
+ for filename in os.listdir(sitePath):
+ try:
+ filePath = sitePath + '/' + filename
+ if os.path.islink(filePath):
+ continue
+ if os.path.isdir(filePath):
+ dirnames.append('/' + filename)
+ except:
+ pass
+
+ data['dirs'] = dirnames
+ return data
+
def getHostConf(self, siteName):
return public.getServerDir() + '/openresty/nginx/conf/vhost/' + siteName + '.conf'
@@ -609,6 +740,24 @@ class site_api:
return public.returnJson(False, '日志为空')
return public.returnJson(True, public.getNumLines(logPath, 100))
+ # 取日志状态
+ def getLogsStatus(self, siteName):
+ filename = self.getHostConf(siteName)
+ conf = public.readFile(filename)
+ if conf.find('#ErrorLog') != -1:
+ return False
+ if conf.find("access_log /dev/null") != -1:
+ return False
+ return True
+
+ # 取目录加密状态
+ def getHasPwd(self, siteName):
+ filename = self.getHostConf(siteName)
+ conf = public.readFile(filename)
+ if conf.find('#AUTH_START') != -1:
+ return True
+ return False
+
def getSitePhpVersion(self, siteName):
conf = public.readFile(self.getHostConf(siteName))
rep = "enable-php-([0-9]{2,3})\.conf"
diff --git a/route/static/app/site.js b/route/static/app/site.js
index d0cb0e994..413742a08 100755
--- a/route/static/app/site.js
+++ b/route/static/app/site.js
@@ -283,66 +283,65 @@ function webAdd(type) {
//修改网站目录
function webPathEdit(id){
- $.post("/data?action=getKey","table=sites&key=path&id="+id,function(rdata){
- $.post('/site?action=GetDirUserINI','path='+rdata+'&id='+id,function(userini){
- var userinicheckeds = userini.userini?'checked':'';
- var logscheckeds = userini.logs?'checked':'';
- var opt = ''
- var selected = '';
- for(var i=0;i '+lan.soft.pma_user+' '+lan.soft.pma_pass1+' '+lan.soft.pma_pass2+' 注意:设置防跨站需要重启PHP才能生效! '+lan.soft.pma_user+' '+lan.soft.pma_pass1+' '+lan.soft.pma_pass2+' 注意:设置防跨站需要重启PHP才能生效! 子目录绑定 子目录绑定 网站目录 流量限制 伪静态 配置文件 SSL PHP版本 301重定向 重定向 反向代理 防盗链 响应日志 "+lan.site.get_ssl_err+": 证书获取失败:\
-
"
- +'\
+
"
+ +'"+rdata.binding[i].domain+" "+rdata.binding[i].port+" "+rdata.binding[i].path+" "+lan.site.site_menu_4+" | "+lan.public.del+" ";
@@ -1276,18 +1274,17 @@ function DirBinding(id){
}
var body = ""
- +"
"
- +"" + echoHtml + ""
- +""+lan.site.domain+" "+lan.site.port+" "+lan.site.subdirectories+" "+lan.site.operate+" "
+ + "
"
+ + "" + echoHtml + ""
+ + "域名 端口 子目录 操作
"
+ data = "
"
for(var i=0;i
"+lan.site.err_type+": "+rdata.out[i].Type+"
" - + ""+lan.site.details+": "+rdata.out[i].Detail+"
" - + "域名: "+rdata.out[i].Domain+"
" + + "错误类型: "+rdata.out[i].Type+"
" + + "详情: "+rdata.out[i].Detail+"
" + + "