Compare commits

..

No commits in common. "1.0" and "main" have entirely different histories.
1.0 ... main

186 changed files with 17253 additions and 4011 deletions

View File

@ -5,13 +5,13 @@ DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE] [DATABASE]
TYPE = mysql TYPE = mysql
HOSTNAME = localhost HOSTNAME = {dbhost}
DATABASE = btcloud DATABASE = {dbname}
USERNAME = btcloud USERNAME = {dbuser}
PASSWORD = 123456 PASSWORD = {dbpwd}
HOSTPORT = 3306 HOSTPORT = {dbport}
CHARSET = utf8mb4 CHARSET = utf8mb4
PREFIX = cloud_ PREFIX = {dbprefix}
DEBUG = false DEBUG = false
[LANG] [LANG]

114
README.md
View File

@ -1,48 +1,66 @@
# 宝塔面板第三方云端 # 宝塔面板第三方云端
这是一个用php开发的宝塔面板第三方云端站点程序。 这是一个用php开发的宝塔面板第三方云端站点程序。
你可以使用此程序搭建属于自己的宝塔面板第三方云端实现最新版宝塔面板私有化部署不与宝塔官方接口通信满足隐私安全合规需求。同时还可以去除面板强制绑定账号DIY面板功能等。 你可以使用此程序搭建属于自己的宝塔面板第三方云端实现最新版宝塔面板私有化部署不与宝塔官方接口通信满足隐私安全合规需求。同时还可以去除面板强制绑定账号DIY面板功能等。
网站后台管理可一键同步宝塔官方的插件列表与增量更新插件包还有云端使用记录、IP黑白名单、操作日志、定时任务等功能。 网站后台管理可一键同步宝塔官方的插件列表与增量更新插件包还有云端使用记录、IP黑白名单、操作日志、定时任务等功能。
本项目自带的宝塔安装包和更新包是7.9.2最新版已修改适配此第三方云端并且全开源无so等加密文件。 本项目自带 **宝塔Linux面板**、**宝塔Windows面板**、**aaPanel面板**、**宝塔云监控** 的最新版安装包和更新包,已修改适配此第三方云端,并且全开源,无.so等加密文件。
觉得该项目不错的可以给个Star~ 觉得该项目不错的可以给个Star~
## 声明 ## 声明
1.此项目只能以自用为目的,不得侵犯堡塔公司及其他第三方的知识产权和其他合法权利。 1.此项目只能以自用为目的,不得侵犯堡塔公司及其他第三方的知识产权和其他合法权利。
2.搭建使用此项目必须有一定的编程和Linux运维基础纯小白不建议使用。 2.搭建使用此项目必须有一定的编程和Linux运维基础纯小白不建议使用。
## 环境要求 ## 环境要求
* `PHP` >= 7.4 * `PHP` >= 7.4
* `MySQL` >= 5.6 * `MySQL` >= 5.6
* `fileinfo`扩展 * `fileinfo`扩展
* `ZipArchive`扩展 * `ZipArchive`扩展
## 部署方法 ## 部署方法
- [下载最新版的Release包](https://github.com/flucont/btcloud/releases) - [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
- 如果是下载的源码包,需要执行 `composer install --no-dev` 安装依赖如果是下载的Release包则不需要 - 如果是下载的源码包,需要执行 `composer install --no-dev` 安装依赖如果是下载的Release包则不需要
- 设置网站运行目录为`public` - 设置网站运行目录为`public`
- 设置伪静态为`ThinkPHP` - 设置伪静态为`ThinkPHP`
- 导入`install.sql`到数据库 - 访问网站,会自动跳转到安装页面,根据提示安装完成
- 在`.env`里面修改数据库信息包括数据库地址HOSTNAME、数据库名DATABASE、用户名USERNAME、密码PASSWORD
- 访问`/admin`进入网站后台默认管理员用户名密码admin/123456 ## 使用方法
## 使用方法 - 在`批量替换工具`执行页面显示的命令可将bt安装包、更新包和脚本文件里面的`http://www.example.com`批量替换成当前网站的网址。
- 在`系统基本设置`修改宝塔面板接口设置。你需要准备一个使用官方最新脚本安装并绑定账号的宝塔面板,用于获取最新插件列表及插件包。并根据界面提示安装好专用插件。
- 在`系统基本设置`修改宝塔面板接口设置。你需要一个官方最新脚本安装并绑定账号的宝塔面板,用于获取最新插件列表及插件包。并根据界面提示安装好专用插件。 - 在`定时任务设置`执行所显示的命令从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。当然你也可以去插件列表,一个一个点击下载。
- 在`定时任务设置`执行所显示的命令从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。当然你也可以去插件列表,一个一个点击下载。 - 访问网站`/download`查看使用此第三方云端的一键安装脚本。
- 在public/install/src和update文件夹里面分别是bt安装包和更新包解压后源码里面全部的 www.example.com 替换成你自己搭建的云端域名然后重新打包。可使用VSCode等支持批量替换的软件。
- 将bt安装脚本public/install/install_6.0.sh和更新脚本update6.sh里面的 www.example.com 替换成你自己搭建的云端域名。 ## 更新方法
- 访问网站`/download`查看使用此第三方云端的一键安装脚本
- [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
## 其他 - 上传覆盖除data文件夹以外的全部文件
- 后台使用批量替换工具->获取最新插件列表->修改软件版本设置里面的版本号
- [bt官方更新包修改记录](./wiki/update.md)
## 其他
- [Linux面板官方更新包修改记录](./wiki/update.md)
- [Windows面板官方更新包修改记录](./wiki/updatewin.md)
- [aaPanel面板官方更新包修改记录](./wiki/aapanel.md)
- [宝塔云监控安装包修改记录](./wiki/btmonitor.md)
- 宝塔面板官方版与此第三方云端版对比:
| | 官方版 | 此第三方云端版 |
| ---------- | ------------------------------------------------------------ | -------------------------------------------------- |
| 版本更新 | 支持 | 支持 |
| 面板广告 | 有广告 | 无广告 |
| 是否全开源 | 没有全开源 | 全开源 |
| 资源占用 | 各种统计上报等任务,资源占用略高 | 去除了很多无用的定时任务,资源占较少 |
| 兼容性 | 由于编译的so文件有系统架构限制兼容的系统仅限已编译的so对应的系统架构 | 由于全开源没有已编译的so文件因此无系统架构限制 |

77
app/command/Clean.php Normal file
View File

@ -0,0 +1,77 @@
<?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 Clean extends Command
{
protected function configure()
{
$this->setName('clean')
->setDescription('the clean command');
}
protected function execute(Input $input, Output $output)
{
$res = Db::name('config')->cache('configs',0)->column('value','key');
Config::set($res, 'sys');
if(config_get('bt_url')){
$this->clean_plugins($input, $output, 'Linux');
}
if(config_get('wbt_url')){
$this->clean_plugins($input, $output, 'Windows');
}
config_set('cleantime', date('Y-m-d H:i:s'));
}
private function clean_plugins(Input $input, Output $output, $os){
$data_dir = get_data_dir($os) . 'plugins/';
$file_list = [];
$json_arr = Plugins::get_plugin_list($os);
if(count($json_arr['list']) == 0) return;
foreach($json_arr['list'] as $plugin){
foreach($plugin['versions'] as $version){
$ver = $version['m_version'].'.'.$version['version'];
if(!isset($version['download'])){
$file_list[] = $plugin['name'].'-'.$ver;
}
}
}
$count = 0;
$dir = opendir($data_dir.'package');
while(false !== ( $file = readdir($dir)) ) {
if($file == '.' || $file == '..') continue;
$name = str_replace('.zip', '', $file);
if(!in_array($name, $file_list)){
$filepath = $data_dir . 'package/' . $file;
unlink($filepath);
$count++;
}
}
$output->writeln($os.'成功清理'.$count.'个历史版本插件包');
$count = 0;
$dir = opendir($data_dir.'folder');
while(false !== ( $file = readdir($dir)) ) {
if($file == '.' || $file == '..') continue;
if(!in_array($file, $file_list)){
$filepath = $data_dir . 'folder/' . $file;
deleteDir($filepath);
$count++;
}
}
$output->writeln($os.'成功清理'.$count.'个历史版本插件目录');
}
}

386
app/command/CleanViteJs.php Normal file
View File

@ -0,0 +1,386 @@
<?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 CleanViteJs extends Command
{
protected function configure()
{
$this->setName('cleanvitejs')
->addArgument('dir', Argument::REQUIRED, '/BTPanel/static/vite/js/路径')
->setDescription('处理宝塔面板vite/js文件');
}
protected function execute(Input $input, Output $output)
{
$dir = trim($input->getArgument('dir'));
if(!file_exists($dir)){
$output->writeln('目录不存在');
return;
}
//$this->handlefile($dir.'/DockerImages.js');
$this->checkdir($dir);
}
private function getExtendCode($content, $part, $n = 1, $startChar = '{', $endChar = '}'){
if(!$part) return false;
$length = strlen($content);
$start = strpos($content, $part);
if($start===false)return false;
$end = $start+strlen($part);
$start--;
$c = 0;
for($i=$start;$i>=0;$i--){
if(substr($content,$i,1) == $startChar) $c++;
if(substr($content,$i,1) == $endChar) $c--;
if($c == $n){
$start = $i;
break;
}
}
$c = 0;
for($i=$end;$i<=$length;$i++){
if(substr($content,$i,1) == $endChar) $c++;
if(substr($content,$i,1) == $startChar) $c--;
if($c == $n){
$end = $i;
break;
}
}
return substr($content, $start, $end - $start + 1);
}
private function getExtendFunction($content, $part, $startChar = '(', $endChar = ')'){
$code = $this->getExtendCode($content, $part, 1, $startChar, $endChar);
if(!$code) return false;
$start = strpos($content, $code) - 1;
$end = $start + strlen($code);
for($i=$start;$i>=0;$i--){
$char = substr($content,$i,1);
if(!ctype_alpha($char)&&$char!='_'){
$start = $i+1;
break;
}
}
if(substr($content,$start-1,1) == ',') $start--;
else if(substr($content,$end+1,1) == ',') $end++;
return substr($content, $start, $end - $start + 1);
}
private function checkdir($basedir){
if($dh=opendir($basedir)){
while (($file=readdir($dh)) !== false){
if($file != '.' && $file != '..'){
if(!is_dir($basedir.'/'.$file) && substr($file,-3)=='.js'){
$this->handlefile($basedir.'/'.$file);
}else if(!is_dir($basedir.'/'.$file) && substr($file,-4)=='.map'){
unlink($basedir.'/'.$file);
}
}
}
closedir($dh);
}
}
private function str_replace_once($needle, $replace, $haystack) {
$pos = strpos($haystack, $needle);
if ($pos === false) {
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
private function handlefile($filepath){
//echo $filepath."\n";
$file = file_get_contents($filepath);
if(!$file)return;
$flag = false;
if(strpos($file, 'window.location.protocol.indexOf("https")>=0')!==false){ //index
$file = str_replace('window.location.protocol.indexOf("https")>=0', '!0', $file);
$code = $this->getExtendCode($file, 'isGetCoupon:', 2);
if($code){
$file = str_replace($code, '{}', $file);
}
$file = preg_replace('!recommendShow:\w+,!', 'recommendShow:!1,', $file, 1);
$code = $this->getExtendCode($file, '"打开需求反馈"', 1, '[', ']');
if($code){
$file = str_replace($code, '[]', $file);
}
$flag = true;
}
if(strpos($file, '"点击打开调查问卷"')!==false){ //index
$code = $this->getExtendCode($file, '"点击打开调查问卷"', 2);
if($code){
$file = str_replace($code, '{}', $file);
}
$flag = true;
}
if(strpos($file, '您有{0}个优惠券待领取')!==false){ //win-index
$code = $this->getExtendCode($file, 'isGetCoupon:', 2);
if($code){
$file = str_replace($code, '{}', $file);
}
$flag = true;
}
if(strpos($file, '论坛求助')!==false && strpos($file, '"/other/customer-qrcode.png"')!==false){ //main
$code = $this->getExtendCode($file, '"微信公众号"', 1);
$code = $this->getExtendFunction($file, $code);
$start = strpos($file, $code) - 1;
for($i=$start;$i>=0;$i--){
if(substr($file,$i,1) == ','){
$start = $i;
break;
}
}
$code = $this->getExtendCode($file, '"/other/customer-qrcode.png"', 2);
$code = $this->getExtendFunction($file, $code);
$end = strpos($file, $code)+strlen($code);
$code = substr($file, $start, $end - $start);
$file = str_replace($code, '', $file);
$flag = true;
}
if(strpos($file, 'useNegotiate')!==false){ //utils
$code = $this->getExtendCode($file, 'createPeerConnection()', 1);
if($code){
$file = str_replace($code, '{}', $file);
}
$file = preg_replace('!computed\(\(\)=>"calc"===\w+\.\w+\.type\)!', '!1', $file);
$file = preg_replace('!computed\(\(\)=>"input"===\w+\.\w+\.type\)!', '!1', $file);
$file = preg_replace('!computed\(function\(\)\{return"calc"===\w+\.\w+\.type\}\)!', '!1', $file);
$file = preg_replace('!computed\(function\(\)\{return"input"===\w+\.\w+\.type\}\)!', '!1', $file);
$file = preg_replace('!computed\(\(\)=>\w+\.\w+\.type==="calc"\)!', '!1', $file);
$file = preg_replace('!computed\(\(\)=>\w+\.\w+\.type==="input"\)!', '!1', $file);
$file = preg_replace('!computed\(function\(\)\{return\w+\.\w+\.type==="calc"\}\)!', '!1', $file);
$file = preg_replace('!computed\(function\(\)\{return\w+\.\w+\.type==="input"\}\)!', '!1', $file);
$code = $this->getExtendCode($file, '"自动部署"', 2);
if($code){
$file = str_replace($code.',', '', $file);
$file = str_replace($code, '', $file);
}
$flag = true;
}
if(strpos($file, '"sqlserver管理"')!==false && strpos($file, '"iis管理"')!==false){ //win-utils
$file = preg_replace('!"calc"===\w+\.\w+\.type!', '!1', $file);
$file = preg_replace('!"input"===\w+\.\w+\.type!', '!1', $file);
$flag = true;
}
if(strpos($file, '请冷静几秒钟,确认以下要删除的数据')!==false && strpos($file, '"计算结果:"')!==false){ //site
$code = $this->getExtendCode($file, '"计算结果:"', 1, '[', ']');
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$file = preg_replace('!\w+\.sum===\w+\.addend1\+\w+\.addend2!', '!0', $file);
$file = preg_replace('!value=\!0,(\w+)\.value=5;!', 'value=!1,$1.value=0;', $file);
$flag = true;
}
if(strpos($file, '"left-waf"')!==false && strpos($file, '"iconWaf"')!==false){ //site.table
$code = $this->getExtendCode($file, '"left-waf"');
$code = $this->getExtendCode($file, $code, 1, '[', ']');
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '""', $file);
$flag = true;
}
if(strpos($file, 'svgtofont-left-waf')!==false && strpos($file, '"iconWaf"')!==false){ //site.table
$code = $this->getExtendCode($file, 'svgtofont-left-waf');
$code = $this->getExtendCode($file, $code, 1, '[', ']');
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '""', $file);
$flag = true;
}
if(strpos($file, 'label:"商用SSL证书"')!==false){ //site-ssl
$code = $this->getExtendFunction($file, 'label:"商用SSL证书"', '{', '}');
$file = str_replace($code, '', $file);
$code = $this->getExtendFunction($file, 'label:"测试证书"', '{', '}');
if($code){
$file = str_replace($code, '', $file);
}
$code = $this->getExtendFunction($file, 'label:"宝塔证书"', '{', '}');
if($code){
$file = str_replace($code, '', $file);
}
$code = $this->getExtendCode($file, '"购买商业证书"', 2);
if($code){
$code2 = str_replace('"busSslList"', '"letsEncryptList"', $code);
$code2 = str_replace($this->getExtendFunction($code, '"购买商业证书"'), '', $code2);
$file = str_replace($code, $code2, $file);
}
$file = str_replace('.value="busSslList"', '.value="letsEncryptList"', $file);
$flag = true;
}
if(strpos($file, '"busSslList"')!==false && strpos($filepath, '/useStore')){ //site-ssl
$file = str_replace('"busSslList"', '"currentCertInfo"', $file);
$flag = true;
}
if(strpos($file, '"商用SSL"')!==false){ //ssl
$code = $this->getExtendFunction($file, '"商用SSL"', '{', '}');
$file = str_replace($code, '', $file);
$code = $this->getExtendFunction($file, '"宝塔证书"', '{', '}');
if($code){
$file = str_replace($code, '', $file);
}
for($i=0;$i<3;$i++){
$code = $this->getExtendCode($file, ',"联系客服"', 2, '[', ']');
if($code){
$file = str_replace($code, '[]', $file);
}
}
$flag = true;
}
if(strpos($file, '"SSL-CERTIFICATE-STORE"')!==false){ //ssl
$file = str_replace('("ssl")', '("encrypt")', $file);
$flag = true;
}
if(strpos($file, '"商业证书"')!==false && strpos($file, 'name:"busSslList"')!==false && strpos($file, 'IIS配置')!==false){ //win-ssl
$code = $this->getExtendFunction($file, 'name:"busSslList"', '{', '}');
$file = str_replace($code, '', $file);
$code = $this->getExtendFunction($file, 'name:"trustAsiaList"', '{', '}');
$file = str_replace($code, '', $file);
$file = $this->str_replace_once('"busSslList"', '"currentCertInfo"', $file);
$flag = true;
}
if(strpos($file, '如果您希望添加其它Docker应用')!==false){
$code = $this->getExtendCode($file, '如果您希望添加其它Docker应用', 1, '[', ']');
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$flag = true;
}
if(strpos($file, '"recom-view"')!==false){ //soft
$code = $this->getExtendCode($file, '"recom-view"');
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$flag = true;
}
if(strpos($file, '"打开插件文件目录"')!==false && strpos($file, '"(续费)"')!==false){ //soft.table
$code = $this->getExtendFunction($file, '"(续费)"');
$file = str_replace($code, '""', $file);
$code = $this->getExtendCode($file, 'activity_id:47', 2);
if($code){
$file = str_replace($code, '{}', $file);
}
$flag = true;
}
if(strpos($file, 'path:"register"')!==false){ //domain
$code = $this->getExtendCode($file, 'path:"register"');
$file = str_replace($code.',', '', $file);
$flag = true;
}
for($i=0;$i<5;$i++){
$code = $this->getExtendCode($file, ',"需求反馈"', 1, '[', ']');
if($code){
if(strpos($code, 'svgtofont-desired')){
$file = str_replace($code, '[]', $file);
}else{
$code = $this->getExtendFunction($code, ',"需求反馈"');
$file = str_replace($code, '', $file);
}
$flag = true;
}
}
$code = $this->getExtendCode($file, '("需求反馈",-1)', 1, '[', ']');
if($code){
$file = str_replace($code, '[]', $file);
$flag = true;
}
$code = $this->getExtendCode($file, '(" 需求反馈 ",-1)', 1, '[', ']');
if($code){
$file = str_replace($code, '[]', $file);
$flag = true;
}
$code = $this->getExtendFunction($file, 'label:"需求反馈",', '{', '}');
if($code){
$file = str_replace($code, '', $file);
$flag = true;
}
if(strpos($file, '暂无搜索结果,<span class="text-primary cursor-pointer NpsDialog">提交需求反馈</span>')!==false){
$file = str_replace('暂无搜索结果,<span class="text-primary cursor-pointer NpsDialog">提交需求反馈</span>', '暂无搜索结果', $file);
$flag = true;
}
if(strpos($file, 'getReceiveCoupon()')!==false){ //aapanel-优惠券
$code = $this->getExtendCode($file, 'getReceiveCoupon()');
$file = str_replace($code, '{}', $file);
$flag = true;
}
if(strpos($file, '"Site.DelSite.index_1"')!==false){ //aapanel-site
$code = $this->getExtendCode($file, '"Site.DelSite.index_10"', 3, '(', ')');
if($code){
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$file = preg_replace('@\w+\.value!==\w+\.value\+\w+\.value@', '!1', $file);
$file = preg_replace('@null==\w+\.value\|\|null==\w+\.value@', '!1', $file);
$file = str_replace('disabled:!0', 'disabled:!1', $file);
$flag = true;
}
}
if(strpos($file, '"Component.Confirm.index_4"')!==false){ //aapanel-public
$code = $this->getExtendCode($file, '"Component.Confirm.index_4"', 2, '(', ')');
if($code){
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$file = preg_replace('@\w+\.value===\w+\.value\+\w+\.value@', '!0', $file);
$flag = true;
}
$code = $this->getExtendCode($file, '"Component.Confirm.index_1"', 1, '(', ')');
if($code){
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$file = preg_replace('@\w+\.value===\w+\.value\?@', '!0?', $file);
$flag = true;
}
}
if(strpos($file, '"Component.Feedback.index_7"')!==false){ //aapanel-需求反馈
$code = $this->getExtendCode($file, '"Component.Feedback.index_7"', 2);
if($code){
$code = $this->getExtendFunction($file, $code);
$file = str_replace($code, '', $file);
$flag = true;
}
}
if(strpos($file, '"Soft.index_16"')!==false){ //aapanel-soft
$code = $this->getExtendCode($file, '"Soft.index_16"', 2);
if($code){
$file = str_replace($code, '{}', $file);
$flag = true;
}
}
if(!$flag) return;
if(file_put_contents($filepath, $file)){
echo '文件:'.$filepath.' 处理成功'."\n";
}else{
echo '文件:'.$filepath.' 处理失败,可能无写入权限'."\n";
}
}
}

115
app/command/DecryptFile.php Normal file
View 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'){
$this->decode_module_file($output, $file);
}elseif($type == 'classdir'){
$file = rtrim($file, '/');
if(file_exists($file.'/common.py')){
$class_v = 1;
}elseif(file_exists($file.'/common_v2.py')){
$class_v = 2;
}else{
$output->writeln('当前路径非宝塔面板class目录');
return;
}
$dirs = glob($file.'/*Model'.($class_v == 2 ? 'V2' : ''));
foreach($dirs as $dir){
if(!is_dir($dir))continue;
$files = glob($dir.'/*Model.py');
foreach($files as $filepath){
$this->decode_module_file($output, $filepath);
}
}
if($class_v == 2){
$filepath = $file.'/wp_toolkit/core.py';
if(file_exists($filepath)){
$this->decode_module_file($output, $filepath);
}
}else{
$filepath = $file.'/public/authorization.py';
if(file_exists($filepath)){
$this->decode_module_file($output, $filepath);
}
}
}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') {
$this->decode_module_file($output, $filepath);
}
}
}
closedir($dir);
}
private function decode_module_file(Output $output, $filepath){
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);
}
}
}

View File

@ -25,60 +25,73 @@ class UpdateAll extends Command
$res = Db::name('config')->cache('configs',0)->column('value','key'); $res = Db::name('config')->cache('configs',0)->column('value','key');
Config::set($res, 'sys'); Config::set($res, 'sys');
if(!config_get('bt_type') && config_get('bt_url') || config_get('bt_type')==1 && config_get('bt_surl')){
$this->process_plugins($input, $output, 'Linux');
}
if(!config_get('wbt_type') && config_get('wbt_url') || config_get('wbt_type')==1 && config_get('wbt_surl')){
$this->process_plugins($input, $output, 'Windows');
}
if(!config_get('enbt_type') && config_get('enbt_url') || config_get('enbt_type')==1 && config_get('enbt_surl')){
$this->process_plugins($input, $output, 'en');
}
config_set('runtime', date('Y-m-d H:i:s'));
}
private function process_plugins(Input $input, Output $output, $os){
//刷新插件列表 //刷新插件列表
if(!$this->refresh_plugin_list($input, $output)){ if(!$this->refresh_plugin_list($input, $output, $os)){
return; return;
} }
$count = 0; $count = 0;
$type = intval(config_get('updateall_type')); if($os=='Windows'){
$type = intval(config_get('updateall_type_win'));
}elseif($os=='en'){
$type = intval(config_get('updateall_type_en'));
}else{
$type = intval(config_get('updateall_type'));
}
$json_arr = Plugins::get_plugin_list(); $json_arr = Plugins::get_plugin_list($os);
//循环下载缺少的插件 //循环下载缺少的插件
foreach($json_arr['list'] as $plugin){ foreach($json_arr['list'] as $plugin){
if($type == 0 && ($plugin['type']==8 || $plugin['type']==12) || $type == 1 && $plugin['type']==12 || $plugin['type']==10 || $plugin['type']==5) continue; if($type == 0 && ($plugin['type']==8 || $plugin['type']==12) || $type == 1 && $plugin['type']==12 || $plugin['type']==10 || $plugin['type']==5) continue;
if(in_array($plugin['name'], \app\lib\BtPlugins::$skip_plugins)) continue;
foreach($plugin['versions'] as $version){ foreach($plugin['versions'] as $version){
$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, $os)){
sleep(1);
$this->download_plugin($input, $output, $plugin['name'], $ver, $os);
}
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($os).'plugins/package/'.$plugin['name'].'-'.$ver.'.zip')){
$this->download_plugin($input, $output, $plugin['name'], $ver); if(!$this->download_plugin($input, $output, $plugin['name'], $ver, $os)){
sleep(1);
$this->download_plugin($input, $output, $plugin['name'], $ver, $os);
}
sleep(1); sleep(1);
$count++; $count++;
} }
} }
} }
} }
$imgcount = 0;
//循环下载缺少的插件图片
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)){
$this->download_plugin_image($input, $output, $fname);
sleep(1);
$imgcount++;
}
}
}
$output->writeln('本次成功下载'.$count.'个插件'.($imgcount>0?''.$imgcount.'个图片':'')); $output->writeln($os.'本次成功下载'.$count.'个插件');
config_set('runtime', date('Y-m-d H:i:s'));
} }
private function refresh_plugin_list(Input $input, Output $output){ private function refresh_plugin_list(Input $input, Output $output, $os){
try{ try{
Plugins::refresh_plugin_list(); Plugins::refresh_plugin_list($os);
Db::name('log')->insert(['uid' => 1, 'action' => '刷新插件列表', 'data' => '刷新插件列表成功', 'addtime' => date("Y-m-d H:i:s")]); Db::name('log')->insert(['uid' => 1, 'action' => '刷新插件列表', 'data' => '刷新'.$os.'插件列表成功', 'addtime' => date("Y-m-d H:i:s")]);
$output->writeln('刷新插件列表成功'); $output->writeln('刷新'.$os.'插件列表成功');
return true; return true;
}catch(\Exception $e){ }catch(\Exception $e){
$output->writeln($e->getMessage()); $output->writeln($e->getMessage());
@ -87,12 +100,12 @@ class UpdateAll extends Command
} }
} }
private function download_plugin(Input $input, Output $output, $plugin_name, $version){ private function download_plugin(Input $input, Output $output, $plugin_name, $version, $os){
$fullname = $plugin_name.'-'.$version; $fullname = $plugin_name.'-'.$version;
try{ try{
Plugins::download_plugin($plugin_name, $version); Plugins::download_plugin($plugin_name, $version, $os);
Db::name('log')->insert(['uid' => 1, 'action' => '下载插件', 'data' => $fullname, 'addtime' => date("Y-m-d H:i:s")]); Db::name('log')->insert(['uid' => 1, 'action' => '下载插件', 'data' => $fullname.' os:'.$os, 'addtime' => date("Y-m-d H:i:s")]);
$output->writeln('下载插件: '.$fullname.' 成功'); $output->writeln('下载'.$os.'插件: '.$fullname.' 成功');
return true; return true;
}catch(\Exception $e){ }catch(\Exception $e){
$output->writeln($fullname.' '.$e->getMessage()); $output->writeln($fullname.' '.$e->getMessage());
@ -100,16 +113,4 @@ class UpdateAll extends Command
return false; return false;
} }
} }
private function download_plugin_image(Input $input, Output $output, $fname){
try{
Plugins::download_plugin_other($fname);
$output->writeln('下载图片: '.$fname.' 成功');
return true;
}catch(\Exception $e){
$output->writeln($fname.' '.$e->getMessage());
errorlog($fname.' '.$e->getMessage());
return false;
}
}
} }

