Browse Source

update

tags/2.7 2.7
flucout 4 months ago
parent
commit
aba885f434
  1. 29
      app/command/Clean.php
  2. 26
      app/common.php
  3. 29
      app/controller/Api.php
  4. 10
      app/lib/BtPlugins.php
  5. 1
      app/lib/ThirdPlugins.php
  6. 7
      app/view/admin/plugins.html
  7. 4
      route/app.php

29
app/command/Clean.php

@ -68,37 +68,10 @@ class Clean extends Command
if($file == '.' || $file == '..') continue; if($file == '.' || $file == '..') continue;
if(!in_array($file, $file_list)){ if(!in_array($file, $file_list)){
$filepath = $data_dir . 'folder/' . $file; $filepath = $data_dir . 'folder/' . $file;
$this->delete_dir($filepath);
deleteDir($filepath);
$count++; $count++;
} }
} }
$output->writeln($os.'成功清理'.$count.'个历史版本插件目录'); $output->writeln($os.'成功清理'.$count.'个历史版本插件目录');
} }
// 删除文件夹
private function delete_dir($dir){
$rd = opendir($dir);
if (!$rd) {
return false;
}
while (($file = readdir($rd)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$file = $dir . '/' . $file;
if (is_dir($file)) {
$this->delete_dir($file);
}
else {
unlink($file);
}
}
closedir($rd);
rmdir($dir);
return true;
}
} }

26
app/common.php

@ -295,3 +295,29 @@ EOF;
return ['cert' => $certificate, 'key' => $privateKey]; return ['cert' => $certificate, 'key' => $privateKey];
} }
function deleteDir($dir){
$rd = opendir($dir);
if (!$rd) {
return false;
}
while (($file = readdir($rd)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$file = $dir . '/' . $file;
if (is_dir($file)) {
deleteDir($file);
}
else {
unlink($file);
}
}
closedir($rd);
rmdir($dir);
return true;
}

29
app/controller/Api.php

@ -48,7 +48,7 @@ class Api extends BaseController
if(!preg_match('/^[a-zA-Z0-9_]+$/', $plugin_name) || !preg_match('/^[0-9.]+$/', $version)){ if(!preg_match('/^[a-zA-Z0-9_]+$/', $plugin_name) || !preg_match('/^[0-9.]+$/', $version)){
return '参数不正确'; return '参数不正确';
} }
if(!$this->checklist()) '你的服务器被禁止使用此云端';
if(!$this->checklist()) return '你的服务器被禁止使用此云端';
$filepath = get_data_dir($os).'plugins/package/'.$plugin_name.'-'.$version.'.zip'; $filepath = get_data_dir($os).'plugins/package/'.$plugin_name.'-'.$version.'.zip';
if(file_exists($filepath)){ if(file_exists($filepath)){
$filename = $plugin_name.'.zip'; $filename = $plugin_name.'.zip';
@ -70,21 +70,23 @@ class Api extends BaseController
if(!preg_match('/^[a-zA-Z0-9_]+$/', $plugin_name) || !preg_match('/^[0-9.]+$/', $version)){ if(!preg_match('/^[a-zA-Z0-9_]+$/', $plugin_name) || !preg_match('/^[0-9.]+$/', $version)){
return '参数不正确'; return '参数不正确';
} }
if(!$this->checklist()) '你的服务器被禁止使用此云端';
$filepath = get_data_dir($os).'plugins/main/'.$plugin_name.'-'.$version.'.dat';
if(file_exists($filepath)){
if(!$this->checklist()) return '你的服务器被禁止使用此云端';
$filepath = get_data_dir($os).'plugins/package/'.$plugin_name.'-'.$version.'.zip';
$mainfilepath = get_data_dir($os).'plugins/folder/'.$plugin_name.'-'.$version.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
if(file_exists($mainfilepath)){
$filename = $plugin_name.'_main.py'; $filename = $plugin_name.'_main.py';
$this->output_file($filepath, $filename);
$this->output_file($mainfilepath, $filename);
}elseif(file_exists($filepath)){
$zip = new \ZipArchive;
if ($zip->open($filepath) === true){
echo $zip->getFromName($plugin_name.'/'.$plugin_name.'_main.py');
}else{ }else{
$filepath = get_data_dir($os).'plugins/folder/'.$plugin_name.'-'.$version.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
if(file_exists($filepath)){
$filename = $plugin_name.'_main.py';
$this->output_file($filepath, $filename);
return '插件包解压缩失败';
}
}else{ }else{
return '云端不存在该插件主文件'; return '云端不存在该插件主文件';
} }
} }
}
//下载插件其他文件 //下载插件其他文件
public function download_plugin_other(){ public function download_plugin_other(){
@ -469,13 +471,15 @@ class Api extends BaseController
public function bt_cert(){ public function bt_cert(){
$data = input('post.data'); $data = input('post.data');
$param = json_decode($data, true); $param = json_decode($data, true);
if(!$param || !isset($param['domain'])) return json(['status'=>false, 'msg'=>'参数错误']);
if(!$param || !isset($param['action']) || !isset($param['domain'])) return json(['status'=>false, 'msg'=>'参数错误']);
$dir = app()->getBasePath().'script/'; $dir = app()->getBasePath().'script/';
$ssl_path = app()->getRootPath().'public/ssl/baota_root.pfx'; $ssl_path = app()->getRootPath().'public/ssl/baota_root.pfx';
$isca = file_exists($dir.'ca.crt') && file_exists($dir.'ca.key') && file_exists($ssl_path); $isca = file_exists($dir.'ca.crt') && file_exists($dir.'ca.key') && file_exists($ssl_path);
if(!$isca) return json(['status'=>false, 'msg'=>'CA证书不存在']); if(!$isca) return json(['status'=>false, 'msg'=>'CA证书不存在']);
if($param['action'] == 'get_domain_cert'){
if(!$this->checklist()) return json(['status'=>false, 'msg'=>'你的服务器被禁止使用此云端']);
$domain = $param['domain']; $domain = $param['domain'];
if(empty($domain)) return json(['status'=>false, 'msg'=>'域名不能为空']); if(empty($domain)) return json(['status'=>false, 'msg'=>'域名不能为空']);
$domain_list = explode(',', $domain); $domain_list = explode(',', $domain);
@ -490,5 +494,8 @@ class Api extends BaseController
} }
$ca_pfx = base64_encode(file_get_contents($ssl_path)); $ca_pfx = base64_encode(file_get_contents($ssl_path));
return json(['status'=>true, 'msg'=>'生成证书成功', 'cert'=>$result['cert'], 'key'=>$result['key'], 'pfx'=>$ca_pfx, 'password'=>'']); return json(['status'=>true, 'msg'=>'生成证书成功', 'cert'=>$result['cert'], 'key'=>$result['key'], 'pfx'=>$ca_pfx, 'password'=>'']);
}else{
return json(['status'=>false, 'msg'=>'不支持当前操作']);
}
} }
} }

