From 4a1348403a27bdce6270649b2c784c469db9ee60 Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 6 May 2025 15:42:15 +0800 Subject: [PATCH 1/3] Update app.sh --- scripts/quick/app.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/quick/app.sh b/scripts/quick/app.sh index 5b52c54da..8212b179d 100755 --- a/scripts/quick/app.sh +++ b/scripts/quick/app.sh @@ -24,6 +24,13 @@ else echo "openresty alreay exist!" fi +# redis +if [ ! -d /www/server/redis ];then + cd /www/server/mdserver-web/plugins/redis && bash install.sh install 7.4.3 +else + echo "redis alreay exist!" +fi + # php if [ ! -d /www/server/php/71 ];then From 992555e80e9d6677d6f077c795b436de35dbd254 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 10 May 2025 14:51:54 +0800 Subject: [PATCH 2/3] Update cmd.md --- cmd.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd.md b/cmd.md index 8763cc397..fb4c09a95 100644 --- a/cmd.md +++ b/cmd.md @@ -4,6 +4,9 @@ - 面板相关命令 ``` +mw start | 启动面板服务器 +mw stop | 停止面板服务器 +mw restart | 重启面板服务器 mw default | 显示登录信息 mw db | 快捷连接MySQL mw redis | 快捷连接Redis From 2934d8fd7dcd8389b15d41143079b2e243459f89 Mon Sep 17 00:00:00 2001 From: dami Date: Fri, 16 May 2025 01:47:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E7=A7=8D?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=92=8C=E8=A7=A3=E5=8E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7z,tgz,zip,rar --- scripts/install/debian.sh | 1 + scripts/install/rhel.sh | 2 + scripts/install/ubuntu.sh | 1 + web/core/mw.py | 7 +++ web/static/app/files.js | 130 +++++++++++++++++++++++++++++----------------- web/utils/file.py | 31 +++++++---- 6 files changed, 114 insertions(+), 58 deletions(-) diff --git a/scripts/install/debian.sh b/scripts/install/debian.sh index 04798b8ae..5ceb48802 100644 --- a/scripts/install/debian.sh +++ b/scripts/install/debian.sh @@ -81,6 +81,7 @@ apt install -y python3-venv apt install -y libncurses5 apt install -y libncurses5-dev apt install -y bzip2 +apt install -y p7zip-full apt install -y libnuma1 apt install -y libaio1 diff --git a/scripts/install/rhel.sh b/scripts/install/rhel.sh index 313cb2d51..23e906e68 100644 --- a/scripts/install/rhel.sh +++ b/scripts/install/rhel.sh @@ -38,6 +38,8 @@ $PKGMGR install -y curl-devel libmcrypt libmcrypt-devel python3-devel $PKGMGR install -y net-tools $PKGMGR install -y unixODBC-devel +$PKGMGR install -y p7zip +$PKGMGR install -y p7zip-plugins $PKGMGR install -y libncurses* diff --git a/scripts/install/ubuntu.sh b/scripts/install/ubuntu.sh index c875e9192..0ac30c1b4 100644 --- a/scripts/install/ubuntu.sh +++ b/scripts/install/ubuntu.sh @@ -39,6 +39,7 @@ apt install -y libncurses5 apt install -y libncurses5-dev apt install -y software-properties-common apt install -y bzip2 +apt install -y p7zip-full apt install -y libnuma1 apt install -y libaio1 diff --git a/web/core/mw.py b/web/core/mw.py index 80c69ef0d..213a7506c 100644 --- a/web/core/mw.py +++ b/web/core/mw.py @@ -69,6 +69,13 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True): error = str(e) return (success, error) +def checkBinExist(name): + d = execShell('which ' + name) + if d[0] != '': + return True + return False + + def getTracebackInfo(): import traceback diff --git a/web/static/app/files.js b/web/static/app/files.js index 9b2d577fe..897baaaf7 100755 --- a/web/static/app/files.js +++ b/web/static/app/files.js @@ -450,10 +450,10 @@ function getFiles(Path) { 剪切 | \ 重命名 | \ 权限 | \ - 压缩 | \ 删除\ \ "; + // 压缩 | \ } else { //图标展示 $("#set_icon").addClass("active"); @@ -490,10 +490,12 @@ function getFiles(Path) { var displayCompress = 1; if(isCompressFile(fmp[0])){ bodyZip = "解压 | "; + } else { + bodyZip = "压缩 | "; } if(isText(fmp[0])){ - bodyZip = "编辑 | "; + bodyZip += "编辑 | "; } if(isImage(fmp[0])){ @@ -515,8 +517,7 @@ function getFiles(Path) { 复制 | \ 剪切 | \ 重命名 | \ - 权限 | \ - 压缩 | " + 权限 | " + bodyZip + download + "删除\ @@ -1307,67 +1308,100 @@ function pasteTo(path,copyName,cutName,fileName){ //压缩目录 function zip(dirName,submits) { - var path = $("#DirPathPlace input").val(); + var dirNameArr = dirName.split('/'); + var fileName = dirNameArr[dirNameArr.length-1]; + var pathName = dirName.replace('/'+fileName,''); + var randStr = getRandomString(6); + if(submits != undefined){ - if(dirName.indexOf(',') == -1){ - tmp = $("#sfile").val().split('/'); - sfile = encodeURIComponent(tmp[tmp.length-1]); - }else{ - sfile = encodeURIComponent(dirName); - } - - dfile = encodeURIComponent($("#dfile").val()); - layer.closeAll(); - layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); - $.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) { + var sfile = $("#sfile").val(); + var path = $("#path").val(); + var ztype = $('select[name="z_type"]').val(); + var dfile = $("#dfile").val(); + + layer.msg('正在压缩,请稍候...', {icon: 16,time: 0,shade: [0.3, '#000']}); + $.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type='+ztype+'&path='+encodeURIComponent(path), function(rdata) { layer.closeAll(); if(rdata == null || rdata == undefined){ - layer.msg(lan.files.zip_ok,{icon:1}); - getFiles(path) + layer.msg('服务器正在后台压缩文件,请稍候刷新文件列表查看进度!',{icon:1}); + getFiles($("#DirPathPlace input").val()); reloadFiles(); return; } - layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); - if(rdata.status) getFiles(path); + + showMsg(rdata.msg, function(){ + if(rdata.status) { + getFiles($("#DirPathPlace input").val()); + } + },{icon: rdata.status ? 1 : 2}); },'json'); return } - - param = dirName; - if(dirName.indexOf(',') != -1){ - tmp = path.split('/'); - dirName = path + '/' + tmp[tmp.length-1]; - } - + + var defaultDfile = pathName+'/'+fileName+'_'+randStr+'.tar.gz'; + layer.open({ type: 1, shift: 5, closeBtn: 1, area: '650px', - title: lan.files.zip_title, - content: '
' - +'
' - +'' - +''+lan.files.zip_to+'\ - \ - ' - +'
' - +'
' - +'' - +'' - +'
' + title: '压缩文件['+fileName+']', + btn: ['确定','取消'], + content: '
' + + '
' + + '压缩类型\ +
\ + \ +
\ +
' + // + + '
' + + '' + + '' + + '压缩路径\ + \ + ' + + '
' +'
', success:function(){ - $("#dfile").change(function(){ - var dfile = $(this).val() - tmp = dfile.split('.'); - if(tmp[tmp.length-1] != 'gz'){ - var path = $("#DirPathPlace input").val(); - tmp = path.split('/'); - dfile += '/' + tmp[tmp.length-1] + '.tar.gz' - $(this).val(dfile.replace(/\/\//g,'/')) + $('#change_dir').click(function(){ + changePathCallback('dfile', function(val){ + var z_type = $('select[name="z_type"]').val(); + $('#dfile').val(val+'/'+fileName+'_'+randStr+'.'+z_type.replace('_','.')); + $('#path').val(val); + }); + }); + + $('select[name="z_type"]').change(function(){ + var z_type = $(this).val(); + var path = $('#path').val(); + var newPathName = path+'/'+fileName+'_'+randStr; + if (z_type == 'tar_gz') { + $("#dfile").val(newPathName + '.tar.gz'); + } else if (z_type == 'zip') { + $("#dfile").val(newPathName + '.zip'); + } else if (z_type == 'rar') { + $("#dfile").val(newPathName + '.rar'); + } else if (z_type == 'gz') { + $("#dfile").val(newPathName + '.gz'); + } else if (z_type == '7z') { + $("#dfile").val(newPathName + '.7z'); } }); + + $("#dfile").change(function(){ + var dfile = $(this).val(); + $(this).val(dfile.replace(/\/\//g,'/')); + }); + }, + btn1: function(index){ + zip(dirName,1); + return false; } }); @@ -1424,7 +1458,7 @@ function unZip(fileName, type) { function isCompressFile(fileName){ var ext = fileName.split('.'); var extName = ext[ext.length-1].toLowerCase(); - var support = ['zip','gz','tgz','rar']; + var support = ['zip','gz','tgz','rar','7z']; for (x in support) { if (support[x]==extName){ return true; diff --git a/web/utils/file.py b/web/utils/file.py index 002526b77..eefb76fee 100644 --- a/web/utils/file.py +++ b/web/utils/file.py @@ -140,11 +140,14 @@ def uncompress(sfile, dfile, path): if suffix_gz == tar_gz: extension = suffix_gz - if not extension in ['tar.gz', 'gz', 'zip', 'rar']: + if not extension in ['tar.gz', 'gz', 'zip', 'rar', '7z']: return mw.returnData(False, '现在仅支持gz,zip,rar格式解压!') - if mw.isAppleSystem() and extension == 'rar': - return mw.returnData(False, 'macosx暂时不支持rar格式解压') + if extension == 'rar' and not mw.checkBinExist('rar'): + return mw.returnData(False, 'rar解压命令不存在,请安装!') + if extension == '7z' and not mw.checkBinExist('7z'): + return mw.returnData(False, '7z解药命令不存在,请安装!') + cmd = "cd " + path + " " try: @@ -152,15 +155,18 @@ def uncompress(sfile, dfile, path): if extension == 'zip': cmd += "&& unzip -o -d '" + dfile + "' '" + sfile + "' > " + tmps + " 2>&1 &" mw.execShell(cmd) - if extension == 'tar.gz': + elif extension == 'tar.gz': cmd += "&& tar -zxvf " + sfile + " -C " + dfile + " > " + tmps + " 2>&1 &" mw.execShell(cmd) - if extension == 'gz': + elif extension == 'gz': cmd += "&& gunzip -k " + sfile + " > " + tmps + " 2>&1 &" mw.execShell(cmd) - if extension == 'rar': + elif extension == 'rar': cmd += "&& unrar x " + sfile + " " + dfile + " > " + tmps + " 2>&1 &" mw.execShell(cmd) + elif extension == '7z': + cmd += "&& 7z x " + sfile + " -r -o" + dfile + " > " + tmps + " 2>&1 &" + mw.execShell(cmd) if os.path.exists(dfile): setFileAccept(dfile) @@ -286,8 +292,13 @@ def zip(sfile, dfile, stype, path): try: tmps = mw.getPanelDir() + '/logs/panel_exec.log' if stype == 'zip': - mw.execShell("cd '" + path + "' && zip '" + dfile + - "' -r '" + sfile + "' > " + tmps + " 2>&1") + mw.execShell("cd '" + path + "' && zip '" + dfile + "' -r '" + sfile + "' > " + tmps + " 2>&1") + elif stype == '7z': + mw.execShell("cd '" + path + "' && 7z a '" + dfile + "' -r '" + sfile + "' > " + tmps + " 2>&1") + elif stype == 'tar_gz': + mw.execShell("cd '" + path + "' && tar -zcvf '" + dfile + "' " + sfile + " > " + tmps + " 2>&1") + elif stype == 'rar': + mw.execShell("cd '" + path + "' && rar a '" + dfile + "' '" + sfile + "' > " + tmps + " 2>&1") else: sfiles = '' for sfile in sfile.split(','): @@ -298,8 +309,8 @@ def zip(sfile, dfile, stype, path): setFileAccept(dfile) mw.writeLog("文件管理", '文件[{1}]压缩[{2}]成功!', (sfile, dfile)) return mw.returnData(True, '文件压缩成功!') - except: - return mw.returnData(False, '文件压缩失败!') + except Exception as e: + return mw.returnData(False, '文件压缩失败:'+str(e)) def unzip(sfile, dfile, stype, path): if not os.path.exists(sfile):