I have written a PHP script that obscures the URL of the directory that my JPG files are stored in. What do I have to gain by doing this? Visitors can still right-click on images to save a copy. I also have .htaccess configured to prevent hot-liking of JPG files. Is this PHP script of any real value?
The name of the PHP file is images.php.
The following HTML is in a separate file.
The name of the PHP file is images.php.
Code: Select all
<?php
$path = "path/to/images/directory/";
$regex = "/^[0-9]{1,2}$/";
$id = $_GET['id'];
if(preg_match($regex, $id))
$id = $path . $id . ".jpg";
else
exit;
header('Content-type: image/jpeg');
readfile($id);
exit;
?>
Code: Select all
<img src="images.php?id=1" />