10
app/lib/BtPlugins.php

@ -11,7 +11,7 @@ class BtPlugins
private $os; private $os;
//需屏蔽的插件名称列表 //需屏蔽的插件名称列表
private static $block_plugins = ['dns'];
private static $block_plugins = ['dns','bt_boce','ssl_verify'];
public function __construct($os){ public function __construct($os){
$this->os = $os; $this->os = $os;
@ -72,9 +72,10 @@ class BtPlugins
$zip = new ZipArchive; $zip = new ZipArchive;
if ($zip->open($filepath) === true) if ($zip->open($filepath) === true)
{ {
$zip->extractTo(get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version);
$plugins_dir = get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version;
$zip->extractTo($plugins_dir, $plugin_name.'/'.$plugin_name.'_main.py');
$zip->close(); $zip->close();
$main_filepath = get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
$main_filepath = $plugins_dir.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
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文件,需要解密
$this->decode_plugin_main($plugin_name, $version, $main_filepath); $this->decode_plugin_main($plugin_name, $version, $main_filepath);
@ -84,6 +85,7 @@ class BtPlugins
$zip->close(); $zip->close();
} }
} }
deleteDir($plugins_dir);
}else{ }else{
unlink($filepath); unlink($filepath);
throw new Exception('插件包解压缩失败'); throw new Exception('插件包解压缩失败');
@ -197,6 +199,8 @@ class BtPlugins
$data = str_replace('\'https://www.bt.cn/api/bt_waf/reportInterceptFail', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/reportInterceptFail', $data); $data = str_replace('\'https://www.bt.cn/api/bt_waf/reportInterceptFail', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/reportInterceptFail', $data);
$data = str_replace('\'https://www.bt.cn/api/v2/contact/nps/questions', 'public.GetConfigValue(\'home\')+\'/panel/notpro', $data); $data = str_replace('\'https://www.bt.cn/api/v2/contact/nps/questions', 'public.GetConfigValue(\'home\')+\'/panel/notpro', $data);
$data = str_replace('\'https://www.bt.cn/api/v2/contact/nps/submit', 'public.GetConfigValue(\'home\')+\'/panel/notpro', $data); $data = str_replace('\'https://www.bt.cn/api/v2/contact/nps/submit', 'public.GetConfigValue(\'home\')+\'/panel/notpro', $data);
$data = str_replace('\'http://www.bt.cn/api/Auth', 'public.GetConfigValue(\'home\')+\'/api/Auth', $data);
$data = str_replace('\'https://www.bt.cn/api/Auth', 'public.GetConfigValue(\'home\')+\'/api/Auth', $data);
file_put_contents($main_filepath, $data); file_put_contents($main_filepath, $data);
} }

1
app/lib/ThirdPlugins.php

@ -65,7 +65,6 @@ class ThirdPlugins
$zip = new ZipArchive; $zip = new ZipArchive;
if ($zip->open($filepath) === true) if ($zip->open($filepath) === true)
{ {
$zip->extractTo(get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version);
$zip->close(); $zip->close();
return true; return true;
}else{ }else{

7
app/view/admin/plugins.html

@ -157,8 +157,13 @@ function download_item(){
layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();}); layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();});
return; return;
} }
$.downloadCount++;
var plugin = $.preDownload[0]; var plugin = $.preDownload[0];
if(plugin.name == 'firewall'){
$.preDownload.shift();
download_item();
return;
}
$.downloadCount++;
var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0}); var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
$.ajax({ $.ajax({
type : 'POST', type : 'POST',

4
route/app.php

@ -119,6 +119,10 @@ Route::group('api', function () {
Route::post('/bt_waf/reportInterceptFail', 'api/return_empty'); Route::post('/bt_waf/reportInterceptFail', 'api/return_empty');
Route::any('/panel/get_spider', 'api/get_spider'); Route::any('/panel/get_spider', 'api/get_spider');
Route::post('/Auth/GetSocre', 'api/get_ssl_list');
Route::post('/Auth/SetSocre', 'api/get_ssl_list');
Route::post('/Auth/SubmitScore', 'api/get_ssl_list');
Route::miss('api/return_error'); Route::miss('api/return_error');
}); });

Loading…
Cancel
Save