I’ve got a basic random.php file that displays a random picture on my frontpage (code is displayed below). I’ve recently noticed that someone posted a link in a forum directly to the random.php file that bypasses my frontpage like this [url]http://www.mysite.com/random.php
Also, I’d like to provide hotlink protection for my pics. People have also been posting that same link – ‘
[code]<?php
Header(“Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0”);
Header(“Expires: Thu, 19 Nov 1981 08:52:00 GMT”);
Header(“Pragma: no-cache”);
Header(“Content-Type: image/jpg”);
$dir = “images”; // This is the folder where the images are
srand((double)microtime()*1000000);
$i = 0;
$dirHandle = opendir($dir); // Open the images folder
while(($im = readdir($dirHandle)))
{
if($im != “..” && $im != “.”) // Don’t read in the 2 folders “..” and “.”
{
$image[$i] = $im; // Select an image
$i++;
}
}
closedir($dirHandle); // Close the folder
$n = rand(0,(count($image)-1));
if(!readfile($dir.”/”.$image[$n])) // Read the image
readfile($dir.”error/error.gif”); // If the script can’t find the directory, display this image
?>