Forum Moderators: not2easy
Isn't that lovely? The page with the hotlinked image never finishes loading, and displays my URL in the status bar continually :)
If you are lucky enough not to have a bandwidth limit then just send them as fast as they'll fly out. That will severely constrain the browser's bandwidth and stop them doing anything but leaving the page.
[edited by: vincevincevince at 3:30 pm (utc) on Nov. 17, 2005]
$yoursite="yourdomain.com";
if (((strlen($_SERVER[HTTP_REFERER])>0)&&(strpos($_SERVER[HTTP_REFERER],$yoursite)))¦¦( (strlen($_SERVER[HTTP_REFERER])==0) ))
{
// HERE RETURN YOUR IMAGE AS NORMAL (print file_get_contents(....))
}
else
{
//this is a hotlinked image
set_time_limit(0);
header("Content-type: image/png");
print file_get_contents("images/ad.png");
for ($a=0;$a<1000000;$a++)
{
print " ";
sleep(1);
}
This is used (for me) in conjunction with a 404 trick (where the images are in another internal directory, and when links to images are made, it calls a php script via 404 which grabs the image from the directory and spews it out.
You can also use it with .htaccess / mod_rewrite methods of rewriting .jpg / .png etc. to a script.
<edit>
It will show 'images/ad.png' which although it displays will never stop loading whenever an image is hotlinked. It will show the correct image when the image is requested with no referer (helpful for images in google images etc).
</edit>