From 0093af2661b6407e57c11cded6fc5affc3837f8e Mon Sep 17 00:00:00 2001 From: hiCasper Date: Tue, 13 Dec 2022 12:44:25 +0800 Subject: [PATCH] Sync upstream --- README.md | 19 ++- class/core/config_api.py | 155 +++++++++++++++++++----- class/core/files_api.py | 11 +- class/core/mw.py | 15 ++- class/core/site_api.py | 4 + data/tpl/nginx_panel.conf | 23 ++-- plugins/php/install.sh | 12 +- plugins/php/versions/82/install.sh | 5 +- plugins/php/versions/common/fileinfo.sh | 19 ++- plugins/php/versions/common/phalcon.sh | 4 +- plugins/php/versions/common/redis.sh | 2 + plugins/php/versions/common/yaf.sh | 5 - plugins/php/versions/common/yar.sh | 6 - plugins/php/versions/phplib.conf | 6 +- rewrite/nginx/sub.conf.tpl | 16 +++ route/static/app/files.js | 8 +- route/static/app/public.js | 13 ++ scripts/init.d/mw.tpl | 3 +- scripts/install.sh | 2 +- scripts/install_dev.sh | 2 +- setting.py | 3 - tools.py | 18 +++ 22 files changed, 260 insertions(+), 91 deletions(-) create mode 100644 rewrite/nginx/sub.conf.tpl diff --git a/README.md b/README.md index 6e7db8290..03f02c4d3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ logo

mdserver-web

一款简单Linux面板服务

+

强烈推荐系统:debian

