Hunt down Hotlinkers.

B

Brandon

Guest
I just wrote some code that will display a JPG image and show the site that was the referer to the image. This could be used to hunt down hotlinkers.

Create a document and place the following code editing the required fields. Save it as image.jpg

PHP:
<?
//Identify as JPEG
header("Content-type: image/jpeg");
//Log File - Must be CHMOD 777
$log_file = "referer.txt";
//Get Referer
$referer = getenv('HTTP_REFERER'); 
//Open Log
$fp = fopen("$log_file", "a");
//Put Referer in Log
fputs($fp, "$referer
");
flock($fp, 3); 
//Close Log
fclose($fp);
//Display JPG Image
$bg = imagecreatefromjpeg("Brigand.jpg");
//Output and Destroy
imagejpeg($bg);
imagedestroy($bg);
?>

Then in a .htaccess file place

HTML:
<FilesMatch "image.jpg">
SetHandler application/x-httpd-php
</FilesMatch>

Now everyone who visits the image you can open referer.txt and view where people are viewing your images from.
 
Last edited by a moderator:

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
do you have an exaple?
 

moose

New Member
Messages
1,056
Reaction score
0
Points
0
Hmm pretty cool. I like the idea. I'll also wait for that demo.
 
Top