mirror of
https://github.com/flucont/btcloud.git
synced 2025-10-15 07:15:17 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8946b4fd11 | ||
![]() |
5bd1670955 | ||
![]() |
1fc393c8e9 |
115
app/command/DecryptFile.php
Normal file
115
app/command/DecryptFile.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config;
|
||||
use app\lib\Plugins;
|
||||
|
||||
class DecryptFile extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('decrypt')
|
||||
->addArgument('type', Argument::REQUIRED, '文件类型,plugin:插件文件,module:模块文件,classdir:宝塔class目录,all:所有py文件')
|
||||
->addArgument('file', Argument::REQUIRED, '文件路径')
|
||||
->addArgument('os', Argument::OPTIONAL, '操作系统:Windows/Linux')
|
||||
->setDescription('解密宝塔面板python文件');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$type = trim($input->getArgument('type'));
|
||||
$file = trim($input->getArgument('file'));
|
||||
|
||||
if(!file_exists($file)){
|
||||
$output->writeln('文件不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
if($type == 'plugin'){
|
||||
$os = trim($input->getArgument('os'));
|
||||
try{
|
||||
if(Plugins::decode_plugin_main_local($file, $os)){
|
||||
$output->writeln('文件解密成功!');
|
||||
}else{
|
||||
$output->writeln('文件解密失败!');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
$output->writeln($e->getMessage());
|
||||
}
|
||||
}elseif($type == 'module'){
|
||||
try{
|
||||
$res = Plugins::decode_module_file($file);
|
||||
if($res == 2){
|
||||
$output->writeln('文件解密失败!');
|
||||
}elseif($res == 1){
|
||||
$output->writeln('文件解密成功!');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
$output->writeln($e->getMessage());
|
||||
}
|
||||
}elseif($type == 'classdir'){
|
||||
$file = rtrim($file, '/');
|
||||
if(!file_exists($file.'/common.py')){
|
||||
$output->writeln('当前路径非宝塔面板class目录');
|
||||
return;
|
||||
}
|
||||
$dirs = glob($file.'/*Model');
|
||||
foreach($dirs as $dir){
|
||||
if(!is_dir($dir))continue;
|
||||
$files = glob($dir.'/*Model.py');
|
||||
foreach($files as $file){
|
||||
try{
|
||||
$res = Plugins::decode_module_file($file);
|
||||
if($res == 2){
|
||||
$output->writeln('文件解密失败:'.$file);
|
||||
}elseif($res == 1){
|
||||
$output->writeln('文件解密成功:'.$file);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
$output->writeln($e->getMessage().':'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif($type == 'all'){
|
||||
$file = rtrim($file, '/');
|
||||
$this->scan_all_file($input, $output, $file);
|
||||
}else{
|
||||
$output->writeln('未知文件类型');
|
||||
}
|
||||
}
|
||||
|
||||
private function scan_all_file(Input $input, Output $output, $path) {
|
||||
$dir = opendir($path);
|
||||
while(false !== ( $file = readdir($dir)) ) {
|
||||
if (( $file != '.' ) && ( $file != '..' )) {
|
||||
$filepath = $path . '/' . $file;
|
||||
if ( is_dir($filepath) ) {
|
||||
$this->scan_all_file($input, $output, $filepath);
|
||||
}
|
||||
elseif(substr($filepath, -3) == '.py') {
|
||||
try{
|
||||
$res = Plugins::decode_module_file($filepath);
|
||||
if($res == 2){
|
||||
$output->writeln('文件解密失败:'.$filepath);
|
||||
}elseif($res == 1){
|
||||
$output->writeln('文件解密成功:'.$filepath);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
$output->writeln($e->getMessage().':'.$filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -6,6 +6,7 @@ use app\BaseController;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
use think\facade\Request;
|
||||
use think\facade\Cache;
|
||||
use app\lib\Btapi;
|
||||
use app\lib\Plugins;
|
||||
|
||||
@@ -357,4 +358,31 @@ class Admin extends BaseController
|
||||
}
|
||||
return json(['code'=>-1, 'msg'=>'no act']);
|
||||
}
|
||||
|
||||
public function deplist(){
|
||||
$deplist_linux = get_data_dir().'config/deployment_list.json';
|
||||
$deplist_win = get_data_dir('Windows').'config/deployment_list.json';
|
||||
$deplist_linux_time = file_exists($deplist_linux) ? date("Y-m-d H:i:s", filemtime($deplist_linux)) : '不存在';
|
||||
$deplist_win_time = file_exists($deplist_win) ? date("Y-m-d H:i:s", filemtime($deplist_win)) : '不存在';
|
||||
View::assign('deplist_linux_time', $deplist_linux_time);
|
||||
View::assign('deplist_win_time', $deplist_win_time);
|
||||
return view();
|
||||
}
|
||||
|
||||
public function refresh_deplist(){
|
||||
$os = input('get.os');
|
||||
if(!$os) $os = 'Linux';
|
||||
try{
|
||||
Plugins::refresh_deplist($os);
|
||||
Db::name('log')->insert(['uid' => 0, 'action' => '刷新一键部署列表', 'data' => '刷新'.$os.'一键部署列表成功', 'addtime' => date("Y-m-d H:i:s")]);
|
||||
return json(['code'=>0,'msg'=>'获取最新一键部署列表成功!']);
|
||||
}catch(\Exception $e){
|
||||
return json(['code'=>-1, 'msg'=>$e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function cleancache(){
|
||||
Cache::clear();
|
||||
return json(['code'=>0,'msg'=>'succ']);
|
||||
}
|
||||
}
|
@@ -272,6 +272,12 @@ class Api extends BaseController
|
||||
return json($json_arr);
|
||||
}
|
||||
|
||||
//获取宝塔SSL列表
|
||||
public function get_ssl_list(){
|
||||
$data = bin2hex('[]');
|
||||
return json(['status'=>true, 'msg'=>'', 'data'=>$data]);
|
||||
}
|
||||
|
||||
public function return_success(){
|
||||
return json(['status'=>true, 'msg'=>1, 'data'=>(object)[]]);
|
||||
}
|
||||
|
@@ -48,8 +48,7 @@ class Plugins
|
||||
$list[] = $plugin;
|
||||
}
|
||||
$data['list'] = $list;
|
||||
if($data['pro']>-1) $data['pro'] = 0;
|
||||
if($data['ltd']>-1) $data['ltd'] = strtotime('+10 year');
|
||||
$data['ltd'] = strtotime('+10 year');
|
||||
$json_file = get_data_dir($os).'config/plugin_list.json';
|
||||
if(!file_put_contents($json_file, json_encode($data))){
|
||||
throw new Exception('保存插件列表失败,文件无写入权限');
|
||||
@@ -188,6 +187,8 @@ class Plugins
|
||||
$userinfo = $btapi->get_user_info();
|
||||
if(isset($userinfo['uid'])){
|
||||
$src = file_get_contents($main_filepath);
|
||||
if($src===false)throw new Exception('文件打开失败');
|
||||
if(!$src || strpos($src, 'import ')!==false)return true;
|
||||
$uid = $userinfo['uid'];
|
||||
$serverid = $userinfo['serverid'];
|
||||
$key = md5(substr($serverid, 10, 16).$uid.$serverid);
|
||||
@@ -203,7 +204,7 @@ class Plugins
|
||||
if($tmp) $de_text .= $tmp;
|
||||
}
|
||||
}
|
||||
if(!empty($de_text)){
|
||||
if(!empty($de_text) && strpos($de_text, 'import ')!==false){
|
||||
file_put_contents($main_filepath, $de_text);
|
||||
return true;
|
||||
}
|
||||
@@ -213,6 +214,28 @@ class Plugins
|
||||
}
|
||||
}
|
||||
|
||||
public static function decode_module_file($filepath){
|
||||
$src = file_get_contents($filepath);
|
||||
if($src===false)throw new Exception('文件打开失败');
|
||||
if(!$src || strpos($src, 'import ')!==false)return 0;
|
||||
$key = 'Z2B87NEAS2BkxTrh';
|
||||
$iv = 'WwadH66EGWpeeTT6';
|
||||
$data_arr = explode("\n", $src);
|
||||
$de_text = '';
|
||||
foreach($data_arr as $data){
|
||||
$data = trim($data);
|
||||
if(!empty($data)){
|
||||
$tmp = openssl_decrypt($data, 'aes-128-cbc', $key, 0, $iv);
|
||||
if($tmp) $de_text .= $tmp;
|
||||
}
|
||||
}
|
||||
if(!empty($de_text) && strpos($de_text, 'import ')!==false){
|
||||
file_put_contents($filepath, $de_text);
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
//去除插件主程序文件授权校验
|
||||
public static function noauth_plugin_main($main_filepath){
|
||||
$data = file_get_contents($main_filepath);
|
||||
@@ -247,8 +270,9 @@ class Plugins
|
||||
self::download_file($btapi, $filename, $filepath);
|
||||
if(file_exists($filepath)){
|
||||
if($filemd5 && md5_file($filepath) != $filemd5){
|
||||
$msg = filesize($filepath) < 300 ? file_get_contents($filepath) : '插件文件MD5校验失败';
|
||||
@unlink($filepath);
|
||||
throw new Exception('插件文件MD5校验失败');
|
||||
throw new Exception($msg);
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
Linux_Version="7.9.3"
|
||||
Windows_Version="7.6.0"
|
||||
Linux_Version="7.9.4"
|
||||
Windows_Version="7.7.0"
|
||||
|
||||
FILES=(
|
||||
public/install/src/panel6.zip
|
||||
|
49
app/view/admin/deplist.html
Normal file
49
app/view/admin/deplist.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{extend name="admin/layout" /}
|
||||
{block name="title"}一键部署列表{/block}
|
||||
{block name="main"}
|
||||
<div class="container" style="padding-top:70px;">
|
||||
<div class="col-sm-12 col-md-10 col-lg-8 center-block" style="float: none;">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading"><h3 class="panel-title">一键部署列表</h3></div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<div class="list-group-item list-group-item-warning">Linux面板</div>
|
||||
<div class="list-group-item" style="line-height:35px">列表文件更新时间:<font color="blue">{$deplist_linux_time}</font><a href="javascript:refresh_deplist('Linux')" class="btn btn-success pull-right"><i class="fa fa-refresh"></i>重新获取</a></div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item list-group-item-warning">Windows面板</div>
|
||||
<div class="list-group-item" style="line-height:35px">列表文件更新时间:<font color="blue">{$deplist_win_time}</font><a href="javascript:refresh_deplist('Windows')" class="btn btn-success pull-right"><i class="fa fa-refresh"></i>重新获取</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script>
|
||||
<script>
|
||||
function refresh_deplist(os){
|
||||
var confirm = layer.confirm('是否确定从宝塔官方获取最新一键部署列表?', {
|
||||
btn: ['确定','取消']
|
||||
}, function(){
|
||||
layer.close(confirm)
|
||||
var ii = layer.msg('正在获取一键部署列表,请稍候...', {icon: 16, shade:0.1, time: 0});
|
||||
$.ajax({
|
||||
type : 'GET',
|
||||
url : '/admin/refresh_deplist?os='+os,
|
||||
dataType : 'json',
|
||||
success : function(data) {
|
||||
layer.close(ii)
|
||||
if(data.code == 0){
|
||||
layer.alert(data.msg, {icon:1}, function(){window.location.reload()});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon:2});
|
||||
}
|
||||
},
|
||||
error:function(data){
|
||||
layer.close(ii)
|
||||
layer.msg('服务器错误', {icon:2});
|
||||
}
|
||||
});
|
||||
}, function(){
|
||||
layer.close(confirm)
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
@@ -34,11 +34,12 @@
|
||||
<li class="{:checkIfActive('index')}">
|
||||
<a href="/admin"><i class="fa fa-home"></i> 后台首页</a>
|
||||
</li>
|
||||
<li class="{:checkIfActive('plugins,pluginswin')}">
|
||||
<li class="{:checkIfActive('plugins,pluginswin,deplist')}">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cubes"></i> 插件列表<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="{:checkIfActive('plugins')}"><a href="/admin/plugins">Linux面板</a></li>
|
||||
<li class="{:checkIfActive('pluginswin')}"><a href="/admin/pluginswin">Windows面板</a></li>
|
||||
<li class="{:checkIfActive('deplist')}"><a href="/admin/deplist">一键部署列表</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="{:checkIfActive('record')}">
|
||||
|
@@ -160,6 +160,7 @@
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
|
||||
</div>
|
||||
<a href="javascript:cleancache()" class="btn btn-default btn-sm btn-block">清理缓存</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -301,5 +302,21 @@ function saveAccount(obj){
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function cleancache(){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.ajax({
|
||||
type : 'GET',
|
||||
url : '/admin/cleancache',
|
||||
dataType : 'json',
|
||||
success : function(data) {
|
||||
layer.close(ii);
|
||||
layer.msg('清理缓存成功', {icon: 1});
|
||||
},
|
||||
error:function(data){
|
||||
layer.close(ii);
|
||||
layer.msg('服务器错误');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
@@ -6,5 +6,6 @@ return [
|
||||
// 指令定义
|
||||
'commands' => [
|
||||
'updateall' => 'app\command\UpdateAll',
|
||||
'decrypt' => 'app\command\DecryptFile',
|
||||
],
|
||||
];
|
||||
|
0
data/plugins/folder/.gitkeep
Normal file
0
data/plugins/folder/.gitkeep
Normal file
0
data/plugins/main/.gitkeep
Normal file
0
data/plugins/main/.gitkeep
Normal file
0
data/plugins/other/other/.gitkeep
Normal file
0
data/plugins/other/other/.gitkeep
Normal file
0
data/plugins/package/.gitkeep
Normal file
0
data/plugins/package/.gitkeep
Normal file
0
data/win/plugins/folder/.gitkeep
Normal file
0
data/win/plugins/folder/.gitkeep
Normal file
0
data/win/plugins/main/.gitkeep
Normal file
0
data/win/plugins/main/.gitkeep
Normal file
0
data/win/plugins/package/.gitkeep
Normal file
0
data/win/plugins/package/.gitkeep
Normal file
@@ -12,7 +12,7 @@ INSERT INTO `cloud_config` (`key`, `value`) VALUES
|
||||
('bt_key', ''),
|
||||
('whitelist', '0'),
|
||||
('download_page', '1'),
|
||||
('new_version', '7.9.3'),
|
||||
('new_version', '7.9.4'),
|
||||
('update_msg', '暂无更新日志'),
|
||||
('update_date', '2022-07-13'),
|
||||
('new_version_win', '7.6.0'),
|
||||
|
@@ -184,6 +184,11 @@ get_node_url(){
|
||||
echo '---------------------------------------------';
|
||||
echo "Selected download node...";
|
||||
nodes=(http://dg2.bt.cn http://dg1.bt.cn http://125.90.93.52:5880 http://36.133.1.8:5880 http://123.129.198.197 http://38.34.185.130 http://116.213.43.206:5880 http://128.1.164.196);
|
||||
|
||||
if [ "$1" ];then
|
||||
nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
|
||||
fi
|
||||
|
||||
tmp_file1=/dev/shm/net_test1.pl
|
||||
tmp_file2=/dev/shm/net_test2.pl
|
||||
[ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
|
||||
@@ -304,6 +309,10 @@ Install_RPM_Pack(){
|
||||
}
|
||||
Install_Deb_Pack(){
|
||||
ln -sf bash /bin/sh
|
||||
UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
|
||||
if [ "${UBUNTU_22}" ];then
|
||||
apt-get remove needrestart -y
|
||||
fi
|
||||
apt-get update -y
|
||||
apt-get install ruby -y
|
||||
apt-get install lsb-release -y
|
||||
@@ -329,7 +338,7 @@ Install_Deb_Pack(){
|
||||
|
||||
for debPack in ${debPacks}
|
||||
do
|
||||
packCheck=$(dpkg -l ${debPack})
|
||||
packCheck=$(dpkg -l|grep ${debPack})
|
||||
if [ "$?" -ne "0" ] ;then
|
||||
apt-get install -y $debPack
|
||||
fi
|
||||
@@ -484,6 +493,10 @@ Install_Python_Lib(){
|
||||
if [ "${os_version}" != "" ];then
|
||||
pyenv_file="/www/pyenv.tar.gz"
|
||||
wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10
|
||||
if [ "$?" != "0" ];then
|
||||
get_node_url $download_Url
|
||||
wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10
|
||||
fi
|
||||
tmp_size=$(du -b $pyenv_file|awk '{print $1}')
|
||||
if [ $tmp_size -lt 703460 ];then
|
||||
rm -f $pyenv_file
|
||||
@@ -836,7 +849,14 @@ if [ "$go" == 'n' ];then
|
||||
exit;
|
||||
fi
|
||||
|
||||
ARCH_LINUX=$(cat /etc/os-release |grep "Arch Linux")
|
||||
if [ "${ARCH_LINUX}" ] && [ -f "/usr/bin/pacman" ];then
|
||||
pacman -Sy
|
||||
pacman -S curl wget unzip firewalld openssl pkg-config make gcc cmake libxml2 libxslt libvpx gd libsodium oniguruma sqlite libzip autoconf inetutils sudo --noconfirm
|
||||
fi
|
||||
|
||||
Install_Main
|
||||
|
||||
echo > /www/server/panel/data/bind.pl
|
||||
echo -e "=================================================================="
|
||||
echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
|
||||
@@ -855,4 +875,3 @@ endTime=`date +%s`
|
||||
echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
|
||||
|
||||
|
||||
|
||||
|
@@ -11,6 +11,11 @@ export LANGUAGE=en_US:en
|
||||
|
||||
get_node_url(){
|
||||
nodes=(http://dg2.bt.cn http://dg1.bt.cn http://36.133.1.8:5880 http://123.129.198.197 http://38.34.185.130 http://116.213.43.206:5880 http://128.1.164.196);
|
||||
|
||||
if [ "$1" ];then
|
||||
nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
|
||||
fi
|
||||
|
||||
tmp_file1=/dev/shm/net_test1.pl
|
||||
tmp_file2=/dev/shm/net_test2.pl
|
||||
[ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -42,7 +42,7 @@ download_Url=$NODE_URL
|
||||
setup_path=/www
|
||||
version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
|
||||
if [ "$version" = '' ];then
|
||||
version='7.9.3'
|
||||
version='7.9.4'
|
||||
fi
|
||||
armCheck=$(uname -m|grep arm)
|
||||
if [ "${armCheck}" ];then
|
||||
|
@@ -70,7 +70,7 @@ select_node(){
|
||||
get_version(){
|
||||
version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
|
||||
if [ "$version" = '' ];then
|
||||
version='7.9.3'
|
||||
version='7.9.4'
|
||||
fi
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -36,6 +36,9 @@ Route::group('api', function () {
|
||||
Route::get('/getIpAddress', 'api/get_ip_address');
|
||||
Route::post('/Auth/GetAuthToken', 'api/get_auth_token');
|
||||
Route::post('/Auth/GetBindCode', 'api/return_error');
|
||||
Route::post('/Auth/GetSSLList', 'api/get_ssl_list');
|
||||
Route::post('/Cert/get_order_list', 'api/return_empty_array');
|
||||
Route::post('/Cert/get_product_list', 'api/return_success');
|
||||
Route::get('/Pluginother/get_file', 'api/download_plugin_other');
|
||||
|
||||
Route::post('/Pluginother/create_order', 'api/return_error');
|
||||
@@ -114,6 +117,9 @@ Route::group('admin', function () {
|
||||
Route::get('/list', 'admin/list');
|
||||
Route::post('/list_data', 'admin/list_data');
|
||||
Route::post('/list_op', 'admin/list_op');
|
||||
Route::get('/deplist', 'admin/deplist');
|
||||
Route::get('/refresh_deplist', 'admin/refresh_deplist');
|
||||
Route::get('/cleancache', 'admin/cleancache');
|
||||
|
||||
})->middleware(\app\middleware\CheckAdmin::class);
|
||||
|
||||
|
@@ -36,6 +36,7 @@ def get_auth_state():
|
||||
#执行插件方法(插件名,方法名,参数)
|
||||
def plugin_run(plugin_name, def_name, args):
|
||||
if not plugin_name or not def_name: return public.returnMsg(False,'插件名称和插件方法名称不能为空!')
|
||||
if not path_check(plugin_name) or not path_check(def_name): return public.returnMsg(False,'插件名或方法名不能包含特殊符号!')
|
||||
p_path = public.get_plugin_path(plugin_name)
|
||||
if not os.path.exists(p_path + '/index.php') and not os.path.exists(p_path + '/%s_main.py' % plugin_name): return public.returnMsg(False,'插件不存在!')
|
||||
|
||||
@@ -73,12 +74,21 @@ def plugin_run(plugin_name, def_name, args):
|
||||
#执行模块方法(模块名,方法名,参数)
|
||||
def module_run(mod_name, def_name, args):
|
||||
if not mod_name or not def_name: return public.returnMsg(False,'模块名称和模块方法名称不能为空!')
|
||||
if not path_check(mod_name) or not path_check(def_name): return public.returnMsg(False,'模块名或方法名不能包含特殊符号!')
|
||||
|
||||
if 'model_index' in args:
|
||||
if args.model_index:
|
||||
mod_file = "{}/{}Model/{}Model.py".format(public.get_class_path(),args.model_index,mod_name)
|
||||
else:
|
||||
mod_file = "{}/projectModel/{}Model.py".format(public.get_class_path(),mod_name)
|
||||
else:
|
||||
module_list = get_module_list()
|
||||
for module_dir in module_list:
|
||||
mod_file = "{}/{}/{}Model.py".format(public.get_class_path(),module_dir,mod_name)
|
||||
if os.path.exists(mod_file): break
|
||||
|
||||
mod_file = "{}/projectModel/{}Model.py".format(public.get_class_path(),mod_name)
|
||||
if not os.path.exists(mod_file):
|
||||
mod_file = "{}/databaseModel/{}Model.py".format(public.get_class_path(),mod_name)
|
||||
if not os.path.exists(mod_file):
|
||||
return public.returnMsg(False,'模块[%s]不存在' % mod_name)
|
||||
return public.returnMsg(False,'模块[%s]不存在' % mod_name)
|
||||
|
||||
def_object = public.get_script_object(mod_file)
|
||||
if not def_object: return public.returnMsg(False,'模块[%s]不存在!' % mod_name)
|
||||
@@ -92,3 +102,21 @@ def module_run(mod_name, def_name, args):
|
||||
result = run_object(args)
|
||||
return result
|
||||
|
||||
#获取模块文件夹列表
|
||||
def get_module_list():
|
||||
list = []
|
||||
class_path = public.get_class_path()
|
||||
f_list = os.listdir(class_path)
|
||||
for fname in f_list:
|
||||
f_path = class_path+'/'+fname
|
||||
if os.path.isdir(f_path) and len(fname) > 6 and fname.find('.') == -1 and fname.find('Model') != -1:
|
||||
list.append(fname)
|
||||
return list
|
||||
|
||||
#检查路径是否合法
|
||||
def path_check(path):
|
||||
list = ["./","..",",",";",":","?","'","\"","<",">","|","\\","\n","\r","\t","\b","\a","\f","\v","*","%","&","$","#","@","!","~","`","^","(",")","+","=","{","}","[","]"]
|
||||
for i in path:
|
||||
if i in list:
|
||||
return False
|
||||
return True
|
||||
|
@@ -40,8 +40,9 @@ if("undefined" != typeof bt && bt.hasOwnProperty("prompt_confirm")){
|
||||
}
|
||||
if("undefined" != typeof database && database.hasOwnProperty("del_database")){
|
||||
database.del_database = function (wid, dbname,obj, callback) {
|
||||
var type = $('.database-pos .tabs-item.active').data('type')
|
||||
title = '',
|
||||
tips = '是否确认【删除数据库】,删除后可能会影响业务使用!';
|
||||
tips = '是否确认【删除数据库】,'+ (type !== 'mysql'?'当前数据库暂不支持数据库回收站,删除后将无法恢复,请谨慎操作':',删除后可能会影响业务使用!');
|
||||
if(obj && obj.db_type > 0) tips = '远程数据库不支持数据库回收站,删除后将无法恢复,请谨慎操作';
|
||||
var title = typeof dbname === "function" ?'批量删除数据库':'删除数据库 [ '+ dbname +' ]';
|
||||
layer.open({
|
||||
@@ -157,7 +158,10 @@ if("undefined" != typeof bt && bt.hasOwnProperty("firewall") && bt.firewall.hasO
|
||||
if (port.indexOf('-') != -1) ports = port.split('-');
|
||||
for (var i = 0; i < ports.length; i++) {
|
||||
if (!bt.check_port(ports[i])) {
|
||||
layer.msg(lan.firewall.port_err, { icon: 5 });
|
||||
layer.msg('可用端口范围:1-65535', { icon: 2 });
|
||||
// layer.msg(lan.firewall.port_err, {
|
||||
// icon: 5
|
||||
// });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
122
wiki/files/win/PluginLoader.py
Normal file
122
wiki/files/win/PluginLoader.py
Normal file
@@ -0,0 +1,122 @@
|
||||
#coding: utf-8
|
||||
import public,os,sys,json
|
||||
|
||||
#获取插件列表(0/1)
|
||||
def get_plugin_list(force = 0):
|
||||
api_root_url = 'https://api.bt.cn'
|
||||
api_url = api_root_url+ '/wpanel/get_plugin_list'
|
||||
cache_file = 'data/plugin_list.json'
|
||||
|
||||
if force==0 and os.path.exists(cache_file):
|
||||
jsonData = public.readFile(cache_file)
|
||||
softList = json.loads(jsonData)
|
||||
else:
|
||||
try:
|
||||
jsonData = public.HttpGet(api_url)
|
||||
except Exception as ex:
|
||||
raise public.error_conn_cloud(str(ex))
|
||||
softList = json.loads(jsonData)
|
||||
if type(softList)!=dict or 'list' not in softList: raise Exception('云端插件列表获取失败')
|
||||
public.writeFile(cache_file, jsonData)
|
||||
return softList
|
||||
|
||||
#获取授权状态() 返回:0.免费版 1.专业版 2.企业版 -1.获取失败
|
||||
def get_auth_state():
|
||||
try:
|
||||
softList = get_plugin_list()
|
||||
if softList['ltd'] > -1:
|
||||
return 2
|
||||
elif softList['pro'] > -1:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except:
|
||||
return -1
|
||||
|
||||
#执行插件方法(插件名,方法名,参数)
|
||||
def plugin_run(plugin_name, def_name, args):
|
||||
if not plugin_name or not def_name: return public.returnMsg(False,'插件名称和插件方法名称不能为空!')
|
||||
if not path_check(plugin_name) or not path_check(def_name): return public.returnMsg(False,'插件名或方法名不能包含特殊符号!')
|
||||
p_path = public.get_plugin_path(plugin_name)
|
||||
if not os.path.exists(p_path + '/index.php') and not os.path.exists(p_path + '/%s_main.py' % plugin_name): return public.returnMsg(False,'插件不存在!')
|
||||
|
||||
is_php = os.path.exists(p_path + '/index.php')
|
||||
if not is_php:
|
||||
sys.path.append(p_path)
|
||||
plugin_main = __import__(plugin_name + '_main')
|
||||
try:
|
||||
if sys.version_info[0] == 2:
|
||||
reload(plugin_main)
|
||||
else:
|
||||
from imp import reload
|
||||
reload(plugin_main)
|
||||
except:
|
||||
pass
|
||||
plu = eval('plugin_main.' + plugin_name + '_main()')
|
||||
if not hasattr(plu, def_name):
|
||||
return public.returnMsg(False,'在[%s]插件中找不到[%s]方法' % (plugin_name,def_name))
|
||||
|
||||
if 'plugin_get_object' in args and args.plugin_get_object == 1:
|
||||
if not is_php:
|
||||
return getattr(plu, def_name)
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
if not is_php:
|
||||
data = eval('plu.' + def_name + '(args)')
|
||||
else:
|
||||
import panelPHP
|
||||
args.s = def_name
|
||||
args.name = plugin_name
|
||||
data = panelPHP.panelPHP(plugin_name).exec_php_script(args)
|
||||
return data
|
||||
|
||||
#执行模块方法(模块名,方法名,参数)
|
||||
def module_run(mod_name, def_name, args):
|
||||
if not mod_name or not def_name: return public.returnMsg(False,'模块名称和模块方法名称不能为空!')
|
||||
if not path_check(mod_name) or not path_check(def_name): return public.returnMsg(False,'模块名或方法名不能包含特殊符号!')
|
||||
|
||||
if 'model_index' in args:
|
||||
if args.model_index:
|
||||
mod_file = "{}/{}Model/{}Model.py".format(public.get_class_path(),args.model_index,mod_name)
|
||||
else:
|
||||
mod_file = "{}/projectModel/{}Model.py".format(public.get_class_path(),mod_name)
|
||||
else:
|
||||
module_list = get_module_list()
|
||||
for module_dir in module_list:
|
||||
mod_file = "{}/{}/{}Model.py".format(public.get_class_path(),module_dir,mod_name)
|
||||
if os.path.exists(mod_file): break
|
||||
|
||||
if not os.path.exists(mod_file):
|
||||
return public.returnMsg(False,'模块[%s]不存在' % mod_name)
|
||||
|
||||
def_object = public.get_script_object(mod_file)
|
||||
if not def_object: return public.returnMsg(False,'模块[%s]不存在!' % mod_name)
|
||||
try:
|
||||
run_object = getattr(def_object.main(),def_name,None)
|
||||
except:
|
||||
return public.returnMsg(False,'模块入口实例化失败' % mod_name)
|
||||
if not run_object: return public.returnMsg(False,'在[%s]模块中找不到[%s]方法' % (mod_name,def_name))
|
||||
if 'module_get_object' in args and args.module_get_object == 1:
|
||||
return run_object
|
||||
result = run_object(args)
|
||||
return result
|
||||
|
||||
#获取模块文件夹列表
|
||||
def get_module_list():
|
||||
list = []
|
||||
class_path = public.get_class_path()
|
||||
f_list = os.listdir(class_path)
|
||||
for fname in f_list:
|
||||
f_path = class_path+'/'+fname
|
||||
if os.path.isdir(f_path) and len(fname) > 6 and fname.find('.') == -1 and fname.find('Model') != -1:
|
||||
list.append(fname)
|
||||
return list
|
||||
|
||||
#检查路径是否合法
|
||||
def path_check(path):
|
||||
list = ["./","..",",",";",":","?","'","\"","<",">","|","\\","\n","\r","\t","\b","\a","\f","\v","*","%","&","$","#","@","!","~","`","^","(",")","+","=","{","}","[","]"]
|
||||
for i in path:
|
||||
if i in list:
|
||||
return False
|
||||
return True
|
@@ -1,60 +0,0 @@
|
||||
#coding: utf-8
|
||||
import public,os,sys,json
|
||||
|
||||
class Plugin:
|
||||
name = False
|
||||
p_path = None
|
||||
is_php = False
|
||||
plu = None
|
||||
__api_root_url = 'https://api.bt.cn'
|
||||
__api_url = __api_root_url+ '/wpanel/get_plugin_list'
|
||||
__cache_file = 'data/plugin_list.json'
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.p_path = public.get_plugin_path(name)
|
||||
self.is_php = os.path.exists(self.p_path + '/index.php')
|
||||
|
||||
def get_plugin_list(self, force = False):
|
||||
if force==False and os.path.exists(self.__cache_file):
|
||||
jsonData = public.readFile(self.__cache_file)
|
||||
softList = json.loads(jsonData)
|
||||
else:
|
||||
try:
|
||||
jsonData = public.HttpGet(self.__api_url)
|
||||
except Exception as ex:
|
||||
raise public.error_conn_cloud(str(ex))
|
||||
softList = json.loads(jsonData)
|
||||
if type(softList)!=dict or 'list' not in softList: raise Exception('云端插件列表获取失败')
|
||||
public.writeFile(self.__cache_file, jsonData)
|
||||
|
||||
return softList
|
||||
|
||||
def isdef(self, fun):
|
||||
if not self.is_php:
|
||||
sys.path.append(self.p_path)
|
||||
plugin_main = __import__(self.name + '_main')
|
||||
try:
|
||||
from imp import reload
|
||||
reload(plugin_main)
|
||||
except:
|
||||
pass
|
||||
self.plu = eval('plugin_main.' + self.name + '_main()')
|
||||
if not hasattr(self.plu, fun):
|
||||
if self.name == 'btwaf' and fun == 'index':
|
||||
raise Exception("未购买")
|
||||
return False
|
||||
return True
|
||||
|
||||
def exec_fun(self, args):
|
||||
fun = args.s
|
||||
if not self.is_php:
|
||||
plu = self.plu
|
||||
data = eval('plu.' + fun + '(args)')
|
||||
else:
|
||||
import panelPHP
|
||||
args.s = fun
|
||||
args.name = self.name
|
||||
data = panelPHP.panelPHP(self.name).exec_php_script(args)
|
||||
return data
|
||||
|
@@ -10,9 +10,11 @@
|
||||
|
||||
- 将PluginLoader.py复制到class文件夹
|
||||
|
||||
- 批量解密模块文件:执行 php think decrypt classdir <面板class文件夹路径>
|
||||
|
||||
- 全局搜索替换 https://api.bt.cn => http://www.example.com
|
||||
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/(需排除clearModel.py)
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/(需排除clearModel.py、scanningModel.py、ipsModel.py)
|
||||
|
||||
- 全局搜索替换 http://download.bt.cn/install/update6.sh => http://www.example.com/install/update6.sh
|
||||
|
||||
@@ -40,6 +42,8 @@
|
||||
|
||||
- class/panelPlugin.py 文件,download_icon方法内替换 public.GetConfigValue('home') => 'https://www.bt.cn'
|
||||
|
||||
- class/panelPlugin.py 文件,删除public.total_keyword(get.query)这一行
|
||||
|
||||
- class/panelPlugin.py 文件,set_pyenv方法内,temp_file = public.readFile(filename)这行代码下面加上
|
||||
|
||||
```python
|
||||
@@ -61,16 +65,16 @@
|
||||
|
||||
"update_software_list": update_software_list,
|
||||
|
||||
"check_files_panel": check_files_panel,
|
||||
|
||||
"check_panel_msg": check_panel_msg,
|
||||
|
||||
- 去除面板日志上报:script/site_task.py 文件
|
||||
PluginLoader.daemon_task()
|
||||
|
||||
删除最下面 logs_analysis() 这1行
|
||||
PluginLoader.daemon_panel()
|
||||
|
||||
- 去除首页广告:BTPanel/static/js/index.js 文件删除最下面index.recommend_paid_version()这一行
|
||||
|
||||
- 去除内页广告:BTPanel/templates/default/layout.html 删除getPaymentStatus();这一行
|
||||
|
||||
- 去除首页自动检测更新,避免频繁请求云端:BTPanel/static/js/index.js 文件注释掉bt.system.check_update这一段代码外的setTimeout
|
||||
|
||||
- [可选]去除各种计算题:复制bt.js到 BTPanel/static/ ,在 BTPanel/templates/default/layout.html 的\</body\>前面加入
|
||||
@@ -91,9 +95,8 @@
|
||||
|
||||
- [可选]关闭未绑定域名提示页面:在class/panelSite.py,root /www/server/nginx/html改成return 400
|
||||
|
||||
- [可选]关闭自动生成访问日志:在 BT-Panel,WSGIServer((HOST, PORT)里面增加参数 log=None
|
||||
- [可选]关闭自动生成访问日志:在 BTPanel/\_\_init\_\_.py 删除public.write_request_log()这一行
|
||||
|
||||
在 BTPanel/\_\_init\_\_.py 删除public.write_request_log()这一行
|
||||
|
||||
解压安装包panel6.zip,将更新包改好的文件覆盖到里面,然后重新打包,即可更新安装包。(
|
||||
|
||||
|
@@ -8,11 +8,11 @@
|
||||
|
||||
Windows版宝塔由于加密文件太多,无法全部解密,因此无法做到全开源。
|
||||
|
||||
- 删除pluginAuth.cp38-win_amd64.pyd,将win/pluginAuth.py复制到class文件夹
|
||||
- 删除PluginLoader.pyd,将win/PluginLoader.py复制到class文件夹
|
||||
|
||||
- 全局搜索替换 https://api.bt.cn => http://www.example.com
|
||||
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/(需排除ipsModel.py)
|
||||
|
||||
- 全局搜索替换 http://www.bt.cn/api/ => http://www.example.com/api/
|
||||
|
||||
@@ -50,7 +50,7 @@ Windows版宝塔由于加密文件太多,无法全部解密,因此无法做
|
||||
|
||||
- 去除面板日志上报:script/site_task.py 文件
|
||||
|
||||
删除最下面 logs_analysis() 这1行
|
||||
- 删除最下面 logs_analysis() 这1行
|
||||
|
||||
- 去除首页广告:BTPanel/static/js/index.js 文件删除最下面index.recommend_paid_version()这一行
|
||||
|
||||
@@ -72,5 +72,5 @@ Windows版宝塔由于加密文件太多,无法全部解密,因此无法做
|
||||
|
||||
删除 if not os.path.exists(self.sitePath + '/.htaccess') 这一行
|
||||
|
||||
|
||||
- [可选]关闭自动生成访问日志:在 BTPanel/\_\_init\_\_.py 删除public.write_request_log()这一行
|
||||
|
||||
|
Reference in New Issue
Block a user