View File

@ -2,8 +2,14 @@
// 应用公共文件 // 应用公共文件
use think\facade\Db; use think\facade\Db;
function get_data_dir(){ function get_data_dir($os = 'Linux'){
return app()->getRootPath().'data/'; if($os == 'en'){
return app()->getRootPath().'data/en/';
}elseif($os == 'Windows'){
return app()->getRootPath().'data/win/';
}else{
return app()->getRootPath().'data/';
}
} }
@ -48,6 +54,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) function get_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobody=0, $addheader=0)
{ {
$ch = curl_init(); $ch = curl_init();
@ -169,8 +186,144 @@ function checkIfActive($string) {
return null; return null;
} }
function checkDomain($domain){
if(empty($domain) || !preg_match('/^[-$a-z0-9_*.]{2,512}$/i', $domain) || (stripos($domain, '.') === false) || substr($domain, -1) == '.' || substr($domain, 0 ,1) == '.' || substr($domain, 0 ,1) == '*' && substr($domain, 1 ,1) != '.' || substr_count($domain, '*')>1 || strpos($domain, '*')>0 || strlen($domain)<4) return false;
return true;
}
function errorlog($msg){ function errorlog($msg){
$handle = fopen(app()->getRootPath()."record.txt", 'a'); $handle = fopen(app()->getRootPath()."record.txt", 'a');
fwrite($handle, date('Y-m-d H:i:s')."\t".$msg."\r\n"); fwrite($handle, date('Y-m-d H:i:s')."\t".$msg."\r\n");
fclose($handle); fclose($handle);
}
function licenseEncrypt($data, $key){
$iv = substr($key, 0, 16);
return openssl_encrypt($data, 'AES-256-CBC', $key, 0, $iv);
}
function licenseDecrypt($data, $key){
$iv = substr($key, 0, 16);
return openssl_decrypt($data, 'AES-256-CBC', $key, 0, $iv);
}
function generateKeyPairs(){
$pkey_dir = app()->getRootPath().'data/config/';
$public_key_path = $pkey_dir.'public_key.pem';
$private_key_path = $pkey_dir.'private_key.pem';
if(file_exists($public_key_path) && file_exists($private_key_path)){
return [file_get_contents($public_key_path), file_get_contents($private_key_path)];
}
$pkey_config = ['private_key_bits'=>4096];
$pkey_res = openssl_pkey_new($pkey_config);
$private_key = '';
openssl_pkey_export($pkey_res, $private_key, null, $pkey_config);
$pkey_details = openssl_pkey_get_details($pkey_res);
if(!$pkey_details) return false;
$public_key = $pkey_details['key'];
file_put_contents($public_key_path, $public_key);
file_put_contents($private_key_path, $private_key);
return [$public_key, $private_key];
}
function pemToBase64($pem){
$lines = explode("\n", $pem);
$encoded = '';
foreach ($lines as $line) {
if (trim($line) != '' && strpos($line, '-----BEGIN') === false && strpos($line, '-----END') === false) {
$encoded .= trim($line);
}
}
return $encoded;
}
function makeSelfSignSSL(string $commonName, array $domainList, $validity = 3650){
// 加载 CA 证书和私钥
$dir = app()->getBasePath().'script/';
$caCert = file_get_contents($dir.'ca.crt');
$caPrivateKey = file_get_contents($dir.'ca.key');
$opensslConfigFile = sys_get_temp_dir().'/openssl'.time().mt_rand(1000, 9999).'.cnf';
$opensslConfigContent = <<<EOF
[req]
req_extensions = extension_section
x509_extensions = extension_section
distinguished_name = dn
[dn]
[extension_section]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
EOF;
$ip_index = 1;
$dns_index = 1;
foreach ($domainList as $value) {
if(empty($value)) continue;
if(filter_var($value, FILTER_VALIDATE_IP)){
$opensslConfigContent .= sprintf("\nIP.%d = %s", $ip_index, $value);
$ip_index++;
}else{
$opensslConfigContent .= sprintf("\nDNS.%d = %s", $dns_index, $value);
$dns_index++;
}
}
if(!file_put_contents($opensslConfigFile, $opensslConfigContent)) return false;
// 生成域名证书的私钥和 CSR
$domainPrivateKey = openssl_pkey_new([
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
]);
if(!$domainPrivateKey) return false;
$csrConfig = ['digest_alg' => 'sha256', 'config' => $opensslConfigFile];
$domainCsr = openssl_csr_new([
'commonName' => $commonName
], $domainPrivateKey, $csrConfig);
if(!$domainCsr) return false;
// 生成域名证书
$domainCertificate = openssl_csr_sign($domainCsr, $caCert, $caPrivateKey, $validity, $csrConfig);
if(!$domainCertificate) return false;
// 导出域名证书
openssl_x509_export($domainCertificate, $certificate);
openssl_pkey_export($domainPrivateKey, $privateKey);
$certificate .= $caCert;
unlink($opensslConfigFile);
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;
} }

View File

@ -1,341 +1,466 @@
<?php <?php
namespace app\controller; namespace app\controller;
use app\BaseController; use app\BaseController;
use think\facade\Db; use think\facade\Db;
use think\facade\View; use think\facade\View;
use think\facade\Request; use think\facade\Request;
use app\lib\Btapi; use think\facade\Cache;
use app\lib\Plugins; use app\lib\Btapi;
use app\lib\Plugins;
class Admin extends BaseController
{ class Admin extends BaseController
public function verifycode() {
{ public function verifycode()
return captcha(); {
} return captcha();
}
public function login(){
if(request()->islogin){ public function login(){
return redirect('/admin'); if(request()->islogin){
} return redirect('/admin');
if(request()->isAjax()){ }
$username = input('post.username',null,'trim'); if(request()->isAjax()){
$password = input('post.password',null,'trim'); $username = input('post.username',null,'trim');
$code = input('post.code',null,'trim'); $password = input('post.password',null,'trim');
$code = input('post.code',null,'trim');
if(empty($username) || empty($password)){
return json(['code'=>-1, 'msg'=>'用户名或密码不能为空']); if(empty($username) || empty($password)){
} return json(['code'=>-1, 'msg'=>'用户名或密码不能为空']);
if(!captcha_check($code)){ }
return json(['code'=>-1, 'msg'=>'验证码错误']); if(!captcha_check($code)){
} return json(['code'=>-1, 'msg'=>'验证码错误']);
if($username == config_get('admin_username') && $password == config_get('admin_password')){ }
Db::name('log')->insert(['uid' => 0, 'action' => '登录后台', 'data' => 'IP:'.$this->clientip, 'addtime' => date("Y-m-d H:i:s")]); if($username == config_get('admin_username') && $password == config_get('admin_password')){
$session = md5($username.config_get('admin_password')); Db::name('log')->insert(['uid' => 0, 'action' => '登录后台', 'data' => 'IP:'.$this->clientip, 'addtime' => date("Y-m-d H:i:s")]);
$expiretime = time()+2562000; $session = md5($username.config_get('admin_password'));
$token = authcode("{$username}\t{$session}\t{$expiretime}", 'ENCODE', config_get('syskey')); $expiretime = time()+2562000;
cookie('admin_token', $token, ['expire' => $expiretime, 'httponly' => true]); $token = authcode("{$username}\t{$session}\t{$expiretime}", 'ENCODE', config_get('syskey'));
config_set('admin_lastlogin', date('Y-m-d H:i:s')); cookie('admin_token', $token, ['expire' => $expiretime, 'httponly' => true]);
return json(['code'=>0]); config_set('admin_lastlogin', date('Y-m-d H:i:s'));
}else{ return json(['code'=>0]);
return json(['code'=>-1, 'msg'=>'用户名或密码错误']); }else{
} return json(['code'=>-1, 'msg'=>'用户名或密码错误']);
} }
return view(); }
} return view();
}
public function logout()
{ public function logout()
cookie('admin_token', null); {
return redirect('/admin/login'); cookie('admin_token', null);
} return redirect('/admin/login');
}
public function index()
{ public function index()
$stat = ['total'=>0, 'free'=>0, 'pro'=>0, 'ltd'=>0, 'third'=>0]; {
$json_arr = Plugins::get_plugin_list(); $stat = ['total'=>0, 'free'=>0, 'pro'=>0, 'ltd'=>0, 'third'=>0];
if($json_arr){ $json_arr = Plugins::get_plugin_list();
foreach($json_arr['list'] as $plugin){ if($json_arr){
$stat['total']++; foreach($json_arr['list'] as $plugin){
if($plugin['type']==10) $stat['third']++; $stat['total']++;
elseif($plugin['type']==12) $stat['ltd']++; if($plugin['type']==10) $stat['third']++;
elseif($plugin['type']==8) $stat['pro']++; elseif($plugin['type']==12) $stat['ltd']++;
elseif($plugin['type']==5 || $plugin['type']==6 || $plugin['type']==7) $stat['free']++; elseif($plugin['type']==8) $stat['pro']++;
} elseif($plugin['type']==5 || $plugin['type']==6 || $plugin['type']==7) $stat['free']++;
} }
$stat['runtime'] = Db::name('config')->where('key','runtime')->value('value') ?? '<font color="red">未运行</font>'; }
$stat['record_total'] = Db::name('record')->count(); $stat['runtime'] = Db::name('config')->where('key','runtime')->value('value') ?? '<font color="red">未运行</font>';
$stat['record_isuse'] = Db::name('record')->whereTime('usetime', '>=', strtotime('-7 days'))->count(); $stat['record_total'] = Db::name('record')->count();
View::assign('stat', $stat); $stat['record_isuse'] = Db::name('record')->whereTime('usetime', '>=', strtotime('-7 days'))->count();
View::assign('stat', $stat);
$tmp = 'version()';
$mysqlVersion = Db::query("select version()")[0][$tmp]; $tmp = 'version()';
$info = [ $mysqlVersion = Db::query("select version()")[0][$tmp];
'framework_version' => app()::VERSION, $info = [
'php_version' => PHP_VERSION, 'framework_version' => app()::VERSION,
'mysql_version' => $mysqlVersion, 'php_version' => PHP_VERSION,
'software' => $_SERVER['SERVER_SOFTWARE'], 'mysql_version' => $mysqlVersion,
'os' => php_uname(), 'software' => $_SERVER['SERVER_SOFTWARE'],
'date' => date("Y-m-d H:i:s"), 'os' => php_uname(),
]; 'date' => date("Y-m-d H:i:s"),
View::assign('info', $info); ];
return view(); View::assign('info', $info);
} return view();
}
public function set(){
if(request()->isAjax()){ public function set(){
$params = Request::param(); if(request()->isAjax()){
$params = Request::param();
foreach ($params as $key => $value) {
config_set($key, $value); foreach ($params as $key => $value) {
} config_set($key, $value);
cache('configs', NULL); }
return json(['code'=>0]); cache('configs', NULL);
} return json(['code'=>0]);
$mod = input('param.mod', 'sys'); }
View::assign('mod', $mod); $mod = input('param.mod', 'sys');
View::assign('conf', config('sys')); View::assign('mod', $mod);
$runtime = Db::name('config')->where('key','runtime')->value('value') ?? '<font color="red">未运行</font>'; View::assign('conf', config('sys'));
View::assign('runtime', $runtime); $runtime = Db::name('config')->where('key','runtime')->value('value') ?? '<font color="red">未运行</font>';
return view(); View::assign('runtime', $runtime);
} View::assign('is_user_www', isset($_SERVER['USER']) && $_SERVER['USER'] == 'www');
return view();
public function setaccount(){ }
$params = Request::param();
if(isset($params['username']))$params['username']=trim($params['username']); public function setaccount(){
if(isset($params['oldpwd']))$params['oldpwd']=trim($params['oldpwd']); $params = Request::param();
if(isset($params['newpwd']))$params['newpwd']=trim($params['newpwd']); if(isset($params['username']))$params['username']=trim($params['username']);
if(isset($params['newpwd2']))$params['newpwd2']=trim($params['newpwd2']); if(isset($params['oldpwd']))$params['oldpwd']=trim($params['oldpwd']);
if(isset($params['newpwd']))$params['newpwd']=trim($params['newpwd']);
if(empty($params['username'])) return json(['code'=>-1, 'msg'=>'用户名不能为空']); if(isset($params['newpwd2']))$params['newpwd2']=trim($params['newpwd2']);
config_set('admin_username', $params['username']); if(empty($params['username'])) return json(['code'=>-1, 'msg'=>'用户名不能为空']);
if(!empty($params['oldpwd']) && !empty($params['newpwd']) && !empty($params['newpwd2'])){ config_set('admin_username', $params['username']);
if(config_get('admin_password') != $params['oldpwd']){
return json(['code'=>-1, 'msg'=>'旧密码不正确']); if(!empty($params['oldpwd']) && !empty($params['newpwd']) && !empty($params['newpwd2'])){
} if(config_get('admin_password') != $params['oldpwd']){
if($params['newpwd'] != $params['newpwd2']){ return json(['code'=>-1, 'msg'=>'旧密码不正确']);
return json(['code'=>-1, 'msg'=>'两次新密码输入不一致']); }
} if($params['newpwd'] != $params['newpwd2']){
config_set('admin_password', $params['newpwd']); return json(['code'=>-1, 'msg'=>'两次新密码输入不一致']);
} }
cache('configs', NULL); config_set('admin_password', $params['newpwd']);
cookie('admin_token', null); }
return json(['code'=>0]); cache('configs', NULL);
} cookie('admin_token', null);
return json(['code'=>0]);
public function testbturl(){ }
$bt_url = input('post.bt_url');
$bt_key = input('post.bt_key'); public function testbturl(){
if(!$bt_url || !$bt_key)return json(['code'=>-1, 'msg'=>'参数不能为空']); $bt_type = input('post.bt_type/d');
$btapi = new Btapi($bt_url, $bt_key);
$result = $btapi->get_config(); if($bt_type == 1){
if($result && isset($result['status']) && $result['status']==1){ $bt_surl = input('post.bt_surl');
$result = $btapi->get_user_info(); if(!$bt_surl)return json(['code'=>-1, 'msg'=>'参数不能为空']);
if($result && isset($result['username'])){ $res = get_curl($bt_surl . 'api/SetupCount');
return json(['code'=>0, 'msg'=>'面板连接测试成功!']); if(strpos($res, 'ok')!==false){
}else{ return json(['code'=>0, 'msg'=>'第三方云端连接测试成功!']);
return json(['code'=>-1, 'msg'=>'面板连接测试成功,但未安装专用插件']); }else{
} return json(['code'=>-1, 'msg'=>'第三方云端连接测试失败']);
}else{ }
return json(['code'=>-1, 'msg'=>isset($result['msg'])?$result['msg']:'面板地址无法连接']); }else{
} $bt_url = input('post.bt_url');
} $bt_key = input('post.bt_key');
$os = input('post.os');
public function plugins(){ if(!$bt_url || !$bt_key)return json(['code'=>-1, 'msg'=>'参数不能为空']);
$typelist = []; $btapi = new Btapi($bt_url, $bt_key);
$json_arr = Plugins::get_plugin_list(); if ($os == 'win') {
if($json_arr){ $result = $btapi->get_config_go();
foreach($json_arr['type'] as $type){ if($result && isset($result['config'])){
$typelist[$type['id']] = $type['title']; $result = $btapi->get_user_info();
} if($result && isset($result['username'])){
} return json(['code'=>0, 'msg'=>'面板连接测试成功!']);
View::assign('typelist', $typelist); }else{
return view(); return json(['code'=>-1, 'msg'=>'面板连接测试成功,但未安装专用插件/未登录账号']);
} }
}else{
public function plugins_data(){ return json(['code'=>-1, 'msg'=>isset($result['msg'])?$result['msg']:'面板地址无法连接']);
$type = input('post.type/d'); }
$keyword = input('post.keyword', null, 'trim'); } else {
$result = $btapi->get_config();
$json_arr = Plugins::get_plugin_list(); if($result && isset($result['status']) && ($result['status']==1 || isset($result['sites_path']))){
if(!$json_arr) return json([]); $result = $btapi->get_user_info();
if($result && isset($result['username'])){
$typelist = []; return json(['code'=>0, 'msg'=>'面板连接测试成功!']);
foreach($json_arr['type'] as $row){ }else{
$typelist[$row['id']] = $row['title']; return json(['code'=>-1, 'msg'=>'面板连接测试成功,但未安装专用插件/未登录账号']);
} }
}else{
$list = []; return json(['code'=>-1, 'msg'=>isset($result['msg'])?$result['msg']:'面板地址无法连接']);
foreach($json_arr['list'] as $plugin){ }
if($type > 0 && $plugin['type']!=$type) continue; }
if(!empty($keyword) && $keyword != $plugin['name'] && stripos($plugin['title'], $keyword)===false) continue; }
$versions = []; }
foreach($plugin['versions'] as $version){
$ver = $version['m_version'].'.'.$version['version']; public function plugins(){
if(isset($version['download'])){ $typelist = [];
$status = false; $json_arr = Plugins::get_plugin_list();
if(file_exists(get_data_dir().'plugins/other/'.$version['download'])){ if($json_arr){
$status = true; foreach($json_arr['type'] as $type){
} if($type['title'] == '一键部署') continue;
$versions[] = ['status'=>$status, 'type'=>1, 'version'=>$ver, 'download'=>$version['download'], 'md5'=>$version['md5']]; $typelist[$type['id']] = $type['title'];
}else{ }
$status = false; }
if(file_exists(get_data_dir().'plugins/package/'.$plugin['name'].'-'.$ver.'.zip')){ View::assign('typelist', $typelist);
$status = true; View::assign('skip_plugins', \app\lib\BtPlugins::$skip_plugins);
} return view();
$versions[] = ['status'=>$status, 'type'=>0, 'version'=>$ver]; }
}
} public function pluginswin(){
$list[] = [ $typelist = [];
'id' => $plugin['id'], $json_arr = Plugins::get_plugin_list('Windows');
'name' => $plugin['name'], if($json_arr){
'title' => $plugin['title'], foreach($json_arr['type'] as $type){
'type' => $plugin['type'], if($type['title'] == '一键部署') continue;
'typename' => $typelist[$plugin['type']], $typelist[$type['id']] = $type['title'];
'desc' => str_replace('target="_blank"','target="_blank" rel="noopener noreferrer"',$plugin['ps']), }
'price' => $plugin['price'], }
'author' => isset($plugin['author']) ? $plugin['author'] : '官方', View::assign('typelist', $typelist);
'versions' => $versions return view();
]; }
}
return json($list); public function pluginsen(){
} $typelist = [];
$json_arr = Plugins::get_plugin_list('en');
public function download_plugin(){ if($json_arr){
$name = input('post.name', null, 'trim'); foreach($json_arr['type'] as $type){
$version = input('post.version', null, 'trim'); if($type['title'] == '一键部署') continue;
if(!$name || !$version) return json(['code'=>-1, 'msg'=>'参数不能为空']); $typelist[$type['id']] = $type['title'];
try{ }
Plugins::download_plugin($name, $version); }
Db::name('log')->insert(['uid' => 0, 'action' => '下载插件', 'data' => $name.'-'.$version, 'addtime' => date("Y-m-d H:i:s")]); View::assign('typelist', $typelist);
return json(['code'=>0,'msg'=>'下载成功']); return view();
}catch(\Exception $e){ }
return json(['code'=>-1, 'msg'=>$e->getMessage()]);
} public function plugins_data(){
} $type = input('post.type/d');
$keyword = input('post.keyword', null, 'trim');
public function refresh_plugins(){ $os = input('get.os');
try{ if(!$os) $os = 'Linux';
Plugins::refresh_plugin_list();
Db::name('log')->insert(['uid' => 0, 'action' => '刷新插件列表', 'data' => '刷新插件列表成功', 'addtime' => date("Y-m-d H:i:s")]); $json_arr = Plugins::get_plugin_list($os);
return json(['code'=>0,'msg'=>'获取最新插件列表成功!']); if(!$json_arr) return json([]);
}catch(\Exception $e){
return json(['code'=>-1, 'msg'=>$e->getMessage()]); $typelist = [];
} foreach($json_arr['type'] as $row){
} $typelist[$row['id']] = $row['title'];
}
public function record(){
return view(); $list = [];
} foreach($json_arr['list'] as $plugin){
if($type > 0 && $plugin['type']!=$type) continue;
public function record_data(){ if(!empty($keyword) && $keyword != $plugin['name'] && stripos($plugin['title'], $keyword)===false) continue;
$ip = input('post.ip', null, 'trim'); $versions = [];
$offset = input('post.offset/d'); foreach($plugin['versions'] as $version){
$limit = input('post.limit/d'); $ver = $version['m_version'].'.'.$version['version'];
if(isset($version['download'])){
$select = Db::name('record'); $status = false;
if(!empty($ip)){ if(file_exists(get_data_dir().'plugins/other/'.$version['download'])){
$select->where('ip', $ip); $status = true;
} }
$total = $select->count(); $versions[] = ['status'=>$status, 'type'=>1, 'version'=>$ver, 'download'=>$version['download'], 'md5'=>$version['md5']];
$rows = $select->order('id','desc')->limit($offset, $limit)->select(); }else{
$status = false;
return json(['total'=>$total, 'rows'=>$rows]); if(file_exists(get_data_dir($os).'plugins/package/'.$plugin['name'].'-'.$ver.'.zip')){
} $status = true;
}
public function log(){ $versions[] = ['status'=>$status, 'type'=>0, 'version'=>$ver];
return view(); }
} }
if($plugin['name'] == 'obs') $plugin['ps'] = substr($plugin['ps'],0,strpos($plugin['ps'],'<a '));
public function log_data(){ $list[] = [
$action = input('post.action', null, 'trim'); 'id' => $plugin['id'],
$offset = input('post.offset/d'); 'name' => $plugin['name'],
$limit = input('post.limit/d'); 'title' => $plugin['title'],
'type' => $plugin['type'],
$select = Db::name('log'); 'typename' => isset($typelist[$plugin['type']]) ? $typelist[$plugin['type']] : '未知',
if(!empty($action)){ 'desc' => str_replace('target="_blank"','target="_blank" rel="noopener noreferrer"',$plugin['ps']),
$select->where('action', $action); 'price' => $plugin['price'],
} 'author' => isset($plugin['author']) ? $plugin['author'] : '官方',
$total = $select->count(); 'versions' => $versions
$rows = $select->order('id','desc')->limit($offset, $limit)->select(); ];
}
return json(['total'=>$total, 'rows'=>$rows]); return json($list);
} }
public function list(){ public function download_plugin(){
$type = input('param.type', 'black'); $name = input('post.name', null, 'trim');
View::assign('type', $type); $version = input('post.version', null, 'trim');
View::assign('typename', $type=='white'?'白名单':'黑名单'); $os = input('post.os');
return view(); if(!$os) $os = 'Linux';
} if(!$name || !$version) return json(['code'=>-1, 'msg'=>'参数不能为空']);
try{
public function list_data(){ Plugins::download_plugin($name, $version, $os);
$type = input('param.type', 'black'); Db::name('log')->insert(['uid' => 0, 'action' => '下载插件', 'data' => $name.'-'.$version.' os:'.$os, 'addtime' => date("Y-m-d H:i:s")]);
$ip = input('post.ip', null, 'trim'); return json(['code'=>0,'msg'=>'下载成功']);
$offset = input('post.offset/d'); }catch(\Exception $e){
$limit = input('post.limit/d'); return json(['code'=>-1, 'msg'=>$e->getMessage()]);
}
$tablename = $type == 'black' ? 'black' : 'white'; }
$select = Db::name($tablename);
if(!empty($ip)){ public function refresh_plugins(){
$select->where('ip', $ip); $os = input('get.os');
} if(!$os) $os = 'Linux';
$total = $select->count(); try{
$rows = $select->order('id','desc')->limit($offset, $limit)->select(); Plugins::refresh_plugin_list($os);
Db::name('log')->insert(['uid' => 0, 'action' => '刷新插件列表', 'data' => '刷新'.$os.'插件列表成功', 'addtime' => date("Y-m-d H:i:s")]);
return json(['total'=>$total, 'rows'=>$rows]); return json(['code'=>0,'msg'=>'获取最新插件列表成功!']);
} }catch(\Exception $e){
return json(['code'=>-1, 'msg'=>$e->getMessage()]);
public function list_op(){ }
$type = input('param.type', 'black'); }
$tablename = $type == 'black' ? 'black' : 'white';
$act = input('post.act', null); public function record(){
if($act == 'get'){ return view();
$id = input('post.id/d'); }
if(!$id) return json(['code'=>-1, 'msg'=>'no id']);
$data = Db::name($tablename)->where('id', $id)->find(); public function record_data(){
return json(['code'=>0, 'data'=>$data]); $ip = input('post.ip', null, 'trim');
}elseif($act == 'add'){ $offset = input('post.offset/d');
$ip = input('post.ip', null, 'trim'); $limit = input('post.limit/d');
if(!$ip) return json(['code'=>-1, 'msg'=>'IP不能为空']);
if(Db::name($tablename)->where('ip', $ip)->find()){ $select = Db::name('record');
return json(['code'=>-1, 'msg'=>'该IP已存在']); if(!empty($ip)){
} $select->where('ip', $ip);
Db::name($tablename)->insert([ }
'ip' => $ip, $total = $select->count();
'enable' => 1, $rows = $select->order('id','desc')->limit($offset, $limit)->select();
'addtime' => date("Y-m-d H:i:s")
]); return json(['total'=>$total, 'rows'=>$rows]);
return json(['code'=>0, 'msg'=>'succ']); }
}elseif($act == 'edit'){
$id = input('post.id/d'); public function log(){
$ip = input('post.ip', null, 'trim'); return view();
if(!$id || !$ip) return json(['code'=>-1, 'msg'=>'IP不能为空']); }
if(Db::name($tablename)->where('ip', $ip)->where('id', '<>', $id)->find()){
return json(['code'=>-1, 'msg'=>'该IP已存在']); public function log_data(){
} $action = input('post.action', null, 'trim');
Db::name($tablename)->where('id', $id)->update([ $offset = input('post.offset/d');
'ip' => $ip $limit = input('post.limit/d');
]);
return json(['code'=>0, 'msg'=>'succ']); $select = Db::name('log');
}elseif($act == 'enable'){ if(!empty($action)){
$id = input('post.id/d'); $select->where('action', $action);
$enable = input('post.enable/d'); }
if(!$id) return json(['code'=>-1, 'msg'=>'no id']); $total = $select->count();
Db::name($tablename)->where('id', $id)->update([ $rows = $select->order('id','desc')->limit($offset, $limit)->select();
'enable' => $enable
]); return json(['total'=>$total, 'rows'=>$rows]);
return json(['code'=>0, 'msg'=>'succ']); }
}elseif($act == 'del'){
$id = input('post.id/d'); public function list(){
if(!$id) return json(['code'=>-1, 'msg'=>'no id']); $type = input('param.type', 'black');
Db::name($tablename)->where('id', $id)->delete(); View::assign('type', $type);
return json(['code'=>0, 'msg'=>'succ']); View::assign('typename', $type=='white'?'白名单':'黑名单');
} return view();
return json(['code'=>-1, 'msg'=>'no act']); }
}
public function list_data(){
$type = input('param.type', 'black');
$ip = input('post.ip', null, 'trim');
$offset = input('post.offset/d');
$limit = input('post.limit/d');
$tablename = $type == 'black' ? 'black' : 'white';
$select = Db::name($tablename);
if(!empty($ip)){
$select->where('ip', $ip);
}
$total = $select->count();
$rows = $select->order('id','desc')->limit($offset, $limit)->select();
return json(['total'=>$total, 'rows'=>$rows]);
}
public function list_op(){
$type = input('param.type', 'black');
$tablename = $type == 'black' ? 'black' : 'white';
$act = input('post.act', null);
if($act == 'get'){
$id = input('post.id/d');
if(!$id) return json(['code'=>-1, 'msg'=>'no id']);
$data = Db::name($tablename)->where('id', $id)->find();
return json(['code'=>0, 'data'=>$data]);
}elseif($act == 'add'){
$ip = input('post.ip', null, 'trim');
if(!$ip) return json(['code'=>-1, 'msg'=>'IP不能为空']);
if(Db::name($tablename)->where('ip', $ip)->find()){
return json(['code'=>-1, 'msg'=>'该IP已存在']);
}
Db::name($tablename)->insert([
'ip' => $ip,
'enable' => 1,
'addtime' => date("Y-m-d H:i:s")
]);
return json(['code'=>0, 'msg'=>'succ']);
}elseif($act == 'edit'){
$id = input('post.id/d');
$ip = input('post.ip', null, 'trim');
if(!$id || !$ip) return json(['code'=>-1, 'msg'=>'IP不能为空']);
if(Db::name($tablename)->where('ip', $ip)->where('id', '<>', $id)->find()){
return json(['code'=>-1, 'msg'=>'该IP已存在']);
}
Db::name($tablename)->where('id', $id)->update([
'ip' => $ip
]);
return json(['code'=>0, 'msg'=>'succ']);
}elseif($act == 'enable'){
$id = input('post.id/d');
$enable = input('post.enable/d');
if(!$id) return json(['code'=>-1, 'msg'=>'no id']);
Db::name($tablename)->where('id', $id)->update([
'enable' => $enable
]);
return json(['code'=>0, 'msg'=>'succ']);
}elseif($act == 'del'){
$id = input('post.id/d');
if(!$id) return json(['code'=>-1, 'msg'=>'no id']);
Db::name($tablename)->where('id', $id)->delete();
return json(['code'=>0, 'msg'=>'succ']);
}
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']);
}
public function ssl(){
if(request()->isAjax()){
$domain_list = input('post.domain_list', null, 'trim');
$common_name = input('post.common_name', null, 'trim');
$validity = input('post.validity/d');
if(empty($domain_list) || empty($validity)){
return json(['code'=>-1, 'msg'=>'参数不能为空']);
}
$array = explode("\n", $domain_list);
$domain_list = [];
foreach($array as $domain){
$domain = trim($domain);
if(empty($domain)) continue;
if(!checkDomain($domain)) return json(['code'=>-1, 'msg'=>'域名或IP格式不正确:'.$domain]);
$domain_list[] = $domain;
}
if(empty($domain_list)) return json(['code'=>-1, 'msg'=>'域名列表不能为空']);
if(empty($common_name)) $common_name = $domain_list[0];
$result = makeSelfSignSSL($common_name, $domain_list, $validity);
if(!$result){
return json(['code'=>-1, 'msg'=>'生成证书失败']);
}
return json(['code'=>0, 'msg'=>'生成证书成功', 'cert'=>$result['cert'], 'key'=>$result['key']]);
}
$dir = app()->getBasePath().'script/';
$ssl_path = app()->getRootPath().'public/ssl/baota_root.pfx';
$ssl_path_mac = app()->getRootPath().'public/ssl/baota_root.crt';
$isca = file_exists($dir.'ca.crt') && file_exists($dir.'ca.key') && file_exists($ssl_path) && file_exists($ssl_path_mac);
View::assign('isca', $isca);
return view();
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,13 @@ class Index extends BaseController
{ {
public function index() public function index()
{ {
return 'Server is ok'; return '';
} }
public function download() public function download()
{ {
if(config_get('download_page') == '0' && !request()->islogin){ if(config_get('download_page') == '0' && !request()->islogin){
return redirect('/admin/login'); return 'need login';
} }
View::assign('siteurl', request()->root(true)); View::assign('siteurl', request()->root(true));
return view(); return view();

View File

@ -0,0 +1,83 @@
<?php
namespace app\controller;
use PDO;
use Exception;
use app\BaseController;
use think\facade\View;
use think\facade\Cache;
class Install extends BaseController
{
public function index()
{
if (file_exists(app()->getRootPath().'.env')){
return '当前已经安装成功,如果需要重新安装,请手动删除根目录.env文件';
}
if(request()->isPost()){
$mysql_host = input('post.mysql_host', null, 'trim');
$mysql_port = intval(input('post.mysql_port', '3306'));
$mysql_user = input('post.mysql_user', null, 'trim');
$mysql_pwd = input('post.mysql_pwd', null, 'trim');
$mysql_name = input('post.mysql_name', null, 'trim');
$mysql_prefix = input('post.mysql_prefix', 'cloud_', 'trim');
$admin_username = input('post.admin_username', null, 'trim');
$admin_password = input('post.admin_password', null, 'trim');
if(!$mysql_host || !$mysql_user || !$mysql_pwd || !$mysql_name || !$admin_username || !$admin_password){
return json(['code'=>0, 'msg'=>'必填项不能为空']);
}
$configdata = file_get_contents(app()->getRootPath().'.env.example');
$configdata = str_replace(['{dbhost}','{dbname}','{dbuser}','{dbpwd}','{dbport}','{dbprefix}'], [$mysql_host, $mysql_name, $mysql_user, $mysql_pwd, $mysql_port, $mysql_prefix], $configdata);
try{
$DB=new PDO("mysql:host=".$mysql_host.";dbname=".$mysql_name.";port=".$mysql_port,$mysql_user,$mysql_pwd);
}catch(Exception $e){
if($e->getCode() == 2002){
$errorMsg='连接数据库失败:数据库地址填写错误!';
}elseif($e->getCode() == 1045){
$errorMsg='连接数据库失败:数据库用户名或密码填写错误!';
}elseif($e->getCode() == 1049){
$errorMsg='连接数据库失败:数据库名不存在!';
}else{
$errorMsg='连接数据库失败:'.$e->getMessage();
}
return json(['code'=>0, 'msg'=>$errorMsg]);
}
$DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$DB->exec("set sql_mode = ''");
$DB->exec("set names utf8");
$sqls=file_get_contents(app()->getRootPath().'install.sql');
$sqls=explode(';', $sqls);
$sqls[]="REPLACE INTO `".$mysql_prefix."config` VALUES ('syskey', '".random(16)."')";
$sqls[]="REPLACE INTO `".$mysql_prefix."config` VALUES ('admin_username', '".addslashes($admin_username)."')";
$sqls[]="REPLACE INTO `".$mysql_prefix."config` VALUES ('admin_password', '".addslashes($admin_password)."')";
$success=0;$error=0;$errorMsg=null;
foreach ($sqls as $value) {
$value=trim($value);
if(empty($value))continue;
$value = str_replace('cloud_',$mysql_prefix,$value);
if($DB->exec($value)===false){
$error++;
$dberror=$DB->errorInfo();
$errorMsg.=$dberror[2]."\n";
}else{
$success++;
}
}
if(empty($errorMsg)){
if(!file_put_contents(app()->getRootPath().'.env', $configdata)){
return json(['code'=>0, 'msg'=>'保存失败,请确保网站根目录有写入权限']);
}
Cache::clear();
return json(['code'=>1, 'msg'=>'安装完成成功执行SQL语句'.$success.'条']);
}else{
return json(['code'=>0, 'msg'=>$errorMsg]);
}
}
return view();
}
}

308
app/lib/BtPlugins.php Normal file
View File

@ -0,0 +1,308 @@
<?php
namespace app\lib;
use Exception;
use ZipArchive;
class BtPlugins
{
private $btapi;
private $os;
//需屏蔽的插件名称列表
public static $block_plugins = ['dns', 'bt_boce', 'ssl_verify', 'firewall', 'KylinOperatingSystem', 'KingdeeApusicDistributedCache', 'BorlandCacheServer', 'GBase8s', 'KingdeeApusicLoadBalancer', 'BorlandWebServer'];
public static $skip_plugins = ['php_filter', 'enterprise_backup', 'tamper_drive'];
public function __construct($os){
$this->os = $os;
if($os == 'en'){
$bt_url = config_get('enbt_url');
$bt_key = config_get('enbt_key');
}elseif($os == 'Windows'){
$bt_url = config_get('wbt_url');
$bt_key = config_get('wbt_key');
}else{
$bt_url = config_get('bt_url');
$bt_key = config_get('bt_key');
}
if(!$bt_url || !$bt_key) throw new Exception('请先配置好宝塔面板接口信息');
$this->btapi = new Btapi($bt_url, $bt_key);
}
//获取插件列表
public function get_plugin_list(){
$result = $this->btapi->get_plugin_list();
if($result && isset($result['list']) && isset($result['type'])){
if(empty($result['list']) || empty($result['type'])){
throw new Exception('获取插件列表失败:插件列表为空');
}
$newlist = [];
foreach($result['list'] as $item){
if(!in_array($item['name'], self::$block_plugins)) $newlist[] = $item;
}
$result['list'] = $newlist;
return $result;
}else{
throw new Exception('获取插件列表失败:'.(isset($result['msg'])?$result['msg']:'面板连接失败'));
}
}
//下载插件(自动判断是否第三方)
public function download_plugin($plugin_name, $version, $plugin_info){
if($plugin_info['type'] == 10 && isset($plugin_info['versions'][0]['download'])){
if($plugin_info['price'] == 0){
$this->btapi->create_plugin_other_order($plugin_info['id']);
}
$fname = $plugin_info['versions'][0]['download'];
$filemd5 = $plugin_info['versions'][0]['md5'];
$this->download_plugin_other($fname, $filemd5);
if(isset($plugin_info['min_image']) && strpos($plugin_info['min_image'], 'fname=')){
$fname = substr($plugin_info['min_image'], strpos($plugin_info['min_image'], '?fname=')+7);
$this->download_plugin_other($fname);
}
}else{
$this->download_plugin_package($plugin_name, $version);
}
}
//下载插件包
private function download_plugin_package($plugin_name, $version){
$filepath = get_data_dir($this->os).'plugins/package/'.$plugin_name.'-'.$version.'.zip';
$result = $this->btapi->get_plugin_filename($plugin_name, $version);
if($result && isset($result['status'])){
if($result['status'] == true){
$filename = $result['filename'];
$this->download_file($filename, $filepath);
if(file_exists($filepath)){
$zip = new ZipArchive;
if ($zip->open($filepath) === true)
{
$plugins_dir = get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version;
$zip->extractTo($plugins_dir, $plugin_name.'/'.$plugin_name.'_main.py');
$zip->close();
$main_filepath = $plugins_dir.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
if(file_exists($main_filepath) && filesize($main_filepath)>10){
if(!strpos(file_get_contents($main_filepath), 'import ')){ //加密py文件需要解密
$this->decode_plugin_main($plugin_name, $version, $main_filepath);
$this->noauth_plugin_main($main_filepath);
$zip->open($filepath, ZipArchive::CREATE);
$zip->addFile($main_filepath, $plugin_name.'/'.$plugin_name.'_main.py');
$zip->close();
}
}
deleteDir($plugins_dir);
}else{
unlink($filepath);
throw new Exception('插件包解压缩失败');
}
return true;
}else{
throw new Exception('下载插件包失败,本地文件不存在');
}
}else{
throw new Exception('下载插件包失败:'.($result['msg']?$result['msg']:'未知错误'));
}
}else{
throw new Exception('下载插件包失败,接口返回错误');
}
}
//下载插件主程序文件
public function download_plugin_main($plugin_name, $version){
$filepath = get_data_dir($this->os).'plugins/main/'.$plugin_name.'-'.$version.'.dat';
$result = $this->btapi->get_plugin_main_filename($plugin_name, $version);
if($result && isset($result['status'])){
if($result['status'] == true){
$filename = $result['filename'];
$this->download_file($filename, $filepath);
if(file_exists($filepath)){
return true;
}else{
throw new Exception('下载插件主程序文件失败,本地文件不存在');
}
}else{
throw new Exception('下载插件主程序文件失败:'.($result['msg']?$result['msg']:'未知错误'));
}
}else{
throw new Exception('下载插件主程序文件失败,接口返回错误');
}
}
//解密并下载插件主程序文件
private function decode_plugin_main($plugin_name, $version, $main_filepath){
if($this->decode_plugin_main_local($main_filepath)) return true;
$result = $this->btapi->get_decode_plugin_main($plugin_name, $version);
if($result && isset($result['status'])){
if($result['status'] == true){
$filename = $result['filename'];
$this->download_file($filename, $main_filepath);
return true;
}else{
throw new Exception('解密插件主程序文件失败:'.($result['msg']?$result['msg']:'未知错误'));
}
}else{
throw new Exception('解密插件主程序文件失败,接口返回错误');
}
}
//本地解密插件主程序文件
public function decode_plugin_main_local($main_filepath){
$userinfo = $this->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);
$iv = md5($key.$serverid);
$key = substr($key, 8, 16);
$iv = substr($iv, 8, 16);
$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 !== false) $de_text .= $tmp;
}
}
if(!empty($de_text) && strpos($de_text, 'import ')!==false){
file_put_contents($main_filepath, $de_text);
return true;
}
return false;
}else{
throw new Exception('解密插件主程序文件失败,获取用户信息失败');
}
}
//去除插件主程序文件授权校验
private 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);
$data = str_replace('\'http://www.bt.cn/api/wpanel/get_soft_list_test', 'public.GetConfigValue(\'home\')+\'/api/wpanel/get_soft_list_test', $data);
$data = str_replace('\'https://www.bt.cn/api/wpanel/get_soft_list_test', 'public.GetConfigValue(\'home\')+\'/api/wpanel/get_soft_list_test', $data);
$data = str_replace('\'http://www.bt.cn/api/wpanel/get_soft_list', 'public.GetConfigValue(\'home\')+\'/api/wpanel/get_soft_list', $data);
$data = str_replace('\'https://www.bt.cn/api/wpanel/get_soft_list', 'public.GetConfigValue(\'home\')+\'/api/wpanel/get_soft_list', $data);
$data = str_replace('\'http://www.bt.cn/api/wpanel/notpro', 'public.GetConfigValue(\'home\')+\'/api/wpanel/notpro', $data);
$data = str_replace('\'https://www.bt.cn/api/wpanel/notpro', 'public.GetConfigValue(\'home\')+\'/api/wpanel/notpro', $data);
$data = str_replace('"https://www.bt.cn/api/bt_waf/get_malicious', 'public.GetConfigValue(\'home\')+"/api/bt_waf/get_malicious', $data);
$data = str_replace('\'http://www.bt.cn/api/bt_waf/getSpiders', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/getSpiders', $data);
$data = str_replace('\'https://www.bt.cn/api/bt_waf/getSpiders', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/getSpiders', $data);
$data = str_replace('\'http://www.bt.cn/api/bt_waf/addSpider', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/addSpider', $data);
$data = str_replace('\'https://www.bt.cn/api/bt_waf/addSpider', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/addSpider', $data);
$data = str_replace('\'https://www.bt.cn/api/bt_waf/getVulScanInfoList', 'public.GetConfigValue(\'home\')+\'/api/bt_waf/getVulScanInfoList', $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/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/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);
$data = str_replace('\'https://brandnew.aapanel.com/api/panel/getSoftList', 'public.OfficialApiBase()+\'/api/panel/getSoftList', $data);
file_put_contents($main_filepath, $data);
}
//下载插件其他文件
private function download_plugin_other($fname, $filemd5 = null){
$filepath = get_data_dir().'plugins/other/'.$fname;
@mkdir(dirname($filepath), 0777, true);
$result = $this->btapi->get_plugin_other_filename($fname);
if($result && isset($result['status'])){
if($result['status'] == true){
$filename = $result['filename'];
$this->download_file($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($msg);
}
return true;
}else{
throw new Exception('下载插件文件失败,本地文件不存在');
}
}else{
throw new Exception('下载插件文件失败:'.($result['msg']?$result['msg']:'未知错误'));
}
}else{
throw new Exception('下载插件文件失败,接口返回错误');
}
}
//下载文件
private function download_file($filename, $filepath){
try{
$this->btapi->download($filename, $filepath);
}catch(Exception $e){
@unlink($filepath);
//宝塔bug小文件下载失败改用base64下载
$result = $this->btapi->get_file($filename);
if($result && isset($result['status']) && $result['status']==true){
$filedata = base64_decode($result['data']);
if(strlen($filedata) < 4096 && substr($filedata,0,1)=='{' && substr($filedata,-1,1)=='}'){
$arr = json_decode($filedata, true);
if($arr){
throw new Exception('获取文件失败:'.($arr['msg']?$arr['msg']:'未知错误'));
}
}
if(!$filedata){
throw new Exception('获取文件失败:文件内容为空');
}
file_put_contents($filepath, $filedata);
}elseif($result){
throw new Exception('获取文件失败:'.($result['msg']?$result['msg']:'未知错误'));
}else{
throw new Exception('获取文件失败:未知错误');
}
}
}
//获取一键部署列表
public function get_deplist(){
$result = $this->btapi->get_deplist();
if($result && isset($result['list']) && isset($result['type'])){
if(empty($result['list']) || empty($result['type'])){
throw new Exception('获取一键部署列表失败:一键部署列表为空');
}
return $result;
}else{
throw new Exception('获取一键部署列表失败:'.(isset($result['msg'])?$result['msg']:'面板连接失败'));
}
}
//获取蜘蛛IP列表
public function btwaf_getspiders(){
$result = $this->btapi->btwaf_getspiders();
if(isset($result['status']) && $result['status']){
return $result['data'];
}else{
throw new Exception(isset($result['msg'])?$result['msg']:'获取失败');
}
}
//获取堡塔恶意情报IP库
public function btwaf_getmalicious(){
$result = $this->btapi->btwaf_getmalicious();
if(isset($result['success'])){
return $result;
}elseif(isset($result['msg'])){
throw new Exception($result['msg']);
}else{
throw new Exception(isset($result['res'])?$result['res']:'获取失败');
}
}
}

View File

@ -1,203 +1,266 @@
<?php <?php
namespace app\lib; namespace app\lib;
use Exception; use Exception;
class Btapi class Btapi
{ {
private $BT_KEY; //接口密钥 private $BT_KEY; //接口密钥
private $BT_PANEL; //面板地址 private $BT_PANEL; //面板地址
public function __construct($bt_panel, $bt_key){ public function __construct($bt_panel, $bt_key){
$this->BT_PANEL = $bt_panel; $this->BT_PANEL = $bt_panel;
$this->BT_KEY = $bt_key; $this->BT_KEY = $bt_key;
} }
//获取面板配置信息 //获取面板配置信息
public function get_config(){ public function get_config(){
$url = $this->BT_PANEL.'/config?action=get_config'; $url = $this->BT_PANEL.'/config?action=get_config';
$p_data = $this->GetKeyData(); $p_data = $this->GetKeyData();
$result = $this->curl($url,$p_data); $result = $this->curl($url,$p_data);
$data = json_decode($result,true); $data = json_decode($result,true);
return $data; return $data;
} }
//获取已登录用户信息 public function get_config_go(){
public function get_user_info(){ $url = $this->BT_PANEL.'/panel/get_config';
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_user_info';
$p_data = $this->GetKeyData();
$p_data = $this->GetKeyData();
$result = $this->curl($url,$p_data);
$result = $this->curl($url,$p_data);
$data = json_decode($result,true);
$data = json_decode($result,true); return $data;
return $data; }
}
//获取已登录用户信息
//从云端获取插件列表 public function get_user_info(){
public function get_plugin_list(){ $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_user_info';
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_plugin_list';
$p_data = $this->GetKeyData();
$p_data = $this->GetKeyData();
$result = $this->curl($url,$p_data);
$result = $this->curl($url,$p_data);
$data = json_decode($result,true);
$data = json_decode($result,true); return $data;
return $data; }
}
//从云端获取插件列表
//下载插件包,返回文件路径 public function get_plugin_list(){
public function get_plugin_filename($plugin_name, $version){ $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_plugin_list';
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin';
$p_data = $this->GetKeyData();
$p_data = $this->GetKeyData();
$p_data['plugin_name'] = $plugin_name; $result = $this->curl($url,$p_data);
$p_data['version'] = $version;
$data = json_decode($result,true);
$result = $this->curl($url,$p_data); return $data;
}
$data = json_decode($result,true);
return $data; //下载插件包,返回文件路径
} public function get_plugin_filename($plugin_name, $version){
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin';
//下载插件主程序文件,返回文件路径
public function get_plugin_main_filename($plugin_name, $version){ $p_data = $this->GetKeyData();
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin_main'; $p_data['plugin_name'] = $plugin_name;
$p_data['version'] = $version;
$p_data = $this->GetKeyData();
$p_data['plugin_name'] = $plugin_name; $result = $this->curl($url,$p_data);
$p_data['version'] = $version;
$data = json_decode($result,true);
$result = $this->curl($url,$p_data); return $data;
}
$data = json_decode($result,true);
return $data; //下载插件主程序文件,返回文件路径
} public function get_plugin_main_filename($plugin_name, $version){
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin_main';
//解密插件主程序py代码返回文件路径
public function get_decode_plugin_main($plugin_name, $version){ $p_data = $this->GetKeyData();
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=decode_plugin_main'; $p_data['plugin_name'] = $plugin_name;
$p_data['version'] = $version;
$p_data = $this->GetKeyData();
$p_data['plugin_name'] = $plugin_name; $result = $this->curl($url,$p_data);
$p_data['version'] = $version;
$data = json_decode($result,true);
$result = $this->curl($url,$p_data); return $data;
}
$data = json_decode($result,true);
return $data; //解密插件主程序py代码返回文件路径
} public function get_decode_plugin_main($plugin_name, $version){
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=decode_plugin_main';
//下载插件其他文件,返回文件路径
public function get_plugin_other_filename($fname){ $p_data = $this->GetKeyData();
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin_other'; $p_data['plugin_name'] = $plugin_name;
$p_data['version'] = $version;
$p_data = $this->GetKeyData();
$p_data['fname'] = $fname; $result = $this->curl($url,$p_data);
$result = $this->curl($url,$p_data); $data = json_decode($result,true);
return $data;
$data = json_decode($result,true); }
return $data;
} //下载插件其他文件,返回文件路径
public function get_plugin_other_filename($fname){
//下载文件 $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=download_plugin_other';
public function download($filename, $localpath){
$url = $this->BT_PANEL.'/download'; $p_data = $this->GetKeyData();
$p_data['fname'] = $fname;
$p_data = $this->GetKeyData();
$p_data['filename'] = $filename; $result = $this->curl($url,$p_data);
$result = $this->curl_download($url.'?'.http_build_query($p_data), $localpath); $data = json_decode($result,true);
return $data;
return $result; }
}
//下载文件
//获取文件base64 public function download($filename, $localpath){
public function get_file($filename){ $url = $this->BT_PANEL.'/download';
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_file';
$p_data = $this->GetKeyData();
$p_data = $this->GetKeyData(); $p_data['filename'] = $filename;
$p_data['filename'] = $filename;
$result = $this->curl_download($url.'?'.http_build_query($p_data), $localpath);
$result = $this->curl($url,$p_data);
return $result;
$data = json_decode($result,true); }
return $data;
} //获取文件base64
public function get_file($filename){
$url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_file';
private function GetKeyData(){
$now_time = time(); $p_data = $this->GetKeyData();
$p_data = array( $p_data['filename'] = $filename;
'request_token' => md5($now_time.''.md5($this->BT_KEY)),
'request_time' => $now_time $result = $this->curl($url,$p_data);
);
return $p_data; $data = json_decode($result,true);
} return $data;
}
private function curl($url, $data = null, $timeout = 60) //购买第三方插件
{ public function create_plugin_other_order($pid){
//定义cookie保存位置 $url = $this->BT_PANEL.'/auth?action=create_plugin_other_order';
$cookie_file=app()->getRuntimePath().md5($this->BT_PANEL).'.cookie';
if(!file_exists($cookie_file)){ $p_data = $this->GetKeyData();
touch($cookie_file); $p_data['pid'] = $pid;
} $p_data['cycle'] = '999';
$p_data['type'] = '0';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); $result = $this->curl($url,$p_data);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if($data){ $data = json_decode($result,true);
curl_setopt($ch, CURLOPT_POST, 1); return $data;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); }
}
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); //获取一键部署列表
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); public function get_deplist(){
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=get_deplist';
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $p_data = $this->GetKeyData();
$output = curl_exec($ch);
curl_close($ch); $result = $this->curl($url,$p_data);
return $output;
} $data = json_decode($result,true);
return $data;
private function curl_download($url, $localpath, $timeout = 60) }
{
//定义cookie保存位置 //BTWAF-获取蜘蛛列表
$cookie_file=app()->getRuntimePath().md5($this->BT_PANEL).'.cookie'; public function btwaf_getspiders(){
if(!file_exists($cookie_file)){ $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=btwaf_getspiders';
touch($cookie_file);
} $p_data = $this->GetKeyData();
$ch = curl_init(); $result = $this->curl($url,$p_data);
curl_setopt($ch, CURLOPT_URL, $url); $result = str_replace("\u0000", '', $result);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $data = json_decode($result,true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); return $data;
$fp = fopen($localpath, 'w+'); }
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //BTWAF-获取堡塔恶意情报IP库
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); public function btwaf_getmalicious(){
curl_exec($ch); $url = $this->BT_PANEL.'/plugin?action=a&name=kaixin&s=btwaf_getmalicious';
if (curl_errno($ch)) {
$message = curl_error($ch); $p_data = $this->GetKeyData();
curl_close($ch);
fclose($fp); $result = $this->curl($url,$p_data);
throw new Exception('下载文件失败:'.$message);
} $data = json_decode($result,true);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); return $data;
if($httpcode>299){ }
curl_close($ch);
fclose($fp);
throw new Exception('下载文件失败HTTPCODE-'.$httpcode); private function GetKeyData(){
} $now_time = time();
curl_close($ch); $p_data = array(
fclose($fp); 'request_token' => md5($now_time.''.md5($this->BT_KEY)),
return true; 'request_time' => $now_time
} );
return $p_data;
}
private function curl($url, $data = null, $timeout = 60)
{
//定义cookie保存位置
$cookie_file=app()->getRuntimePath().md5($this->BT_PANEL).'.cookie';
if(!file_exists($cookie_file)){
touch($cookie_file);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if($data){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
private function curl_download($url, $localpath, $timeout = 300)
{
//定义cookie保存位置
$cookie_file=app()->getRuntimePath().md5($this->BT_PANEL).'.cookie';
if(!file_exists($cookie_file)){
touch($cookie_file);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$fp = fopen($localpath, 'w+');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
if (curl_errno($ch)) {
$message = curl_error($ch);
curl_close($ch);
fclose($fp);
throw new Exception('下载文件失败:'.$message);
}
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpcode>299){
curl_close($ch);
fclose($fp);
throw new Exception('下载文件失败HTTPCODE-'.$httpcode);
}
curl_close($ch);
fclose($fp);
return true;
}
} }

View File

@ -1,229 +1,218 @@
<?php <?php
namespace app\lib; namespace app\lib;
use Exception; use Exception;
use ZipArchive; use ZipArchive;
class Plugins class Plugins
{ {
private static function get_btapi(){ private static function get_btapi($os){
$bt_url = config_get('bt_url'); if(self::is_third($os)){
$bt_key = config_get('bt_key'); return new ThirdPlugins($os);
if(!$bt_url || !$bt_key) throw new Exception('请先配置好宝塔面板接口信息'); }else{
$btapi = new Btapi($bt_url, $bt_key); return new BtPlugins($os);
return $btapi; }
} }
//刷新插件列表 private static function is_third($os){
public static function refresh_plugin_list(){ if($os == 'en'){
$btapi = self::get_btapi(); $type = config_get('enbt_type');
$result = $btapi->get_plugin_list(); }elseif($os == 'Windows'){
if($result && isset($result['list']) && isset($result['type'])){ $type = config_get('wbt_type');
if(empty($result['list']) || empty($result['type'])){ }else{
throw new Exception('获取插件列表失败:插件列表为空'); $type = config_get('bt_type');
} }
self::save_plugin_list($result); return $type == 1;
}else{ }
throw new Exception('获取插件列表失败:'.($result['msg']?$result['msg']:'面板连接失败'));
} //刷新插件列表
} public static function refresh_plugin_list($os = 'Linux'){
$btapi = self::get_btapi($os);
//保存插件列表 $result = $btapi->get_plugin_list();
private static function save_plugin_list($data){ self::save_plugin_list($result, $os);
$data['ip'] = '127.0.0.1'; }
$data['serverid'] = '';
$data['beta'] = 0; //保存插件列表
$data['uid'] = 1; private static function save_plugin_list($data, $os){
$data['skey'] = ''; $data['ip'] = '127.0.0.1';
$list = []; if($os == 'en'){
foreach($data['list'] as $plugin){ $data['serverId'] = '';
if(isset($plugin['endtime'])) $plugin['endtime'] = 0; $data['aln'] = self::get_aln();
$list[] = $plugin; $data['pro'] = 0;
} $data['pro_authorization_sn'] = '0';
$data['list'] = $list; if(!empty($data['authorization_map'])){
if($data['pro']>-1) $data['pro'] = 0; foreach($data['authorization_map'] as $code => &$plugin){
if($data['ltd']>-1) $data['ltd'] = strtotime('+1 year'); if($code != '0' && isset($plugin['end_time'])) $plugin['end_time'] = 0;
$json_file = get_data_dir().'config/plugin_list.json'; }
if(!file_put_contents($json_file, json_encode($data))){ }
throw new Exception('保存插件列表失败,文件无写入权限'); if(isset($data['expansions']['mail'])){
} $data['expansions']['mail']['total'] = 2000000;
} $data['expansions']['mail']['available'] = 2000000;
}
//获取插件列表 }else{
public static function get_plugin_list(){ $data['serverid'] = '';
$json_file = get_data_dir().'config/plugin_list.json'; $data['aln'] = self::get_aln();
if(file_exists($json_file)){ $data['beta'] = 0;
$data = file_get_contents($json_file); $data['uid'] = 1;
$json_arr = json_decode($data, true); $data['skey'] = '';
if($json_arr){ $data['pro'] = -1;
return $json_arr; $data['ltd'] = strtotime('+10 year');
} }
} foreach($data['list'] as &$plugin){
return false; if(isset($plugin['endtime'])) $plugin['endtime'] = 0;
} }
$json_file = get_data_dir($os).'config/plugin_list.json';
//获取一个插件信息 if(!file_put_contents($json_file, json_encode($data))){
public static function get_plugin_info($name){ throw new Exception('保存插件列表失败,文件无写入权限');
$json_arr = self::get_plugin_list(); }
if(!$json_arr) return null; }
foreach($json_arr['list'] as $plugin){
if($plugin['name'] == $name){ //多账号数量
return $plugin; private static function get_aln($count = '9999'){
} $key = 'FB8upo8XMgP5by54';
} $iv = 'lOrrq3lNEURZNdK7';
return null; return openssl_encrypt($count, 'aes-128-cbc', $key, 0, $iv);
} }
//下载插件(自动判断是否第三方) //获取插件列表
public static function download_plugin($plugin_name, $version){ public static function get_plugin_list($os = 'Linux'){
$plugin_info = Plugins::get_plugin_info($plugin_name); $json_file = get_data_dir($os).'config/plugin_list.json';
if(!$plugin_info) throw new Exception('未找到该插件信息'); if(file_exists($json_file)){
if($plugin_info['type'] == 10 && isset($plugin_info['versions'][0]['download'])){ $data = file_get_contents($json_file);
$fname = $plugin_info['versions'][0]['download']; $json_arr = json_decode($data, true);
$filemd5 = $plugin_info['versions'][0]['md5']; if($json_arr){
Plugins::download_plugin_other($fname, $filemd5); return $json_arr;
if(isset($plugin_info['min_image']) && strpos($plugin_info['min_image'], 'fname=')){ }
$fname = substr($plugin_info['min_image'], strpos($plugin_info['min_image'], '?fname=')+7); }
Plugins::download_plugin_other($fname); return false;
} }
}else{
Plugins::download_plugin_package($plugin_name, $version); //获取一个插件信息
} public static function get_plugin_info($name, $os = 'Linux'){
} $json_arr = self::get_plugin_list($os);
if(!$json_arr) return null;
//下载插件包 foreach($json_arr['list'] as $plugin){
public static function download_plugin_package($plugin_name, $version){ if($plugin['name'] == $name){
$filepath = get_data_dir().'plugins/package/'.$plugin_name.'-'.$version.'.zip'; return $plugin;
$btapi = self::get_btapi(); }
$result = $btapi->get_plugin_filename($plugin_name, $version); }
if($result && isset($result['status'])){ return null;
if($result['status'] == true){ }
$filename = $result['filename'];
self::download_file($btapi, $filename, $filepath); //下载插件(自动判断是否第三方)
if(file_exists($filepath)){ public static function download_plugin($plugin_name, $version, $os = 'Linux'){
$zip = new ZipArchive; $plugin_info = Plugins::get_plugin_info($plugin_name, $os);
if ($zip->open($filepath) === true) if(!$plugin_info) throw new Exception('未找到该插件信息');
{ $btapi = self::get_btapi($os);
$zip->extractTo(get_data_dir().'plugins/folder/'.$plugin_name.'-'.$version); $btapi->download_plugin($plugin_name, $version, $plugin_info);
$zip->close(); }
$main_filepath = get_data_dir().'plugins/folder/'.$plugin_name.'-'.$version.'/'.$plugin_name.'/'.$plugin_name.'_main.py';
if(file_exists($main_filepath) && filesize($main_filepath)>10){ //下载插件主程序文件
if(!strpos(file_get_contents($main_filepath), 'import ')){ //加密py文件需要解密 public static function download_plugin_main($plugin_name, $version, $os = 'Linux'){
self::decode_plugin_main($plugin_name, $version, $main_filepath); $btapi = self::get_btapi($os);
$zip->open($filepath, ZipArchive::CREATE); $btapi->download_plugin_main($plugin_name, $version);
$zip->addFile($main_filepath, $plugin_name.'/'.$plugin_name.'_main.py'); }
$zip->close();
} //本地解密插件主程序文件
} public static function decode_plugin_main_local($main_filepath, $os = 'Linux'){
}else{ $btapi = new BtPlugins($os);
throw new Exception('插件包解压缩失败'); return $btapi->decode_plugin_main_local($main_filepath);
} }
return true;
}else{ //本地解密模块文件
throw new Exception('下载插件包失败,本地文件不存在'); public static function decode_module_file($filepath){
} $src = file_get_contents($filepath);
}else{ if($src===false)throw new Exception('文件打开失败');
throw new Exception('下载插件包失败:'.($result['msg']?$result['msg']:'未知错误')); if(!$src || strpos($src, 'import ')!==false)return 0;
} $key = 'Z2B87NEAS2BkxTrh';
}else{ $iv = 'WwadH66EGWpeeTT6';
throw new Exception('下载插件包失败,接口返回错误'); $data_arr = explode("\n", $src);
} $de_text = '';
} foreach($data_arr as $data){
$data = trim($data);
//下载插件主程序文件 if(!empty($data)){
public static function download_plugin_main($plugin_name, $version){ $tmp = openssl_decrypt($data, 'aes-128-cbc', $key, 0, $iv);
$filepath = get_data_dir().'plugins/main/'.$plugin_name.'-'.$version.'.dat'; if($tmp !== false) $de_text .= $tmp;
$btapi = self::get_btapi(); }
$result = $btapi->get_plugin_main_filename($plugin_name, $version); }
if($result && isset($result['status'])){ if(!empty($de_text) && strpos($de_text, 'import ')!==false){
if($result['status'] == true){ file_put_contents($filepath, $de_text);
$filename = $result['filename']; return 1;
self::download_file($btapi, $filename, $filepath); }
if(file_exists($filepath)){ return 2;
return true; }
}else{
throw new Exception('下载插件主程序文件失败,本地文件不存在'); //刷新一键部署列表
} public static function refresh_deplist($os = 'Linux'){
}else{ $btapi = self::get_btapi($os);
throw new Exception('下载插件主程序文件失败:'.($result['msg']?$result['msg']:'未知错误')); $result = $btapi->get_deplist();
} $json_file = get_data_dir($os).'config/deployment_list.json';
}else{ if(!file_put_contents($json_file, json_encode($result))){
throw new Exception('下载插件主程序文件失败,接口返回错误'); throw new Exception('保存一键部署列表失败,文件无写入权限');
} }
} }
//解密并下载插件主程序文件 //获取一键部署列表
public static function decode_plugin_main($plugin_name, $version, $main_filepath){ public static function get_deplist($os = 'Linux'){
$btapi = self::get_btapi(); $json_file = get_data_dir($os).'config/deployment_list.json';
$result = $btapi->get_decode_plugin_main($plugin_name, $version); if(file_exists($json_file)){
if($result && isset($result['status'])){ $data = file_get_contents($json_file);
if($result['status'] == true){ $json_arr = json_decode($data, true);
$filename = $result['filename']; if($json_arr){
self::download_file($btapi, $filename, $main_filepath); return $json_arr;
return true; }
}else{ }
throw new Exception('解密插件主程序文件失败:'.($result['msg']?$result['msg']:'未知错误')); return false;
} }
}else{
throw new Exception('解密插件主程序文件失败,接口返回错误'); //获取蜘蛛IP列表
} public static function btwaf_getspiders(){
} $result = cache('btwaf_getspiders');
if($result){
//下载插件其他文件 return $result;
public static function download_plugin_other($fname, $filemd5 = null){ }
$filepath = get_data_dir().'plugins/other/'.$fname; $btapi = self::get_btapi('Linux');
@mkdir(dirname($filepath), 0777, true); $result = $btapi->btwaf_getspiders();
$btapi = self::get_btapi(); cache('btwaf_getspiders', $result, 3600 * 24 * 3);
$result = $btapi->get_plugin_other_filename($fname); return $result;
if($result && isset($result['status'])){ }
if($result['status'] == true){
$filename = $result['filename']; //分类获取蜘蛛IP列表
self::download_file($btapi, $filename, $filepath); public static function get_spider($type){
if(file_exists($filepath)){ $result = cache('get_spider_'.$type);
if($filemd5 && md5_file($filepath) != $filemd5){ if($result){
unlink($filepath); return $result;
throw new Exception('插件文件MD5校验失败'); }
} $url = 'https://www.bt.cn/api/panel/get_spider?spider='.$type;
return true; $data = get_curl($url);
}else{ $result = json_decode($data, true);
throw new Exception('下载插件文件失败,本地文件不存在'); if(!$result) return [];
} cache('get_spider_'.$type, $result, 3600 * 24);
}else{ return $result;
throw new Exception('下载插件文件失败:'.($result['msg']?$result['msg']:'未知错误')); }
}
}else{ //获取堡塔恶意情报IP库
throw new Exception('下载插件文件失败,接口返回错误'); public static function btwaf_getmalicious(){
} $btapi = self::get_btapi('Linux');
} $result = $btapi->btwaf_getmalicious();
return $result;
//下载文件 }
private static function download_file($btapi, $filename, $filepath){
try{ //加密插件列表
$btapi->download($filename, $filepath); public static function encrypt_plugin_list($list, $server_id, $uid){
}catch(Exception $e){ $data = json_encode($list);
unlink($filepath); $block_size = 51200;
//宝塔bug小文件下载失败改用base64下载 $key = md5(substr($server_id, 10, 16) . $uid . $server_id);
$result = $btapi->get_file($filename); $iv = md5($key . $server_id);
if($result && isset($result['status']) && $result['status']==true){ $key = substr($key, 8, 16);
$filedata = base64_decode($result['data']); $iv = substr($iv, 8, 16);
if(strlen($filedata) < 4096 && substr($filedata,0,1)=='{' && substr($filedata,-1,1)=='}'){ $encrypted_content = '';
$arr = json_decode($filedata, true); foreach (str_split($data, $block_size) as $block) {
if($arr){ $encrypted_content .= openssl_encrypt($block, 'aes-128-cbc', $key, 0, $iv) . "\n";
throw new Exception('获取文件失败:'.($arr['msg']?$arr['msg']:'未知错误')); }
} return $encrypted_content;
} }
if(!$filedata){
throw new Exception('获取文件失败:文件内容为空');
}
file_put_contents($filepath, $filedata);
}elseif($result){
throw new Exception('获取文件失败:'.($result['msg']?$result['msg']:'未知错误'));
}else{
throw new Exception('获取文件失败:未知错误');
}
}
}
} }

