View Full Version : How to tell if an image is being hotlinked...
awesty
Jun 8th 2007, 8:58 pm
Is there anyway to be able to tell if an image you are hosting is being viewed on another site, and if so tell which image it is and run a script when it is viewed?
thanks :)
renoir
Jun 8th 2007, 9:27 pm
well, you can see my blog for an example of image hotlinking (http://www.netpaths.net/blog/).
you can stop it with .htaccess mod_rewrite
awesty
Jun 9th 2007, 4:55 am
I had a look but couldnt find the article. can you give me a direct link?
i am not trying to stop people hotlinking, i just want to run a php script that will update a database everytime an image is viewed on any site.
krakjoe
Jun 9th 2007, 5:02 am
Couple of ways you could do it, are you wanting to track all images or all images from a particular location, gimme a look at an example url of an image you want to track.
I would rewrite image urls to a php script, lets assume your images are in /hotlinked/
RewriteEngine On
RewriteRule ^/hotlinked/(.*)$ count_my_images.php?image=$1
count_my_images.php =
<?
if( file_exists( sprintf( '/hotlinked/%s', $_GET['image'] ) ) )
{
update_my_data_base( $_GET['image'] );
echo file_get_contents( sprintf( '/hotlinked/%s', $_GET['image'] ) );
}
else
{
echo file_get_contents( '/hotlinked/404.image.jpg' );
}
That code prolly won't actually work for you, is an example, gimme some more details and I'll write something that does.....
awesty
Jun 9th 2007, 6:57 am
okay, thanks. i will mess around with the code you gave me.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.