From f500f987d56f6051693e2a593c371b940d8533c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Wed, 6 Nov 2019 11:49:22 +0100 Subject: [PATCH] Simplify and fix image proxy --- composer.json | 1 + public/typo3conf/ext/ep_theme/extimg.php | 19 ++----------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index d4643665..62c02aa3 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "type": "project", "require": { "php": "^7.2", + "ext-curl": "*", "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", diff --git a/public/typo3conf/ext/ep_theme/extimg.php b/public/typo3conf/ext/ep_theme/extimg.php index 451aaa35..6fe4d1d2 100644 --- a/public/typo3conf/ext/ep_theme/extimg.php +++ b/public/typo3conf/ext/ep_theme/extimg.php @@ -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;