226
app/lib/ThirdPlugins.php Normal file
View File

@ -0,0 +1,226 @@
<?php
namespace app\lib;
use Exception;
use ZipArchive;
class ThirdPlugins
{
private $url;
private $os;
public function __construct($os)
{
$this->os = $os;
if($os == 'en'){
$url = config_get('enbt_surl');
}elseif($os == 'Windows'){
$url = config_get('wbt_surl');
}else{
$url = config_get('bt_surl');
}
if(!$url) throw new Exception('请先配置好第三方云端首页URL');
$this->url = $url;
}
//获取插件列表
public function get_plugin_list()
{
if($this->os == 'en'){
$url = $this->url . 'api/panel/getSoftListEn';
}elseif($this->os == 'Windows'){
$url = $this->url . 'api/wpanel/get_soft_list';
}else{
$url = $this->url . 'api/panel/get_soft_list';
}
$res = $this->curl($url);
$result = json_decode($res, true);
if($result && isset($result['list']) && isset($result['type'])){
if(empty($result['list']) || empty($result['type'])){
throw new Exception('获取插件列表失败:插件列表为空');
}
return $result;
}else{
throw new Exception('获取插件列表失败:'.(isset($result['msg'])?$result['msg']:'第三方云端连接失败'));
}
}
//下载插件(自动判断是否第三方)
public function download_plugin($plugin_name, $version, $plugin_info){
if($plugin_info['type'] == 10 && isset($plugin_info['versions'][0]['download'])){
$fname = $plugin_info['versions'][0]['download'];
$filemd5 = $plugin_info['versions'][0]['md5'];
$this->download_plugin_other($fname, $filemd5);
if(isset($plugin_info['min_image']) && strpos($plugin_info['min_image'], 'fname=')){
$fname = substr($plugin_info['min_image'], strpos($plugin_info['min_image'], '?fname=')+7);
$this->download_plugin_other($fname);
}
}else{
$this->download_plugin_package($plugin_name, $version);
}
}
//下载插件包
private function download_plugin_package($plugin_name, $version){
$filepath = get_data_dir($this->os).'plugins/package/'.$plugin_name.'-'.$version.'.zip';
$url = $this->url . 'down/download_plugin';
$post = ['name'=>$plugin_name, 'version'=>$version, 'os'=>$this->os];
$this->curl_download($url, $post, $filepath);
if(file_exists($filepath)){
$handle = fopen($filepath, "rb");
$file_head = fread($handle, 4);
fclose($handle);
if(bin2hex($file_head) === '504b0304'){
$zip = new ZipArchive;
if ($zip->open($filepath) === true)
{
$zip->close();
return true;
}else{
@unlink($filepath);
throw new Exception('插件包解压缩失败');
}
}else{
$handle = fopen($filepath, "rb");
$errmsg = htmlspecialchars(fgets($handle));
fclose($handle);
@unlink($filepath);
throw new Exception('下载插件包失败:'.($errmsg?$errmsg:'未知错误'));
}
}else{
throw new Exception('下载插件包失败,本地文件不存在');
}
}
//下载插件主程序文件
public function download_plugin_main($plugin_name, $version){
$filepath = get_data_dir($this->os).'plugins/main/'.$plugin_name.'-'.$version.'.dat';
$url = $this->url . 'down/download_plugin_main';
$post = ['name'=>$plugin_name, 'version'=>$version, 'os'=>$this->os];
$this->curl_download($url, $post, $filepath);
if(file_exists($filepath)){
$line = count(file($filepath));
if($line > 3) return true;
$handle = fopen($filepath, "rb");
$errmsg = htmlspecialchars(fgets($handle));
fclose($handle);
@unlink($filepath);
throw new Exception('下载插件主程序文件失败:'.($errmsg?$errmsg:'未知错误'));
}else{
throw new Exception('下载插件主程序文件失败,本地文件不存在');
}
}
//下载插件其他文件
private function download_plugin_other($fname, $filemd5 = null){
$filepath = get_data_dir().'plugins/other/'.$fname;
@mkdir(dirname($filepath), 0777, true);
$url = $this->url . 'api/Pluginother/get_file?fname='.urlencode($fname);
$this->curl_download($url, false, $filepath);
if(file_exists($filepath)){
$handle = fopen($filepath, "rb");
$file_head = fread($handle, 15);
fclose($handle);
if($file_head === '{"status":false'){
$res = file_get_contents($filepath);
$result = json_decode($res, true);
@unlink($filepath);
throw new Exception('下载插件文件失败:'.($result?$result['msg']:'未知错误'));
}
if($filemd5 && md5_file($filepath) != $filemd5){
$msg = filesize($filepath) < 300 ? file_get_contents($filepath) : '插件文件MD5校验失败';
@unlink($filepath);
throw new Exception($msg);
}
return true;
}else{
throw new Exception('下载插件文件失败,本地文件不存在');
}
}
//获取一键部署列表
public function get_deplist(){
$url = $this->url . 'api/panel/get_deplist';
$post = ['os' => $this->os];
$res = $this->curl($url, http_build_query($post));
$result = json_decode($res, true);
if($result && isset($result['list']) && isset($result['type'])){
if(empty($result['list']) || empty($result['type'])){
throw new Exception('获取一键部署列表失败:一键部署列表为空');
}
return $result;
}else{
throw new Exception('获取一键部署列表失败:'.(isset($result['msg'])?$result['msg']:'第三方云端连接失败'));
}
}
//获取蜘蛛IP列表
public function btwaf_getspiders(){
$url = $this->url . 'api/bt_waf/getSpiders';
$res = $this->curl($url);
$result = json_decode($res, true);
if(isset($result['status']) && !$result['status']){
throw new Exception(isset($result['msg'])?$result['msg']:'获取失败');
}else{
return $result;
}
}
//获取堡塔恶意情报IP库
public function btwaf_getmalicious(){
$url = $this->url . 'api/bt_waf/get_malicious';
$res = $this->curl($url);
$result = json_decode($res, true);
if(isset($result['success'])){
return $result;
}else{
throw new Exception(isset($result['res'])?$result['res']:'获取失败');
}
}
private function curl($url, $post = 0){
$ua = "Mozilla/5.0 (BtCloud; ".request()->root(true).")";
return get_curl($url, $post, 0, 0, 0, $ua);
}
private function curl_download($url, $post, $localpath, $timeout = 300)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$fp = fopen($localpath, 'w+');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (BtCloud; ".request()->root(true).")");
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_exec($ch);
if (curl_errno($ch)) {
$message = curl_error($ch);
curl_close($ch);
fclose($fp);
throw new Exception('下载文件失败:'.$message);
}
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpcode>299){
curl_close($ch);
fclose($fp);
throw new Exception('下载文件失败HTTPCODE-'.$httpcode);
}
curl_close($ch);
fclose($fp);
return true;
}
}

