wallpaper_to_CDN

master
cn.yimian.xyz 3 years ago
parent 7d03619dbb
commit 1e2f2f5959
  1. 11
      functions.php
  2. 6
      index.php

@ -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){

@ -168,7 +168,11 @@ function returnImg($path){
$url = getImgCDN($path);
//$url = getImgOneindex($path);
}else{
$url = getImg($path);
if($GLOBALS['type'] == 'wallpaper') {
$url = getImgCDNwallpaper($path);
}else{
$url = getImg($path);
}
}
if($GLOBALS['display']) echo file_get_contents($url); else header("Location: $url");
}

Loading…
Cancel
Save