自动去除插件授权

This commit is contained in:
flucont 2022-06-07 14:21:19 +08:00
parent 17d2025d8c
commit 4689707987
5 changed files with 31 additions and 6 deletions

View File

@ -43,13 +43,19 @@ class UpdateAll extends Command
$ver = $version['m_version'].'.'.$version['version']; $ver = $version['m_version'].'.'.$version['version'];
if(isset($version['download'])){ if(isset($version['download'])){
if(!file_exists(get_data_dir().'plugins/other/'.$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); sleep(1);
$count++; $count++;
} }
}else{ }else{
if(!file_exists(get_data_dir().'plugins/package/'.$plugin['name'].'-'.$ver.'.zip')){ 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); sleep(1);
$count++; $count++;
} }
@ -59,7 +65,7 @@ class UpdateAll extends Command
$imgcount = 0; $imgcount = 0;
//循环下载缺少的插件图片 //循环下载缺少的插件图片
foreach($json_arr['list'] as $plugin){ /*foreach($json_arr['list'] as $plugin){
if(isset($plugin['min_image']) && strpos($plugin['min_image'], 'fname=')){ if(isset($plugin['min_image']) && strpos($plugin['min_image'], 'fname=')){
$fname = substr($plugin['min_image'], strpos($plugin['min_image'], '?fname=')+7); $fname = substr($plugin['min_image'], strpos($plugin['min_image'], '?fname=')+7);
if(!file_exists(get_data_dir().'plugins/other/'.$fname)){ if(!file_exists(get_data_dir().'plugins/other/'.$fname)){
@ -68,7 +74,7 @@ class UpdateAll extends Command
$imgcount++; $imgcount++;
} }
} }
} }*/
$output->writeln('本次成功下载'.$count.'个插件'.($imgcount>0?''.$imgcount.'个图片':'')); $output->writeln('本次成功下载'.$count.'个插件'.($imgcount>0?''.$imgcount.'个图片':''));
config_set('runtime', date('Y-m-d H:i:s')); config_set('runtime', date('Y-m-d H:i:s'));

View File

@ -190,6 +190,7 @@ class Admin extends BaseController
$versions[] = ['status'=>$status, 'type'=>0, 'version'=>$ver]; $versions[] = ['status'=>$status, 'type'=>0, 'version'=>$ver];
} }
} }
if($plugin['name'] == 'obs') $plugin['ps'] = substr($plugin['ps'],0,strpos($plugin['ps'],'<a '));
$list[] = [ $list[] = [
'id' => $plugin['id'], 'id' => $plugin['id'],
'name' => $plugin['name'], 'name' => $plugin['name'],

View File

@ -26,7 +26,7 @@ class Plugins
} }
self::save_plugin_list($result); self::save_plugin_list($result);
}else{ }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(file_exists($main_filepath) && filesize($main_filepath)>10){
if(!strpos(file_get_contents($main_filepath), 'import ')){ //加密py文件需要解密 if(!strpos(file_get_contents($main_filepath), 'import ')){ //加密py文件需要解密
self::decode_plugin_main($plugin_name, $version, $main_filepath); self::decode_plugin_main($plugin_name, $version, $main_filepath);
self::noauth_plugin_main($main_filepath);
$zip->open($filepath, ZipArchive::CREATE); $zip->open($filepath, ZipArchive::CREATE);
$zip->addFile($main_filepath, $plugin_name.'/'.$plugin_name.'_main.py'); $zip->addFile($main_filepath, $plugin_name.'/'.$plugin_name.'_main.py');
$zip->close(); $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){ public static function download_plugin_other($fname, $filemd5 = null){
$filepath = get_data_dir().'plugins/other/'.$fname; $filepath = get_data_dir().'plugins/other/'.$fname;

View File

@ -67,6 +67,7 @@
<div class="panel-body"> <div class="panel-body">
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form"> <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="alert alert-info">使用以下命令可以从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。<br/>你也可以将此命令添加到crontab以使此云端的插件保持最新建议1天执行1次。</div> <div class="alert alert-info">使用以下命令可以从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。<br/>你也可以将此命令添加到crontab以使此云端的插件保持最新建议1天执行1次。</div>
<div class="alert alert-danger">使用命令执行之后,可能会导致 /data 目录下文件权限不对,后台插件列表下载插件覆盖会报错,需要手动循环设置 /data 目录权限。</div>
<div class="alert alert-warning">上次运行时间:{$runtime|raw}</div> <div class="alert alert-warning">上次运行时间:{$runtime|raw}</div>
<div class="list-group-item">php {:app()->getRootPath()}think updateall</div><br/> <div class="list-group-item">php {:app()->getRootPath()}think updateall</div><br/>
</form> </form>

View File

@ -14,6 +14,8 @@ Route::post('/panel/get_unbinding', 'api/return_success');
Route::post('/bt_cert', 'api/return_error'); Route::post('/bt_cert', 'api/return_error');
Route::group('api', function () { 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('/getUpdateLogs', 'api/get_update_logs');
Route::get('/panel/get_version', 'api/get_version'); Route::get('/panel/get_version', 'api/get_version');
Route::get('/SetupCount', 'api/setup_count'); 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/get_re_order_status', 'api/return_error');
Route::post('/Plugin/create_order_voucher', 'api/return_error'); Route::post('/Plugin/create_order_voucher', 'api/return_error');
Route::post('/Plugin/get_voucher', 'api/return_empty_array'); 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_voucher', 'api/return_empty_array');
Route::post('/invite/get_order_status', 'api/return_error'); 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('/panel/model_total', 'api/return_empty');
Route::post('/wpanel/model_click', 'api/return_empty'); Route::post('/wpanel/model_click', 'api/return_empty');
Route::post('/v2/statistics/report_plugin_daily', 'api/return_error'); 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('/LinuxBeta', 'api/return_error');
Route::post('/panel/apple_beta', 'api/return_error'); Route::post('/panel/apple_beta', 'api/return_error');