1
app/lib/cn.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,24 +1,26 @@
<?php <?php
declare (strict_types=1); declare (strict_types=1);
namespace app\middleware; namespace app\middleware;
class AuthAdmin class AuthAdmin
{ {
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
$islogin = false; $islogin = false;
$cookie = cookie('admin_token'); $cookie = cookie('admin_token');
if($cookie){ if($cookie){
$token=authcode($cookie, 'DECODE', config_get('syskey')); $token=authcode($cookie, 'DECODE', config_get('syskey'));
list($user, $sid, $expiretime) = explode("\t", $token); if($token){
$session=md5(config_get('admin_username').config_get('admin_password')); list($user, $sid, $expiretime) = explode("\t", $token);
if($session==$sid && $expiretime>time()) { $session=md5(config_get('admin_username').config_get('admin_password'));
$islogin = true; if($session==$sid && $expiretime>time()) {
} $islogin = true;
} }
request()->islogin = $islogin; }
return $next($request); }
} request()->islogin = $islogin;
} return $next($request);
}
}

View File

@ -1,19 +1,19 @@
<?php <?php
declare (strict_types=1); declare (strict_types=1);
namespace app\middleware; namespace app\middleware;
class CheckAdmin class CheckAdmin
{ {
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
if (!request()->islogin) { if (!request()->islogin) {
if ($request->isAjax() || !$request->isGet()) { if ($request->isAjax() || !$request->isGet()) {
return json(['code'=>-1, 'msg'=>'未登录'])->code(401); return json(['code'=>-1, 'msg'=>'未登录'])->code(401);
} }
return redirect((string)url('/admin/login')); return redirect((string)url('/admin/login'));
} }
return $next($request); return $next($request);
} }
} }

View File

