mirror of https://github.com/flucont/btcloud.git
flucout
1 year ago
27 changed files with 3015 additions and 2473 deletions
-
16app/command/UpdateAll.php
-
37app/controller/Admin.php
-
28app/controller/Api.php
-
282app/lib/BtPlugins.php
-
254app/lib/Plugins.php
-
203app/lib/ThirdPlugins.php
-
4app/script/convert.sh
-
7app/view/admin/layout.html
-
6app/view/admin/list.html
-
4app/view/admin/log.html
-
72app/view/admin/plugins.html
-
72app/view/admin/pluginswin.html
-
4app/view/admin/record.html
-
169app/view/admin/set.html
-
8install.sql
-
13public/install/install_6.0.sh
-
3public/install/install_btmonitor.sh
-
BINpublic/install/src/bt-monitor-2.2.9.zip
-
BINpublic/install/src/panel6.zip
-
BINpublic/install/update/LinuxPanel-8.0.2.zip
-
12public/install/update6.sh
-
3public/install/update_btmonitor.sh
-
BINpublic/win/panel/panel_7.9.0.zip
-
3route/app.php
-
2wiki/update.md
@ -0,0 +1,282 @@ |
|||
<?php |
|||
|
|||
namespace app\lib; |
|||
|
|||
use Exception; |
|||
use ZipArchive; |
|||
|
|||
class BtPlugins |
|||
{ |
|||
private $btapi; |
|||
private $os; |
|||
|
|||
//需屏蔽的插件名称列表
|
|||
private static $block_plugins = ['dns']; |
|||
|
|||
public function __construct($os){ |
|||
$this->os = $os; |
|||
if($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('获取插件列表失败:插件列表为空'); |
|||
} |
|||
foreach($result['list'] as $k=>$v){ |
|||
if(in_array($v['name'], self::$block_plugins)) unset($result['list'][$k]); |
|||
} |
|||
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) |
|||
{ |
|||
$zip->extractTo(get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version); |
|||
$zip->close(); |
|||
$main_filepath = get_data_dir($this->os).'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文件,需要解密
|
|||
$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(); |
|||
} |
|||
} |
|||
}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) && strlen($data)!=24){ |
|||
$tmp = openssl_decrypt($data, 'aes-128-cbc', $key, 0, $iv); |
|||
if($tmp) $de_text .= $tmp; |
|||
} |
|||
} |
|||
if(!empty($de_text) && strpos($de_text, 'import ')!==false){ |
|||
file_put_contents($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('\'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/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); |
|||
|
|||
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']:'获取失败'); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,203 @@ |
|||
<?php |
|||
|
|||
namespace app\lib; |
|||
|
|||
use Exception; |
|||
use ZipArchive; |
|||
|
|||
class ThirdPlugins |
|||
{ |
|||
private $url; |
|||
private $os; |
|||
|
|||
public function __construct($os) |
|||
{ |
|||
$this->os = $os; |
|||
$url = $os == 'Windows' ? config_get('wbt_surl') : config_get('bt_surl'); |
|||
if(!$url) throw new Exception('请先配置好第三方云端首页URL'); |
|||
$this->url = $url; |
|||
} |
|||
|
|||
//获取插件列表
|
|||
public function get_plugin_list() |
|||
{ |
|||
$url = $this->os == 'Windows' ? $this->url . 'api/wpanel/get_soft_list' : $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->extractTo(get_data_dir($this->os).'plugins/folder/'.$plugin_name.'-'.$version); |
|||
$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; |
|||
} |
|||
} |
|||
|
|||
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; |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue