mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:29:26 +08:00
update
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `backup` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`pid` INTEGER,
|
||||
`type` INTEGER,
|
||||
`name` TEXT,
|
||||
`pid` INTEGER,
|
||||
`filename` TEXT,
|
||||
`size` INTEGER,
|
||||
`add_time` TEXT
|
||||
|
||||
@@ -23,7 +23,7 @@ import thisdb
|
||||
|
||||
from .site import blueprint
|
||||
|
||||
# 设置默认站
|
||||
# 获取备份列表
|
||||
@blueprint.route('/get_backup', endpoint='get_backup',methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_backup():
|
||||
@@ -32,6 +32,22 @@ def get_backup():
|
||||
site_id = request.form.get('search', '')
|
||||
return MwSites.instance().getBackup(site_id,page=page,size=limit)
|
||||
|
||||
# 设置备份
|
||||
@blueprint.route('/to_backup', endpoint='to_backup',methods=['POST'])
|
||||
@panel_login_required
|
||||
def to_backup():
|
||||
site_id = request.form.get('id', '')
|
||||
return MwSites.instance().toBackup(site_id)
|
||||
|
||||
# 删除备份
|
||||
@blueprint.route('/del_backup', endpoint='del_backup',methods=['POST'])
|
||||
@panel_login_required
|
||||
def del_backup():
|
||||
site_id = request.form.get('id', '')
|
||||
return MwSites.instance().delBackup(site_id)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+15
-15
@@ -803,7 +803,7 @@ function getBackup(id,name,page) {
|
||||
var ftpdown = "<a class='btlink' href='/files/download?filename="+frdata.data[i].filename+"&name="+frdata.data[i].name+"' target='_blank'>下载</a> | ";
|
||||
body += "<tr><td><span class='glyphicon glyphicon-file'></span>"+frdata.data[i].name+"</td>\
|
||||
<td>" + (toSize(frdata.data[i].size)) + "</td>\
|
||||
<td>" + frdata.data[i].addtime + "</td>\
|
||||
<td>" + frdata.data[i].add_time + "</td>\
|
||||
<td class='text-right' style='color:#ccc'>"+ ftpdown + "<a class='btlink' href='javascript:;' onclick=\"webBackupDelete('" + frdata.data[i].id + "',"+id+")\">删除</a></td>\
|
||||
</tr>"
|
||||
}
|
||||
@@ -813,9 +813,9 @@ function getBackup(id,name,page) {
|
||||
|
||||
if(name == 0){
|
||||
var sBody = "<table width='100%' id='webBackupList' class='table table-hover'>\
|
||||
<thead><tr><th>文件名称</th><th>文件大小</th><th>打包时间</th><th width='140px' class='text-right'>操作</th></tr></thead>\
|
||||
<tbody id='webBackupBody' class='list-list'>"+body+"</tbody>\
|
||||
</table>"
|
||||
<thead><tr><th>文件名称</th><th>文件大小</th><th>打包时间</th><th width='140px' class='text-right'>操作</th></tr></thead>\
|
||||
<tbody id='webBackupBody' class='list-list'>"+body+"</tbody>\
|
||||
</table>"
|
||||
$("#webBackupList").html(sBody);
|
||||
$(".page").html(frdata.page);
|
||||
return;
|
||||
@@ -830,17 +830,17 @@ function getBackup(id,name,page) {
|
||||
shift: 0,
|
||||
shadeClose: false,
|
||||
content: "<div class='bt-form ptb15 mlr15' id='webBackup'>\
|
||||
<button class='btn btn-default btn-sm' style='margin-right:10px' type='button' onclick=\"webBackup('" + frdata['site']['id'] + "','" + frdata['site']['name'] + "')\">打包备份</button>\
|
||||
<div class='divtable mtb15' style='margin-bottom:0'>\
|
||||
<table width='100%' id='webBackupList' class='table table-hover'>\
|
||||
<thead>\
|
||||
<tr><th>文件名称</th><th>文件大小</th><th>打包时间</th><th width='140px' class='text-right'>操作</th></tr>\
|
||||
</thead>\
|
||||
<tbody id='webBackupBody' class='list-list'>" + body + "</tbody>\
|
||||
</table>\
|
||||
<div class='page'>" + frdata.page + "</div>\
|
||||
</div>\
|
||||
</div>"
|
||||
<button class='btn btn-default btn-sm' style='margin-right:10px' type='button' onclick=\"webBackup('" + frdata['site']['id'] + "','" + frdata['site']['name'] + "')\">打包备份</button>\
|
||||
<div class='divtable mtb15' style='margin-bottom:0'>\
|
||||
<table width='100%' id='webBackupList' class='table table-hover'>\
|
||||
<thead>\
|
||||
<tr><th>文件名称</th><th>文件大小</th><th>打包时间</th><th width='140px' class='text-right'>操作</th></tr>\
|
||||
</thead>\
|
||||
<tbody id='webBackupBody' class='list-list'>" + body + "</tbody>\
|
||||
</table>\
|
||||
<div class='page'>" + frdata.page + "</div>\
|
||||
</div>\
|
||||
</div>"
|
||||
});
|
||||
},'json');
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ from .option import *
|
||||
|
||||
from .sites import *
|
||||
from .site_types import *
|
||||
from .backup import *
|
||||
|
||||
from .domain import *
|
||||
from .binding import *
|
||||
|
||||
|
||||
+22
-8
@@ -10,16 +10,27 @@
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
# 站点-子目录绑定
|
||||
__FIELD = 'id,pid,type,name,filename,size,add_time'
|
||||
|
||||
__FIELD = 'id,type,name,pid,filename,size,add_time'
|
||||
def addBackup(pid,name,filename,size,type=0):
|
||||
|
||||
def getBackupPage(
|
||||
site_id = 1,
|
||||
page = 1,
|
||||
size = 10,
|
||||
):
|
||||
start = (page - 1) * size
|
||||
add_time = mw.formatDate()
|
||||
insert_data = {
|
||||
'type':type,
|
||||
'name':name,
|
||||
'pid':pid,
|
||||
'filename':filename,
|
||||
'size':size,
|
||||
'add_time':add_time,
|
||||
}
|
||||
mw.M('backup').insert(insert_data)
|
||||
return True
|
||||
|
||||
def getBackupById(bp_id):
|
||||
return mw.M('backup').field(__FIELD).where("id=?", (bp_id,)).find()
|
||||
|
||||
def getBackupPage(site_id,page = 1,size = 10):
|
||||
start = (int(page) - 1) * int(size)
|
||||
limit = str(start) + ',' + str(size)
|
||||
bk_list = mw.M('backup').where('pid=?', (site_id,)).field(__FIELD).limit(limit).order('id desc').select()
|
||||
count = mw.M('backup').where('pid=?', (site_id,)).count()
|
||||
@@ -28,3 +39,6 @@ def getBackupPage(
|
||||
rdata['list'] = bk_list
|
||||
rdata['count'] = count
|
||||
return rdata
|
||||
|
||||
def deleteBackupById(bp_id):
|
||||
return mw.M('backup').where("id=?", (bp_id,)).delete()
|
||||
|
||||
+36
-5
@@ -2351,15 +2351,46 @@ export PATH
|
||||
data = {}
|
||||
data['data'] = info['list']
|
||||
data['site'] = site_info
|
||||
data['page'] = mw.getPage({'count':info['count'],'tojs':'getBackup','p':page, 'row':limit})
|
||||
data['page'] = mw.getPage({'count':info['count'],'tojs':'getBackup','p':page, 'row':size})
|
||||
return data
|
||||
|
||||
def toBackup(self, site_id):
|
||||
site_info = thisdb.getSitesById(site_id)
|
||||
|
||||
filename = site_info['name'] + '_' + time.strftime('%Y%m%d_%H%M%S', time.localtime()) + '.zip'
|
||||
backup_path = mw.getBackupDir() + '/site'
|
||||
zip_name = backup_path + '/' + filename
|
||||
if not (os.path.exists(backup_path)):
|
||||
os.makedirs(backup_path)
|
||||
exec_log = mw.getPanelDir() + '/logs/panel_exec.log'
|
||||
cmd = "cd '" + site_info['path'] + "' && zip '" + zip_name + "' -r ./* > " + exec_log + " 2>&1"
|
||||
mw.execShell(cmd)
|
||||
|
||||
fsize = 0
|
||||
if os.path.exists(zip_name):
|
||||
fsize = os.path.getsize(zip_name)
|
||||
|
||||
thisdb.addBackup(site_id,filename,zip_name,fsize)
|
||||
|
||||
msg = mw.getInfo('备份网站[{1}]成功!', (site_info['name'],))
|
||||
mw.writeLog('网站管理', msg)
|
||||
return mw.returnData(True, '备份成功!')
|
||||
|
||||
def delBackup(self,backup_id):
|
||||
info = thisdb.getBackupById(backup_id)
|
||||
if os.path.exists(info['filename']):
|
||||
os.remove(info['filename'])
|
||||
msg = mw.getInfo('删除网站[{1}]的备份[{2}]成功!', (info['name'], info['filename']))
|
||||
mw.writeLog('网站管理', msg)
|
||||
|
||||
thisdb.deleteBackupById(backup_id)
|
||||
return mw.returnData(True, '站点删除成功!')
|
||||
|
||||
|
||||
def getPhpVersion(self):
|
||||
phpVersions = ('00', '52', '53', '54', '55',
|
||||
'56', '70', '71', '72', '73',
|
||||
'74', '80', '81', '82', '83',
|
||||
'84')
|
||||
phpVersions = ('00', '52', '53', '54', '55', '56',
|
||||
'70', '71', '72', '73', '74', '80',
|
||||
'81', '82', '83', '84')
|
||||
data = []
|
||||
for val in phpVersions:
|
||||
tmp = {}
|
||||
|
||||
Reference in New Issue
Block a user