redirect no refer to jsdelivr

;
master
cn.yimian.xyz 2 years ago
parent ffb8658fcd
commit f1aa448823
  1. 11
      functions.php
  2. 3
      index.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');

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

Loading…
Cancel
Save