-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcds.php
More file actions
23 lines (23 loc) · 712 Bytes
/
cds.php
File metadata and controls
23 lines (23 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
error_reporting(0);
if(isset($_GET['url']) && isset($_SERVER['HTTP_REFERER'])){
$url = urldecode($_GET['url']);
$referer = parse_url($_SERVER['HTTP_REFERER']);
if(preg_match("/^http/",$url)){//防盗链验证
$opts = array('http'=>array(
'method'=>'GET',
'timeout'=>10
));
$result = file_get_contents($url,FALSE,stream_context_create($opts));
if($result){
header("Cache-Control:public;maxage=604800");//设置缓存时间
echo $result;
}else{
header("HTTP/1.1 404 Not Found");
}
}else{
header("HTTP/1.1 400 Bad Request");
}
}else{
header("HTTP/1.1 403 Forbidden");
}