|
|
|
@ -312,9 +312,18 @@ function getImgOneindex($path){ |
|
|
|
|
|
|
|
|
|
function getImgCDN($path){ |
|
|
|
|
preg_match_all('/img_(\S*?)_(\d{2,4})x(\d{2,4})_(\S*?)_(\S*?)_(\S*?).(jpe?g|png|gif|svg)\b/', $path, $arr); |
|
|
|
|
return str_replace('yimian-image.obs.cn-east-2.myhuaweicloud.com:443/moe','cdn.jsdelivr.net/npm/ushio-api-img-moe@5.0.'.intval($arr[1][0]/10).'',obsSign($path, $time)); |
|
|
|
|
return str_replace('moe','https://cdn.jsdelivr.net/npm/ushio-api-img-moe@5.0.'.intval($arr[1][0]/10).'',$path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getImgCDNwallpaper($path){ |
|
|
|
|
preg_match_all('/img_(\S*?)_(\d{2,4})x(\d{2,4})_(\S*?)_(\S*?)_(\S*?).(jpe?g|png|gif|svg)\b/', $path, $arr); |
|
|
|
|
$date = strtotime($arr[1][0].' 00:00:00'); |
|
|
|
|
$dateline = strtotime('2021-07-11 00:00:00'); |
|
|
|
|
if($date < $dateline) |
|
|
|
|
return str_replace('wallpaper','https://cdn.jsdelivr.net/npm/ushio-api-img-wallpaper@1.1'.date('y.nw', $date).'',$path); |
|
|
|
|
else |
|
|
|
|
return getImg($path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function obsSign($path, $expires = 300){ |
|
|
|
@ -343,30 +352,42 @@ function obsSign($path, $expires = 300){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getImgsInfo($type, $isFast = false){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$obsClient = new ObsClient([ |
|
|
|
|
'key' => $GLOBALS['huawei_AK'], |
|
|
|
|
'secret' => $GLOBALS['huawei_SK'], |
|
|
|
|
'endpoint' => "https://obs.cn-east-2.myhuaweicloud.com", |
|
|
|
|
]); |
|
|
|
|
$redis = new redis(); |
|
|
|
|
$redis->connect('redis',6379); |
|
|
|
|
|
|
|
|
|
$resp = $obsClient -> listObjects([ |
|
|
|
|
'Bucket' => 'yimian-image', |
|
|
|
|
'MaxKeys' => 10000, |
|
|
|
|
'Prefix' => $type.'/', |
|
|
|
|
'Marker' => $type.'/img' |
|
|
|
|
]); |
|
|
|
|
$pifix = '__imgInfoCache/'.$type; |
|
|
|
|
|
|
|
|
|
if($redis->exists($pifix) && strlen($redis->get($pifix)) > 10){ |
|
|
|
|
$str = $redis->get($pifix); |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
//ini_set("pcre.backtrack_limit" , -1); ini_set("pcre.recursion_limit" , -1); ini_set("memory_limit" , "1024M"); |
|
|
|
|
$obsClient = new ObsClient([ |
|
|
|
|
'key' => $GLOBALS['huawei_AK'], |
|
|
|
|
'secret' => $GLOBALS['huawei_SK'], |
|
|
|
|
'endpoint' => "https://obs.cn-east-2.myhuaweicloud.com", |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
foreach($resp['Contents'] as $index => $val){ |
|
|
|
|
$str .= $val['Key'].' '; |
|
|
|
|
}; |
|
|
|
|
$resp = $obsClient -> listObjects([ |
|
|
|
|
'Bucket' => 'yimian-image', |
|
|
|
|
'MaxKeys' => 10000, |
|
|
|
|
'Prefix' => $type.'/', |
|
|
|
|
'Marker' => $type.'/img' |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$obsClient -> close(); |
|
|
|
|
|
|
|
|
|
//ini_set("pcre.backtrack_limit" , -1); ini_set("pcre.recursion_limit" , -1); ini_set("memory_limit" , "1024M"); |
|
|
|
|
|
|
|
|
|
foreach($resp['Contents'] as $index => $val){ |
|
|
|
|
$str .= $val['Key'].' '; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
$obsClient -> close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$redis->setEx($pifix, 3600, $str); |
|
|
|
|
} |
|
|
|
|
preg_match_all('/img_(\S*?)_(\d{2,4})x(\d{2,4})_(\S*?)_(\S*?)_(\S*?).(jpe?g|png|gif|svg)\b/', $str, $arr); |
|
|
|
|
|
|
|
|
|
//echo var_dump($arr); |
|
|
|
|