Merge branch 'hotfix/image-proxy'
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-pdo": "*",
|
||||
|
||||
@@ -36,22 +36,7 @@ if ($hash !== $token) {
|
||||
die('Access denied');
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
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);
|
||||
}
|
||||
|
||||
$imageInfo = getimagesize($url);
|
||||
header('Content-type: '.$imageInfo['mime']);
|
||||
readfile($url);
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user