diff --git a/README.md b/README.md index b8fbb30..7014183 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 网站后台管理可一键同步宝塔官方的插件列表与增量更新插件包,还有云端使用记录、IP黑白名单、操作日志、定时任务等功能。 -本项目自带的宝塔安装包和更新包是7.9.2最新版,已修改适配此第三方云端,并且全开源,无so等加密文件。 +本项目自带的宝塔安装包和更新包是7.9.3最新版,已修改适配此第三方云端,并且全开源,无so等加密文件。 觉得该项目不错的可以给个Star~ diff --git a/app/common.php b/app/common.php index 3f8eb10..65d4024 100644 --- a/app/common.php +++ b/app/common.php @@ -48,6 +48,17 @@ function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { } } +function random($length, $numeric = 0) { + $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); + $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); + $hash = ''; + $max = strlen($seed) - 1; + for($i = 0; $i < $length; $i++) { + $hash .= $seed[mt_rand(0, $max)]; + } + return $hash; +} + function get_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobody=0, $addheader=0) { $ch = curl_init(); diff --git a/app/controller/Api.php b/app/controller/Api.php index 92fcead..13d7558 100644 --- a/app/controller/Api.php +++ b/app/controller/Api.php @@ -259,10 +259,12 @@ class Api extends BaseController //绑定账号 public function get_auth_token(){ - return json(['status'=>false, 'msg'=>'不支持绑定宝塔官网账号', 'data'=>'5b5d']); + $userinfo = ['uid'=>1, 'username'=>'Administrator', 'address'=>'127.0.0.1', 'serverid'=>'1', 'access_key'=>random(32), 'secret_key'=>random(48), 'ukey'=>md5(time()), 'state'=>1]; + $data = bin2hex(urlencode(json_encode($userinfo))); + return json(['status'=>true, 'msg'=>'登录成功!', 'data'=>$data]); } - //绑定一键部署列表 + //一键部署列表 public function get_deplist(){ $os = input('post.os'); $json_arr = Plugins::get_deplist($os); diff --git a/app/lib/Btapi.php b/app/lib/Btapi.php index 360c4b7..168fdd6 100644 --- a/app/lib/Btapi.php +++ b/app/lib/Btapi.php @@ -144,6 +144,18 @@ class Btapi $data = json_decode($result,true); return $data; } + + //获取一键部署列表 + public function get_deplist(){ + $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_deplist'; + + $p_data = $this->GetKeyData(); + + $result = $this->curl($url,$p_data); + + $data = json_decode($result,true); + return $data; + } private function GetKeyData(){ diff --git a/app/lib/Plugins.php b/app/lib/Plugins.php index 13a38fd..84d8294 100644 --- a/app/lib/Plugins.php +++ b/app/lib/Plugins.php @@ -258,6 +258,23 @@ class Plugins } } + //刷新一键部署列表 + public static function refresh_deplist($os = 'Linux'){ + $btapi = self::get_btapi($os); + $result = $btapi->get_deplist(); + if($result && isset($result['list']) && isset($result['type'])){ + if(empty($result['list']) || empty($result['type'])){ + throw new Exception('获取一键部署列表失败:一键部署列表为空'); + } + $json_file = get_data_dir($os).'config/deployment_list.json'; + if(!file_put_contents($json_file, json_encode($result))){ + throw new Exception('保存一键部署列表失败,文件无写入权限'); + } + }else{ + throw new Exception('获取一键部署列表失败:'.(isset($result['msg'])?$result['msg']:'面板连接失败')); + } + } + //获取一键部署列表 public static function get_deplist($os = 'Linux'){ $json_file = get_data_dir($os).'config/deployment_list.json'; diff --git a/app/view/admin/index.html b/app/view/admin/index.html index 2af0c04..b1c8139 100644 --- a/app/view/admin/index.html +++ b/app/view/admin/index.html @@ -18,7 +18,7 @@