From 46897079874053d5609799d7b9181c5912346c5d Mon Sep 17 00:00:00 2001 From: flucont Date: Tue, 7 Jun 2022 14:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8E=BB=E9=99=A4=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/UpdateAll.php | 14 ++++++++++---- app/controller/Admin.php | 1 + app/lib/Plugins.php | 16 +++++++++++++++- app/view/admin/set.html | 1 + route/app.php | 5 ++++- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/command/UpdateAll.php b/app/command/UpdateAll.php index 381bdf0..3395667 100644 --- a/app/command/UpdateAll.php +++ b/app/command/UpdateAll.php @@ -43,13 +43,19 @@ class UpdateAll extends Command $ver = $version['m_version'].'.'.$version['version']; if(isset($version['download'])){ if(!file_exists(get_data_dir().'plugins/other/'.$version['download'])){ - $this->download_plugin($input, $output, $plugin['name'], $ver); + if(!$this->download_plugin($input, $output, $plugin['name'], $ver)){ + sleep(1); + $this->download_plugin($input, $output, $plugin['name'], $ver); + } sleep(1); $count++; } }else{ if(!file_exists(get_data_dir().'plugins/package/'.$plugin['name'].'-'.$ver.'.zip')){ - $this->download_plugin($input, $output, $plugin['name'], $ver); + if(!$this->download_plugin($input, $output, $plugin['name'], $ver)){ + sleep(1); + $this->download_plugin($input, $output, $plugin['name'], $ver); + } sleep(1); $count++; } @@ -59,7 +65,7 @@ class UpdateAll extends Command $imgcount = 0; //循环下载缺少的插件图片 - foreach($json_arr['list'] as $plugin){ + /*foreach($json_arr['list'] as $plugin){ if(isset($plugin['min_image']) && strpos($plugin['min_image'], 'fname=')){ $fname = substr($plugin['min_image'], strpos($plugin['min_image'], '?fname=')+7); if(!file_exists(get_data_dir().'plugins/other/'.$fname)){ @@ -68,7 +74,7 @@ class UpdateAll extends Command $imgcount++; } } - } + }*/ $output->writeln('本次成功下载'.$count.'个插件'.($imgcount>0?','.$imgcount.'个图片':'')); config_set('runtime', date('Y-m-d H:i:s')); diff --git a/app/controller/Admin.php b/app/controller/Admin.php index fa70c16..bda4bc0 100644 --- a/app/controller/Admin.php +++ b/app/controller/Admin.php @@ -190,6 +190,7 @@ class Admin extends BaseController $versions[] = ['status'=>$status, 'type'=>0, 'version'=>$ver]; } } + if($plugin['name'] == 'obs') $plugin['ps'] = substr($plugin['ps'],0,strpos($plugin['ps'],' $plugin['id'], 'name' => $plugin['name'], diff --git a/app/lib/Plugins.php b/app/lib/Plugins.php index dacdb8e..10742a1 100644 --- a/app/lib/Plugins.php +++ b/app/lib/Plugins.php @@ -26,7 +26,7 @@ class Plugins } self::save_plugin_list($result); }else{ - throw new Exception('获取插件列表失败:'.($result['msg']?$result['msg']:'面板连接失败')); + throw new Exception('获取插件列表失败:'.(isset($result['msg'])?$result['msg']:'面板连接失败')); } } @@ -116,6 +116,7 @@ class Plugins if(file_exists($main_filepath) && filesize($main_filepath)>10){ if(!strpos(file_get_contents($main_filepath), 'import ')){ //加密py文件,需要解密 self::decode_plugin_main($plugin_name, $version, $main_filepath); + self::noauth_plugin_main($main_filepath); $zip->open($filepath, ZipArchive::CREATE); $zip->addFile($main_filepath, $plugin_name.'/'.$plugin_name.'_main.py'); $zip->close(); @@ -175,6 +176,19 @@ class Plugins } } + //去除插件主程序文件授权校验 + public static function noauth_plugin_main($main_filepath){ + $data = file_get_contents($main_filepath); + if(!$data) return false; + $data = str_replace('\'http://www.bt.cn/api/panel/get_soft_list_test', 'public.GetConfigValue(\'home\')+\'/api/panel/get_soft_list_test', $data); + $data = str_replace('\'https://www.bt.cn/api/panel/get_soft_list_test', 'public.GetConfigValue(\'home\')+\'/api/panel/get_soft_list_test', $data); + $data = str_replace('\'http://www.bt.cn/api/panel/get_soft_list', 'public.GetConfigValue(\'home\')+\'/api/panel/get_soft_list', $data); + $data = str_replace('\'https://www.bt.cn/api/panel/get_soft_list', 'public.GetConfigValue(\'home\')+\'/api/panel/get_soft_list', $data); + $data = str_replace('\'http://www.bt.cn/api/panel/notpro', 'public.GetConfigValue(\'home\')+\'/api/panel/notpro', $data); + $data = str_replace('\'https://www.bt.cn/api/panel/notpro', 'public.GetConfigValue(\'home\')+\'/api/panel/notpro', $data); + file_put_contents($main_filepath, $data); + } + //下载插件其他文件 public static function download_plugin_other($fname, $filemd5 = null){ $filepath = get_data_dir().'plugins/other/'.$fname; diff --git a/app/view/admin/set.html b/app/view/admin/set.html index e5c6ef0..50b260e 100644 --- a/app/view/admin/set.html +++ b/app/view/admin/set.html @@ -67,6 +67,7 @@
使用以下命令可以从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。
你也可以将此命令添加到crontab以使此云端的插件保持最新,建议1天执行1次。
+
使用命令执行之后,可能会导致 /data 目录下文件权限不对,后台插件列表下载插件覆盖会报错,需要手动循环设置 /data 目录权限。
上次运行时间:{$runtime|raw}
php {:app()->getRootPath()}think updateall

diff --git a/route/app.php b/route/app.php index fda85a5..4686ff2 100644 --- a/route/app.php +++ b/route/app.php @@ -14,6 +14,8 @@ Route::post('/panel/get_unbinding', 'api/return_success'); Route::post('/bt_cert', 'api/return_error'); Route::group('api', function () { + Route::any('/panel/get_soft_list', 'api/get_plugin_list'); + Route::any('/panel/get_soft_list_test', 'api/get_plugin_list'); Route::get('/getUpdateLogs', 'api/get_update_logs'); Route::get('/panel/get_version', 'api/get_version'); Route::get('/SetupCount', 'api/setup_count'); @@ -41,6 +43,7 @@ Route::group('api', function () { Route::post('/Plugin/get_re_order_status', 'api/return_error'); Route::post('/Plugin/create_order_voucher', 'api/return_error'); Route::post('/Plugin/get_voucher', 'api/return_empty_array'); + Route::post('/Plugin/check_plugin_status', 'api/return_success'); Route::post('/invite/get_voucher', 'api/return_empty_array'); Route::post('/invite/get_order_status', 'api/return_error'); @@ -62,7 +65,7 @@ Route::group('api', function () { Route::post('/panel/model_total', 'api/return_empty'); Route::post('/wpanel/model_click', 'api/return_empty'); Route::post('/v2/statistics/report_plugin_daily', 'api/return_error'); - Route::post('/panel/notpro', 'api/return_empty'); + Route::get('/panel/notpro', 'api/return_empty'); Route::post('/LinuxBeta', 'api/return_error'); Route::post('/panel/apple_beta', 'api/return_error');