Protecting your images from use out of context
Archive - Originally posted on "The Horse's Mouth" - 2010-08-29 10:06:01 - Graham EllisThe script is a simple one:
<?php
header("Content-type: image/jpeg");
if (preg_match('/www\.wellho\.net/',$_SERVER[HTTP_REFERER])) {
$file = "doginfield.jpg";
} else {
$file = "dogstolenfromfield.jpg";
}
$stuff = file_get_contents($file);
print $stuff;
?>
... in fact, that's oversimple in the demo (and if you read it, you could find the images directly!!) and you would for a security script locate your .jpg files away from the document root ...