|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\File\File;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\CosService;
|
|
|
|
use App\Utils\EncryptUtils;
|
|
...
|
...
|
@@ -456,11 +457,11 @@ if (!function_exists('getImageUrl')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
function getImageUrl($path,$location = 0,$storage_type = 0){
|
|
|
|
function getImageUrl($path,$storage_type = 0){
|
|
|
|
if(is_array($path)){
|
|
|
|
$url =[];
|
|
|
|
foreach ($path as $v){
|
|
|
|
$url[] = getImageUrl($v,$location,$storage_type);
|
|
|
|
$url[] = getImageUrl($v,$storage_type);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(empty($path)){
|
|
...
|
...
|
@@ -472,7 +473,12 @@ if (!function_exists('getImageUrl')) { |
|
|
|
if(substr($path,0,2) == '//'){
|
|
|
|
return 'https:'.$path;
|
|
|
|
}
|
|
|
|
if($location == 0){
|
|
|
|
$imageModel = new Image();
|
|
|
|
$imageInfo = $imageModel->read(['path'=>$path],'is_cos');
|
|
|
|
if($imageInfo === false){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if($imageInfo['is_cos'] == 1){
|
|
|
|
$cos = config('filesystems.disks.cos');
|
|
|
|
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
|
|
|
|
$url = $cosCdn.$path;
|
|
...
|
...
|
@@ -494,11 +500,11 @@ if (!function_exists('getFileUrl')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
function getFileUrl($path,$location = 0,$storage_type = 0){
|
|
|
|
function getFileUrl($path,$storage_type = 0){
|
|
|
|
if(is_array($path)){
|
|
|
|
$url =[];
|
|
|
|
foreach ($path as $v){
|
|
|
|
$url[] = getFileUrl($v,$location,$storage_type);
|
|
|
|
$url[] = getFileUrl($v,$storage_type);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(empty($path)){
|
|
...
|
...
|
@@ -510,7 +516,12 @@ if (!function_exists('getFileUrl')) { |
|
|
|
if(substr($path,0,2) == '//'){
|
|
|
|
return 'https:'.$path;
|
|
|
|
}
|
|
|
|
if($location == 0){
|
|
|
|
$fileModel = new File();
|
|
|
|
$fileInfo = $fileModel->read(['path'=>$path],'is_cos');
|
|
|
|
if($fileInfo === false){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if($fileInfo['is_cos'] == 1){
|
|
|
|
$cos = config('filesystems.disks.cos');
|
|
|
|
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
|
|
|
|
$url = $cosCdn.$path;
|
|
...
|
...
|
@@ -568,7 +579,8 @@ if (!function_exists('str_replace_url')) { |
|
|
|
$cos = config('filesystems.disks.cos');
|
|
|
|
$cosCdn = $cos['cdn'];
|
|
|
|
$cosCdn1 = $cos['cdn1'];
|
|
|
|
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false))){
|
|
|
|
$cosCdn2 = config('filesystems.disks.s3')['cdn'];
|
|
|
|
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){
|
|
|
|
// 外部URL无需解析
|
|
|
|
// 使用 parse_url 函数来解析 URL
|
|
|
|
$urlParts = parse_url($url);
|
...
|
...
|
|