@ -5,6 +5,7 @@ namespace app\middleware;
use think\facade\Db; use think\facade\Db;
use think\facade\Config; use think\facade\Config;
use think\facade\View;
class LoadConfig class LoadConfig
{ {
@ -17,10 +18,21 @@ class LoadConfig
*/ */
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
if (!file_exists(app()->getRootPath().'.env')){
if(strpos(request()->url(),'/installapp')===false){
return redirect((string)url('/installapp'))->header([
'Cache-Control' => 'no-store, no-cache, must-revalidate',
'Pragma' => 'no-cache',
]);
}else{
return $next($request);
}
}
$res = Db::name('config')->cache('configs',0)->column('value','key'); $res = Db::name('config')->cache('configs',0)->column('value','key');
Config::set($res, 'sys'); Config::set($res, 'sys');
View::assign('cdnpublic', 'https://s4.zstatic.net/ajax/libs/');
return $next($request)->header([ return $next($request)->header([
'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Cache-Control' => 'no-store, no-cache, must-revalidate',
'Pragma' => 'no-cache', 'Pragma' => 'no-cache',

View File

@ -1,24 +1,24 @@
<?php <?php
declare (strict_types=1); declare (strict_types=1);
namespace app\middleware; namespace app\middleware;
use think\facade\View; use think\facade\View;
class RefererCheck class RefererCheck
{ {
/** /**
* 处理请求 * 处理请求
* *
* @param \think\Request $request * @param \think\Request $request
* @param \Closure $next * @param \Closure $next
* @return Response * @return Response
*/ */
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
if(!checkRefererHost()){ if(!checkRefererHost()){
return response('Access Denied', 403); return response('Access Denied', 403);
} }
return $next($request); return $next($request);
} }
} }

31
app/script/cacert.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
OPENSSL_CHECK=$(which openssl)
if [ "$?" != "0" ]; then
echo "未安装OpenSSL"
exit 1
fi
if [ ! -f ca.key ] && [ ! -f ca.crt ]; then
openssl genrsa -out ca.key 2048
openssl req -new -x509 -utf8 -days 3650 -extensions v3_ca -subj "/C=CN/O=宝塔面板/CN=宝塔面板" -key ca.key -out ca.crt
fi
openssl genrsa -out server.key 2048
openssl req -new -nodes -key server.key -subj "/C=CN/O=BTPanel/CN=BTPanel" -out server.csr
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -extensions req_ext
cat ca.crt >> server.crt
openssl pkcs12 -export -out baota_root.pfx -inkey server.key -in server.crt -password pass:
if [ "$?" != "0" ]; then
echo "生成CA根证书失败"
exit 1
fi
mkdir -p ../../public/ssl
\cp baota_root.pfx ../../public/ssl/baota_root.pfx
\cp ca.crt ../../public/ssl/baota_root.crt
rm -f server.crt server.key server.csr
echo "生成CA根证书成功"

88
app/script/convert.sh Normal file
View File

@ -0,0 +1,88 @@
#!/bin/bash
Linux_Version="11.5.0"
Windows_Version="8.2.2"
Aapanel_Version="7.0.25"
Btm_Version="2.3.3"
FILES=(
public/install/src/panel6.zip
public/install/update/LinuxPanel-${Linux_Version}.zip
public/install/install_panel.sh
public/install/update_panel.sh
public/install/update6.sh
public/win/install/panel_update.py
public/win/panel/data/setup.py
public/install/src/bt-monitor-${Btm_Version}.zip
public/install/install_btmonitor.sh
public/install/update_btmonitor.sh
public/install/src/panel_7_en.zip
public/install/update/LinuxPanel_EN-${Aapanel_Version}.zip
public/install/install_7.0_en.sh
public/install/update_7.x_en.sh
)
PL_FILE="public/install/update/LinuxPanel-${Linux_Version}.pl"
DIR=$1
SITEURL=$2
if [ ! -d "$DIR" ]; then
echo "网站目录不存在"
exit 1
fi
if [ "$SITEURL" = "" ]; then
echo "网站URL不正确"
exit 1
fi
function handleFile()
{
Filename=$1
if [ "${Filename##*.}" = "zip" ]; then
handleZipFile $Filename
else
handleTextFile $Filename
fi
}
function handleZipFile()
{
Filename=$1
mkdir -p /tmp/package
unzip -o -q $Filename -d /tmp/package
grep -rl --include=\*.py --include=\*.sh --include=index.js 'http://www.example.com' /tmp/package | xargs -I @ sed -i "s|http://www.example.com|${SITEURL}|g" @
Sprit_SITEURK=${SITEURL//\//\\\\\/}
grep -rl --include=\*.sh 'http:\\\/\\\/www.example.com' /tmp/package | xargs -I @ sed -i "s|http:\\\/\\\/www.example.com|${Sprit_SITEURK}|g" @
rm -f $Filename
cd /tmp/package && zip -9 -q -r $Filename * && cd -
rm -rf /tmp/package
}
function handleTextFile()
{
sed -i "s|http://www.example.com|${SITEURL}|g" $1
}
echo "=========================="
echo "正在处理中..."
echo "=========================="
for File in ${FILES[@]}
do
Filename="${DIR}${File}"
if [ -f "$Filename" ]; then
handleFile $Filename
echo -e "成功处理文件:\033[32m${Filename}\033[0m"
else
echo -e "文件不存在:\033[33m${Filename}\033[0m"
fi
done
HASH=$(sha256sum "${DIR}public/install/update/LinuxPanel-${Linux_Version}.zip" | awk '{print $1}')
TIMESTAMP=$(date +%s)
printf '{"hash": "%s", "update_time": "%s"}' "$HASH" "$TIMESTAMP" > "${DIR}${PL_FILE}"
echo "=========================="
echo "处理完成"
echo "=========================="

View 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="{$cdnpublic}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}

View File

@ -1,59 +1,60 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}宝塔第三方云端管理中心{/block} {block name="title"}宝塔第三方云端管理中心{/block}
{block name="main"} {block name="main"}
<style> <style>
.query-title { .table>tbody>tr>td{white-space: normal;}
background-color:#f5fafe; .query-title {
word-break: keep-all; background-color:#f5fafe;
} word-break: keep-all;
.query-result{ }
word-break: break-all; .query-result{
} word-break: break-all;
</style> }
<div class="container" style="padding-top:70px;"> </style>
<div class="col-xs-12 col-sm-10 col-md-8 center-block" style="float: none;"> <div class="container" style="padding-top:70px;">
<div class="panel panel-primary"> <div class="col-xs-12 col-sm-10 col-md-8 center-block" style="float: none;">
<div class="panel-heading"><h3 class="panel-title">后台管理首页</h3></div> <div class="panel panel-primary">
<div class="list-group"> <div class="panel-heading"><h3 class="panel-title">后台管理首页</h3></div>
<div class="list-group-item"><span class="glyphicon glyphicon-stats"></span> <b>宝塔插件统计:</b>共有 {$stat.total} 个,其中免费插件 {$stat.free} 个,专业版插件 {$stat.pro} 个,企业版插件 {$stat.ltd} 个,第三方插件 {$stat.third} 个</div> <div class="list-group">
<div class="list-group-item"><span class="glyphicon glyphicon-tint"></span> <b>使用记录统计:</b>历史总共数量:{$stat.record_total},正在使用数量:{$stat.record_isuse}</div> <div class="list-group-item"><span class="glyphicon glyphicon-stats"></span> <b>宝塔插件统计:</b>共有 {$stat.total} 个,其中免费插件 {$stat.free} 个,专业版插件 {$stat.pro} 个,企业版插件 {$stat.ltd} 个,第三方插件 {$stat.third} 个</div>
<div class="list-group-item"><span class="glyphicon glyphicon-time"></span> <b>任务运行情况:</b>上次运行时间:{$stat.runtime|raw}&nbsp;&nbsp;<a href="/admin/set/mod/task" class="btn btn-xs btn-info">查看详情</a></div> <div class="list-group-item"><span class="glyphicon glyphicon-tint"></span> <b>使用记录统计:</b>历史总共数量:{$stat.record_total},正在使用数量:{$stat.record_isuse}</div>
<div class="list-group-item"><span class="glyphicon glyphicon-cog"></span> <b>常用功能入口:</b><a href="/admin/plugins" class="btn btn-xs btn-default">插件列表</a>&nbsp;<a href="/admin/record" class="btn btn-xs btn-default">使用记录</a>&nbsp;<a href="/admin/black" class="btn btn-xs btn-default">黑白名单</a>&nbsp;<a href="/download" class="btn btn-xs btn-default" target="_blank">安装脚本</a></div> <div class="list-group-item"><span class="glyphicon glyphicon-time"></span> <b>任务运行情况:</b>上次运行时间:{$stat.runtime|raw}&nbsp;&nbsp;<a href="/admin/set/mod/task" class="btn btn-xs btn-info">查看详情</a></div>
</div> <div class="list-group-item"><span class="glyphicon glyphicon-cog"></span> <b>常用功能入口:</b><a href="/admin/plugins" class="btn btn-xs btn-default">插件列表</a>&nbsp;<a href="/admin/record" class="btn btn-xs btn-default">使用记录</a>&nbsp;<a href="/admin/list" class="btn btn-xs btn-default">黑白名单</a>&nbsp;<a href="/download" class="btn btn-xs btn-default" target="_blank">安装脚本</a></div>
</div> </div>
<div class="panel panel-info"> </div>
<div class="panel-heading"> <div class="panel panel-info">
<h3 class="panel-title">服务器信息</h3> <div class="panel-heading">
</div> <h3 class="panel-title">服务器信息</h3>
<table class="table table-bordered"> </div>
<tbody> <table class="table table-bordered">
<tr> <tbody>
<td class="query-title">框架版本</td> <tr>
<td class="query-result">{$info.framework_version}</td> <td class="query-title">框架版本</td>
</tr> <td class="query-result">{$info.framework_version}</td>
<tr> </tr>
<td class="query-title">PHP版本</td> <tr>
<td class="query-result">{$info.php_version}</td> <td class="query-title">PHP版本</td>
</tr> <td class="query-result">{$info.php_version}</td>
<tr> </tr>
<td class="query-title">MySQL版本</td> <tr>
<td class="query-result">{$info.mysql_version}</td> <td class="query-title">MySQL版本</td>
</tr> <td class="query-result">{$info.mysql_version}</td>
<tr> </tr>
<td class="query-title">WEB软件</td> <tr>
<td class="query-result">{$info.software}</td> <td class="query-title">WEB软件</td>
</tr> <td class="query-result">{$info.software}</td>
<tr> </tr>
<td class="query-title">操作系统</td> <tr>
<td class="query-result">{$info.os}</td> <td class="query-title">操作系统</td>
</tr> <td class="query-result">{$info.os}</td>
<tr> </tr>
<td class="query-title">服务器时间</td> <tr>
<td class="query-result">{$info.date}</td> <td class="query-title">服务器时间</td>
</tr> <td class="query-result">{$info.date}</td>
</tbody> </tr>
</table> </tbody>
</div> </table>
</div> </div>
</div> </div>
</div>
{/block} {/block}

View File

@ -1,67 +1,78 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-cn"> <html lang="zh-cn">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>{block name="title"}标题{/block}</title> <title>{block name="title"}标题{/block}</title>
<link href="//cdn.staticfile.org/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" /> <link href="{$cdnpublic}twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" />
<link href="//cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> <link href="{$cdnpublic}font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="/static/css/bootstrap-table.css" rel="stylesheet" /> <link href="/static/css/bootstrap-table.css" rel="stylesheet" />
<script src="//cdn.staticfile.org/modernizr/2.8.3/modernizr.min.js"></script> <script src="{$cdnpublic}modernizr/2.8.3/modernizr.min.js"></script>
<script src="//cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script> <script src="{$cdnpublic}jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.staticfile.org/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="{$cdnpublic}twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="//cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="{$cdnpublic}html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <script src="{$cdnpublic}respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
</head> </head>
<body> <body>
<nav class="navbar navbar-fixed-top navbar-default"> <nav class="navbar navbar-fixed-top navbar-default">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar"> aria-expanded="false" aria-controls="navbar">
<span class="sr-only">导航按钮</span> <span class="sr-only">导航按钮</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="./">宝塔第三方云端管理中心</a> <a class="navbar-brand" href="/admin">宝塔第三方云端管理中心</a>
</div><!-- /.navbar-header --> </div><!-- /.navbar-header -->
<div id="navbar" class="collapse navbar-collapse"> <div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="{:checkIfActive('index')}"> <li class="{:checkIfActive('index')}">
<a href="/admin"><i class="fa fa-home"></i> 后台首页</a> <a href="/admin"><i class="fa fa-home"></i> 后台首页</a>
</li> </li>
<li class="{:checkIfActive('plugins')}"> <li class="{:checkIfActive('plugins,pluginswin,pluginsen,deplist')}">
<a href="/admin/plugins"><i class="fa fa-cubes"></i> 插件列表</a> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cubes"></i> 插件列表<b class="caret"></b></a>
</li> <ul class="dropdown-menu">
<li class="{:checkIfActive('record')}"> <li class="{:checkIfActive('plugins')}"><a href="/admin/plugins">Linux面板</a></li>
<a href="/admin/record"><i class="fa fa-list"></i> 使用记录</a> <li class="{:checkIfActive('pluginswin')}"><a href="/admin/pluginswin">Windows面板</a></li>
</li> <li class="{:checkIfActive('pluginsen')}"><a href="/admin/pluginsen">aaPanel面板</a></li>
<li class="{:checkIfActive('list')}"> <li class="{:checkIfActive('deplist')}"><a href="/admin/deplist">一键部署列表</a></li>
<a href="/admin/list"><i class="fa fa-globe"></i> 黑白名单</a> </ul>
</li> </li>
<li class="{:checkIfActive('log')}"> <li class="{:checkIfActive('record')}">
<a href="/admin/log"><i class="fa fa-calendar"></i> 操作日志</a> <a href="/admin/record"><i class="fa fa-list"></i> 使用记录</a>
</li> </li>
<li class="{:checkIfActive('set')}"> <li class="{:checkIfActive('list')}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"></i> 系统设置<b <a href="/admin/list"><i class="fa fa-globe"></i> 黑白名单</a>
class="caret"></b></a> </li>
<ul class="dropdown-menu"> <li class="{:checkIfActive('log')}">
<li><a href="/admin/set">系统基本设置</a></li> <a href="/admin/log"><i class="fa fa-calendar"></i> 操作日志</a>
<li><a href="/admin/set/mod/task">定时任务设置</a></li> </li>
<li><a href="/admin/set/mod/account">管理账号设置</a></li> <li class="{:checkIfActive('ssl')}">
</ul> <a href="/admin/ssl"><i class="fa fa-expeditedssl"></i> 自签SSL</a>
</li> </li>
<li> <li class="{:checkIfActive('set')}">
<a href="/admin/logout" onclick="return confirm('确定退出登录吗?')"><i class="fa fa-power-off"></i> 退出登录</a> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"></i> 系统设置<b
</li> class="caret"></b></a>
</ul> <ul class="dropdown-menu">
</div><!-- /.navbar-collapse --> <li><a href="/admin/set">软件版本设置</a></li>
</div><!-- /.container --> <li><a href="/admin/set/mod/api">面板接口设置</a></li>
</nav><!-- /.navbar --> <li><a href="/admin/set/mod/task">自动更新插件设置</a></li>
{block name="main"}主内容{/block} <li><a href="/admin/set/mod/tools">替换与清理工具</a></li>
</body> <li><a href="/admin/set/mod/account">管理账号设置</a></li>
</ul>
</li>
<li>
<a href="/admin/logout" onclick="return confirm('确定退出登录吗?')"><i class="fa fa-power-off"></i> 退出登录</a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav><!-- /.navbar -->
{block name="main"}主内容{/block}
</body>
</html> </html>

View File

@ -1,209 +1,209 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}黑白名单{/block} {block name="title"}黑白名单{/block}
{block name="main"} {block name="main"}
<style> <style>
.alert{margin-bottom: 5px;} .alert{margin-bottom: 5px;}
</style> </style>
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 col-md-10 center-block" style="float: none;"> <div class="col-xs-12 col-md-10 center-block" style="float: none;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="{if $type=='black'}active{/if}"><a href="/admin/list">黑名单列表</a></li><li class="{if $type=='white'}active{/if}"><a href="/admin/list/type/white">白名单列表</a></li> <li class="{if $type=='black'}active{/if}"><a href="/admin/list">黑名单列表</a></li><li class="{if $type=='white'}active{/if}"><a href="/admin/list/type/white">白名单列表</a></li>
</ul> </ul>
{if $type=='black' && config_get('whitelist')=='1'} {if $type=='black' && config_get('whitelist')=='1'}
<div class="alert alert-warning">提示:当前为白名单模式,黑名单列表里面的记录不会生效。</div> <div class="alert alert-warning">提示:当前为白名单模式,黑名单列表里面的记录不会生效。</div>
{/if} {/if}
{if $type=='white' && config_get('whitelist')=='0'} {if $type=='white' && config_get('whitelist')=='0'}
<div class="alert alert-warning">提示:当前未开启白名单模式,白名单列表里面的记录不会生效。</div> <div class="alert alert-warning">提示:当前未开启白名单模式,白名单列表里面的记录不会生效。</div>
{/if} {/if}
{if $type=='black'} {if $type=='black'}
<div class="alert alert-info">添加到黑名单列表中的服务器IP将无法使用此云端</div> <div class="alert alert-info">添加到黑名单列表中的服务器IP将无法使用此云端</div>
{/if} {/if}
{if $type=='white'} {if $type=='white'}
<div class="alert alert-info">只有添加到白名单列表中的服务器IP才可以使用此云端</div> <div class="alert alert-info">只有添加到白名单列表中的服务器IP才可以使用此云端</div>
{/if} {/if}
<div id="searchToolbar"> <div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline"> <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group"> <div class="form-group">
<label>搜索</label> <label>搜索</label>
<input type="text" class="form-control" name="ip" placeholder="服务器IP"> <input type="text" class="form-control" name="ip" placeholder="服务器IP">
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>搜索</button>&nbsp; <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i>重置</a>&nbsp; <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
<a href="javascript:add_item()" class="btn btn-success"><i class="fa fa-plus"></i>添加</a>&nbsp; <a href="javascript:add_item()" class="btn btn-success"><i class="fa fa-plus"></i> 添加</a>&nbsp;
</div> </div>
</form> </form>
</div> </div>
<table id="listTable"> <table id="listTable">
</table> </table>
</div> </div>
</div> </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/bootstrap-table.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script src="/static/js/custom.js"></script> <script src="/static/js/custom.js"></script>
<script> <script>
function setEnable(id,enable) { function setEnable(id,enable) {
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : '/admin/list_op/type/{$type}', url : '/admin/list_op/type/{$type}',
data: { act:'enable', id:id, enable:enable}, data: { act:'enable', id:id, enable:enable},
dataType : 'json', dataType : 'json',
success : function(data) { success : function(data) {
if(data.code == 0){ if(data.code == 0){
searchSubmit(); searchSubmit();
}else{ }else{
layer.msg(data.msg, {icon:2, time:1500}); layer.msg(data.msg, {icon:2, time:1500});
} }
}, },
error:function(data){ error:function(data){
layer.msg('服务器错误'); layer.msg('服务器错误');
} }
}); });
} }
function add_item(){ function add_item(){
layer.open({ layer.open({
area: ['360px'], area: ['360px'],
title: '添加IP{$typename}', title: '添加IP{$typename}',
content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value=""></div>', content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value=""></div>',
yes: function(){ yes: function(){
var ip = $("input[name='item_input']").val(); var ip = $("input[name='item_input']").val();
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : '/admin/list_op/type/{$type}', url : '/admin/list_op/type/{$type}',
data: { act:'add', ip:ip}, data: { act:'add', ip:ip},
dataType : 'json', dataType : 'json',
success : function(data) { success : function(data) {
if(data.code == 0){ if(data.code == 0){
layer.msg('添加成功', {icon:1, time:800}); layer.msg('添加成功', {icon:1, time:800});
searchSubmit(); searchSubmit();
}else{ }else{
layer.alert(data.msg, {icon: 2}); layer.alert(data.msg, {icon: 2});
} }
}, },
error:function(data){ error:function(data){
layer.msg('服务器错误'); layer.msg('服务器错误');
} }
}); });
}, },
shadeClose: true shadeClose: true
}); });
} }
function edit_item(id){ function edit_item(id){
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : '/admin/list_op/type/{$type}', url : '/admin/list_op/type/{$type}',
data: { act:'get', id:id}, data: { act:'get', id:id},
dataType : 'json', dataType : 'json',
success : function(data) { success : function(data) {
if(data.code == 0){ if(data.code == 0){
layer.open({ layer.open({
area: ['360px'], area: ['360px'],
title: '编辑IP{$typename}', title: '编辑IP{$typename}',
content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value="'+data.data.ip+'"></div>', content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value="'+data.data.ip+'"></div>',
yes: function(){ yes: function(){
var ip = $("input[name='item_input']").val(); var ip = $("input[name='item_input']").val();
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : '/admin/list_op/type/{$type}', url : '/admin/list_op/type/{$type}',
data: { act:'edit', id:id, ip:ip}, data: { act:'edit', id:id, ip:ip},
dataType : 'json', dataType : 'json',
success : function(data) { success : function(data) {
if(data.code == 0){ if(data.code == 0){
layer.msg('修改成功', {icon:1, time:800}); layer.msg('修改成功', {icon:1, time:800});
searchSubmit(); searchSubmit();
}else{ }else{
layer.alert(data.msg, {icon: 2}); layer.alert(data.msg, {icon: 2});
} }
}, },
error:function(data){ error:function(data){
layer.msg('服务器错误'); layer.msg('服务器错误');
} }
}); });
}, },
shadeClose: true shadeClose: true
}); });
}else{ }else{
layer.alert(data.msg, {icon: 2}); layer.alert(data.msg, {icon: 2});
} }
}, },
error:function(data){ error:function(data){
layer.msg('服务器错误'); layer.msg('服务器错误');
} }
}); });
} }
function del_item(id) { function del_item(id) {
if(confirm('是否确定删除此记录?')){ if(confirm('是否确定删除此记录?')){
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : '/admin/list_op/type/{$type}', url : '/admin/list_op/type/{$type}',
data: { act:'del', id:id}, data: { act:'del', id:id},
dataType : 'json', dataType : 'json',
success : function(data) { success : function(data) {
if(data.code == 0){ if(data.code == 0){
layer.msg('删除成功!', {icon:1, time:800}); layer.msg('删除成功!', {icon:1, time:800});
searchSubmit(); searchSubmit();
}else{ }else{
layer.alert(data.msg, {icon:2}); layer.alert(data.msg, {icon:2});
} }
}, },
error:function(data){ error:function(data){
layer.msg('服务器错误'); layer.msg('服务器错误');
} }
}); });
} }
} }
$(document).ready(function(){ $(document).ready(function(){
updateToolbar(); updateToolbar();
const defaultPageSize = 15; const defaultPageSize = 15;
const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1; const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize; const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize;
$("#listTable").bootstrapTable({ $("#listTable").bootstrapTable({
url: '/admin/list_data/type/{$type}', url: '/admin/list_data/type/{$type}',
pageNumber: pageNumber, pageNumber: pageNumber,
pageSize: pageSize, pageSize: pageSize,
classes: 'table table-striped table-hover table-bottom-border', classes: 'table table-striped table-hover table-bottom-border',
columns: [ columns: [
{ {
field: 'id', field: 'id',
title: 'ID', title: 'ID',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<b>'+value+'</b>'; return '<b>'+value+'</b>';
} }
}, },
{ {
field: 'ip', field: 'ip',
title: '服务器IP' title: '服务器IP'
}, },
{ {
field: 'enable', field: 'enable',
title: '是否生效', title: '是否生效',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return value?'<a href="javascript:setEnable('+row.id+',0)"><font color=green><i class="fa fa-check-circle"></i>已生效</font></a>':'<a href="javascript:setEnable('+row.id+',1)"><font color=red><i class="fa fa-times-circle"></i>未生效</font></a>'; return value?'<a href="javascript:setEnable('+row.id+',0)"><font color=green><i class="fa fa-check-circle"></i>已生效</font></a>':'<a href="javascript:setEnable('+row.id+',1)"><font color=red><i class="fa fa-times-circle"></i>未生效</font></a>';
} }
}, },
{ {
field: 'addtime', field: 'addtime',
title: '添加时间' title: '添加时间'
}, },
{ {
field: '', field: '',
title: '操作', title: '操作',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<a href="javascript:edit_item('+row.id+')" class="btn btn-xs btn-info">编辑</a>&nbsp;<a href="javascript:del_item('+row.id+')" class="btn btn-xs btn-danger">删除</a>'; return '<a href="javascript:edit_item('+row.id+')" class="btn btn-xs btn-info">编辑</a>&nbsp;<a href="javascript:del_item('+row.id+')" class="btn btn-xs btn-danger">删除</a>';
}, },
}, },
], ],
}) })
}) })
</script> </script>
{/block} {/block}

View File

@ -1,74 +1,74 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}操作日志{/block} {block name="title"}操作日志{/block}
{block name="main"} {block name="main"}
<style> <style>
</style> </style>
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 col-md-10 center-block" style="float: none;"> <div class="col-xs-12 col-md-10 center-block" style="float: none;">
<div id="searchToolbar"> <div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline"> <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group"> <div class="form-group">
<label>搜索</label> <label>搜索</label>
<input type="text" class="form-control" name="action" placeholder="操作类型"> <input type="text" class="form-control" name="action" placeholder="操作类型">
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>搜索</button>&nbsp; <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i>重置</a>&nbsp; <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
</div> </div>
</form> </form>
</div> </div>
<table id="listTable"> <table id="listTable">
</table> </table>
</div> </div>
</div> </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/bootstrap-table.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script src="/static/js/custom.js"></script> <script src="/static/js/custom.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
updateToolbar(); updateToolbar();
const defaultPageSize = 20; const defaultPageSize = 20;
const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1; const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize; const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize;
$("#listTable").bootstrapTable({ $("#listTable").bootstrapTable({
url: '/admin/log_data', url: '/admin/log_data',
pageNumber: pageNumber, pageNumber: pageNumber,
pageSize: pageSize, pageSize: pageSize,
classes: 'table table-striped table-hover table-bottom-border', classes: 'table table-striped table-hover table-bottom-border',
columns: [ columns: [
{ {
field: 'id', field: 'id',
title: 'ID', title: 'ID',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<b>'+value+'</b>'; return '<b>'+value+'</b>';
} }
}, },
{ {
field: 'uid', field: 'uid',
title: '操作人', title: '操作人',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return value==1?'<font color="green">定时任务</font>':'<font color="blue">管理员</font>'; return value==1?'<font color="green">定时任务</font>':'<font color="blue">管理员</font>';
} }
}, },
{ {
field: 'action', field: 'action',
title: '操作类型' title: '操作类型'
}, },
{ {
field: 'data', field: 'data',
title: '操作详情', title: '操作详情',
}, },
{ {
field: 'addtime', field: 'addtime',
title: '操作时间' title: '操作时间'
}, },
], ],
}) })
}) })
</script> </script>
{/block} {/block}

View File

@ -1,97 +1,100 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-cn"> <html lang="zh-cn">
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>管理员登录</title> <title>管理员登录</title>
<link href="//cdn.staticfile.org/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/> <link href="{$cdnpublic}twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="//cdn.staticfile.org/modernizr/2.8.3/modernizr.min.js"></script> <script src="{$cdnpublic}modernizr/2.8.3/modernizr.min.js"></script>
<script src="//cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script> <script src="{$cdnpublic}jquery/2.1.4/jquery.min.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="//cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="{$cdnpublic}html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <script src="{$cdnpublic}respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
</head> </head>
<body> <body>
<nav class="navbar navbar-fixed-top navbar-default"> <nav class="navbar navbar-fixed-top navbar-default">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">导航按钮</span> <span class="sr-only">导航按钮</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="./">宝塔第三方云端管理中心</a> <a class="navbar-brand" href="./">Cloud</a>
</div><!-- /.navbar-header --> </div><!-- /.navbar-header -->
<div id="navbar" class="collapse navbar-collapse"> <div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="active"> <li class="active">
<a href="./login.php"><span class="glyphicon glyphicon-user"></span> 登录</a> <a href="#"><span class="glyphicon glyphicon-user"></span> 登录</a>
</li> </li>
</ul> </ul>
</div><!-- /.navbar-collapse --> </div><!-- /.navbar-collapse -->
</div><!-- /.container --> </div><!-- /.container -->
</nav><!-- /.navbar --> </nav><!-- /.navbar -->
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-6 center-block" style="float: none;"> <div class="col-xs-12 col-sm-10 col-md-8 col-lg-6 center-block" style="float: none;">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title">管理员登录</h3></div> <div class="panel-heading"><h3 class="panel-title">管理员登录</h3></div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" role="form" onsubmit="return submitlogin()"> <form class="form-horizontal" role="form" onsubmit="return submitlogin()">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span> <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" name="user" value="" class="form-control input-lg" placeholder="用户名" required="required"/> <input type="text" name="user" value="" class="form-control input-lg" placeholder="用户名" required="required"/>
</div><br/> </div><br/>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span> <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" name="pass" class="form-control input-lg" placeholder="密码" required="required"/> <input type="password" name="pass" class="form-control input-lg" placeholder="密码" required="required"/>
</div><br/> </div><br/>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-adjust"></span></span> <span class="input-group-addon"><span class="glyphicon glyphicon-adjust"></span></span>
<input type="text" class="form-control input-lg" name="code" placeholder="输入验证码" autocomplete="off" required> <input type="text" class="form-control input-lg" name="code" placeholder="输入验证码" autocomplete="off" required>
<span class="input-group-addon" style="padding: 0"> <span class="input-group-addon" style="padding: 0">
<img src="/admin/verifycode" height="45" id="verifycode" onclick="this.src='/admin/verifycode?r='+Math.random();" title="点击更换验证码"> <img src="/admin/verifycode" height="45" id="verifycode" onclick="this.src='/admin/verifycode?r='+Math.random();" title="点击更换验证码">
</span> </span>
</div><br/> </div><br/>
<div class="form-group"> <div class="form-group">
<div class="col-xs-12"><input type="submit" value="立即登录" class="btn btn-primary btn-block btn-lg"/></div> <div class="col-xs-12"><input type="submit" value="立即登录" class="btn btn-primary btn-block btn-lg"/></div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script> <script>
function submitlogin(){ function submitlogin(){
var user = $("input[name='user']").val(); var user = $("input[name='user']").val();
var pass = $("input[name='pass']").val(); var pass = $("input[name='pass']").val();
var code = $("input[name='code']").val(); var code = $("input[name='code']").val();
if(user=='' || pass==''){layer.alert('用户名或密码不能为空!');return false;} if(user=='' || pass==''){layer.alert('用户名或密码不能为空!');return false;}
$.ajax({ var ii = layer.load(2);
type : 'POST', $.ajax({
url : '{:request()->url()}', type : 'POST',
data: {username:user, password:pass, code:code}, url : '{:request()->url()}',
dataType : 'json', data: {username:user, password:pass, code:code},
success : function(data) { dataType : 'json',
if(data.code == 0){ success : function(data) {
layer.msg('登录成功,正在跳转', {icon: 1,shade: 0.01,time: 15000}); layer.close(ii);
window.location.href='/admin'; if(data.code == 0){
}else{ layer.msg('登录成功,正在跳转', {icon: 1,shade: 0.01,time: 15000});
if(data.msg.indexOf('验证码')==-1){ window.location.href='/admin';
$("#verifycode").attr('src', '/admin/verifycode?r='+Math.random()) }else{
} if(data.msg.indexOf('验证码')==-1){
layer.alert(data.msg, {icon: 2}); $("#verifycode").attr('src', '/admin/verifycode?r='+Math.random())
} }
}, layer.alert(data.msg, {icon: 2});
error:function(data){ }
layer.msg('服务器错误'); },
} error:function(data){
}); layer.close(ii);
return false; layer.msg('服务器错误');
} }
</script> });
</body> return false;
}
</script>
</body>
</html> </html>

View File

@ -1,214 +1,282 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}插件列表{/block} {block name="title"}插件列表{/block}
{block name="main"} {block name="main"}
<style> <style>
td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;} td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;}
.bt-ico-ask { .bt-ico-ask {
border: 1px solid #fb7d00; border: 1px solid #fb7d00;
border-radius: 8px; border-radius: 8px;
color: #fb7d00; color: #fb7d00;
cursor: help; cursor: help;
display: inline-block; display: inline-block;
font-family: arial; font-family: arial;
font-size: 11px; font-size: 11px;
font-style: normal; font-style: normal;
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
margin-left: 5px; margin-left: 5px;
text-align: center; text-align: center;
width: 16px width: 16px
} }
.bt-ico-ask:hover { .bt-ico-ask:hover {
background-color: #fb7d00; background-color: #fb7d00;
color: #fff color: #fff
} }
</style> </style>
<div class="modal fade" id="help" tabindex="-1" role="dialog"> <div class="modal fade" id="help" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
<h4 class="modal-title">帮助</h4> <h4 class="modal-title">帮助</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。</p> <p>“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。</p>
<p>插件包本地存储路径是/data/plugins/package/软件标识-版本号.zip对于部分包含二次验证的插件可以自行修改。</p> <p>官方插件包本地存储路径是/data/plugins/package/软件标识-版本号.zip第三方插件包路径是/data/plugins/other/other/,对于部分包含二次验证的插件可以自行修改。</p>
<p>点击【重新获取】按钮会从宝塔官方获取最新插件列表,但是插件包需要手动点击下载。如果需要批量下载插件包,可查看<a href="/admin/set/type/task">定时任务设置</a></p> <p>若对接的服务器网速较慢,可能会导致下载失败,提示"服务器错误",可稍等一会,进入对接服务器/tmp/plugins目录下载插件包将_改成-,并上传到本站/data/plugins/package目录下。</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 center-block" style="float: none;"> <div class="col-xs-12 center-block" style="float: none;">
<div id="searchToolbar"> <div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline"> <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group"> <div class="form-group">
<label>搜索</label> <label>搜索</label>
<input type="text" class="form-control" name="keyword" placeholder="应用名称"> <input type="text" class="form-control" name="keyword" placeholder="应用名称">
</div> </div>
<div class="form-group"> <div class="form-group">
<select name="type" class="form-control"><option value="0">全部插件</option> <select name="type" class="form-control"><option value="0">全部插件</option>
{foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select> {foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>搜索</button>&nbsp; <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i>重置</a>&nbsp; <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
<a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></i>重新获取</a>&nbsp; <a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></i> 刷新列表</a>&nbsp;
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#help"><i class="fa fa-info-circle"></i>帮助</button> <a href="javascript:download_plugins()" class="btn btn-warning" id="batch_down" style="display:none;"><i class="fa fa-download"></i> 批量下载</a>&nbsp;
</div> <button type="button" class="btn btn-default" data-toggle="modal" data-target="#help"><i class="fa fa-info-circle"></i> 帮助</button>
</form> </div>
</div> </form>
</div>
<table id="listTable">
</table> <table id="listTable">
</div> </table>
</div> </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> </div>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/bootstrap-table.min.js"></script> <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="/static/js/custom.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script> <script src="/static/js/custom.js"></script>
<script>
function download_version(name, version, status){ var skip_plugins = {:json_encode($skip_plugins)};
if(status == true){ function download_version(name, version, status){
var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', { if(status == true){
btn: ['确定','取消'] var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', {
}, function(){ btn: ['确定','取消']
download_plugin(name, version) }, function(){
}, function(){ download_plugin(name, version)
layer.close(confirm) }, function(){
}); layer.close(confirm)
}else{ });
download_plugin(name, version) }else{
} download_plugin(name, version)
} }
}
function download_plugin(name, version){
var ii = layer.msg('正在下载,请稍候...', {icon: 16, shade:0.1, time: 0}); function download_plugin(name, version){
$.ajax({ var ii = layer.msg('正在下载,请稍候...', {icon: 16, shade:0.1, time: 0});
type : 'POST', $.ajax({
url : '/admin/download_plugin', type : 'POST',
data: { name:name, version:version}, url : '/admin/download_plugin',
dataType : 'json', data: { name:name, version:version},
success : function(data) { dataType : 'json',
layer.close(ii) success : function(data) {
if(data.code == 0){ layer.close(ii)
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();}); if(data.code == 0){
}else{ layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
layer.alert(data.msg, {icon:2}); }else{
} layer.alert(data.msg, {icon:2});
}, }
error:function(data){ },
layer.close(ii) error:function(data){
layer.msg('服务器错误', {icon:2}); layer.close(ii)
} layer.msg('服务器错误', {icon:2});
}); }
} });
}
function refresh_plugins(){
var confirm = layer.confirm('是否确定从宝塔官方获取最新插件列表?', { function refresh_plugins(){
btn: ['确定','取消'] var confirm = layer.confirm('是否确定从宝塔官方获取最新插件列表?', {
}, function(){ btn: ['确定','取消']
layer.close(confirm) }, function(){
var ii = layer.msg('正在获取插件列表,请稍候...', {icon: 16, shade:0.1, time: 0}); layer.close(confirm)
$.ajax({ var ii = layer.msg('正在获取插件列表,请稍候...', {icon: 16, shade:0.1, time: 0});
type : 'GET', $.ajax({
url : '/admin/refresh_plugins', type : 'GET',
dataType : 'json', url : '/admin/refresh_plugins',
success : function(data) { dataType : 'json',
layer.close(ii) success : function(data) {
if(data.code == 0){ layer.close(ii)
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();}); if(data.code == 0){
}else{ layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
layer.alert(data.msg, {icon:2}); }else{
} layer.alert(data.msg, {icon:2});
}, }
error:function(data){ },
layer.close(ii) error:function(data){
layer.msg('服务器错误', {icon:2}); layer.close(ii)
} layer.msg('服务器错误', {icon:2});
}); }
}, function(){ });
layer.close(confirm) }, function(){
}); layer.close(confirm)
} });
}
function searchByType(type){
$("input[name=keyword]").val(''); function download_plugins(){
$("select[name=type]").val(type); var confirm = layer.confirm('批量下载当前分类下未下载的插件包', {
searchSubmit() btn: ['确定','取消']
} }, function(){
layer.close(confirm)
$(document).ready(function(){ $.downloadCount = 0;
updateToolbar(); $.preDownloadCount = $.preDownload.length;
const defaultPageSize = 20; download_item();
}, function(){
$("#listTable").bootstrapTable({ layer.close(confirm)
url: '/admin/plugins_data', });
pageNumber: 1, }
pageSize: 15,
sidePagination: 'client', function download_item(){
classes: 'table table-striped table-hover table-bottom-border', if($.preDownload.length == 0){
columns: [ layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();});
{ return;
field: 'name', }
title: '软件标识', var plugin = $.preDownload[0];
formatter: function(value, row, index) { if(skip_plugins.indexOf(plugin.name) != -1){
return '<b>'+value+'</b>'; $.preDownload.shift();
} download_item();
}, return;
{ }
field: 'title', $.downloadCount++;
title: '软件名称' var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
}, $.ajax({
{ type : 'POST',
field: 'type', url : '/admin/download_plugin',
title: '软件分类', data: { name:plugin.name, version:plugin.version},
formatter: function(value, row, index) { dataType : 'json',
return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>'; success : function(data) {
} layer.close(ii)
}, if(data.code == 0){
{ $.preDownload.shift();
field: 'desc', download_item();
title: '说明', }else{
}, layer.alert(data.msg, {icon:2});
{ }
field: 'price', },
title: '价格', error:function(data){
formatter: function(value, row, index) { layer.close(ii)
return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费'; layer.msg('服务器错误', {icon:2});
} }
}, });
{ }
field: 'author',
title: '开发商' function searchByType(type){
}, $("input[name=keyword]").val('');
{ $("select[name=type]").val(type);
field: 'versions', searchSubmit()
title: '版本与状态', }
formatter: function(value, row, index) {
var html = ''; $(document).ready(function(){
if(row.type == 5){ updateToolbar();
html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>'; const defaultPageSize = 20;
}else{
$.each(value, function(index,item){ $("#listTable").bootstrapTable({
if(item.status) url: '/admin/plugins_data',
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;'; pageNumber: 1,
else pageSize: 15,
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;'; sidePagination: 'client',
}) classes: 'table table-striped table-hover table-bottom-border',
} columns: [
return html {
} field: 'name',
}, title: '软件标识',
], formatter: function(value, row, index) {
}) return '<b>'+value+'</b>';
}) }
</script> },
{
field: 'title',
title: '软件名称'
},
{
field: 'type',
title: '软件分类',
formatter: function(value, row, index) {
return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
}
},
{
field: 'desc',
title: '说明',
},
{
field: 'price',
title: '价格',
formatter: function(value, row, index) {
return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
}
},
{
field: 'author',
title: '开发商'
},
{
field: 'versions',
title: '版本与状态',
formatter: function(value, row, index) {
var html = '';
if(row.type == 5){
html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
}else{
$.each(value, function(index,item){
if(item.status)
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
else
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
})
}
return html
}
},
],
onLoadSuccess: function(data){
$.preDownload = [];
var type = $("select[name=type] option:selected").text();
if(type != '全部插件' && type != '运行环境' && type != '第三方应用'){
$("#batch_down").show();
if(data.length > 0){
$.each(data, function(index, plugin){
if(plugin.versions.length > 0){
$.each(plugin.versions, function(index, version){
if(!version.status){
$.preDownload.push({name:plugin.name, version:version.version})
}
});
}
});
}
}else{
$("#batch_down").hide();
}
}
})
})
</script>
{/block} {/block}

View File

@ -0,0 +1,276 @@
{extend name="admin/layout" /}
{block name="title"}插件列表{/block}
{block name="main"}
<style>
td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;}
.bt-ico-ask {
border: 1px solid #fb7d00;
border-radius: 8px;
color: #fb7d00;
cursor: help;
display: inline-block;
font-family: arial;
font-size: 11px;
font-style: normal;
height: 16px;
line-height: 16px;
margin-left: 5px;
text-align: center;
width: 16px
}
.bt-ico-ask:hover {
background-color: #fb7d00;
color: #fff
}
</style>
<div class="modal fade" id="help" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">帮助</h4>
</div>
<div class="modal-body">
<p>“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。</p>
<p>官方插件包本地存储路径是/data/en/plugins/package/软件标识-版本号.zip第三方插件包路径是/data/plugins/other/other/,对于部分包含二次验证的插件可以自行修改。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<div class="container" style="padding-top:70px;">
<div class="col-xs-12 center-block" style="float: none;">
<div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group">
<label>搜索</label>
<input type="text" class="form-control" name="keyword" placeholder="应用名称">
</div>
<div class="form-group">
<select name="type" class="form-control"><option value="0">全部插件</option>
{foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select>
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
<a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></i> 刷新列表</a>&nbsp;
<a href="javascript:download_plugins()" class="btn btn-warning" id="batch_down" style="display:none;"><i class="fa fa-download"></i> 批量下载</a>&nbsp;
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#help"><i class="fa fa-info-circle"></i> 帮助</button>
</div>
</form>
</div>
<table id="listTable">
</table>
</div>
</div>
<script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script src="/static/js/custom.js"></script>
<script>
function download_version(name, version, status){
if(status == true){
var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', {
btn: ['确定','取消']
}, function(){
download_plugin(name, version)
}, function(){
layer.close(confirm)
});
}else{
download_plugin(name, version)
}
}
function download_plugin(name, version){
var ii = layer.msg('正在下载,请稍候...', {icon: 16, shade:0.1, time: 0});
$.ajax({
type : 'POST',
url : '/admin/download_plugin',
data: { name:name, version:version, os:'en'},
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}
function refresh_plugins(){
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_plugins?os=en',
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}, function(){
layer.close(confirm)
});
}
function download_plugins(){
var confirm = layer.confirm('批量下载当前分类下未下载的插件包', {
btn: ['确定','取消']
}, function(){
layer.close(confirm)
$.downloadCount = 0;
$.preDownloadCount = $.preDownload.length;
download_item();
}, function(){
layer.close(confirm)
});
}
function download_item(){
if($.preDownload.length == 0){
layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();});
return;
}
$.downloadCount++;
var plugin = $.preDownload[0];
var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
$.ajax({
type : 'POST',
url : '/admin/download_plugin',
data: { name:plugin.name, version:plugin.version, os:'en'},
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
$.preDownload.shift();
download_item();
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}
function searchByType(type){
$("input[name=keyword]").val('');
$("select[name=type]").val(type);
searchSubmit()
}
$(document).ready(function(){
updateToolbar();
const defaultPageSize = 20;
$("#listTable").bootstrapTable({
url: '/admin/plugins_data?os=en',
pageNumber: 1,
pageSize: 15,
sidePagination: 'client',
classes: 'table table-striped table-hover table-bottom-border',
columns: [
{
field: 'name',
title: '软件标识',
formatter: function(value, row, index) {
return '<b>'+value+'</b>';
}
},
{
field: 'title',
title: '软件名称'
},
{
field: 'type',
title: '软件分类',
formatter: function(value, row, index) {
return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
}
},
{
field: 'desc',
title: '说明',
},
{
field: 'price',
title: '价格',
formatter: function(value, row, index) {
return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
}
},
{
field: 'author',
title: '开发商'
},
{
field: 'versions',
title: '版本与状态',
formatter: function(value, row, index) {
var html = '';
if(row.type == 5 || row.name == 'mail_sys' || row.name == 'dns_manager'){
html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
}else{
$.each(value, function(index,item){
if(item.status)
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
else
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
})
}
return html
}
},
],
onLoadSuccess: function(data){
$.preDownload = [];
var type = $("select[name=type] option:selected").text();
if(type != '全部插件' && type != '运行环境' && type != '第三方应用'){
$("#batch_down").show();
if(data.length > 0){
$.each(data, function(index, plugin){
if(plugin.versions.length > 0 && plugin.name!='mail_sys' && plugin.name!='dns_manager'){
$.each(plugin.versions, function(index, version){
if(!version.status){
$.preDownload.push({name:plugin.name, version:version.version})
}
});
}
});
}
}else{
$("#batch_down").hide();
}
}
})
})
</script>
{/block}

View File

@ -0,0 +1,276 @@
{extend name="admin/layout" /}
{block name="title"}插件列表{/block}
{block name="main"}
<style>
td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;}
.bt-ico-ask {
border: 1px solid #fb7d00;
border-radius: 8px;
color: #fb7d00;
cursor: help;
display: inline-block;
font-family: arial;
font-size: 11px;
font-style: normal;
height: 16px;
line-height: 16px;
margin-left: 5px;
text-align: center;
width: 16px
}
.bt-ico-ask:hover {
background-color: #fb7d00;
color: #fff
}
</style>
<div class="modal fade" id="help" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">帮助</h4>
</div>
<div class="modal-body">
<p>“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。</p>
<p>官方插件包本地存储路径是/data/win/plugins/package/软件标识-版本号.zip第三方插件包路径是/data/plugins/other/other/,对于部分包含二次验证的插件可以自行修改。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<div class="container" style="padding-top:70px;">
<div class="col-xs-12 center-block" style="float: none;">
<div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group">
<label>搜索</label>
<input type="text" class="form-control" name="keyword" placeholder="应用名称">
</div>
<div class="form-group">
<select name="type" class="form-control"><option value="0">全部插件</option>
{foreach $typelist as $k=>$v}<option value="{$k}">{$v}</option>{/foreach} </select>
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
<a href="javascript:refresh_plugins()" class="btn btn-success"><i class="fa fa-refresh"></i> 刷新列表</a>&nbsp;
<a href="javascript:download_plugins()" class="btn btn-warning" id="batch_down" style="display:none;"><i class="fa fa-download"></i> 批量下载</a>&nbsp;
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#help"><i class="fa fa-info-circle"></i> 帮助</button>
</div>
</form>
</div>
<table id="listTable">
</table>
</div>
</div>
<script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script src="/static/js/custom.js"></script>
<script>
function download_version(name, version, status){
if(status == true){
var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', {
btn: ['确定','取消']
}, function(){
download_plugin(name, version)
}, function(){
layer.close(confirm)
});
}else{
download_plugin(name, version)
}
}
function download_plugin(name, version){
var ii = layer.msg('正在下载,请稍候...', {icon: 16, shade:0.1, time: 0});
$.ajax({
type : 'POST',
url : '/admin/download_plugin',
data: { name:name, version:version, os:'Windows'},
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}
function refresh_plugins(){
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_plugins?os=Windows',
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
layer.alert(data.msg, {icon:1}, function(){layer.closeAll();searchSubmit();});
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}, function(){
layer.close(confirm)
});
}
function download_plugins(){
var confirm = layer.confirm('批量下载当前分类下未下载的插件包', {
btn: ['确定','取消']
}, function(){
layer.close(confirm)
$.downloadCount = 0;
$.preDownloadCount = $.preDownload.length;
download_item();
}, function(){
layer.close(confirm)
});
}
function download_item(){
if($.preDownload.length == 0){
layer.alert('成功下载'+$.downloadCount+'个插件包!', {icon:1}, function(){layer.closeAll();searchSubmit();});
return;
}
$.downloadCount++;
var plugin = $.preDownload[0];
var ii = layer.msg('['+$.downloadCount+'/'+$.preDownloadCount+']正在下载'+plugin.name+'-'+plugin.version, {icon: 16, shade:0.1, time: 0});
$.ajax({
type : 'POST',
url : '/admin/download_plugin',
data: { name:plugin.name, version:plugin.version, os:'Windows'},
dataType : 'json',
success : function(data) {
layer.close(ii)
if(data.code == 0){
$.preDownload.shift();
download_item();
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.close(ii)
layer.msg('服务器错误', {icon:2});
}
});
}
function searchByType(type){
$("input[name=keyword]").val('');
$("select[name=type]").val(type);
searchSubmit()
}
$(document).ready(function(){
updateToolbar();
const defaultPageSize = 20;
$("#listTable").bootstrapTable({
url: '/admin/plugins_data?os=Windows',
pageNumber: 1,
pageSize: 15,
sidePagination: 'client',
classes: 'table table-striped table-hover table-bottom-border',
columns: [
{
field: 'name',
title: '软件标识',
formatter: function(value, row, index) {
return '<b>'+value+'</b>';
}
},
{
field: 'title',
title: '软件名称'
},
{
field: 'type',
title: '软件分类',
formatter: function(value, row, index) {
return '<a href="javascript:searchByType('+value+')" title="查看该分类下的插件">'+row.typename+'</a>';
}
},
{
field: 'desc',
title: '说明',
},
{
field: 'price',
title: '价格',
formatter: function(value, row, index) {
return value > 0 ? '<span style="color:#fc6d26">¥'+value+'</span>' : '免费';
}
},
{
field: 'author',
title: '开发商'
},
{
field: 'versions',
title: '版本与状态',
formatter: function(value, row, index) {
var html = '';
if(row.type == 5){
html += '<a href="javascript:" class="btn btn-xs btn-success" disabled>无需下载</a>';
}else{
$.each(value, function(index,item){
if(item.status)
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-success">'+item.version+'</a>&nbsp;';
else
html += '<a href="javascript:download_version(\''+row.name+'\',\''+item.version+'\','+item.status+')" class="btn btn-xs btn-danger">'+item.version+'</a>&nbsp;';
})
}
return html
}
},
],
onLoadSuccess: function(data){
$.preDownload = [];
var type = $("select[name=type] option:selected").text();
if(type != '全部插件' && type != '运行环境' && type != '第三方应用'){
$("#batch_down").show();
if(data.length > 0){
$.each(data, function(index, plugin){
if(plugin.versions.length > 0){
$.each(plugin.versions, function(index, version){
if(!version.status){
$.preDownload.push({name:plugin.name, version:version.version})
}
});
}
});
}
}else{
$("#batch_down").hide();
}
}
})
})
</script>
{/block}

View File

@ -1,67 +1,67 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}使用记录{/block} {block name="title"}使用记录{/block}
{block name="main"} {block name="main"}
<style> <style>
</style> </style>
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 col-md-10 center-block" style="float: none;"> <div class="col-xs-12 col-md-10 center-block" style="float: none;">
<div id="searchToolbar"> <div id="searchToolbar">
<form onsubmit="return searchSubmit()" method="GET" class="form-inline"> <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
<div class="form-group"> <div class="form-group">
<label>搜索</label> <label>搜索</label>
<input type="text" class="form-control" name="ip" placeholder="服务器IP"> <input type="text" class="form-control" name="ip" placeholder="服务器IP">
</div> </div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" type="submit"><i class="fa fa-search"></i>搜索</button>&nbsp; <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
<a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i>重置</a>&nbsp; <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
</div> </div>
</form> </form>
</div> </div>
<table id="listTable"> <table id="listTable">
</table> </table>
</div> </div>
</div> </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> <script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/bootstrap-table.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
<script src="//cdn.staticfile.org/bootstrap-table/1.20.2/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script> <script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
<script src="/static/js/custom.js"></script> <script src="/static/js/custom.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
updateToolbar(); updateToolbar();
const defaultPageSize = 15; const defaultPageSize = 15;
const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1; const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize; const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize;
$("#listTable").bootstrapTable({ $("#listTable").bootstrapTable({
url: '/admin/record_data', url: '/admin/record_data',
pageNumber: pageNumber, pageNumber: pageNumber,
pageSize: pageSize, pageSize: pageSize,
classes: 'table table-striped table-hover table-bottom-border', classes: 'table table-striped table-hover table-bottom-border',
columns: [ columns: [
{ {
field: 'id', field: 'id',
title: 'ID', title: 'ID',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return '<b>'+value+'</b>'; return '<b>'+value+'</b>';
} }
}, },
{ {
field: 'ip', field: 'ip',
title: '服务器IP' title: '服务器IP'
}, },
{ {
field: 'addtime', field: 'addtime',
title: '首次安装时间', title: '首次安装时间',
}, },
{ {
field: 'usetime', field: 'usetime',
title: '最后使用时间' title: '最后使用时间'
}, },
], ],
}) })
}) })
</script> </script>
{/block} {/block}

View File

