From f4fb0da9d18b5759ab663c6f70373c0f46aa12b6 Mon Sep 17 00:00:00 2001
From: "bt.cn" <287962566@qq.com>
Date: Mon, 24 Jun 2019 10:03:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9Bbz2=E5=8E=8B=E7=BC=A9?=
=?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=9A=84=E8=A7=A3=E5=8E=8B=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BTPanel/__init__.py | 1 +
BTPanel/static/css/site.css | 4 ++--
BTPanel/static/js/crontab.js | 18 +++++++++++++-----
BTPanel/static/js/files.js | 6 +++---
class/crontab.py | 4 +++-
class/panelTask.py | 2 ++
runserver.py | 4 +++-
script/backup.py | 22 +++++++++++++++++-----
8 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/BTPanel/__init__.py b/BTPanel/__init__.py
index 4de1f2d9..d5c6043b 100644
--- a/BTPanel/__init__.py
+++ b/BTPanel/__init__.py
@@ -967,6 +967,7 @@ def publicObject(toObject,defs,action=None,get = None):
if hasattr(get,'path'):
get.path = get.path.replace('//','/').replace('\\','/');
+ if get.path.find('..') != -1: return public.ReturnJson(False,'不安全的路径'),json_header
if get.path.find('->') != -1:
get.path = get.path.split('->')[0].strip();
not_acts = ['GetTaskSpeed','GetNetWork','check_pay_status','get_re_order_status','get_order_stat']
diff --git a/BTPanel/static/css/site.css b/BTPanel/static/css/site.css
index 62463a02..1f17074c 100644
--- a/BTPanel/static/css/site.css
+++ b/BTPanel/static/css/site.css
@@ -3172,8 +3172,8 @@ html .menu .menu_exit:hover {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYFJREFUeNpi/P//P8NAAhZkzrVr1zyB1FwglqSiHSZAfBZZQEtLC7sDQJZL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DASnZ7uVv5PgW+A5imIHK1jicA2sUjuvtLEwk49LvLngs6e4uEVaewTHjxtk5h2XTZ+u4tmg4iQ0XYPchCK9bRPcgO2lRasW7y48WOo758m5ejjWjUYKdiwXjZFiEdPOoBboJbArBvrRXrlllg0y3ytRovEUIGO1P7MPcpfbxNQRpvdfI1MPTmxAAJhI3UeXWamkw10E/lTuX23ZH0/iImkIOWADQDAITLmIRnP/vJ3BlQZYw+H8+/AFShLMorUUd8AAAAAElFTkSuQmCC")
+.list-list .ico-gz, .list-list .ico-bz2 {
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAHtSURBVFiF7Ze/T8JAFMe/1QYCRKIDIe1AYcAfLJLowL/grCbGydEJTXBw0qiLA4NxNGFlkX/A0UlJJGEBQzoAC3EzxhgTgz0HPXI9jrahxTr4TZrm3r3r+/Tdu2tPIoTAT8lso9lsrgEoAVA8jLEKoMYaMpmMGABASVVVJRKJeBJZ13UAuAawmU6nayKfKa6thEIhGIbhyQUAiUTiBsC1rusrTgA8VzAY3NU07RZARQQxcQAACAQCO8lk8l4EwdeAp4pGo7QOAGDr5/4AQPoVgFgshng8brIxQM4AXisn6PdaYwHI6gJmNo6tfewe0u+1MJcvC/ueL7dH9tF+O7kqwrl82VGQiQHYZWDiAP8ZoBC+AriV7wCudkK38w/8lQxI0ve3odFoDDuoC2MXmqzMC+003gDASnZ7uVv5PgW+A5imIHK1jicA2sUjuvtLEwk49LvLngs6e4uEVaewTHjxtk5h2XTZ+u4tmg4iQ0XYPchCK9bRPcgO2lRasW7y48WOo758m5ejjWjUYKdiwXjZFiEdPOoBboJbArBvrRXrlllg0y3ytRovEUIGO1P7MPcpfbxNQRpvdfI1MPTmxAAJhI3UeXWamkw10E/lTuX23ZH0/iImkIOWADQDAITLmIRnP/vJ3BlQZYw+H8+/AFShLMorUUd8AAAAAElFTkSuQmCC")
}
.list-list .ico-bt {
diff --git a/BTPanel/static/js/crontab.js b/BTPanel/static/js/crontab.js
index c5130f90..20960932 100644
--- a/BTPanel/static/js/crontab.js
+++ b/BTPanel/static/js/crontab.js
@@ -97,7 +97,7 @@ function edit_task_info(id){
minute: rdata.where_minute,
week: rdata.where1,
sType: rdata.sType,
- sBody: rdata.sBody,
+ sBody: rdata.sBody == 'undefined' ? '' : rdata.sBody,
sName: rdata.sName,
backupTo: rdata.backupTo,
save: rdata.save,
@@ -146,7 +146,7 @@ function edit_task_info(id){
layer.open({
type:1,
title:'编辑计划任务-['+rdata.name+']',
- area: ['850px','450px'],
+ area: '850px',
skin:'layer-create-content',
shadeClose:false,
closeBtn:2,
@@ -213,9 +213,9 @@ function edit_task_info(id){
\
\
\
-
'
}else{
$(".planname input[name='name']").val(sMsg+'[/www/wwwroot/]');
sOptBody = '
'
@@ -819,6 +819,14 @@ function toBackup(type){
\
'+lan.crontab.save_num+'\
';
+ if (sType == 'sites') {
+ sBody += '\
+
排除目录
\
+ \
+ \
+
\
+ ';
+ }
$("#implement").html(sBody);
getselectname();
$(".dropdown ul li a").click(function(){
diff --git a/BTPanel/static/js/files.js b/BTPanel/static/js/files.js
index 0abb23f6..297a7ba1 100644
--- a/BTPanel/static/js/files.js
+++ b/BTPanel/static/js/files.js
@@ -826,7 +826,7 @@ function BatchPasteTo(data,path){
}
function GetExtName(fileName){
var extArr = fileName.split(".");
- var exts = ['folder','folder-unempty','sql','c','cpp','cs','flv','css','js','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','rtf','docx','fdf','potm','pptx','txt','xlsb','xlsx','7z','cab','iso','rar','zip','gz','bt','file','apk','bookfolder','folder','folder-empty','folder-unempty','fromchromefolder','documentfolder','fromphonefolder','mix','musicfolder','picturefolder','videofolder','sefolder','access','mdb','accdb','sql','c','cpp','cs','js','fla','flv','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','doc','docm','dotx','dotm','dot','rtf','docx','pdf','fdf','ppt','pptm','pot','potm','pptx','txt','xls','csv','xlsm','xlsb','xlsx','7z','gz','cab','iso','rar','zip','bt','file','apk','css'];
+ var exts = ['folder','folder-unempty','sql','c','cpp','cs','flv','css','js','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','rtf','docx','fdf','potm','pptx','txt','xlsb','xlsx','7z','cab','iso','bz2','rar','zip','gz','bt','file','apk','bookfolder','folder','folder-empty','folder-unempty','fromchromefolder','documentfolder','fromphonefolder','mix','musicfolder','picturefolder','videofolder','sefolder','access','mdb','accdb','sql','c','cpp','cs','js','fla','flv','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','doc','docm','dotx','dotm','dot','rtf','docx','pdf','fdf','ppt','pptm','pot','potm','pptx','txt','xls','csv','xlsm','xlsb','xlsx','7z','gz','cab','iso','rar','zip','bt','file','apk','css'];
var extLastName = extArr[extArr.length - 1];
for(var i=0; i 1:
+ exports = param['sBody'].replace("\r\n","\n").replace("\n",",")
+ head += "BT_EXCLUDE=\"" + exports.strip() + "\"\nexport BT_EXCLUDE\n"
wheres={
'path': head + "python " + public.GetConfigValue('setup_path')+"/panel/script/backup.py path "+param['sName']+" "+str(param['save']),
'site' : head + "python " + public.GetConfigValue('setup_path')+"/panel/script/backup.py site "+param['sName']+" "+str(param['save']),
diff --git a/class/panelTask.py b/class/panelTask.py
index b05c1cbb..5a833d87 100644
--- a/class/panelTask.py
+++ b/class/panelTask.py
@@ -257,6 +257,8 @@ def _unzip(self,sfile,dfile,password,log_file):
os.system('echo "'+password+'"|' + rar_file + ' x -u -y "' + sfile + '" "' + dfile + '" &> ' + log_file)
elif sfile[-4:] == '.war':
os.system("unzip -P '"+password+"' -o '" + sfile + "' -d '" + dfile + "' &> " + log_file)
+ elif sfile[-4:] == '.bz2':
+ os.system("tar jxvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
else:
os.system("gunzip -c " + sfile + " > " + sfile[:-3])
diff --git a/runserver.py b/runserver.py
index 327f707f..072f8f05 100644
--- a/runserver.py
+++ b/runserver.py
@@ -10,6 +10,8 @@
from BTPanel import app,socketio,sys
if __name__ == '__main__':
- PORT = 8888
+ f = open('data/port.pl')
+ PORT = int(f.read())
HOST = '0.0.0.0'
+ f.close()
socketio.run(app,host=HOST,port=PORT)
diff --git a/script/backup.py b/script/backup.py
index 25df150b..cec2a265 100644
--- a/script/backup.py
+++ b/script/backup.py
@@ -13,7 +13,11 @@
import public,db,time
class backupTools:
-
+ __exclude = ""
+
+ def __init__(self):
+ self.get_exclode()
+
def backupSite(self,name,count):
sql = db.Sql();
path = sql.table('sites').where('name=?',(name,)).getField('path');
@@ -27,9 +31,8 @@ def backupSite(self,name,count):
backup_path = sql.table('config').where("id=?",(1,)).getField('backup_path') + '/site';
if not os.path.exists(backup_path): public.ExecShell("mkdir -p " + backup_path);
-
filename= backup_path + "/Web_" + name + "_" + time.strftime('%Y%m%d_%H%M%S',time.localtime()) + '.tar.gz'
- public.ExecShell("cd " + os.path.dirname(path) + " && tar zcvf '" + filename + "' '" + os.path.basename(path) + "' > /dev/null")
+ public.ExecShell("cd " + os.path.dirname(path) + " && tar zcvf '" + filename + "' '" + os.path.basename(path) + "'"+self.__exclude +" > /dev/null")
endDate = time.strftime('%Y/%m/%d %X',time.localtime())
@@ -48,6 +51,7 @@ def backupSite(self,name,count):
print(u"★["+endDate+"] " + log)
print(u"|---保留最新的["+count+u"]份备份")
print(u"|---文件名:"+filename)
+ if self.__exclude: print(u"|---排除规则: " + self.__exclude)
#清理多余备份
backups = sql.table('backup').where('type=? and pid=? and filename!=? and filename!=? and filename!=? and filename!=? and filename!=?',('0',pid,'alioss','txcos','upyun','qiniu','ftp')).field('id,filename').select();
@@ -134,7 +138,7 @@ def backupPath(self,path,count):
backup_path = sql.table('config').where("id=?",(1,)).getField('backup_path') + '/path';
if not os.path.exists(backup_path): os.makedirs(backup_path);
filename= backup_path + "/Path_" + name + "_" + time.strftime('%Y%m%d_%H%M%S',time.localtime()) + '.tar.gz'
- os.system("cd " + os.path.dirname(path) + " && tar zcvf '" + filename + "' '" + os.path.basename(path) + "' > /dev/null")
+ os.system("cd " + os.path.dirname(path) + " && tar zcvf '" + filename + "' '" + os.path.basename(path) + "'" + self.__exclude + " > /dev/null")
endDate = time.strftime('%Y/%m/%d %X',time.localtime())
if not os.path.exists(filename):
@@ -150,6 +154,7 @@ def backupPath(self,path,count):
print(u"★["+endDate+"] " + log)
print(u"|---保留最新的["+count+u"]份备份")
print(u"|---文件名:"+filename)
+ if self.__exclude: print(u"|---排除规则: " + self.__exclude)
#清理多余备份
backups = sql.table('backup').where('type=? and pid=? and name=?',('2',0,path)).field('id,filename').select();
@@ -174,7 +179,14 @@ def backupDatabaseAll(self,save):
for database in databases:
self.backupDatabase(database['name'],save)
-
+ def get_exclode(self):
+ tmp_exclude = os.getenv('BT_EXCLUDE')
+ if not tmp_exclude: return ""
+ for ex in tmp_exclude.split(','):
+ self.__exclude += " --exclude=\"" + ex + "\""
+ self.__exclude += " "
+ return self.__exclude
+
if __name__ == "__main__":