2023-02-14 15:02:08 +00:00
|
|
|
<?php
|
2023-02-16 14:51:28 +00:00
|
|
|
require "misc/tools.php";
|
2024-05-16 16:08:23 +00:00
|
|
|
$url = filter_var($_REQUEST["url"], FILTER_SANITIZE_URL);
|
2023-09-02 22:14:18 +00:00
|
|
|
$requested_root_domain = get_root_domain($url);
|
2024-05-16 16:08:23 +00:00
|
|
|
$allowed_domains = array("pinimg.com", "i.pinimg.com", "pinterest.com", "pin.it");
|
|
|
|
|
if (in_array($requested_root_domain, $allowed_domains)) {
|
|
|
|
|
$image_src = request($url);
|
|
|
|
|
if ($image_src !== false) {
|
|
|
|
|
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
|
|
|
|
$mime_type = $finfo->buffer($image_src);
|
|
|
|
|
if (strpos($mime_type, 'image/') === 0) {
|
|
|
|
|
header("Content-Type: $mime_type");
|
|
|
|
|
echo $image_src;
|
|
|
|
|
} else {
|
|
|
|
|
header("HTTP/1.1 415 Unsupported Media Type");
|
|
|
|
|
echo "Error: The requested URL does not contain a valid image.";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
header("HTTP/1.1 404 Not Found");
|
|
|
|
|
echo "Error: Unable to fetch the image.";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
header("HTTP/1.1 400 Bad Request");
|
|
|
|
|
echo "Error: Invalid domain.";
|
2023-02-16 14:51:28 +00:00
|
|
|
}
|
2023-02-17 12:20:14 +00:00
|
|
|
?>
|