@ -1,211 +1,571 @@
{extend name="admin/layout" /} {extend name="admin/layout" /}
{block name="title"}系统设置{/block} {block name="title"}系统设置{/block}
{block name="main"} {block name="main"}
<div class="container" style="padding-top:70px;"> <div class="container" style="padding-top:70px;">
<div class="col-xs-12 col-sm-10 col-lg-8 center-block" style="float: none;"> {if $mod=='sys'}
{if $mod=='sys'} <div class="col-sm-12 col-md-6 center-block">
<div class="panel panel-primary"> <div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">系统基本设置</h3></div> <div class="panel-heading"><h3 class="panel-title">系统基本设置</h3></div>
<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="form-group"> <div class="form-group">
<label>是否开启白名单模式:</label><br/> <label>是否开启白名单模式:</label><br/>
<select class="form-control" name="whitelist" default="{:config_get('whitelist')}"><option value="0">关闭</option><option value="1">开启</option></select> <select class="form-control" name="whitelist" default="{:config_get('whitelist')}"><option value="0">关闭</option><option value="1">开启</option></select>
<font color="green">开启白名单模式后,只有在<a href="/admin/list/type/white" target="_blank">白名单列表</a>中的服务器IP才能使用此云端</font> <font color="green">开启白名单模式后,只有在<a href="/admin/list/type/white" target="_blank">白名单列表</a>中的服务器IP才能使用此云端</font>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>安装脚本展示页面开关:</label> <label>安装脚本展示页面开关:</label>
<select class="form-control" name="download_page" default="{:config_get('download_page')}"><option value="0">关闭</option><option value="1">开启</option></select> <select class="form-control" name="download_page" default="{:config_get('download_page')}"><option value="0">关闭</option><option value="1">开启</option></select>
<font color="green">页面地址:<a href="/download" target="_blank">/download</a>,开启后可以公开访问,否则只能管理员访问</font> <font color="green">页面地址:<a href="/download" target="_blank">/download</a>,开启后可以公开访问,否则只能管理员访问</font>
</div> </div>
<div class="form-group"> <div class="form-group text-center">
<label>宝塔面板最新版本号:</label> <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
<input type="text" name="new_version" value="{:config_get('new_version')}" class="form-control"/> </div>
<font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/install/update/放置对应版本更新包</font> </form>
</div> </div>
<div class="form-group"> </div>
<label>宝塔面板最新版更新日志:</label> <div class="panel panel-info">
<textarea class="form-control" name="update_msg" rows="5" placeholder="支持HTML代码">{:config_get('update_msg')}</textarea> <div class="panel-heading"><h3 class="panel-title">Linux面板版本设置</h3></div>
<font color="green">用于检测更新接口返回</font> <div class="panel-body">
</div> <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="form-group"> <div class="form-group">
<label>宝塔面板最新版更新日期:</label> <label>宝塔Linux面板最新版本号</label>
<input type="date" name="update_date" value="{:config_get('update_date')}" class="form-control"/> <input type="text" name="new_version" value="{:config_get('new_version')}" class="form-control"/>
<font color="green">用于检测更新接口返回</font> <font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/install/update/放置对应版本更新包</font>
</div> </div>
<div class="form-group text-center"> <div class="form-group">
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/> <label>宝塔Linux面板更新日志</label>
</div> <textarea class="form-control" name="update_msg" rows="5" placeholder="支持HTML代码">{:config_get('update_msg')}</textarea>
</form> <font color="green">用于检测更新接口返回</font>
</div> </div>
</div> <div class="form-group">
<div class="panel panel-primary"> <label>宝塔Linux面板更新日期</label>
<div class="panel-heading"><h3 class="panel-title">宝塔面板接口设置</h3></div> <input type="date" name="update_date" value="{:config_get('update_date')}" class="form-control"/>
<div class="panel-body"> <font color="green">用于检测更新接口返回</font>
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form"> </div>
<p>以下宝塔面板请使用官方最新脚本安装并绑定账号,用于获取最新插件列表及插件包</p> <div class="form-group text-center">
<p><a href="/static/file/kaixin.zip">下载专用插件</a>,在面板【软件商店】->【第三方应用】,点击【导入插件】,导入该专用插件,<b>然后重启一次面板</b></p> <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
<div class="form-group"> </div>
<label>宝塔面板URL</label><br/> </form>
<input type="text" name="bt_url" value="{:config_get('bt_url')}" class="form-control"/> </div>
<font color="green">填写规则如:<u>http://192.168.1.1:8888</u> ,不要带其他后缀</font> </div>
</div> <div class="panel panel-info">
<div class="form-group"> <div class="panel-heading"><h3 class="panel-title">Windows面板版本设置</h3></div>
<label>宝塔面板接口密钥:</label> <div class="panel-body">
<input type="text" name="bt_key" value="{:config_get('bt_key')}" class="form-control"/> <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
</div> <div class="form-group">
<div class="form-group text-center"> <label>宝塔Windows面板最新版本号</label>
<button type="button" class="btn btn-info btn-block" id="testbturl">测试连接</button> <input type="text" name="new_version_win" value="{:config_get('new_version_win')}" class="form-control"/>
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/> <font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/win/panel/放置对应版本更新包</font>
</div> </div>
</form> <div class="form-group">
</div> <label>宝塔Windows面板更新日志</label>
</div> <textarea class="form-control" name="update_msg_win" rows="5" placeholder="支持HTML代码">{:config_get('update_msg_win')}</textarea>
{elseif $mod=='task'} <font color="green">用于检测更新接口返回</font>
<div class="panel panel-success"> </div>
<div class="panel-heading"><h3 class="panel-title">定时任务说明</h3></div> <div class="form-group">
<div class="panel-body"> <label>宝塔Windows面板更新日期</label>
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form"> <input type="date" name="update_date_win" value="{:config_get('update_date_win')}" class="form-control"/>
<div class="alert alert-info">使用以下命令可以从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。<br/>你也可以将此命令添加到crontab以使此云端的插件保持最新建议1天执行1次。</div> <font color="green">用于检测更新接口返回</font>
<div class="alert alert-warning">上次运行时间:{$runtime|raw}</div> </div>
<div class="list-group-item">php {:app()->getRootPath()}think updateall</div><br/> <div class="form-group text-center">
</form> <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
</div> </div>
</div> </form>
<div class="panel panel-info"> </div>
<div class="panel-heading"><h3 class="panel-title">定时任务设置</h3></div> </div>
<div class="panel-body"> </div>
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form"> <div class="col-sm-12 col-md-6 center-block">
<div class="form-group"> <div class="panel panel-info">
<label>批量下载插件范围:</label><br/> <div class="panel-heading"><h3 class="panel-title">云监控版本设置</h3></div>
<select class="form-control" name="updateall_type" default="{:config_get('updateall_type')}"><option value="0">仅免费插件</option><option value="1">免费插件+专业版插件</option><option value="2">免费插件+专业版插件+企业版插件</option></select><font color="green">(批量下载不包含所有第三方插件,第三方插件需要去手动下载。)</font> <div class="panel-body">
</div> <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="form-group text-center"> <div class="form-group">
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/> <label>宝塔云监控最新版本号:</label>
</div> <input type="text" name="new_version_btm" value="{:config_get('new_version_btm')}" class="form-control"/>
</form> <font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/install/src/放置对应版本更新包</font>
</div> </div>
</div> <div class="form-group">
{elseif $mod=='account'} <label>宝塔云监控更新日志:</label>
<div class="panel panel-primary"> <textarea class="form-control" name="update_msg_btm" rows="3" placeholder="支持HTML代码">{:config_get('update_msg_btm')}</textarea>
<div class="panel-heading"><h3 class="panel-title">管理账号设置</h3></div> </div>
<div class="panel-body"> <div class="form-group">
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form"> <label>宝塔云监控更新日期:</label>
<div class="form-group"> <input type="date" name="update_date_btm" value="{:config_get('update_date_btm')}" class="form-control"/>
<label>用户名:</label><br/> </div>
<input type="text" name="username" value="{:config_get('admin_username')}" class="form-control" required/> <div class="form-group text-center">
</div> <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
<div class="form-group"> </div>
<label>旧密码:</label> </form>
<input type="password" name="oldpwd" value="" class="form-control" placeholder="请输入当前的管理员密码"/> </div>
</div> </div>
<div class="form-group"> <div class="panel panel-info">
<label>新密码:</label> <div class="panel-heading"><h3 class="panel-title">aaPanel面板版本设置</h3></div>
<input type="password" name="newpwd" value="" class="form-control" placeholder="不修改请留空"/> <div class="panel-body">
</div> <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="form-group"> <div class="form-group">
<label>重输密码:</label> <label>aaPanel面板最新版本号</label>
<input type="password" name="newpwd2" value="" class="form-control" placeholder="不修改请留空"/> <input type="text" name="new_version_en" value="{:config_get('new_version_en')}" class="form-control"/>
</div> <font color="green">用于一键更新脚本获取最新版本号,以及检测更新接口。并确保已在/public/install/update/放置对应版本更新包</font>
<div class="form-group text-center"> </div>
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/> <div class="form-group">
</div> <label>aaPanel面板更新日志</label>
</form> <textarea class="form-control" name="update_msg_en" rows="5" placeholder="支持HTML代码">{:config_get('update_msg_en')}</textarea>
</div> <font color="green">用于检测更新接口返回</font>
{/if} </div>
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js"></script> <div class="form-group">
<script> <label>aaPanel面板更新日期</label>
$(document).ready(function(){ <input type="date" name="update_date_en" value="{:config_get('update_date_en')}" class="form-control"/>
var items = $("select[default]"); <font color="green">用于检测更新接口返回</font>
for (i = 0; i < items.length; i++) { </div>
$(items[i]).val($(items[i]).attr("default")||0); <div class="form-group text-center">
} <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
$("#testbturl").click(function(){ </div>
var bt_url = $("input[name=bt_url]").val(); </form>
var bt_key = $("input[name=bt_key]").val(); </div>
if(bt_url == ''){ </div>
layer.alert('宝塔面板URL不能为空');return; </div>
} {elseif $mod=='api'}
if(bt_url.indexOf('http://')==-1 && bt_url.indexOf('https://')==-1){ <div class="col-sm-12 col-md-6 center-block">
layer.alert('宝塔面板URL不正确');return; <div class="panel panel-info">
} <div class="panel-heading"><h3 class="panel-title">宝塔Linux面板接口设置</h3></div>
if(bt_key == ''){ <div class="panel-body">
layer.alert('宝塔面板接口密钥不能为空');return; <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
} <div class="form-group">
var ii = layer.load(2, {shade:[0.1,'#fff']}); <label>对接方式:</label><br/>
$.ajax({ <select class="form-control" name="bt_type" default="{:config_get('bt_type')}"><option value="0">对接宝塔面板接口</option><option value="1">对接其他第三方云端</option></select>
type : 'POST', </div><hr/>
url : '/admin/testbturl', <div id="bt_type_0" style="{if config_get('bt_type')==1}display:none;{/if}">
data : {bt_url:bt_url, bt_key:bt_key}, <p>以下宝塔面板请使用官方最新脚本安装并绑定账号,用于获取插件列表及插件包</p>
dataType : 'json', <p><a href="/static/file/kaixin.zip">下载专用插件(Linux)</a>,在面板【软件商店】->【第三方应用】,点击【导入插件】,导入该专用插件。</p>
success : function(data) { <div class="form-group">
layer.close(ii); <label>宝塔面板URL</label><br/>
if(data.code == 0){ <input type="text" name="bt_url" value="{:config_get('bt_url')}" class="form-control"/>
layer.msg(data.msg, {icon: 1, time:1000}) <font color="green">填写规则如:<u>http://192.168.1.1:8888</u> ,不要带其他后缀</font>
}else{ </div>
layer.alert(data.msg, {icon: 2}) <div class="form-group">
} <label>宝塔面板接口密钥:</label>
}, <input type="text" name="bt_key" value="{:config_get('bt_key')}" class="form-control"/>
error:function(data){ </div>
layer.close(ii); </div>
layer.msg('服务器错误'); <div id="bt_type_1" style="{if !config_get('bt_type')}display:none;{/if}">
} <div class="form-group">
}); <label>第三方云端首页URL</label><br/>
}) <input type="text" name="bt_surl" value="{:config_get('bt_surl')}" class="form-control"/>
}) <font color="green">填写规则如:<u>http://www.example.com/</u> ,必须以/结尾</font>
function saveSetting(obj){ </div>
var ii = layer.load(2, {shade:[0.1,'#fff']}); </div>
$.ajax({ <div class="form-group text-center">
type : 'POST', <button type="button" class="btn btn-info btn-block" id="testbturl">测试连接</button>
url : '/admin/set', <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
data : $(obj).serialize(), </div>
dataType : 'json', </form>
success : function(data) { </div>
layer.close(ii); </div>
if(data.code == 0){ </div>
layer.alert('设置保存成功!', { <div class="col-sm-12 col-md-6 center-block">
icon: 1, <div class="panel panel-info">
closeBtn: false <div class="panel-heading"><h3 class="panel-title">宝塔Windows面板接口设置</h3></div>
}, function(){ <div class="panel-body">
window.location.reload() <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
}); <div class="form-group">
}else{ <label>对接方式:</label><br/>
layer.alert(data.msg, {icon: 2}) <select class="form-control" name="wbt_type" default="{:config_get('wbt_type')}"><option value="0">对接宝塔面板接口</option><option value="1">对接其他第三方云端</option></select>
} </div><hr/>
}, <div id="wbt_type_0" style="{if config_get('wbt_type')==1}display:none;{/if}">
error:function(data){ <p>以下宝塔面板请使用官方最新脚本安装并绑定账号,用于获取插件列表及插件包</p>
layer.close(ii); <p><a href="/static/file/win/kaixin.zip">下载专用插件(Win)</a>,上传到 /BtSoft/panel/plugin/ 解压,即可在软件商店已安装列表看到。</p>
layer.msg('服务器错误'); <div class="form-group">
} <label>宝塔面板URL</label><br/>
}); <input type="text" name="wbt_url" value="{:config_get('wbt_url')}" class="form-control"/>
return false; <font color="green">填写规则如:<u>http://192.168.1.1:8888</u> ,不要带其他后缀</font>
} </div>
function saveAccount(obj){ <div class="form-group">
var ii = layer.load(2, {shade:[0.1,'#fff']}); <label>宝塔面板接口密钥:</label>
$.ajax({ <input type="text" name="wbt_key" value="{:config_get('wbt_key')}" class="form-control"/>
type : 'POST', </div>
url : '/admin/setaccount', </div>
data : $(obj).serialize(), <div id="wbt_type_1" style="{if !config_get('wbt_type')}display:none;{/if}">
dataType : 'json', <div class="form-group">
success : function(data) { <label>第三方云端首页URL</label><br/>
layer.close(ii); <input type="text" name="wbt_surl" value="{:config_get('wbt_surl')}" class="form-control"/>
if(data.code == 0){ <font color="green">填写规则如:<u>http://www.example.com/</u> ,必须以/结尾</font>
layer.alert('管理账号保存成功!请重新登录。', { </div>
icon: 1, </div>
closeBtn: false <div class="form-group text-center">
}, function(){ <button type="button" class="btn btn-info btn-block" id="testbturl2">测试连接</button>
window.location.reload() <input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
}); </div>
}else{ </form>
layer.alert(data.msg, {icon: 2}) </div>
} </div>
}, </div>
error:function(data){ <div class="col-sm-12 col-md-6 center-block">
layer.close(ii); <div class="panel panel-info">
layer.msg('服务器错误'); <div class="panel-heading"><h3 class="panel-title">aaPanel面板接口设置</h3></div>
} <div class="panel-body">
}); <form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
return false; <div class="form-group">
} <label>对接方式:</label><br/>
</script> <select class="form-control" name="enbt_type" default="{:config_get('enbt_type')}"><option value="0">对接aaPanel面板接口</option><option value="1">对接其他第三方云端</option></select>
</div><hr/>
<div id="enbt_type_0" style="{if config_get('enbt_type')==1}display:none;{/if}">
<p>以下aaPanel面板请使用官方最新脚本安装并绑定账号用于获取插件列表及插件包</p>
<p><a href="/static/file/en/kaixin.zip">下载专用插件(aaPanel)</a>,在面板【软件商店】->【第三方应用】,点击【导入插件】,导入该专用插件。</p>
<div class="form-group">
<label>aaPanel面板URL</label><br/>
<input type="text" name="enbt_url" value="{:config_get('enbt_url')}" class="form-control"/>
<font color="green">填写规则如:<u>http://192.168.1.1:8888</u> ,不要带其他后缀</font>
</div>
<div class="form-group">
<label>aaPanel面板接口密钥</label>
<input type="text" name="enbt_key" value="{:config_get('enbt_key')}" class="form-control"/>
</div>
</div>
<div id="enbt_type_1" style="{if !config_get('enbt_type')}display:none;{/if}">
<div class="form-group">
<label>第三方云端首页URL</label><br/>
<input type="text" name="enbt_surl" value="{:config_get('enbt_surl')}" class="form-control"/>
<font color="green">填写规则如:<u>http://www.example.com/</u> ,必须以/结尾</font>
</div>
</div>
<div class="form-group text-center">
<button type="button" class="btn btn-info btn-block" id="testbturl3">测试连接</button>
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
</div>
</form>
</div>
</div>
</div>
<script>
$("select[name='bt_type']").change(function(){
if($(this).val() == 1){
$("#bt_type_0").hide();
$("#bt_type_1").show();
}else{
$("#bt_type_0").show();
$("#bt_type_1").hide();
}
});
$("select[name='wbt_type']").change(function(){
if($(this).val() == 1){
$("#wbt_type_0").hide();
$("#wbt_type_1").show();
}else{
$("#wbt_type_0").show();
$("#wbt_type_1").hide();
}
});
$("select[name='enbt_type']").change(function(){
if($(this).val() == 1){
$("#enbt_type_0").hide();
$("#enbt_type_1").show();
}else{
$("#enbt_type_0").show();
$("#enbt_type_1").hide();
}
});
</script>
{elseif $mod=='task'}
<div class="col-sm-12 col-md-6 center-block">
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">自动更新插件说明</h3></div>
<div class="panel-body">
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="alert alert-info">使用以下命令可以从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。<br/>你也可以将此命令添加到crontab以使此云端的插件保持最新建议1天执行1次。</div>
{if $is_user_www}<div class="alert alert-danger">计划任务执行用户必须选择www用户</div>{/if}
<div class="alert alert-warning">上次运行时间:{$runtime|raw}</div>
<div class="list-group-item">php {:app()->getRootPath()}think updateall</div><br/>
</form>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 center-block">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">自动更新插件设置</h3></div>
<div class="panel-body">
<form onsubmit="return saveSetting(this)" method="post" class="form" role="form">
<div class="form-group">
<label>Linux面板批量下载插件范围</label><br/>
<select class="form-control" name="updateall_type" default="{:config_get('updateall_type')}"><option value="0">仅免费插件</option><option value="1">免费插件+专业版插件</option><option value="2">免费插件+专业版插件+企业版插件</option></select><font color="green">(批量下载不包含所有第三方插件,第三方插件需要去手动下载。)</font>
</div>
<div class="form-group">
<label>Windows面板批量下载插件范围</label><br/>
<select class="form-control" name="updateall_type_win" default="{:config_get('updateall_type_win')}"><option value="0">仅免费插件</option><option value="1">免费插件+专业版插件</option><option value="2">免费插件+专业版插件+企业版插件</option></select><font color="green">(批量下载不包含所有第三方插件,第三方插件需要去手动下载。)</font>
</div>
<div class="form-group">
<label>aaPanel面板批量下载插件范围</label><br/>
<select class="form-control" name="updateall_type_en" default="{:config_get('updateall_type_en')}"><option value="0">仅免费插件</option><option value="1">免费插件+专业版插件</option><option value="2">免费插件+专业版插件+企业版插件</option></select><font color="green">(批量下载不包含所有第三方插件,第三方插件需要去手动下载。)</font>
</div>
<div class="form-group text-center">
<input type="submit" name="submit" value="保存" class="btn btn-success btn-block"/>
</div>
</form>
</div>
</div>
</div>
{elseif $mod=='account'}
<div class="col-xs-12 col-sm-8 col-lg-6 center-block" style="float: none;">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title">管理账号设置</h3></div>
<div class="panel-body">
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form">
<div class="form-group">
<label>用户名:</label><br/>
<input type="text" name="username" value="{:config_get('admin_username')}" class="form-control" required/>
</div>
<div class="form-group">
<label>旧密码:</label>
<input type="password" name="oldpwd" value="" class="form-control" placeholder="请输入当前的管理员密码"/>
</div>
<div class="form-group">
<label>新密码:</label>
<input type="password" name="newpwd" value="" class="form-control" placeholder="不修改请留空"/>
</div>
<div class="form-group">
<label>重输密码:</label>
<input type="password" name="newpwd2" value="" class="form-control" placeholder="不修改请留空"/>
</div>
<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>
{elseif $mod=='tools'}
<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">
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form">
<div class="alert alert-info" style="word-break:break-all;">使用以下命令可以将bt安装包、更新包和脚本文件里面的<code>http://www.example.com</code>批量替换成当前网址<code>{:request()->root(true)}</code>,每次更新版本后只需要执行一次即可。</div>
<div class="list-group-item" style="word-break:break-all;">cd {:app()->getRootPath()}app/script && chmod +x convert.sh && ./convert.sh {:app()->getRootPath()} {:request()->root(true)}</div><br/>
</form>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title">清理旧版本插件工具</h3></div>
<div class="panel-body">
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form">
<div class="alert alert-info" style="word-break:break-all;">使用以下命令可清理旧版本的插件文件,以释放空间占用。</div>
<div class="list-group-item" style="word-break:break-all;">php {:app()->getRootPath()}think clean</div><br/>
</form>
</div>
</div>
{/if}
<script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script>
$(document).ready(function(){
var items = $("select[default]");
for (i = 0; i < items.length; i++) {
$(items[i]).val($(items[i]).attr("default")||0);
}
$("#testbturl").click(function(){
var bt_type = $("select[name=bt_type]").val();
if(bt_type == '1'){
var bt_surl = $("input[name=bt_surl]").val();
if(bt_surl == ''){
layer.alert('第三方云端URL不能为空');return;
}
if(bt_surl.indexOf('http://')==-1 && bt_surl.indexOf('https://')==-1){
layer.alert('第三方云端URL不正确');return;
}
var postdata = {bt_type:bt_type, bt_surl:bt_surl};
}else{
var bt_url = $("input[name=bt_url]").val();
var bt_key = $("input[name=bt_key]").val();
if(bt_url == ''){
layer.alert('宝塔面板URL不能为空');return;
}
if(bt_url.indexOf('http://')==-1 && bt_url.indexOf('https://')==-1){
layer.alert('宝塔面板URL不正确');return;
}
if(bt_key == ''){
layer.alert('宝塔面板接口密钥不能为空');return;
}
var postdata = {os:'linux', bt_type:bt_type, bt_url:bt_url, bt_key:bt_key};
}
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/testbturl',
data : postdata,
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.msg(data.msg, {icon: 1, time:1000})
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
})
$("#testbturl2").click(function(){
var wbt_type = $("select[name=wbt_type]").val();
if(wbt_type == '1'){
var wbt_surl = $("input[name=wbt_surl]").val();
if(wbt_surl == ''){
layer.alert('第三方云端URL不能为空');return;
}
if(wbt_surl.indexOf('http://')==-1 && wbt_surl.indexOf('https://')==-1){
layer.alert('第三方云端URL不正确');return;
}
var postdata = {bt_type:wbt_type, bt_surl:wbt_surl};
}else{
var wbt_url = $("input[name=wbt_url]").val();
var wbt_key = $("input[name=wbt_key]").val();
if(wbt_url == ''){
layer.alert('宝塔面板URL不能为空');return;
}
if(wbt_url.indexOf('http://')==-1 && wbt_url.indexOf('https://')==-1){
layer.alert('宝塔面板URL不正确');return;
}
if(wbt_key == ''){
layer.alert('宝塔面板接口密钥不能为空');return;
}
var postdata = {os:'win', bt_type:wbt_type, bt_url:wbt_url, bt_key:wbt_key};
}
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/testbturl',
data : postdata,
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.msg(data.msg, {icon: 1, time:1000})
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
})
$("#testbturl3").click(function(){
var enbt_type = $("select[name=enbt_type]").val();
if(enbt_type == '1'){
var enbt_surl = $("input[name=enbt_surl]").val();
if(enbt_surl == ''){
layer.alert('第三方云端URL不能为空');return;
}
if(enbt_surl.indexOf('http://')==-1 && enbt_surl.indexOf('https://')==-1){
layer.alert('第三方云端URL不正确');return;
}
var postdata = {bt_type:enbt_type, bt_surl:enbt_surl};
}else{
var enbt_url = $("input[name=enbt_url]").val();
var enbt_key = $("input[name=enbt_key]").val();
if(enbt_url == ''){
layer.alert('宝塔面板URL不能为空');return;
}
if(enbt_url.indexOf('http://')==-1 && enbt_url.indexOf('https://')==-1){
layer.alert('宝塔面板URL不正确');return;
}
if(enbt_key == ''){
layer.alert('宝塔面板接口密钥不能为空');return;
}
var postdata = {os:'en', bt_type:enbt_type, bt_url:enbt_url, bt_key:enbt_key};
}
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/testbturl',
data : postdata,
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.msg(data.msg, {icon: 1, time:1000})
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
})
})
function saveSetting(obj){
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/set',
data : $(obj).serialize(),
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.alert('设置保存成功!', {
icon: 1,
closeBtn: false
}, function(){
window.location.reload()
});
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
return false;
}
function saveAccount(obj){
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/setaccount',
data : $(obj).serialize(),
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.alert('管理账号保存成功!请重新登录。', {
icon: 1,
closeBtn: false
}, function(){
window.location.reload()
});
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
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} {/block}

86
app/view/admin/ssl.html Normal file
View File

@ -0,0 +1,86 @@
{extend name="admin/layout" /}
{block name="title"}自签名SSL证书生成{/block}
{block name="main"}
<style>
.control-label[is-required]:before {
content: "*";
color: #f56c6c;
margin-right: 4px;
}
</style>
<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">自签名SSL证书生成</h3></div>
<div class="panel-body">
{if $isca}
<div class="alert alert-warning" style="word-break:break-all;">下载CA证书并导入可解决浏览器不安全提醒。<br/>Windows<a href="/ssl/baota_root.pfx">baota_root.pfx</a>密码为空Mac/Linux<a href="/ssl/baota_root.crt">baota_root.crt</a></div>
<form onsubmit="return makeSSL(this)" method="post" class="form" role="form">
<div class="form-group">
<label is-required="true" class="control-label">域名列表:</label>
<textarea class="form-control" name="domain_list" rows="6" placeholder="每行一个域名/IP支持通配符" required></textarea>
</div>
<div class="form-group">
<label class="control-label">通用名称:</label>
<input type="text" name="common_name" value="" placeholder="留空则为域名列表第一个域名" class="form-control"/>
</div>
<div class="form-group">
<label is-required="true" class="control-label">有效天数:</label>
<input type="number" name="validity" value="3650" class="form-control" required/>
</div>
<div class="form-group text-center">
<input type="submit" name="submit" value="生成自签名证书" class="btn btn-success btn-block"/>
</div>
<div class="form-group row" id="result" style="display:none;">
<div class="col-md-6">
<label class="control-label">SSL证书</label>
<textarea class="form-control" name="ssl_cert" rows="5" onclick="copy(this)" title="点击复制"></textarea>
</div>
<div class="col-md-6">
<label class="control-label">SSL证书私钥</label>
<textarea class="form-control" name="ssl_key" rows="5" onclick="copy(this)" title="点击复制"></textarea>
</div>
</div>
</form>
{else}
<div class="alert alert-danger" role="alert">你还没有生成CA证书无法生成SSL证书</div>
<div class="alert alert-info" style="word-break:break-all;">执行以下命令生成自签名CA证书。然后可通过接口或当前页面生成SSL证书用于面板访问。</div>
<div class="list-group-item" style="word-break:break-all;">cd {:app()->getRootPath()}app/script && chmod +x cacert.sh && ./cacert.sh</div><br/>
{/if}
</div>
</div>
<script src="{$cdnpublic}layer/3.5.1/layer.js"></script>
<script>
function makeSSL(obj){
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'POST',
url : '/admin/ssl',
data : $(obj).serialize(),
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
$("textarea[name='ssl_cert']").val(data.cert);
$("textarea[name='ssl_key']").val(data.key);
$("#result").show();
layer.msg('SSL证书生成成功', {icon:1, time:800});
}else{
layer.alert(data.msg, {icon: 2})
}
},
error:function(data){
layer.close(ii);
layer.msg('服务器错误');
}
});
return false;
}
function copy(obj){
if($(obj).val() == '') return;
$(obj).select();
document.execCommand("Copy");
layer.msg('复制成功', {icon:1, time:500});
}
</script>
{/block}

View File

