From 087003b134e5579d47eed6ae07f1c85a602affc0 Mon Sep 17 00:00:00 2001 From: Danii Saahir <158811885+danii-saahir@users.noreply.github.com> Date: Fri, 17 May 2024 00:08:23 +0800 Subject: [PATCH] Update image_proxy.php 1. Add support for "pin.it". 2. Improved error handling with appropriate HTTP response codes and error messages. 3. Utilized `filter_var` for URL sanitization. --- image_proxy.php | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/image_proxy.php b/image_proxy.php index 528288e..c24686d 100644 --- a/image_proxy.php +++ b/image_proxy.php @@ -1,19 +1,26 @@ 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."; } - ?>