-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.php
27 lines (24 loc) · 1008 Bytes
/
file.php
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
<?php
if (isset($_GET['url']) && $_GET['url'] != undefined) {
$fn = $_GET['url'];
$headers = apache_request_headers();
$contentType = getUrlMimeType($_GET['url']);
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($fn))) {
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 304);
} else {
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 200);
header('Content-Length: '.filesize($fn));
header('Content-Type: image/jpeg');
print file_get_contents($fn);
}
$contentType = getUrlMimeType($_GET['url']);
header('Content-type: '+$contentType);
header('Content-Transfer-Encoding: binary');
readfile($_GET['url']);
}
function getUrlMimeType($url) {
$buffer = file_get_contents($url);
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->buffer($buffer);
}
?>