I want to create a basic image proxy for my forum so I can get rid of mixed content warnings. The below code allows you to go to "https://www.example.com/proxy.php?url=http://www.example.net/image.jpg" and it loads the image via https. Is there a safer way I can do this and how can I make it so only the server can use this and not other sites?
$image = htmlentities($_GET['url']);
header('Content-Type: image/png');
if(isset($image)){echo file_get_contents($image);}