Merge branch 'hotfix/image-proxy'

This commit is contained in:
Björn Fromme
2019-11-06 11:49:27 +01:00
2 changed files with 3 additions and 17 deletions
+1
View File
@@ -8,6 +8,7 @@
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.2", "php": "^7.2",
"ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-pdo": "*", "ext-pdo": "*",
+2 -17
View File
@@ -36,22 +36,7 @@ if ($hash !== $token) {
die('Access denied'); die('Access denied');
} }
$ch = curl_init(); $imageInfo = getimagesize($url);
curl_setopt($ch, CURLOPT_URL, $url); header('Content-type: '.$imageInfo['mime']);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = curl_exec($ch);
if ($headers === false) {
exit;
}
foreach (explode("\r\n", $headers) as $header) {
header($header);
}
readfile($url); readfile($url);
exit; exit;