mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -42,15 +42,16 @@ class config:
|
||||
app.config['SECRET_KEY'] = os.urandom(24)
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
|
||||
|
||||
# app.debug = True
|
||||
# app.config.version = self.__version + str(time.time())
|
||||
|
||||
self.initDB()
|
||||
self.initInitD()
|
||||
self.initRoute()
|
||||
app.wsgi_app = MiddleWare(app.wsgi_app)
|
||||
return app
|
||||
|
||||
def startDebug(self):
|
||||
app.debug = True
|
||||
app.config.version = self.__version + str(time.time())
|
||||
|
||||
def initDB(self):
|
||||
try:
|
||||
sql = db.Sql().dbfile('default')
|
||||
|
||||
@@ -98,6 +98,37 @@ class site_api:
|
||||
data['phpversion'] = tmp[0]
|
||||
return public.getJson(data)
|
||||
|
||||
def getIndex(self, sid):
|
||||
print sid
|
||||
siteName = public.M('sites').where("id=?", (sid,)).getField('name')
|
||||
file = self.getHostConf(siteName)
|
||||
conf = public.readFile(file)
|
||||
rep = "\s+index\s+(.+);"
|
||||
tmp = re.search(rep, conf).groups()
|
||||
return tmp[0].replace(' ', ',')
|
||||
|
||||
def setIndex(self, sid, index):
|
||||
if index.find('.') == -1:
|
||||
return public.returnJson(False, '默认文档格式不正确,例:index.html')
|
||||
|
||||
index = index.replace(' ', '')
|
||||
index = index.replace(',,', ',')
|
||||
|
||||
if len(index) < 3:
|
||||
return public.returnJson(False, '默认文档不能为空!')
|
||||
|
||||
siteName = public.M('sites').where("id=?", (sid,)).getField('name')
|
||||
index_l = index.replace(",", " ")
|
||||
file = self.getHostConf(siteName)
|
||||
conf = public.readFile(file)
|
||||
if conf:
|
||||
rep = "\s+index\s+.+;"
|
||||
conf = re.sub(rep, "\n\tindex " + index_l + ";", conf)
|
||||
public.writeFile(file, conf)
|
||||
|
||||
public.writeLog('TYPE_SITE', 'SITE_INDEX_SUCCESS', (siteName, index_l))
|
||||
return public.returnJson(True, '设置成功!')
|
||||
|
||||
def getHostConf(self, siteName):
|
||||
return public.getServerDir() + '/openresty/nginx/conf/vhost/' + siteName + '.conf'
|
||||
|
||||
|
||||
@@ -10,8 +10,9 @@ mw_start(){
|
||||
|
||||
|
||||
mw_start_debug(){
|
||||
gunicorn -b :7200 app:app &
|
||||
python task.py &
|
||||
# gunicorn -b :7200 app:app
|
||||
gunicorn -c setting.py app:app
|
||||
}
|
||||
|
||||
mw_stop()
|
||||
|
||||
@@ -37,6 +37,22 @@ def getDomain():
|
||||
return site_api.site_api().getDomain(pid)
|
||||
|
||||
|
||||
@site.route('get_index', methods=['POST'])
|
||||
def getIndex():
|
||||
sid = request.form.get('id', '').encode('utf-8')
|
||||
data = {}
|
||||
index = site_api.site_api().getIndex(sid)
|
||||
data['index'] = index
|
||||
return public.getJson(data)
|
||||
|
||||
|
||||
@site.route('set_index', methods=['POST'])
|
||||
def setIndex():
|
||||
sid = request.form.get('id', '').encode('utf-8')
|
||||
index = request.form.get('index', '').encode('utf-8')
|
||||
return site_api.site_api().setIndex(sid, index)
|
||||
|
||||
|
||||
@site.route('get_logs', methods=['POST'])
|
||||
def getLogs():
|
||||
siteName = request.form.get('siteName', '').encode('utf-8')
|
||||
|
||||
+16
-19
@@ -449,24 +449,23 @@ function SetSitePs(id){
|
||||
|
||||
|
||||
//设置默认文档
|
||||
function SetIndexEdit(id){
|
||||
$.post('/site?action=GetIndex','id='+id,function(rdata){
|
||||
rdata= rdata.replace(new RegExp(/(,)/g), "\n");
|
||||
function setIndexEdit(id){
|
||||
$.post('/site/get_index','id='+id,function(data){
|
||||
var rdata = data['index'];
|
||||
rdata = rdata.replace(new RegExp(/(,)/g), "\n");
|
||||
var setIndexHtml = "<div id='SetIndex'><div class='SetIndex'>\
|
||||
<div class='line'>\
|
||||
<textarea class='bt-input-text' id='Dindex' name='files' style='height: 180px; width:50%; line-height:20px'>"+rdata+"</textarea>\
|
||||
<button type='button' class='btn btn-success btn-sm pull-right' onclick='SetIndexList("+id+")' style='margin: 70px 130px 0px 0px;'>"+lan.public.save+"</button>\
|
||||
<button type='button' class='btn btn-success btn-sm pull-right' onclick='setIndexList("+id+")' style='margin: 70px 130px 0px 0px;'>"+lan.public.save+"</button>\
|
||||
</div>\
|
||||
<ul class='help-info-text c7 ptb10'>\
|
||||
<li>"+lan.site.default_doc_help+"</li>\
|
||||
<li>默认文档,每行一个,优先级由上至下。</li>\
|
||||
</ul>\
|
||||
</div></div>";
|
||||
$("#webedit-con").html(setIndexHtml);
|
||||
});
|
||||
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止一个站点
|
||||
* @param {Int} wid 网站ID
|
||||
@@ -934,7 +933,7 @@ function setIndex(id){
|
||||
+"</div>"
|
||||
+"<div class='bt-form-submit-btn'>"
|
||||
+" <button type='button' id='web_end_time' class='btn btn-danger btn-sm btn-title' onclick='layer.closeAll()'>"+lan.public.cancel+"</button>"
|
||||
+" <button type='button' class='btn btn-success btn-sm btn-title' onclick='SetIndexList("+id+")'>"+lan.public.ok+"</button>"
|
||||
+" <button type='button' class='btn btn-success btn-sm btn-title' onclick='setIndexList("+id+")'>"+lan.public.ok+"</button>"
|
||||
+"</div>"
|
||||
+"</div></form>"
|
||||
});
|
||||
@@ -988,24 +987,22 @@ function GetDefaultSite(){
|
||||
});
|
||||
}
|
||||
|
||||
function SetIndexList(id){
|
||||
function setIndexList(id){
|
||||
var Dindex = $("#Dindex").val().replace(new RegExp(/(\n)/g), ",");
|
||||
if(id==undefined){
|
||||
var data="id=&Index="+Dindex;
|
||||
}
|
||||
else{
|
||||
var data="id="+id+"&Index="+Dindex;
|
||||
if(id == undefined ){
|
||||
var data="id=&index="+Dindex;
|
||||
} else{
|
||||
var data="id="+id+"&index="+Dindex;
|
||||
}
|
||||
var loadT= layer.load(2);
|
||||
$.post('/site?action=SetIndex',data,function(rdata){
|
||||
$.post('/site/set_index',data,function(rdata){
|
||||
layer.close(loadT);
|
||||
var ico = rdata.status? 1:5;
|
||||
layer.msg(rdata.msg,{icon:ico});
|
||||
});
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*站点修改*/
|
||||
function webEdit(id,website,endTime,addtime){
|
||||
var system = "{$Think.session.system}";
|
||||
@@ -1014,7 +1011,7 @@ function webEdit(id,website,endTime,addtime){
|
||||
+"<p onclick='webPathEdit("+id+")' title='"+lan.site.site_menu_2+"'>"+lan.site.site_menu_2+"</p>"
|
||||
+"<p onclick='limitNet("+id+")' title='"+lan.site.site_menu_3+"'>"+lan.site.site_menu_3+"</p>"
|
||||
+"<p onclick=\"Rewrite('"+website+"')\" title='"+lan.site.site_menu_4+"'>"+lan.site.site_menu_4+"</p>"
|
||||
+"<p onclick='SetIndexEdit("+id+")' title='"+lan.site.site_menu_5+"'>"+lan.site.site_menu_5+"</p>"
|
||||
+"<p onclick='setIndexEdit("+id+")' title='默认文档'>默认文档</p>"
|
||||
+"<p onclick=\"configFile('"+website+"')\" title='"+lan.site.site_menu_6+"'>"+lan.site.site_menu_6+"</p>"
|
||||
+"<p onclick=\"SetSSL("+id+",'"+website+"')\" title='"+lan.site.site_menu_7+"'>"+lan.site.site_menu_7+"</p>"
|
||||
+"<p onclick=\"phpVersion('"+website+"')\" title='"+lan.site.site_menu_8+"'>"+lan.site.site_menu_8+"</p>"
|
||||
|
||||
Reference in New Issue
Block a user