@ -1,60 +1,60 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>温馨提示</title> <title>温馨提示</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta name="renderer" content="webkit"/> <meta name="renderer" content="webkit"/>
<style type="text/css"> <style type="text/css">
*{box-sizing:border-box;margin:0;padding:0;font-family:Lantinghei SC,Open Sans,Arial,Hiragino Sans GB,Microsoft YaHei,"微软雅黑",STHeiti,WenQuanYi Micro Hei,SimSun,sans-serif;-webkit-font-smoothing:antialiased} *{box-sizing:border-box;margin:0;padding:0;font-family:Lantinghei SC,Open Sans,Arial,Hiragino Sans GB,Microsoft YaHei,"微软雅黑",STHeiti,WenQuanYi Micro Hei,SimSun,sans-serif;-webkit-font-smoothing:antialiased}
body{padding:70px 0;background:#edf1f4;font-weight:400;font-size:1pc;-webkit-text-size-adjust:none;color:#333} body{padding:70px 0;background:#edf1f4;font-weight:400;font-size:1pc;-webkit-text-size-adjust:none;color:#333}
a{outline:0;color:#3498db;text-decoration:none;cursor:pointer} a{outline:0;color:#3498db;text-decoration:none;cursor:pointer}
.system-message{margin:20px 5%;padding:40px 20px;background:#fff;box-shadow:1px 1px 1px hsla(0,0%,39%,.1);text-align:center} .system-message{margin:20px 5%;padding:40px 20px;background:#fff;box-shadow:1px 1px 1px hsla(0,0%,39%,.1);text-align:center}
.system-message h1{margin:0;margin-bottom:9pt;color:#444;font-weight:400;font-size:40px} .system-message h1{margin:0;margin-bottom:9pt;color:#444;font-weight:400;font-size:40px}
.system-message .jump,.system-message .image{margin:20px 0;padding:0;padding:10px 0;font-weight:400} .system-message .jump,.system-message .image{margin:20px 0;padding:0;padding:10px 0;font-weight:400}
.system-message .jump{font-size:14px} .system-message .jump{font-size:14px}
.system-message .jump a{color:#333} .system-message .jump a{color:#333}
.system-message p{font-size:9pt;line-height:20px} .system-message p{font-size:9pt;line-height:20px}
.system-message .btn{display:inline-block;margin-right:10px;width:138px;height:2pc;border:1px solid #44a0e8;border-radius:30px;color:#44a0e8;text-align:center;font-size:1pc;line-height:2pc;margin-bottom:5px;} .system-message .btn{display:inline-block;margin-right:10px;width:138px;height:2pc;border:1px solid #44a0e8;border-radius:30px;color:#44a0e8;text-align:center;font-size:1pc;line-height:2pc;margin-bottom:5px;}
.success .btn{border-color:#69bf4e;color:#69bf4e} .success .btn{border-color:#69bf4e;color:#69bf4e}
.error .btn{border-color:#ff8992;color:#ff8992} .error .btn{border-color:#ff8992;color:#ff8992}
.info .btn{border-color:#3498db;color:#3498db} .info .btn{border-color:#3498db;color:#3498db}
.copyright p{width:100%;color:#919191;text-align:center;font-size:10px} .copyright p{width:100%;color:#919191;text-align:center;font-size:10px}
.system-message .btn-grey{border-color:#bbb;color:#bbb} .system-message .btn-grey{border-color:#bbb;color:#bbb}
.clearfix:after{clear:both;display:block;visibility:hidden;height:0;content:"."} .clearfix:after{clear:both;display:block;visibility:hidden;height:0;content:"."}
@media (max-width:768px){body {padding:20px 0;}} @media (max-width:768px){body {padding:20px 0;}}
@media (max-width:480px){.system-message h1{font-size:30px;}} @media (max-width:480px){.system-message h1{font-size:30px;}}
</style> </style>
</head> </head>
<body> <body>
<div class="system-message {$code}"> <div class="system-message {$code}">
<div class="image"> <div class="image">
<img src="/static/images/{$code}.svg" alt="" width="150" /> <img src="/static/images/{$code}.svg" alt="" width="150" />
</div> </div>
<h1>{$msg}</h1> <h1>{$msg}</h1>
{if $url} {if $url}
<p class="jump"> <p class="jump">
页面将在 <span id="wait">{$wait}</span> 秒后自动跳转 页面将在 <span id="wait">{$wait}</span> 秒后自动跳转
</p> </p>
{/if} {/if}
<p class="clearfix"> <p class="clearfix">
<a href="javascript:history.go(-1);" class="btn btn-grey">返回上一页</a> <a href="javascript:history.go(-1);" class="btn btn-grey">返回上一页</a>
{if $url} {if $url}
<a href="{$url}" class="btn btn-primary">立即跳转</a> <a href="{$url}" class="btn btn-primary">立即跳转</a>
{/if} {/if}
</p> </p>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
var wait = document.getElementById('wait'); var wait = document.getElementById('wait');
var interval = setInterval(function () { var interval = setInterval(function () {
var time = --wait.innerHTML; var time = --wait.innerHTML;
if (time <= 0) { if (time <= 0) {
location.href = "{$url}"; location.href = "{$url}";
clearInterval(interval); clearInterval(interval);
} }
}, 1000); }, 1000);
})(); })();
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,159 +1,306 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="renderer" content="webkit" /> <meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" /> <meta name="force-rendering" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>宝塔面板安装脚本</title> <title>宝塔面板安装脚本</title>
<link rel="stylesheet" type="text/css" href="/static/css/sanren.css" /> <link rel="stylesheet" type="text/css" href="/static/css/sanren.css" />
<link rel="stylesheet" type="text/css" href="/static/css/style.css" /> <link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<link rel="stylesheet" type="text/css" href="/static/css/download.css" /> <link rel="stylesheet" type="text/css" href="/static/css/download.css" />
</head> </head>
<body> <body>
<div class="down-main"> <div class="down-main">
<div class="d1"> <div class="d1">
<div class="wrap"> <div class="wrap">
<div class="i1t textcenter"> <div class="i1t textcenter">
<h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚本<img class="ml10" src="/static/images/i1ico_03.png"></h1> <h1 class="disflex flex_center flex_lrcenter textcenter">宝塔面板安装脚本<img class="ml10" src="/static/images/i1ico_03.png"></h1>
<div class="text20 mt_25 wap_mt15 textcenter cl8"> <div class="text20 mt_25 wap_mt15 textcenter cl8">
<p>2分钟装好面板一键管理服务器</p> <p>2分钟装好面板一键管理服务器</p>
<p>集成LAMP/LNMP环境安装网站、FTP、数据库、文件管理、软件安装等功能</p> <p>集成LAMP/LNMP环境安装网站、FTP、数据库、文件管理、软件安装等功能</p>
</div> </div>
<div class="mt_30 i1ta wap_mt15"> <div class="disflex flex_lrcenter mt_50 install-list">
<a href="https://demo.bt.cn" target="_block" rel="noreferrer">查看演示</a> <div class="install-box linux">
<a href="javascript:;" id="goInstallLinux"> <div class="img">
<img class="middle mr10" src="/static/images/i1aico_03.png"> <img src="/static/images/prd_1_03.png">
立即免费安装 </div>
</a> <div class="cont">
</div> <div class="top">
</div> <div class="title">Linux面板 {:config_get('new_version')}</div>
</div> <div class="desc">
</div> 支持Centos、Ubuntu、Deepin、Debian、Fedora等Linux系统。
<div class="d2" id="instal-linux"> <a class="link" href="https://demo.bt.cn/login" target="_blank" style="margin-left: 5px; font-weight: 700" rel="noreferrer">查看演示</a>
<div class="wrap"> </div>
<div class="wrap-title linux-title"> <div class="mark">
<div class="text">使用此云端的宝塔面板(版本:{:config_get('new_version')}</div> <span>2分钟装好</span>
</div> <span>阿里云推荐</span>
<div class="desc"> <span>腾讯云推荐</span>
使用 SSH 连接工具,如 </div>
<a class="link" href="https://www.putty.org/" target="_blank" rel="noreferrer">PUTTY</a> </div>
连接到您的 Linux 服务器后, <div class="bottom">
<a class="link" href="https://www.bt.cn/bbs/thread-50002-1-1.html" target="_blank" rel="noreferrer">挂载磁盘</a> <a class="btn" href="javascript:;" id="goInstallLinux">查看安装脚本</a>
,根据系统执行相应命令开始安装: </div>
</div> </div>
<div class="install-code"> </div>
<span class="osname">一键安装脚本</span> {if config_get('new_version_win')}<div class="install-box windows">
<div class="code-cont"> <div class="img">
<div class="command" title="点击复制一键安装脚本">wget -O install.sh {$siteurl}/install/install_6.0.sh && sh install.sh</div> <img src="/static/images/prd_2_03.png">
<span class="ico-copy" title="点击复制一键安装脚本" data-clipboard-text="wget -O install.sh {$siteurl}/install/install_6.0.sh && sh install.sh">复制</span> </div>
</div> <div class="cont">
</div> <div class="top">
<div class="install-code"> <div class="title">Windows面板 {:config_get('new_version_win')}</div>
<span class="osname">一键更新脚本</span> <div class="desc">支持Windows Server 2008 R2/2012/2016/2019/202264位系统</div>
<div class="code-cont"> <div class="mark">
<div class="command" title="点击复制一键更新脚本">curl {$siteurl}/install/update6.sh|bash</div> <span>操作简单</span>
<span class="ico-copy" title="点击复制一键更新脚本" data-clipboard-text="curl {$siteurl}/install/update6.sh|bash">复制</span> <span>使用方便</span>
</div> </div>
</div> </div>
<div class="tips" style="color: orangered; font-weight: 700"> <div class="bottom">
<p>注意必须为没装过其它环境如Apache/Nginx/php/MySQL的新系统,推荐使用centos 7.X的系统安装宝塔面板</p> <a class="btn" href="javascript:;" id="goInstallWindows">查看安装方法</a>
<p style="text-indent: 3em">推荐使用Chrome、火狐、edge浏览器国产浏览器请使用极速模式访问面板登录地址</p> </div>
<p style="text-indent: 3em">如果使用过官方版或其他第三方云端的版本,使用一键更新脚本即可切换到此云端</p> </div>
</div> </div>{/if}
</div> </div>
</div> {if config_get('new_version_btm') || config_get('new_version_en')}<div class="disflex flex_lrcenter mt_30 install-list">
<div class="d4" id="instal-cloud"> {if config_get('new_version_win')}<div class="install-box monitor">
<div class="wrap"> <div class="img">
<div class="wrap-title"> <img src="/static/images/bt_monitor.png" style="height: 96px;"/>
<div class="text">更新日志</div> </div>
</div> <div class="cont">
<div class="desc"> <div class="top">
<p>宝塔Linux面板更新到{:config_get('new_version')}</p> <div class="title">云安全监控</div>
</div> <div class="desc">多机跨平台安全管理和监控</div>
</div> </div>
</div> <div class="bottom">
<div class="animate-bg"></div> <a class="btn" href="javascript:;" id="goInstallMonitor">查看安装脚本</a>
</div> </div>
</div>
<div class="foot"> </div>{/if}
<div class="wrap"> {if config_get('new_version_en')}<div class="install-box monitor">
<div class="fb textcenter"> <div class="img">
<div class="fb1 textcenter"> <img src="/static/images/aapanel.png" style="height: 96px;"/>
<a href="http://www.bt.cn/new/agreement_open.html" target="_blank" rel="noreferrer">《开源许可协议》</a> </div>
<i></i> <div class="cont">
<a href="http://www.bt.cn/new/agreement_user.html" target="_blank" rel="noreferrer">《用户协议》</a> <div class="top">
<i></i> <div class="title">aaPanel {:config_get('new_version_en')}</div>
<a href="http://www.bt.cn/new/agreement_privacy.html" target="_blank" rel="noreferrer">《隐私声明》</a> <div class="desc">宝塔面板国际版</div>
</div> </div>
<div class="fb2 mt_15"> <div class="bottom">
<p> <a class="btn" href="javascript:;" id="goInstallAaPanel">查看安装脚本</a>
Copyright © 2022 宝塔面板安装脚本 </div>
</p> </div>
</div> </div>{/if}
</div> </div>{/if}
</div> </div>
</div> </div>
</div>
<script src="//cdn.staticfile.org/jquery/3.6.0/jquery.min.js" type="text/javascript" charset="utf-8"></script> <div class="d2" id="instal-linux">
<script src="//cdn.staticfile.org/layer/3.5.1/layer.js" type="text/javascript" charset="utf-8"></script> <div class="wrap">
<div class="wrap-title linux-title">
<script type="text/javascript" src="//cdn.staticfile.org/clipboard.js/1.7.1/clipboard.min.js"></script> <div class="text">Linux面板{:config_get('new_version')}安装脚本</div>
<script type="text/javascript" src="/static/js/dx.js"></script> </div>
<script> <div class="desc">
$(function () { 使用 SSH 连接工具,如
var userId = ''; <a class="link" href="https://www.putty.org/" target="_blank" rel="noreferrer">PUTTY</a>
连接到您的 Linux 服务器后,
// 复制安装命令 <a class="link" href="https://www.bt.cn/bbs/thread-50002-1-1.html" target="_blank" rel="noreferrer">挂载磁盘</a>
var clipboard = new Clipboard('.ico-copy', { ,根据系统执行相应命令开始安装:
text: function (element) { </div>
return $(element).prev().text(); <div class="install-code">
}, <span class="osname">Centos安装脚本</span>
}); <div class="code-cont">
clipboard <div class="command" title="点击复制Centos安装脚本">yum install -y wget && wget -O install.sh {$siteurl}/install/install_panel.sh && sh install.sh</div>
.on('success', function (e) { <span class="ico-copy" title="点击复制Centos安装脚本" data-clipboard-text="yum install -y wget && wget -O install.sh {$siteurl}/install/install_panel.sh && sh install.sh">复制</span>
layer.msg(e.trigger.title + '成功', { icon: 1 }); </div>
}) </div>
.on('error', function (e) { <div class="install-code">
layer.msg('复制失败请手动选中文本Ctrl+c复制内容', { icon: 2 }); <span class="osname">Ubuntu/Debian安装脚本</span>
}); <div class="code-cont">
<div class="command" title="点击复制Ubuntu/Debian安装脚本">wget -O install.sh {$siteurl}/install/install_panel.sh && bash install.sh</div>
$('.install-code .command').click(function () { <span class="ico-copy" title="点击复制Ubuntu/Debian安装脚本" data-clipboard-text="wget -O install.sh {$siteurl}/install/install_panel.sh && bash install.sh">复制</span>
$(this).next('.ico-copy').click(); </div>
}); </div>
<div class="install-code">
$('#goInstallLinux').click(function () { <span class="osname">一键更新脚本</span>
scrollTop('#instal-linux'); <div class="code-cont">
}); <div class="command" title="点击复制一键更新脚本">curl {$siteurl}/install/update6.sh|bash</div>
<span class="ico-copy" title="点击复制一键更新脚本" data-clipboard-text="curl {$siteurl}/install/update6.sh|bash">复制</span>
$('#goOnlineInstall').click(function () { </div>
scrollTop('#online-instal'); </div>
}); <div class="tips" style="color: orangered; font-weight: 700">
<p>注意必须为没装过其它环境如Apache/Nginx/php/MySQL的新系统,推荐使用centos 7.X的系统安装宝塔面板</p>
$('#goInstallCloud').click(function () { <p style="text-indent: 3em">推荐使用Chrome、火狐、edge浏览器国产浏览器请使用极速模式访问面板登录地址</p>
scrollTop('#instal-cloud'); <p style="text-indent: 3em">如果使用过官方版或其他第三方云端的版本,使用一键更新脚本即可切换到此云端</p>
}); </div>
</div>
function GetRequest() { </div>
var url = location.search; {if config_get('new_version_win')}
//获取url中"?"符后的字串 <div class="d4" id="instal-windows" style="background-color: #edf6ef;">
var theRequest = new Object(); <div class="wrap">
if (url.indexOf('?') != -1) { <div class="wrap-title">
var str = url.substr(1); <div class="text">Windows面板{:config_get('new_version_win')}安装方法</div>
} </div>
return str; <div class="desc">
} <p>1、使用<a class="link" href="https://download.bt.cn/win/panel/go/BtSoft.exe" target="_blank" rel="noreferrer">官方安装程序</a>进行安装,安装完先不要进入面板。</p>
if (GetRequest() == 'bt') { <p>2、在命令提示符cmd输入以下一键更新命令然后重启面板。</p>
scrollTop('#instal-linux'); <p>3、打开面板后绑定账号时输入任意账号密码即可。</p>
} </div>
<div class="install-code">
// 滚动到指定位置 <div class="code-cont">
function scrollTop(el) { <div class="command" title="点击复制一键更新命令">wget {$siteurl}/win/install/panel_update.py -O C:/update.py && &quot;C:\Program Files\python\python.exe&quot; C:/update.py {:config_get('new_version_win')}</div>
var headHeight = 0; <span class="ico-copy" title="点击复制一键更新命令" data-clipboard-text="wget {$siteurl}/win/install/panel_update.py -O C:/update.py && &quot;C:\Program Files\python\python.exe&quot; C:/update.py {:config_get('new_version_win')}">复制</span>
$('html, body').animate({ scrollTop: $(el).offset().top - headHeight }, { duration: 200, easing: 'swing' }); </div>
} </div>
}); <div class="tips" style="color: orangered; font-weight: 700">
</script> <p>注意支持Windows Server 2012/Windows 8及以上系统且未安装其它环境</p>
</div>
</body> </div>
</div>{/if}
{if config_get('new_version_btm')}
<div class="d4" id="instal-monitor">
<div class="wrap">
<div class="wrap-title">
<div class="text" style="margin-right: 12px;">云安全监控{:config_get('new_version_btm')}安装脚本</div>
</div>
<div class="desc">
使用 SSH 连接工具,如
<a class="link" href="https://www.putty.org/" target="_blank" rel="noreferrer">PUTTY</a>
连接到您的 Linux 服务器后,根据系统执行相应命令开始安装:
</div>
<div class="install-code">
<span class="osname">云安全监控安装脚本</span>
<div class="code-cont">
<div class="command" title="点击复制安装脚本">curl -sS {$siteurl}/install/install_btmonitor.sh -o /tmp/install_btmonitor.sh && bash /tmp/install_btmonitor.sh</div>
<span class="ico-copy" title="点击复制安装脚本" data-clipboard-text="curl -sS {$siteurl}/install/install_btmonitor.sh -o /tmp/install_btmonitor.sh && bash /tmp/install_btmonitor.sh">复制</span>
</div>
</div>
<div class="install-code">
<span class="osname">云安全监控更新脚本</span>
<div class="code-cont">
<div class="command" title="点击复制更新脚本">curl {$siteurl}/install/update_btmonitor.sh|bash</div>
<span class="ico-copy" title="点击复制更新脚本" data-clipboard-text="curl {$siteurl}/install/update_btmonitor.sh|bash">复制</span>
</div>
</div>
<div class="tips" style="color: orangered; font-weight: 700">
<p>注意安装完成后推荐使用Chrome、火狐、edge浏览器国产浏览器极速模式访问登录系统</p>
</div>
</div>
</div>{/if}
{if config_get('new_version_en')}
<div class="d4" id="instal-aapanel" style="background-color: #edf6ef;">
<div class="wrap">
<div class="wrap-title">
<div class="text">aaPanel {:config_get('new_version_en')} install script</div>
</div>
<div class="desc">
<p>It is recommended that you use Ubuntu22.04 to install aaPanel</p>
</div>
<div class="install-code">
<span class="osname">Instarll script</span>
<div class="code-cont">
<div class="command" title="Copy successfully, please paste it to the server installation">URL={$siteurl}/install/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO $URL ;else wget -O install_7.0_en.sh $URL;fi;bash install_7.0_en.sh</div>
<span class="ico-copy" title="Copy successfully, please paste it to the server installation" data-clipboard-text="URL={$siteurl}/install/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO $URL ;else wget -O install_7.0_en.sh $URL;fi;bash install_7.0_en.sh">复制</span>
</div>
</div>
<div class="install-code">
<span class="osname">Upgrade script</span>
<div class="code-cont">
<div class="command" title="Copy successfully, please paste it to the server installation">curl {$siteurl}/install/update_7.x_en.sh|bash</div>
<span class="ico-copy" title="Copy successfully, please paste it to the server installation" data-clipboard-text="curl {$siteurl}/install/update_7.x_en.sh|bash">复制</span>
</div>
</div>
</div>
</div>{/if}
<div class="animate-bg"></div>
</div>
<div class="foot">
<div class="wrap">
<div class="fb textcenter">
<div class="fb1 textcenter">
<a href="http://www.bt.cn/new/agreement_open.html" target="_blank" rel="noreferrer">《开源许可协议》</a>
<i></i>
<a href="http://www.bt.cn/new/agreement_user.html" target="_blank" rel="noreferrer">《用户协议》</a>
<i></i>
<a href="http://www.bt.cn/new/agreement_privacy.html" target="_blank" rel="noreferrer">《隐私声明》</a>
</div>
<div class="fb2 mt_15">
<p>
Copyright © {:date('Y')} 宝塔面板安装脚本
</p>
</div>
</div>
</div>
</div>
<script src="{$cdnpublic}jquery/3.6.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{$cdnpublic}layer/3.5.1/layer.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="{$cdnpublic}clipboard.js/1.7.1/clipboard.min.js"></script>
<script type="text/javascript" src="/static/js/dx.js"></script>
<script>
$(function () {
var userId = '';
// 复制安装命令
var clipboard = new Clipboard('.ico-copy', {
text: function (element) {
return $(element).prev().text();
},
});
clipboard
.on('success', function (e) {
layer.msg(e.trigger.title + '成功', { icon: 1 });
})
.on('error', function (e) {
layer.msg('复制失败请手动选中文本Ctrl+c复制内容', { icon: 2 });
});
$('.install-code .command').click(function () {
$(this).next('.ico-copy').click();
});
$('#goInstallLinux').click(function () {
scrollTop('#instal-linux');
});
$('#goInstallWindows').click(function () {
scrollTop('#instal-windows');
});
$('#goInstallCloud').click(function () {
scrollTop('#instal-cloud');
});
$('#goInstallMonitor').click(function () {
scrollTop('#instal-monitor');
});
$('#goInstallAaPanel').click(function () {
scrollTop('#instal-aapanel');
});
function GetRequest() {
var url = location.search;
//获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf('?') != -1) {
var str = url.substr(1);
}
return str;
}
if (GetRequest() == 'bt') {
scrollTop('#instal-linux');
}
// 滚动到指定位置
function scrollTop(el) {
var headHeight = 0;
$('html, body').animate({ scrollTop: $(el).offset().top - headHeight }, { duration: 200, easing: 'swing' });
}
});
</script>
</body>
</html> </html>

268
app/view/install/index.html Normal file
View File

@ -0,0 +1,268 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>宝塔第三方云端 - 安装程序</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<style>
body {
background: #f1f6fd;
margin: 0;
padding: 0;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body, input, button {
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, 'Microsoft Yahei', Arial, sans-serif;
font-size: 14px;
color: #7E96B3;
}
.container {
max-width: 480px;
margin: 0 auto;
padding: 20px;
text-align: center;
}
a {
color: #4e73df;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 {
margin-top: 0;
margin-bottom: 10px;
}
h2 {
font-size: 28px;
font-weight: normal;
color: #3C5675;
margin-bottom: 0;
margin-top: 0;
}
form {
margin-top: 40px;
}
.form-group {
margin-bottom: 20px;
}
.form-group .form-field:first-child input {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.form-group .form-field:last-child input {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.form-field input {
background: #fff;
margin: 0 0 2px;
border: 2px solid transparent;
transition: background 0.2s, border-color 0.2s, color 0.2s;
width: 100%;
padding: 15px 15px 15px 180px;
box-sizing: border-box;
}
.form-field input:focus {
border-color: #4e73df;
background: #fff;
color: #444;
outline: none;
}
.form-field label {
float: left;
width: 160px;
text-align: right;
margin-right: -160px;
position: relative;
margin-top: 15px;
font-size: 14px;
pointer-events: none;
opacity: 0.7;
}
button, .btn {
background: #3C5675;
color: #fff;
border: 0;
font-weight: bold;
border-radius: 4px;
cursor: pointer;
padding: 15px 30px;
-webkit-appearance: none;
}
button[disabled] {
opacity: 0.5;
}
.form-buttons {
height: 52px;
line-height: 52px;
}
.form-buttons .btn {
margin-right: 5px;
}
#error, .error, #success, .success, #warmtips, .warmtips {
background: #D83E3E;
color: #fff;
padding: 15px 20px;
border-radius: 4px;
margin-bottom: 20px;
}
#success {
background: #3C5675;
}
#error a, .error a {
color: white;
text-decoration: underline;
}
#warmtips {
background: #fff;
font-size: 14px;
color: #3C5675;
border: 2px solid #4e73df;
text-align: left;
}
</style>
</head>
<body>
<div class="container">
<h1>
<svg t="1660545699809" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4887" width="100px" height="100px">
<path d="M811.4 418.7C765.6 297.9 648.9 212 512.2 212S258.8 297.8 213 418.6C127.3 441.1 64 519.1 64 612c0 110.5 89.5 200 199.9 200h496.2C870.5 812 960 722.5 960 612c0-92.7-63.1-170.7-148.6-193.3z m36.3 281c-23.4 23.4-54.5 36.3-87.6 36.3H263.9c-33.1 0-64.2-12.9-87.6-36.3-23.4-23.4-36.3-54.6-36.3-87.7 0-28 9.1-54.3 26.2-76.3 16.7-21.3 40.2-36.8 66.1-43.7l37.9-9.9 13.9-36.6c8.6-22.8 20.6-44.1 35.7-63.4 14.9-19.2 32.6-35.9 52.4-49.9 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.2c19.9 14 37.5 30.8 52.4 49.9 15.1 19.3 27.1 40.7 35.7 63.4l13.8 36.5 37.8 10c54.3 14.5 92.1 63.8 92.1 120 0 33.1-12.9 64.3-36.3 87.7z" p-id="4888" fill="#4e73df"></path>
</svg>
</h1>
<h2>宝塔第三方云端 - 安装程序</h2>
<div>
<form method="post">
<div id="error" style="display:none"></div>
<div id="success" style="display:none"></div>
<div id="warmtips" style="display:none"><p>安装完成后,你还需要进行以下操作:</p><p>1、在后台使用批量替换工具执行命令一键替换压缩包与安装脚本中的域名。</p><p></p>2、在后台配置面板对接同步插件列表与插件包。</p></div>
<div class="form-group">
<div class="form-field">
<label>MySQL 数据库地址</label>
<input type="text" name="mysql_host" value="localhost" required="">
</div>
<div class="form-field">
<label>MySQL 数据库端口</label>
<input type="number" name="mysql_port" value="3306">
</div>
<div class="form-field">
<label>MySQL 用户名</label>
<input type="text" name="mysql_user" value="" required="">
</div>
<div class="form-field">
<label>MySQL 密码</label>
<input type="text" name="mysql_pwd" value="" required="">
</div>
<div class="form-field">
<label>MySQL 数据库名</label>
<input type="text" name="mysql_name" value="" required="">
</div>
<div class="form-field">
<label>MySQL 数据表前缀</label>
<input type="text" name="mysql_prefix" value="cloud_">
</div>
</div>
<div class="form-group">
<div class="form-field">
<label>管理员用户名</label>
<input type="text" name="admin_username" value="admin" required=""/>
</div>
<div class="form-field">
<label>管理员密码</label>
<input type="text" name="admin_password" value="123456" required="">
</div>
</div>
<div class="form-buttons">
<!--@formatter:off-->
<button type="submit" >点击安装</button>
<!--@formatter:on-->
</div>
</form>
</div>
</div>
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function () {
$('form').on('submit', function (e) {
e.preventDefault();
var form = this;
var $error = $("#error");
var $success = $("#success");
var $button = $(this).find('button')
.text("安装中...")
.prop('disabled', true);
$.ajax({
url: "",
type: "POST",
dataType: "json",
data: $(this).serialize(),
success: function (ret) {
if (ret.code == 1) {
$error.hide();
$(".form-group", form).remove();
$button.remove();
$("#success").text(ret.msg).show();
$("#warmtips").show();
$buttons = $(".form-buttons", form);
$('<a class="btn" href="/admin" style="background:#4e73df">进入后台</a>').appendTo($buttons);
} else {
$error.show().text(ret.msg);
$button.prop('disabled', false).text("点击安装");
$("html,body").animate({
scrollTop: 0
}, 500);
}
},
error: function (xhr) {
$error.show().text(xhr.responseText);
$button.prop('disabled', false).text("点击安装");
$("html,body").animate({
scrollTop: 0
}, 500);
}
});
return false;
});
});
</script>
</body>
</html>

View File

@ -6,5 +6,8 @@ return [
// 指令定义 // 指令定义
'commands' => [ 'commands' => [
'updateall' => 'app\command\UpdateAll', 'updateall' => 'app\command\UpdateAll',
'decrypt' => 'app\command\DecryptFile',
'clean' => 'app\command\Clean',
'cleanvitejs' => 'app\command\CleanViteJs',
], ],
]; ];

0
data/config/.gitkeep Normal file
View File

File diff suppressed because one or more lines are too long

0
data/en/config/.gitkeep Normal file
View File

View File

View File

View File

View File

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Some files were not shown because too many files have changed in this diff Show More