diff --git a/class/core/site_api.py b/class/core/site_api.py
index 64888f11f..f4bd1b799 100755
--- a/class/core/site_api.py
+++ b/class/core/site_api.py
@@ -80,6 +80,59 @@ class site_api:
return public.returnJson(True, '修改成功!')
return public.returnJson(False, '修改失败!')
+ def stopApi(self):
+ mid = request.form.get('id', '').encode('utf-8')
+ name = request.form.get('name', '').encode('utf-8')
+ path = self.setupPath + '/stop'
+
+ if not os.path.exists(path):
+ os.makedirs(path)
+ public.writeFile(path + '/index.html',
+ 'The website has been closed!!!')
+
+ binding = public.M('binding').where('pid=?', (mid,)).field(
+ 'id,pid,domain,path,port,addtime').select()
+ for b in binding:
+ bpath = path + '/' + b['path']
+ if not os.path.exists(bpath):
+ public.execShell('mkdir -p ' + bpath)
+ public.execShell('ln -sf ' + path +
+ '/index.html ' + bpath + '/index.html')
+
+ sitePath = public.M('sites').where("id=?", (mid,)).getField('path')
+
+ # nginx
+ file = self.getHostConf(name)
+ conf = public.readFile(file)
+ if conf:
+ conf = conf.replace(sitePath, path)
+ public.writeFile(file, conf)
+
+ public.M('sites').where("id=?", (mid,)).setField('status', '0')
+ public.restartWeb()
+ msg = public.getInfo('网站[{1}]已被停用!', (name,))
+ public.writeLog('网站管理', msg)
+ return public.returnJson(True, '站点已停用!')
+
+ def startApi(self):
+ mid = request.form.get('id', '').encode('utf-8')
+ name = request.form.get('name', '').encode('utf-8')
+ path = self.setupPath + '/stop'
+ sitePath = public.M('sites').where("id=?", (mid,)).getField('path')
+
+ # nginx
+ file = self.getHostConf(name)
+ conf = public.readFile(file)
+ if conf:
+ conf = conf.replace(path, sitePath)
+ public.writeFile(file, conf)
+
+ public.M('sites').where("id=?", (mid,)).setField('status', '1')
+ public.restartWeb()
+ msg = public.getInfo('网站[{1}]已被启用!', (name,))
+ public.writeLog('网站管理', msg)
+ return public.returnJson(True, '站点已启用!')
+
def getBackupApi(self):
limit = request.form.get('limit', '').encode('utf-8')
p = request.form.get('p', '').encode('utf-8')
diff --git a/route/static/app/site.js b/route/static/app/site.js
index 0bb5044a6..21aa1e9fd 100755
--- a/route/static/app/site.js
+++ b/route/static/app/site.js
@@ -37,7 +37,7 @@ function getWeb(page, search) {
var backup = "无备份";
}
//是否设置有效期
- var web_end_time = (data.data[i].edate == "0000-00-00") ? lan.site.web_end_time : data.data[i].edate;
+ var web_end_time = (data.data[i].edate == "0000-00-00") ? '永久': data.data[i].edate;
//表格主体
var shortwebname = data.data[i].name;
var shortpath = data.data[i].path;
@@ -53,51 +53,51 @@ function getWeb(page, search) {
" + shortwebname + " | \
" + status + " | \
" + backup + " | \
- " + shortpath + " | \
+ " + shortpath + " | \
" + web_end_time + " | \
" + data.data[i].ps + " | \
| \
\
- "+lan.site.set+" \
- | "+lan.public.del+"\
+ 设置\
+ | 删除\
| "
$("#webBody").append(body);
//setEdate(data.data[i].id,data.data[i].edate);
//设置到期日期
- function getDate(a) {
- var dd = new Date();
- dd.setTime(dd.getTime() + (a == undefined || isNaN(parseInt(a)) ? 0 : parseInt(a)) * 86400000);
- var y = dd.getFullYear();
- var m = dd.getMonth() + 1;
- var d = dd.getDate();
- return y + "-" + (m < 10 ? ('0' + m) : m) + "-" + (d < 10 ? ('0' + d) : d);
- }
+ function getDate(a) {
+ var dd = new Date();
+ dd.setTime(dd.getTime() + (a == undefined || isNaN(parseInt(a)) ? 0 : parseInt(a)) * 86400000);
+ var y = dd.getFullYear();
+ var m = dd.getMonth() + 1;
+ var d = dd.getDate();
+ return y + "-" + (m < 10 ? ('0' + m) : m) + "-" + (d < 10 ? ('0' + d) : d);
+ }
$('#webBody').on('click','#site_'+ data.data[i].id,function(){
- var _this = $(this);
- var id = $(this).attr('data-ids');
- laydate.render({
- elem: '#site_'+ id //指定元素
- ,min:getDate(1)
- ,max:'2099-12-31'
- ,vlue:getDate(365)
- ,type:'date'
- ,format :'yyyy-MM-dd'
- ,trigger:'click'
- ,btns:['perpetual', 'confirm']
- ,theme:'#20a53a'
- ,done:function(dates){
- if(_this.html() == '永久'){
- dates = '0000-00-00';
- }
- var loadT = layer.msg(lan.site.saving_txt, { icon: 16, time: 0, shade: [0.3, "#000"]});
- $.post('/site/set_end_date','id='+id+'&edate='+dates,function(rdata){
- layer.close(loadT);
- layer.msg(rdata.msg,{icon:rdata.status?1:5});
- },'json');
- }
- });
- this.click();
+ var _this = $(this);
+ var id = $(this).attr('data-ids');
+ laydate.render({
+ elem: '#site_'+ id //指定元素
+ ,min:getDate(1)
+ ,max:'2099-12-31'
+ ,vlue:getDate(365)
+ ,type:'date'
+ ,format :'yyyy-MM-dd'
+ ,trigger:'click'
+ ,btns:['perpetual', 'confirm']
+ ,theme:'#20a53a'
+ ,done:function(dates){
+ if(_this.html() == '永久'){
+ dates = '0000-00-00';
+ }
+ var loadT = layer.msg(lan.site.saving_txt, { icon: 16, time: 0, shade: [0.3, "#000"]});
+ $.post('/site/set_end_date','id='+id+'&edate='+dates,function(rdata){
+ layer.close(loadT);
+ layer.msg(rdata.msg,{icon:rdata.status?1:5});
+ },'json');
+ }
+ });
+ this.click();
});
}
if(body.length < 10){
@@ -117,8 +117,8 @@ function getWeb(page, search) {
$(".btlinkbed").click(function(){
var dataid = $(this).attr("data-id");
var databak = $(this).text();
- if(databak==lan.site.site_null){
- databak='';
+ if(databak == null){
+ databak = '';
}
$(this).hide().after("");
$(".baktext").focus();
@@ -476,15 +476,14 @@ function setIndexEdit(id){
* @param {String} wname 网站名称
*/
function webStop(wid, wname) {
- layer.confirm(lan.site.site_stop_txt, {icon:3,closeBtn:2},function(index) {
+ layer.confirm('站点停用后将无法访问,您真的要停用这个站点吗?', {icon:3,closeBtn:2},function(index) {
if (index > 0) {
- var loadT = layer.load()
- $.post("/site?action=SiteStop","id=" + wid + "&name=" + wname, function(ret) {
+ var loadT = layer.load();
+ $.post("/site/stop","id=" + wid + "&name=" + wname, function(ret) {
layer.msg(ret.msg,{icon:ret.status?1:2})
layer.close(loadT);
getWeb(1);
-
- });
+ },'json');
}
});
}
@@ -495,14 +494,14 @@ function webStop(wid, wname) {
* @param {String} wname 网站名称
*/
function webStart(wid, wname) {
- layer.confirm(lan.site.site_start_txt,{icon:3,closeBtn:2}, function(index) {
+ layer.confirm('即将启动站点,您真的要启用这个站点吗?',{icon:3,closeBtn:2}, function(index) {
if (index > 0) {
var loadT = layer.load()
- $.post("/site?action=SiteStart","id=" + wid + "&name=" + wname, function(ret) {
+ $.post("/site/start","id=" + wid + "&name=" + wname, function(ret) {
layer.msg(ret.msg,{icon:ret.status?1:2})
layer.close(loadT);
getWeb(1);
- });
+ },'json');
}
});
}