I applied the modification that hides the image path from the user (
http://forum.coppermine-gallery.net/viewtopic.php?p=13483). The modification makes use of a file called 'get_file.php' to stream the image to the browser.
Unforunately, although it hides the actual path of the image well, it doesn't stop people from hot-linking to an image *through* the 'get_file.php' code. I want to prevent people from hot-linking to my images and clobbering my bandwidth, so I added the following code to 'get_file.php' to prevent that. It just does a simple referer check and validates on that. It's not foolproof but it'll knock out the majority of hot-links to your images.
Just paste the following code in at the very top of the 'get_file.php' file, right after the opening <?php tag.
// Hot-Link Stopper by Waylon 3-2004
// is the domain name in the REFERER string?
$legit = strpos ( $HTTP_REFERER, "mydomain.com");
// if not, display the error image
if($legit == ""){
// the error image to display...
$filename = "/path/to/your/error/image.gif";
// stream image out to browser
header('Content-type: image/gif');
header('Content-transfer-encoding: binary');
header('Content-length: '.filesize($filename));
readfile($filename);
// crash-o-la...
exit;
}
1) Make sure you change the '
mydomain.com' text to match your domain.
2) Set the system path to an 'error' image. If the referer check fails, the error image is shown instead. My error image just says "To view this picture go to....", but if you wanted to you could be cruel and use a nasty XXX image to give the hot-linker a rude awakening.
Please feel free to use this this code any way you want; no credit to me is needed or asked for.