forked from hypercities/hypercities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageProxy.php
More file actions
28 lines (23 loc) · 768 Bytes
/
imageProxy.php
File metadata and controls
28 lines (23 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include_once('includes/util.inc');
HC_checkReferer();
//fetch image from posted url
$url = $_GET["url"];
$url = urldecode($url);
$urlArray = parse_url($url);
$ch = curl_init();
$timeout = 10;
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$referer = $urlArray['scheme']."://".$urlArray['host']."/";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
$response = curl_exec($ch);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
header('Content-type: '.$content_type);
echo $response;
?>