### 简介 @@ -10,10 +11,11 @@ 复制了后台管理界面,按照自己想要的方式写了一版。 -![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS) -![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu) ![Debian](https://img.shields.io/badge/LINUX-Debian-blue?style=for-the-badge&logo=Debian) +![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu) ![Fedora](https://img.shields.io/badge/LINUX-Fedora-blue?style=for-the-badge&logo=Fedora) +![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS) + [![Wiki](https://img.shields.io/badge/MW-Wiki-red?style=for-the-badge&logo=wiki)](https://github.com/midoks/mdserver-web/wiki) [![](https://data.jsdelivr.com/v1/package/gh/midoks/mdserver-web/badge?style=for-the-badge)](https://www.jsdelivr.com/package/gh/midoks/mdserver-web) @@ -90,15 +92,12 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443: ``` -### 版本更新 0.11.2 +### 版本更新 0.11.4 -* redis安全强化。 -* 添加php命令行设置。 -* 域名绑定。 -* Gitea优化。 -* 网站统计优化。 -* centos9下php-gd安装优化。 -* php82rc7测试版。 +* PHP82正式释出。 +* PHP-fileinfo扩展优化。 +* 删除任务时删除日志。 +* 优化修改密码后的显示问题(#288)。 ### JSDelivr安装地址 diff --git a/class/core/config_api.py b/class/core/config_api.py index a410d8da2..2b868fa33 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -27,7 +27,7 @@ from flask import request class config_api: - __version = '0.11.2' + __version = '0.11.4' __api_addr = 'data/api.json' def __init__(self): @@ -89,21 +89,6 @@ class config_api: return mw.returnJson(True, '修改成功!') return mw.returnJson(False, '修改失败!') - def setPanelDomainApi(self): - domain = request.form.get('domain', '') - - cfg_domain = 'data/bind_domain.pl' - if domain == '': - os.remove(cfg_domain) - return mw.returnJson(True, '清空域名成功!') - - reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$" - if not re.match(reg, domain): - return mw.returnJson(False, '主域名格式不正确') - - mw.writeFile(cfg_domain, domain) - return mw.returnJson(True, '设置域名成功!') - def syncDateApi(self): if mw.isAppleSystem(): return mw.returnJson(True, '开发系统不必同步时间!') @@ -150,7 +135,8 @@ class config_api: import system_api import firewall_api - if os.path.exists("/lib/systemd/system/firewalld.service"): + sysCfgDir = mw.systemdCfgDir() + if os.path.exists(sysCfgDir + "/firewalld.service"): if not firewall_api.firewall_api().getFwStatus(): return mw.returnJson(False, 'firewalld必须先启动!') @@ -257,7 +243,8 @@ class config_api: import system_api import firewall_api - if os.path.exists("/lib/systemd/system/firewalld.service"): + sysCfgDir = mw.systemdCfgDir() + if os.path.exists(sysCfgDir + "/firewalld.service"): if not firewall_api.firewall_api().getFwStatus(): return mw.returnJson(False, 'firewalld必须先启动!') @@ -355,24 +342,32 @@ class config_api: def getPanelSslApi(self): cert = {} - if not os.path.exists('ssl/certificate.pem'): + keyPath = 'ssl/private.pem' + certPath = 'ssl/cert.pem' + + if not os.path.exists(certPath): mw.createSSL() - cert['privateKey'] = mw.readFile('ssl/privateKey.pem') - cert['certPem'] = mw.readFile('ssl/certificate.pem') + cert['privateKey'] = mw.readFile(keyPath) + cert['certPem'] = mw.readFile(certPath) cert['rep'] = os.path.exists('ssl/input.pl') - cert['info'] = mw.getCertName('ssl/certificate.pem') + cert['info'] = mw.getCertName(certPath) return mw.getJson(cert) # 保存面板证书 def savePanelSslApi(self): - keyPath = 'ssl/privateKey.pem' - certPath = 'ssl/certificate.pem' + keyPath = 'ssl/private.pem' + certPath = 'ssl/cert.pem' checkCert = '/tmp/cert.pl' certPem = request.form.get('certPem', '').strip() privateKey = request.form.get('privateKey', '').strip() + if(privateKey.find('KEY') == -1): + return mw.returnJson(False, '秘钥错误,请检查!') + if(certPem.find('CERTIFICATE') == -1): + return mw.returnJson(False, '证书错误,请检查!') + mw.writeFile(checkCert, certPem) if privateKey: mw.writeFile(keyPath, privateKey) @@ -383,22 +378,128 @@ class config_api: mw.writeFile('ssl/input.pl', 'True') return mw.returnJson(True, '证书已保存!') + def setPanelDomainApi(self): + domain = request.form.get('domain', '') + + panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf" + dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf" + + cfg_domain = 'data/bind_domain.pl' + if domain == '': + os.remove(cfg_domain) + os.remove(dst_panel_path) + mw.restartWeb() + return mw.returnJson(True, '清空域名成功!') + + reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$" + if not re.match(reg, domain): + return mw.returnJson(False, '主域名格式不正确') + + op_dir = mw.getServerDir() + "/openresty" + if not os.path.exists(op_dir): + return mw.returnJson(False, '依赖OpenResty,先安装启动它!') + + content = mw.readFile(panel_tpl) + content = content.replace("{$PORT}", "80") + content = content.replace("{$SERVER_NAME}", domain) + content = content.replace("{$PANAL_PORT}", mw.readFile('data/port.pl')) + content = content.replace("{$LOGPATH}", mw.getRunDir() + '/logs') + content = content.replace("{$PANAL_ADDR}", mw.getRunDir()) + mw.writeFile(dst_panel_path, content) + mw.restartWeb() + + mw.writeFile(cfg_domain, domain) + return mw.returnJson(True, '设置域名成功!') + # 设置面板SSL def setPanelSslApi(self): sslConf = mw.getRunDir() + '/data/ssl.pl' + + panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf" + dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf" if os.path.exists(sslConf): os.system('rm -f ' + sslConf) - mw.restartMw() + + conf = mw.readFile(dst_panel_path) + if conf: + rep = "\s+ssl_certificate\s+.+;\s+ssl_certificate_key\s+.+;" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_protocols\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_ciphers\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_prefer_server_ciphers\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_session_cache\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_session_timeout\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_ecdh_curve\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_session_tickets\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_stapling\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl_stapling_verify\s+.+;\n" + conf = re.sub(rep, '', conf) + rep = "\s+ssl\s+on;" + conf = re.sub(rep, '', conf) + rep = "\s+error_page\s497.+;" + conf = re.sub(rep, '', conf) + rep = "\s+if.+server_port.+\n.+\n\s+\s*}" + conf = re.sub(rep, '', conf) + rep = "\s+listen\s+443.*;" + conf = re.sub(rep, '', conf) + rep = "\s+listen\s+\[\:\:\]\:443.*;" + conf = re.sub(rep, '', conf) + mw.writeFile(dst_panel_path, conf) + + mw.writeLog('面板配置', '面板SSL关闭成功!') + mw.restartWeb() return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!') else: try: if not os.path.exists('ssl/input.ssl'): mw.createSSL() mw.writeFile(sslConf, 'True') + + keyPath = mw.getRunDir() + '/ssl/private.pem' + certPath = mw.getRunDir() + '/ssl/cert.pem' + + conf = mw.readFile(dst_panel_path) + if conf: + if conf.find('ssl_certificate') == -1: + sslStr = """#error_page 404/404.html; + ssl_certificate %s; + ssl_certificate_key %s; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + error_page 497 https://$host$request_uri;""" % (certPath, keyPath) + if(conf.find('ssl_certificate') != -1): + return mw.returnJson(True, 'SSL开启成功!') + + conf = conf.replace('#error_page 404/404.html;', sslStr) + + rep = "listen\s+([0-9]+)\s*[default_server]*;" + tmp = re.findall(rep, conf) + if not mw.inArray(tmp, '443'): + listen = re.search(rep, conf).group() + http_ssl = "\n\tlisten 443 ssl http2;" + http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;" + conf = conf.replace(listen, listen + http_ssl) + + mw.backFile(dst_panel_path) + mw.writeFile(dst_panel_path, conf) + isError = mw.checkWebConfig() + if(isError != True): + mw.restoreFile(dst_panel_path) + return mw.returnJson(False, '证书错误:
' + isError.replace("\n", '
') + '
') except Exception as ex: return mw.returnJson(False, '开启失败:' + str(ex)) - - mw.restartMw() + mw.restartWeb() return mw.returnJson(True, '开启成功,请使用https协议访问面板!') def getApi(self): diff --git a/class/core/files_api.py b/class/core/files_api.py index f4d04c175..b902a0a68 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -97,11 +97,11 @@ class files_api: import shutil try: shutil.move(sfile, dfile) - msg = mw.getInfo('移动文件或目录[{1}]到[{2}]成功!', (sfile, dfile,)) + msg = mw.getInfo('移动或重名命文件[{1}]到[{2}]成功!', (sfile, dfile,)) mw.writeLog('文件管理', msg) - return mw.returnJson(True, '移动文件或目录成功!') + return mw.returnJson(True, '移动或重名命文件成功!') except: - return mw.returnJson(False, '移动文件或目录失败!') + return mw.returnJson(False, '移动或重名命文件失败!') def deleteApi(self): path = request.form.get('path', '') @@ -240,6 +240,11 @@ class files_api: system_api.system_api().restartTask() except: system_api.system_api().restartTask() + + # 删除日志 + task_log = mw.getRunDir() + "/tmp/panelTask.pl" + if os.path.exists(task_log): + os.remove(task_log) return mw.returnJson(True, '任务已删除!') # 上传文件 diff --git a/class/core/mw.py b/class/core/mw.py index 35e0fde47..f64b1a701 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -920,13 +920,22 @@ def checkDomainPanel(): tmp = getHost() domain = readFile('data/bind_domain.pl') port = readFile('data/port.pl').strip() + + npid = getServerDir() + "/openresty/nginx/logs/nginx.pid" + if not os.path.exists(npid): + return False + + nconf = getServerDir() + "/web_conf/nginx/vhost/panel.conf" + if os.path.exists(nconf): + port = "80" + if domain: client_ip = getClientIp() if client_ip in ['127.0.0.1', 'localhost', '::1']: return False if tmp.strip().lower() != domain.strip().lower(): from flask import Flask, redirect, request, url_for - to = "http://" + domain + ":" + port + to = "http://" + domain + ":" + str(port) return redirect(to, code=302) return False @@ -1371,8 +1380,8 @@ def createSSL(): private_key = OpenSSL.crypto.dump_privatekey( OpenSSL.crypto.FILETYPE_PEM, key) if len(cert_ca) > 100 and len(private_key) > 100: - writeFile('ssl/certificate.pem', cert_ca, 'wb+') - writeFile('ssl/privateKey.pem', private_key, 'wb+') + writeFile('ssl/cert.pem', cert_ca, 'wb+') + writeFile('ssl/private.pem', private_key, 'wb+') return True return False diff --git a/class/core/site_api.py b/class/core/site_api.py index 52a98b43a..ad4addca4 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -140,6 +140,10 @@ class site_api: return mw.getJson(data) def getCliPhpVersionApi(self): + php_dir = mw.getServerDir() + '/php' + if not os.path.exists(php_dir): + return mw.returnJson(False, '未安装PHP,无法设置') + php_bin = '/usr/bin/php' php_versions = self.getPhpVersion() php_versions = php_versions[1:] diff --git a/data/tpl/nginx_panel.conf b/data/tpl/nginx_panel.conf index cdd4baf0d..c487094fd 100755 --- a/data/tpl/nginx_panel.conf +++ b/data/tpl/nginx_panel.conf @@ -2,27 +2,22 @@ server { listen {$PORT}; listen [::]:{$PORT}; + server_name {$SERVER_NAME}; index index.php index.html index.htm default.php default.htm default.html; - root {$ROOT_DIR}; #SSL-START #error_page 404/404.html; #SSL-END - - #禁止访问的文件或目录 - location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) - { - return 404; - } - - #一键申请SSL证书验证目录相关设置 - location ~ \.well-known{ - allow all; + #PROXY-START + location ^~ / { + proxy_pass http://0.0.0.0:{$PANAL_PORT}/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; } - - - access_log {$LOGPATH}/{$SERVER_NAME}.log main; + #PROXY-END + error_log {$LOGPATH}/{$SERVER_NAME}.error.log; } \ No newline at end of file diff --git a/plugins/php/install.sh b/plugins/php/install.sh index 3a98e5901..e28431f07 100755 --- a/plugins/php/install.sh +++ b/plugins/php/install.sh @@ -32,9 +32,9 @@ if [ ! -d $curPath/versions/$2 ];then fi -if [ "${action}" == "install" ] && [ -d $serverPath/php/${type} ];then - exit 0 -fi +# if [ "${action}" == "install" ] && [ -d $serverPath/php/${type} ];then +# exit 0 +# fi if [ "${action}" == "uninstall" ];then @@ -71,6 +71,12 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then cd ${rootPath}/plugins/php/versions/common && bash gettext.sh install ${type} cd ${rootPath}/plugins/php/versions/common && bash redis.sh install ${type} cd ${rootPath}/plugins/php/versions/common && bash memcached.sh install ${type} + cd ${rootPath}/plugins/php/versions/common && bash zlib.sh install ${type} + + if [ "${type}" -gt "72" ];then + cd ${rootPath}/plugins/php/versions/common && bash zip.sh install ${type} + fi + echo "install PHP${type} extend end" fi diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index 4650bec20..41f9fbb97 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } -version=8.2.0RC7 +version=8.2.0 PHP_VER=82 Install_php() { @@ -32,8 +32,7 @@ cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then - # wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-${version}.tar.xz - wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-${version}.tar.xz + wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://www.php.net/distributions/php-${version}.tar.xz fi cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz diff --git a/plugins/php/versions/common/fileinfo.sh b/plugins/php/versions/common/fileinfo.sh index 0f07354ac..b947c9a60 100755 --- a/plugins/php/versions/common/fileinfo.sh +++ b/plugins/php/versions/common/fileinfo.sh @@ -49,6 +49,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then + echo "cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version}" cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi @@ -57,9 +58,23 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config + + # It is considered as a temporary bug + if [ "$version" == "81" ] || [ "$version" == "82" ];then + bash ${rootPath}/scripts/getos.sh + OSNAME=`cat ${rootPath}/data/osname.pl` + if [ "$OSNAME" == 'centos' ];then + FILE_softmagic=$sourcePath/php${version}/ext/${LIBNAME}/libmagic/softmagic.c + FIND_UNDEF_STRNDUP=`cat $FILE_softmagic|grep '#undef strndup'` + if [ "$version" -gt "74" ] && [ "$FIND_UNDEF_STRNDUP" == "" ];then + sed -i $BAK "s/char \*strndup/#undef strndup\nchar \*strndup/g" $FILE_softmagic + fi + fi + fi + FIND_C99=`cat Makefile|grep c99` - if [ "$FIND_C99" == "" ];then - sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile + if [ "$version" -gt "74" ] && [ "$FIND_C99" == "" ];then + sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=gnu99/g' Makefile fi make clean && make && make install && make clean diff --git a/plugins/php/versions/common/phalcon.sh b/plugins/php/versions/common/phalcon.sh index bcfcc9fb3..b3c201610 100755 --- a/plugins/php/versions/common/phalcon.sh +++ b/plugins/php/versions/common/phalcon.sh @@ -20,12 +20,10 @@ LIBV=4.1.2 if [ "$version" -lt "73" ];then echo "not support!" exit 1 -else +fi if [ "$version" -gt "74" ];then LIBV=5.1.2 -else - echo "not support!" fi LIB_PATH_NAME=lib/php diff --git a/plugins/php/versions/common/redis.sh b/plugins/php/versions/common/redis.sh index b7502f80d..10d6bb239 100755 --- a/plugins/php/versions/common/redis.sh +++ b/plugins/php/versions/common/redis.sh @@ -21,6 +21,8 @@ if [ "$version" == "52" ];then LIBV=2.2.7 elif [ "$version" -lt "70" ];then LIBV=4.2.0 +elif [ "$version" -gt "74" ];then + LIBV=5.3.5 else echo 'ok' fi diff --git a/plugins/php/versions/common/yaf.sh b/plugins/php/versions/common/yaf.sh index 5b3bf8fb0..632b953e8 100755 --- a/plugins/php/versions/common/yaf.sh +++ b/plugins/php/versions/common/yaf.sh @@ -31,11 +31,6 @@ if [ "$version" -eq "72" ] || [ "$version" -eq "73" ];then LIBV=3.2.5 fi -if [ "$version" -eq "82" ];then - echo "not need" - exit 1 -fi - LIB_PATH_NAME=lib/php if [ -d $serverPath/php/${version}/lib64 ];then diff --git a/plugins/php/versions/common/yar.sh b/plugins/php/versions/common/yar.sh index 69306fbd1..3ea9778cc 100755 --- a/plugins/php/versions/common/yar.sh +++ b/plugins/php/versions/common/yar.sh @@ -21,12 +21,6 @@ if [ "$version" -lt "70" ];then LIBV=1.2.5 fi -if [ "$version" -eq "82" ];then - echo "wait php82 release" - exit 0 -fi - - LIB_PATH_NAME=lib/php if [ -d $serverPath/php/${version}/lib64 ];then LIB_PATH_NAME=lib64 diff --git a/plugins/php/versions/phplib.conf b/plugins/php/versions/phplib.conf index a07765625..2fc5f4b5b 100755 --- a/plugins/php/versions/phplib.conf +++ b/plugins/php/versions/phplib.conf @@ -520,8 +520,7 @@ "73", "74", "80", - "81", - "82" + "81" ], "type": "框架", "msg": "Yaf是一个C语言编写的PHP框架", @@ -541,8 +540,7 @@ "73", "74", "80", - "81", - "82" + "81" ], "type": "框架", "msg": "Yar是一个RPC框架", diff --git a/rewrite/nginx/sub.conf.tpl b/rewrite/nginx/sub.conf.tpl new file mode 100644 index 000000000..5996e01d4 --- /dev/null +++ b/rewrite/nginx/sub.conf.tpl @@ -0,0 +1,16 @@ +location / { + set $replace 'tmplate_replace'; + set $spider_request '0'; + + if ($http_user_agent ~* '(baiduspider|360sipder|Sogou Orion spider|Sogou News Spider|Sogou blog|Sogou spider2|Sogou inst spider|Sogou web spider|Sogou spider|trendiction|Yahoo|semrush|Toutiao|Google|qihoobot|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|MSNBot|ia_archiver|Tomato Bot)') { + set $spider_request '1'; + } + + if ($spider_request = '0' ) { + set $replace 'tmplate_replace'; + } + + sub_filter 'tmplate_replace' $replace; + sub_filter_once on; + sub_filter_types *; +} \ No newline at end of file diff --git a/route/static/app/files.js b/route/static/app/files.js index f47e2f892..bc5e44a13 100755 --- a/route/static/app/files.js +++ b/route/static/app/files.js @@ -1103,7 +1103,7 @@ function reName(type, fileName) { closeBtn: 1, area: '320px', title: '重命名', - btn:["确定","保存"], + btn:["确定","取消"], content: '
\
\ \ @@ -1615,10 +1615,13 @@ function getPathSize(){ $("body").not(".def-log").click(function(){ $("#rmenu").hide() }); + //指定路径 $("#DirPathPlace input").keyup(function(e){ if(e.keyCode == 13) { - getFiles($(this).val()); + var fpath = $(this).val(); + fpath = filterPath(fpath); + getFiles(fpath); } }); @@ -1662,6 +1665,7 @@ function pathLeft(){ $("#PathPlaceBtn ul").css("left",0); } } + //路径快捷点击 $("#PathPlaceBtn").on("click", function(e){ if($("#DirPathPlace").is(":hidden")){ diff --git a/route/static/app/public.js b/route/static/app/public.js index a8f74d2fb..91909d2eb 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -100,6 +100,19 @@ function isContains(str, substr) { return str.indexOf(substr) >= 0; } + +function filterPath(path){ + var path_arr = path.split('/'); + var path_new = []; + for (var i = 0; i < path_arr.length; i++) { + if (path_arr[i]!=''){ + path_new.push(path_arr[i]); + } + } + var rdata = "/"+path_new.join('/'); + return rdata; +} + function msgTpl(msg, args){ if (typeof args == 'string'){ return msg.replace('{1}', args); diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 1a177aa93..8563e9341 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -331,7 +331,8 @@ case "$1" in echo -e "==================================================================" echo -e "$address" echo -e `python3 $mw_path/tools.py username` - echo -e "password: $password" + echo -e `python3 $mw_path/tools.py password` + # echo -e "password: $password" echo -e "\033[33mWarning:\033[0m" echo -e "\033[33mIf you cannot access the panel. \033[0m" echo -e "\033[33mrelease the following port (${show_panel_ip}888|80|443|22) in the security group.\033[0m" diff --git a/scripts/install.sh b/scripts/install.sh index 0d82bfeae..e9cf1e8a5 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -48,7 +48,7 @@ elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/os-release; then apt update -y apt install -y wget curl zip unzip tar cron elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/os-release; then - OSNAME='debian' + OSNAME='ubuntu' apt update -y apt install -y wget curl zip unzip tar cron else diff --git a/scripts/install_dev.sh b/scripts/install_dev.sh index bbb4067cd..c43a34e53 100755 --- a/scripts/install_dev.sh +++ b/scripts/install_dev.sh @@ -47,7 +47,7 @@ elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then apt install -y devscripts apt install -y wget zip unzip elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='debian' + OSNAME='ubuntu' apt install -y wget zip unzip else OSNAME='unknow' diff --git a/setting.py b/setting.py index 6b473ee0f..ceb10c2ac 100755 --- a/setting.py +++ b/setting.py @@ -82,6 +82,3 @@ loglevel = 'info' errorlog = log_dir + '/error.log' accesslog = log_dir + '/access.log' pidfile = log_dir + '/mw.pid' -# if os.path.exists(os.getcwd() + '/data/ssl.pl'): -# certfile = 'ssl/certificate.pem' -# keyfile = 'ssl/privateKey.pem' diff --git a/tools.py b/tools.py index 6f60765e5..be8da7adc 100755 --- a/tools.py +++ b/tools.py @@ -132,6 +132,22 @@ def set_panel_pwd(password, ncli=False): print(username) +def show_panel_pwd(): + # 设置面板密码 + import db + sql = db.Sql() + password = sql.table('users').where('id=?', (1,)).getField('password') + + file_pwd = '' + if os.path.exists('data/default.pl'): + file_pwd = mw.readFile('data/default.pl').strip() + + if mw.md5(file_pwd) == password: + print('password: ' + file_pwd) + return + print("the password has been changed!") + + def set_panel_username(username=None): # 随机面板用户名 import db @@ -171,6 +187,8 @@ if __name__ == "__main__": set_panel_username(sys.argv[2]) else: set_panel_username() + elif method == 'password': + show_panel_pwd() elif method == 'getServerIp': getServerIp() elif method == "cli":