Created
July 8, 2020 12:33
-
-
Save trentwiles/29b618e7170c65627cabab7cafff729a to your computer and use it in GitHub Desktop.
Image Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Image proxy in the works. | |
*/ | |
$image = $_GET['url']; | |
$path = $image; | |
$ext = pathinfo($path, PATHINFO_EXTENSION); | |
$deny = array("jpg", "png", "gif", "jpeg", "bmp", "ico"); | |
if(in_array($ext,$deny)){ | |
header("Content-type: image/${ext}"); | |
echo file_get_contents($image); | |
}else{ | |
$my_img = imagecreate( 200, 80 ); | |
$background = imagecolorallocate( $my_img, 0, 0, 0 ); | |
$text_colour = imagecolorallocate( $my_img, 225, 225, 225 ); | |
imagestring( $my_img, 4, 30, 25, "Invalid File Type", $text_colour ); | |
imagesetthickness ( $my_img, 5 ); | |
header( "Content-type: image/png" ); | |
imagepng( $my_img ); | |
imagecolordeallocate( $text_color ); | |
imagecolordeallocate( $background ); | |
imagedestroy( $my_img ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