diff --git a/functions.php b/functions.php index cb4cd8b..1e9a23c 100755 --- a/functions.php +++ b/functions.php @@ -206,6 +206,7 @@ function get_from(){ if($_SERVER['HTTP_REFERER']) return $_SERVER['HTTP_REFERER']; elseif($_REQUEST['from']) return $_REQUEST['from']; + return ''; } function get_from_domain(){ @@ -309,7 +310,7 @@ function getImgOneindex($path){ return str_replace('yimian-image.obs.cn-east-2.myhuaweicloud.com:443','onedrive.yimian.xyz/img',obsSign($path, $time)); } -function getImgCDN($path){ +function getImgCDNProxy($path){ if(stripos($path, 'moe') !== false){ preg_match_all('/img_(\S*?)_(\d{2,4})x(\d{2,4})_(\S*?)_(\S*?)_(\S*?).(jpe?g|png|gif|svg)\b/', $path, $arr); return 'https://proxy.yimian.xyz/get/?url='.base64_encode(str_replace('moe','https://cdn.jsdelivr.net/npm/ushio-api-img-moe@5.0.'.intval($arr[1][0]/10).'',$path)); @@ -317,6 +318,14 @@ function getImgCDN($path){ return getImg($path); } +function getImgCDN($path){ + if(stripos($path, 'moe') !== false){ + 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('moe','https://cdn.jsdelivr.net/npm/ushio-api-img-moe@5.0.'.intval($arr[1][0]/10).'',$path); + } + return getImg($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'); diff --git a/index.php b/index.php index 0011a17..d4f171f 100755 --- a/index.php +++ b/index.php @@ -170,7 +170,8 @@ yimian__log("log_api", array("api" => "img", "timestamp" => date('Y-m-d H:i:s', function returnImg($path){ if($GLOBALS['type'] != 'wallpaper' && $GLOBALS['type'] != 'imgbed' && $GLOBALS['type'] != 'path' /*&& ((!in_array($GLOBALS['__from'], $GLOBALS['whiteList']) && ($GLOBALS['_num'] > 0 || $GLOBALS['_ip'] > 0)) || ($GLOBALS['_ip'] > 0))*/) { - $url = getImgCDN($path); + if(get_from()=='')$url = getImgCDN($path); + else $url = getImgCDNProxy($path); //$url = getImgOneindex($path); // $url = getImg($path); }else{