Compare commits

...

4 Commits

  1. 3
      functions.php
  2. 70
      index.php

@ -301,7 +301,8 @@ function getVideo($path, $time = 120*60){
/* obs get img */
function getImg($path, $time = 300){
return str_replace('yimian-image.obs.cn-east-2.myhuaweicloud.com:443','image.yimian.xyz',obsSign($path, $time));
//return str_replace('yimian-image.obs.cn-east-2.myhuaweicloud.com:443','image.yimian.xyz',obsSign($path, $time));
return obsSign($path, $time);
}

@ -9,6 +9,33 @@ include './functions.php';
}*/
$whiteList = array(
'www.eee.dog',
'api.yimian.xyz',
'home.yimian.xyz',
'img.yimian.xyz',
'acg.watch',
'iotcat.me',
'ushio.cool',
'yimian.xyz',
'guide.yimian.xyz',
'cp-acc.yimian.xyz',
'v2ray.yimian.xyz',
'onedrive.yimian.xyz',
'login.yimian.xyz',
'user.yimian.xyz',
'imgbed.yimian.xyz',
'share.yimian.xyz',
'proxy.yimian.xyz',
'shorturl.yimian.xyz',
'mksec.yimian.xyz',
'monitor.yimian.xyz',
'blog.yimian.xyz',
'blank.com'
);
header('content-type: image/png');
$path = $_REQUEST['path'];
@ -34,6 +61,49 @@ if(!isset($format) || !($format == "jpg" || $format == "png" || $format == "webp
if(!isset($compress) || !($compress%10 == 0)) $compress = null;
if(!isset($command)) $command = null;
$__from = get_from();
if($__from == '') $__from = 'http://blank.com/';
$__from = parse_url($__from)['host'];
if(!in_array($__from, $whiteList) && $type == "moe"){
$redis = new redis();
$redis->connect('redis',6379);
$__time = 'api/img/_time/'.$__from;
$__num = 'api/img/_num/'.$__from;
if(!$redis->exists($__time) || !$redis->exists($__num)){
$redis->set($__time, time());
$redis->set($__num, -200);
}
$_time = $redis->get($__time);
$_num = $redis->get($__num);
if(time() - $_time > 60*60*24){
$redis->set($__time, time());
$redis->set($__num, 0);
$_num = $redis->get($__num);
$_time = $redis->get($__time);
}
$redis->set($__num, $_num+1);
if($_num > 50) {
header("Location: https://api.vvhan.com/api/acgimg");
yimian__log("log_api", array("api" => "img", "timestamp" => date('Y-m-d H:i:s', time()), "ip" => ip2long(getIp()), "_from" => get_from(), "content" => 'https://api.vvhan.com/api/acgimg'));
die();
}
}
if($path){
returnImg($path);

Loading…
Cancel
Save