Skip to content

Instantly share code, notes, and snippets.

@jonmaim
Created September 16, 2011 03:19
Show Gist options
  • Select an option

  • Save jonmaim/1221124 to your computer and use it in GitHub Desktop.

Select an option

Save jonmaim/1221124 to your computer and use it in GitHub Desktop.
Really unsecure php image proxy.
<?php
$filename = $_GET['url'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
switch ($ext) {
case "gif":
header('Content-Type: image/gif');
readfile($filename);
break;
case "png":
header('Content-Type: image/png');
readfile($filename);
break;
case "jpg":
default:
header('Content-Type: image/jpeg');
readfile($filename);
break;
}
?>
@hackerpro536
Copy link
Copy Markdown

how to fix ?

@reneManqueros
Copy link
Copy Markdown

by changing:
readfile($filename);
to:
readfile('./images/' . $filename);

@rchrd2
Copy link
Copy Markdown

rchrd2 commented Jan 24, 2018

Very insecure, my friend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment