Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
flucout committed Sep 19, 2024
1 parent 247e486 commit d80c0e9
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 27 deletions.
15 changes: 12 additions & 3 deletions app/command/CleanViteJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private function getExtendFunction($content, $part, $startChar = '(', $endChar =
}
}
if(substr($content,$start-1,1) == ',') $start--;
else if(substr($content,$end+1,1) == ',') $end++;
return substr($content, $start, $end - $start + 1);
}

Expand All @@ -90,6 +91,14 @@ private function checkdir($basedir){
closedir($dh);
}
}

private function str_replace_once($needle, $replace, $haystack) {
$pos = strpos($haystack, $needle);
if ($pos === false) {
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}

private function handlefile($filepath){
$file = file_get_contents($filepath);
Expand Down Expand Up @@ -132,7 +141,6 @@ private function handlefile($filepath){
$file = preg_replace('!,isCalc:\w+,isInput:\w+,!', ',isCalc:!1,isInput:!1,', $file);
$file = preg_replace('!"calc"===\w+\.type!', '!1', $file);
$file = preg_replace('!\w+\(\(\(\)=>"input"===\w+\.type\)\)!', '!1', $file);
$file = preg_replace('!"calc"===\w+\.type!', '!1', $file);
$file = preg_replace('!\w+\(\(function\(\)\{return"input"===\w+\.type\}\)\)!', '!1', $file);
$flag = true;
}
Expand Down Expand Up @@ -165,6 +173,7 @@ private function handlefile($filepath){
$file = str_replace($code, '', $file);
$file = str_replace('"currentCertInfo":"busSslList"', '"currentCertInfo":"currentCertInfo"', $file);
$file = preg_replace('!\{(\w+)\.value="busSslList",\w+\(\)\}!', '{$1.value="letsEncryptList"}', $file);
$file = preg_replace('!defaultActive:(\w+)\("sslCertificate"\)!', 'defaultActive:$1("EncryptCertificate")', $file);
$flag = true;
}

Expand Down Expand Up @@ -203,9 +212,9 @@ private function handlefile($filepath){
$code = $this->getExtendFunction($file, $code);
$start = strpos($file, $code);
if(substr($file,$start-1,1) == ':'){
$file = str_replace($code, '{}', $file);
$file = $this->str_replace_once($code, '{}', $file);
}else{
$file = str_replace($code, '', $file);
$file = $this->str_replace_once($code, '', $file);
}
$flag = true;
}
Expand Down
12 changes: 12 additions & 0 deletions app/controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ public function get_version_win(){
return $version;
}

public function get_panel_version(){
$version = config_get('new_version');
$file = app()->getRootPath().'public/install/update/LinuxPanel-'.$version.'.zip';
$hash = hash_file('sha256', $file);
$data = [
'version' => $version,
'hash' => $hash,
'update_time' => filemtime($file),
];
return json($data);
}

//安装统计
public function setup_count(){
return 'ok';
Expand Down
2 changes: 1 addition & 1 deletion app/script/convert.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

Linux_Version="9.1.0"
Linux_Version="9.2.0"
Windows_Version="8.2.0"
Btm_Version="2.3.0"

Expand Down
6 changes: 3 additions & 3 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ INSERT INTO `cloud_config` (`key`, `value`) VALUES
('bt_key', ''),
('whitelist', '0'),
('download_page', '1'),
('new_version', '9.1.0'),
('new_version', '9.2.0'),
('update_msg', '暂无更新日志'),
('update_date', '2024-07-15'),
('update_date', '2024-09-13'),
('new_version_win', '8.1.0'),
('update_msg_win', '暂无更新日志'),
('update_date_win', '2024-07-17'),
Expand Down Expand Up @@ -48,7 +48,7 @@ CREATE TABLE `cloud_white` (
DROP TABLE IF EXISTS `cloud_record`;
CREATE TABLE `cloud_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(200) NOT NULL,
`ip` varchar(20) NOT NULL,
`addtime` datetime NOT NULL,
`usetime` datetime NOT NULL,
PRIMARY KEY (`id`),
Expand Down
10 changes: 10 additions & 0 deletions public/install/install_6.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ Set_Centos7_Repo(){
tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
fi
fi

yum install unzip -y
if [ "$?" != "0" ] ;then
sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
fi

}
# Set_Centos7_Repo(){
# if [ -z "${download_Url}" ];then
Expand Down Expand Up @@ -280,6 +286,10 @@ Set_Centos8_Repo(){
rm -f /etc/yum.repos.d/*.repo
tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
fi
yum install unzip -y
if [ "$?" != "0" ] ;then
sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
fi
}
get_node_url(){
if [ ! -f /bin/curl ];then
Expand Down
Binary file modified public/install/src/panel6.zip
Binary file not shown.
Binary file not shown.
82 changes: 67 additions & 15 deletions public/install/update6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ if [ ! -f "/www/server/panel/pyenv/bin/python3" ];then
echo "请截图发帖至论坛www.bt.cn/bbs求助"
exit 0;
fi
Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
if [ "${Centos6Check}" ];then
echo "Centos6不支持升级宝塔面板,建议备份数据重装更换Centos7/8安装宝塔面板"
exit 1
fi


Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
if [ "${Centos8Check}" ];then
if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
ln -sf /usr/bin/python3 /usr/bin/python
if [ -f "/etc/redhat-release" ];then
Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
if [ "${Centos6Check}" ];then
echo "Centos6不支持升级宝塔面板,建议备份数据重装更换Centos7/8安装宝塔面板"
exit 1
fi
Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
if [ "${Centos8Check}" ];then
if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
ln -sf /usr/bin/python3 /usr/bin/python
fi
fi
fi

Expand All @@ -48,10 +49,61 @@ fi

download_Url=$D_NODE_URL


Set_Centos7_Repo(){
if [ -f "/etc/yum.repos.d/docker-ce.repo" ];then
mv /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce.repo_backup
fi
MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
\cp -rpa /etc/yum.repos.d/ /etc/yumBak
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
fi

TSU_MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "tuna.tsinghua.edu.cn")
if [ "${TSU_MIRROR_CHECK}" ];then
\cp -rpa /etc/yum.repos.d/ /etc/yumBak
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
sed -i 's|#baseurl=https://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
sed -i 's|#baseurl=http://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
fi

ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
return
fi

yum install tree -y
if [ "$?" != "0" ] ;then
TAR_CHECK=$(which tree)
if [ "$?" == "0" ] ;then
\cp -rpa /etc/yum.repos.d/ /etc/yumBak
if [ -z "${download_Url}" ];then
download_Url="http://download.bt.cn"
fi
curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/el7repo.tar.gz
rm -f /etc/yum.repos.d/*.repo
tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
fi
fi

yum install tree -y
if [ "$?" != "0" ] ;then
sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
fi
}
if [ -f "/etc/redhat-release" ];then
Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
if [ "${Centos7Check}" ];then
Set_Centos7_Repo
fi
fi
setup_path=/www
version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
if [ -z "$VERSION_CHECK" ];then
version='9.1.0'
version='9.2.0'
fi
armCheck=$(uname -m|grep arm)
if [ "${armCheck}" ];then
Expand Down Expand Up @@ -144,10 +196,10 @@ if [ -z "${GEOIP_C}" ];then
btpip install geoip2==4.7.0
fi

PANDAS_C=$(echo $pip_list|grep pandas)
if [ -z "${PANDAS_C}" ];then
btpip install pandas
fi
# PANDAS_C=$(echo $pip_list|grep pandas)
# if [ -z "${PANDAS_C}" ];then
# btpip install pandas
# fi

pymysql=$(echo "$pip_list"|grep pycryptodome)
if [ "$pymysql" = "" ];then
Expand Down
Binary file modified public/static/file/kaixin.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions route/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Route::get('/getUpdateLogs', 'api/get_update_logs');
Route::get('/panel/get_version', 'api/get_version');
Route::get('/wpanel/get_version', 'api/get_version_win');
Route::get('/panel/get_panel_version', 'api/get_panel_version');
Route::get('/SetupCount', 'api/setup_count');
Route::any('/panel/updateLinux', 'api/check_update');
Route::any('/wpanel/updateWindows', 'api/check_update_win');
Expand Down Expand Up @@ -123,6 +124,9 @@
Route::post('/Auth/SetSocre', 'api/get_ssl_list');
Route::post('/Auth/SubmitScore', 'api/get_ssl_list');

Route::post('/Cert_cloud_deploy/get_cert_list', 'api/return_success');
Route::post('/Cert_cloud_deploy/del_cert', 'api/return_success');

Route::miss('api/return_error');
});

Expand Down
6 changes: 3 additions & 3 deletions wiki/files/linux/PluginLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ def module_run(module_name,def_name,args):
return public.returnMsg(False,'模块路径不合法')

def_object = public.get_script_object(module_file)
if not def_object: return public.returnMsg(False,'模块[%s]不存在' % module_file)
if not def_object: return public.returnMsg(False,'模块[%s]不存在' % module_name)

# 模块实例化并返回方法对象
try:
run_object = getattr(def_object.main(),def_name,None)
except:
return public.returnMsg(False,'模块[%s]入口实例化失败' % module_file)
if not run_object: return public.returnMsg(False,'在[%s]模块中找不到[%s]方法' % (module_file,def_name))
return public.returnMsg(False,'模块[%s]入口实例化失败' % module_name)
if not run_object: return public.returnMsg(False,'在[%s]模块中找不到[%s]方法' % (module_name,def_name))

if 'module_get_object' in args and args.module_get_object == 1:
return run_object
Expand Down
8 changes: 6 additions & 2 deletions wiki/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

- 全局搜索替换 https://download.bt.cn/install/update6.sh => http://www.example.com/install/update6.sh

http://download.bt.cn/install/update6.sh => http://www.example.com/install/update6.sh

http://download.bt.cn/install/update/ => http://www.example.com/install/update/

- 搜索并删除提交异常报告的代码 bt_error/index.php

- class/ajax.py 文件 \# 是否执行升级程序 下面的 public.get_url() 改成 public.GetConfigValue('home')
Expand Down Expand Up @@ -72,7 +76,7 @@

plugin_bin.pl 改成 plugin_list.json

- class/plugin_deployment.py 文件,SetupPackage方法内替换 public.GetConfigValue('home') => 'https://www.bt.cn'
- class/plugin_deployment.py 文件,__setup_php_environment方法和GetJarPath方法内替换 public.GetConfigValue('home') => 'https://www.bt.cn'

- class/config.py 文件,get_nps方法内data['nps'] = False改成True,get_nps_new方法下面加上 return public.returnMsg(False, "获取问卷失败")

Expand Down Expand Up @@ -119,7 +123,7 @@
<script src="/static/bt.js"></script>
```

在 BTPanel/templates/default/software.html 的 <script>window.vite_public_request_token 前面加入
在 BTPanel/templates/default/software.html 的 \<script\>window.vite_public_request_token 前面加入

- [可选]去除创建网站自动创建的垃圾文件:在class/panelSite.py,分别删除

Expand Down

0 comments on commit d80c0e9

Please sign in to comment.