diff --git a/app/command/CleanViteJs.php b/app/command/CleanViteJs.php new file mode 100644 index 0000000..86199f3 --- /dev/null +++ b/app/command/CleanViteJs.php @@ -0,0 +1,211 @@ +setName('cleanvitejs') + ->addArgument('dir', Argument::REQUIRED, '/BTPanel/static/vite/js/路径') + ->setDescription('处理宝塔面板vite/js文件'); + } + + protected function execute(Input $input, Output $output) + { + $dir = trim($input->getArgument('dir')); + if(!file_exists($dir)){ + $output->writeln('目录不存在'); + return; + } + //$this->handlefile($dir.'/DockerImages.js'); + $this->checkdir($dir); + } + + private function getExtendCode($content, $part, $n = 1, $startChar = '{', $endChar = '}'){ + if(!$part) return false; + $length = strlen($content); + $start = strpos($content, $part); + if($start===false)return false; + $end = $start+strlen($part); + $start--; + $c = 0; + for($i=$start;$i>=0;$i--){ + if(substr($content,$i,1) == $startChar) $c++; + if(substr($content,$i,1) == $endChar) $c--; + if($c == $n){ + $start = $i; + break; + } + } + $c = 0; + for($i=$end;$i<=$length;$i++){ + if(substr($content,$i,1) == $endChar) $c++; + if(substr($content,$i,1) == $startChar) $c--; + if($c == $n){ + $end = $i; + break; + } + } + return substr($content, $start, $end - $start + 1); + } + + private function getExtendFunction($content, $part, $startChar = '(', $endChar = ')'){ + $code = $this->getExtendCode($content, $part, 1, $startChar, $endChar); + if(!$code) return false; + $start = strpos($content, $code) - 1; + $end = $start + strlen($code); + for($i=$start;$i>=0;$i--){ + $char = substr($content,$i,1); + if(!ctype_alpha($char)){ + $start = $i+1; + break; + } + } + if(substr($content,$start-1,1) == ',') $start--; + return substr($content, $start, $end - $start + 1); + } + + private function checkdir($basedir){ + if($dh=opendir($basedir)){ + while (($file=readdir($dh)) !== false){ + if($file != '.' && $file != '..'){ + if(!is_dir($basedir.'/'.$file) && substr($file,-3)=='.js'){ + $this->handlefile($basedir.'/'.$file); + }else if(!is_dir($basedir.'/'.$file) && substr($file,-4)=='.map'){ + unlink($basedir.'/'.$file); + } + } + } + closedir($dh); + } + } + + private function handlefile($filepath){ + $file = file_get_contents($filepath); + if(!$file)return; + + $flag = false; + + if(strpos($file, 'window.location.protocol.indexOf("https")>=0')!==false){ //index + $file = str_replace('(window.location.protocol.indexOf("https")>=0)', '1', $file); + $file = preg_replace('!setTimeout\(\(\(\)=>\w+\(\)\),3e3\)!', '', $file); + $file = preg_replace('!setTimeout\(\(function\(\)\{return \w+\(\)\}\),3e3\)!', '', $file); + $file = preg_replace('!recommendShow:\w+,!', 'recommendShow:!1,', $file); + $code = $this->getExtendCode($file, '"需求反馈"', 2); + if($code){ + $file = str_replace($code, '{}', $file); + } + $flag = true; + } + + if(strpos($file, '"WechatOfficial"')!==false){ //main + $code = $this->getExtendCode($file, '"WechatOfficial"', 5); + $code = $this->getExtendFunction($file, $code); + $start = strpos($file, $code) - 1; + for($i=$start;$i>=0;$i--){ + if(substr($file,$i,1) == ','){ + $start = $i; + break; + } + } + $code = $this->getExtendCode($file, '"/other/customer-service.png"', 2); + $code = $this->getExtendCode($file, $code, 2, '[', ']'); + $end = strpos($file, $code)+strlen($code); + $code = substr($file, $start, $end - $start + 1); + $file = str_replace($code, '', $file); + $file = preg_replace('!,isCalc:\w+,isInput:\w+,isCheck:\w+,!', ',isCalc:!1,isInput:!1,isCheck:!1,', $file); + $file = preg_replace('!computed\(\(\(\)=>"calc"===\w+\.type\|\|"checkConfirm"===\w+\.type\)\)!', '!1', $file); + $file = preg_replace('!computed\(\(\(\)=>"input"===\w+\.type\)\)!', '!1', $file); + $file = preg_replace('!computed\(\(\(\)=>"check"===\w+\.type\|\|"checkConfirm"===\w+\.type\)\)!', '!1', $file); + $file = preg_replace('!computed\(\(function\(\)\{return"calc"===\w+\.type\|\|"checkConfirm"===\w+\.type\}\)\)!', '!1', $file); + $file = preg_replace('!computed\(\(function\(\)\{return"input"===\w+\.type\}\)\)!', '!1', $file); + $file = preg_replace('!computed\(\(function\(\)\{return"check"===\w+\.type\|\|"checkConfirm"===\w+\.type\}\)\)!', '!1', $file); + $file = str_replace('startNegotiate(),', '', $file); + $flag = true; + } + + if(strpos($file, '请冷静几秒钟,确认以下要删除的数据')!==false && strpos($file, '"计算结果:"')!==false){ //site + $code = $this->getExtendCode($file, '"计算结果:"', 2, '[', ']'); + $code = $this->getExtendFunction($file, $code); + $file = str_replace($code, '', $file); + $file = preg_replace('!\w+\.sum===\w+\.addend1\+\w+\.addend2!', '!0', $file); + $file = preg_replace('!\w+\.sum\!==\w+\.addend1\+\w+\.addend2!', '!1', $file); + $file = preg_replace('!,disableDeleteButton:\w+,countdown:\w+,!', ',disableDeleteButton:!1,countdown:!1,', $file); + if(preg_match('/startCountdown:(\w+),/', $file, $matchs)){ + $file = str_replace([';'.$matchs[1].'()', $matchs[1].'(),'], '', $file); + } + $flag = true; + } + + if(strpos($file, '"bt-waf-gray"')!==false){ //site.popup + $code = $this->getExtendCode($file, '"bt-waf-gray"', 2); + $code = $this->getExtendCode($file, $code, 1, '[', ']'); + $code = $this->getExtendFunction($file, $code); + $file = str_replace($code, '""', $file); + $flag = true; + } + + if(strpos($file, '"商用SSL证书"')!==false){ //site-ssl + $code = $this->getExtendFunction($file, '"商用SSL证书"', '{', '}'); + $file = str_replace($code, '', $file); + $code = $this->getExtendFunction($file, '"测试证书"', '{', '}'); + $file = str_replace($code, '', $file); + $file = preg_replace('!\w+\.value="currentCertInfo":\w+\.value="busSslList"!', 'i.value="currentCertInfo":i.value="currentCertInfo"', $file); + $file = preg_replace('!\{\w+\.value="busSslList",\w+\(\)\}!', '{i.value="letsEncryptList"}', $file); + $flag = true; + } + + if(strpos($file, '如果您希望添加其它Docker应用')!==false){ + $code = $this->getExtendCode($file, '如果您希望添加其它Docker应用', 1, '[', ']'); + $code = $this->getExtendFunction($file, $code); + $file = str_replace($code, '', $file); + $flag = true; + } + + for($i=0;$i<5;$i++){ + $code = $this->getExtendCode($file, 'content:"需求反馈"', 2); + if($code){ + $code = $this->getExtendFunction($file, $code); + $start = strpos($file, $code); + if(substr($file,$start-1,1) == ':'){ + $file = str_replace($code, '{}', $file); + }else{ + $file = str_replace($code, '', $file); + } + $flag = true; + } + } + $code = $this->getExtendFunction($file, '("需求反馈")'); + if($code){ + $file = str_replace($code, '', $file); + $flag = true; + } + $code = $this->getExtendFunction($file, '(" 需求反馈 ")'); + if($code){ + $file = str_replace($code, '', $file); + $flag = true; + } + if(strpos('暂无搜索结果,提交需求反馈', $file)!==false){ + $file = str_replace('暂无搜索结果,提交需求反馈', '暂无搜索结果', $file); + $flag = true; + } + + if(!$flag) return; + if(file_put_contents($filepath, $file)){ + echo '文件:'.$filepath.' 处理成功'."\n"; + }else{ + echo '文件:'.$filepath.' 处理失败,可能无写入权限'."\n"; + } + } +} diff --git a/config/console.php b/config/console.php index 90d6c19..023064f 100644 --- a/config/console.php +++ b/config/console.php @@ -8,5 +8,6 @@ return [ 'updateall' => 'app\command\UpdateAll', 'decrypt' => 'app\command\DecryptFile', 'clean' => 'app\command\Clean', + 'cleanvitejs' => 'app\command\CleanViteJs', ], ]; diff --git a/public/install/install_6.0.sh b/public/install/install_6.0.sh index 12f6e24..d1b7759 100644 --- a/public/install/install_6.0.sh +++ b/public/install/install_6.0.sh @@ -425,6 +425,17 @@ Get_Versions(){ fi fi + + if [ -f "/etc/os-release" ];then + . /etc/os-release + OS_V=${VERSION_ID%%.*} + if [ "${ID}" == "opencloudos" ] && [[ "${OS_V}" =~ ^(9)$ ]];then + os_type="opencloudos" + os_version="9" + return + fi + fi + if [ -f $redhat_version_file ];then os_type='el' is_aliyunos=$(cat $redhat_version_file|grep Aliyun) diff --git a/public/install/src/panel6.zip b/public/install/src/panel6.zip index 7c49321..92a278f 100644 Binary files a/public/install/src/panel6.zip and b/public/install/src/panel6.zip differ diff --git a/public/install/update/LinuxPanel-8.1.0.zip b/public/install/update/LinuxPanel-8.1.0.zip index 6fea287..a1a35b7 100644 Binary files a/public/install/update/LinuxPanel-8.1.0.zip and b/public/install/update/LinuxPanel-8.1.0.zip differ diff --git a/wiki/update.md b/wiki/update.md index a13b610..859209c 100644 --- a/wiki/update.md +++ b/wiki/update.md @@ -65,6 +65,13 @@ temp_file = temp_file.replace('https://download.bt.cn/install/public.sh', 'http://www.example.com/install/public.sh') ``` + def check_status(self, softInfo): 方法最后一行加上 + + ```python + if 'endtime' in softInfo: + softInfo['endtime'] = time.time() + 86400 * 3650 + ``` + - class/plugin_deployment.py 文件,SetupPackage方法内替换 public.GetConfigValue('home') => 'https://www.bt.cn' - class/config.py 文件,get_nps方法内data['nps'] = False改成True,get_nps_new方法下面加上 return public.returnMsg(False, "获取问卷失败") @@ -126,10 +133,10 @@ - [可选]关闭自动生成访问日志:在 BTPanel/\_\_init\_\_.py 删除public.write_request_log这一行 -- [可选]删除小图标广告:在BTPanel/static/js/site.js,删除“WAF防火墙”对应的span标签 - - [可选]上传文件默认选中覆盖,在BTPanel/static/js/upload-drog.js,id="all_operation"加checked属性 +- [可选]新版vite页面去除需求反馈、各种广告、计算题等,执行 php think decrypt cleanvitejs <面板BTPanel/static/vite/js路径> + 解压安装包[panel6.zip](http://download.bt.cn/install/src/panel6.zip),将更新包改好的文件覆盖到里面,然后重新打包,即可更新安装包。(