- 2020-4-9
不知道源码
# 商业转载请联系作者获得授权,非商业转载请注明出处。 # For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source. # 协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) # 作者(Author):spirit # 链接(URL):https://spiritx.xyz/984.html # 来源(Source):Spiritの小站 /** * 域名白名单校验函数 * @param $domain_list * @return true/false */ function checkReferer($domain_list = array('spiritx.xyz','other domain')) { $status = false; $refer = $_SERVER['HTTP_REFERER']; //前一URL if ($refer) { $referhost = parse_url($refer); /**来源地址主域名**/ $host = strtolower($referhost['host']); if ($host == $_SERVER['HTTP_HOST'] || in_array($host, $domain_list)) { $status = true; } } return $status; } /** * 从文本文件中读取图片url并跳转 */ function echo_img() { if (checkReferer()) { //调用参数 $type = $_GET['key']; switch ($type) { case 'xxx': ## 省略中间部分代码 } } else { //未授权域名 $img = 'https://v.spirit.codes/images/2019/03/13/404.th.png'; header("Location:$img"); exit(); } } ## 省略中间部分代码 //前一URL $refer = $_SERVER['HTTP_REFERER']; //存在前一URL if ($refer) { echo_img(); } else { //直接访问API地址 $type = $_GET['key']; switch ($type) { case 'xxx': ## 省略中间部分代码 } exit(); }
调用:https://api.spiritx.xyz/images/?key=meizi
刷新一次变一次
https://api.spiritx.xyz/images/?key=bing