pixelfed-imgproxy-apache2/imgproxy/index.php

15 lines
428 B
PHP

<?php
$url = trim($_GET['url']);
# check url matches a https://domain/storage/whatever.jpeg url for images
if (preg_match('/^https:\/\/[^\/]+\/storage\/[^\s\%]+\.(png|jpg|jpeg)(\?v=[^\&])?$/', $url)) {
if (preg_match('/^.*\.png(\?v=[^\&])?$/', $url))
header('Content-Type: image/png');
else if (preg_match('/^.*\.(jpg|jpeg)(\?v=[^\&])?$/', $url))
header('Content-Type: image/jpeg');
echo file_get_contents($url);
}
?>