Record the IPs of everyone who view a .jpg on your site

26Apr08

This script allows php code to be run every time a certain jpg is loaded. The script below would log the IP that loaded image, the date, referer, and useragent, but it could be edited to do loads of things. Strictly for educational purpose.

Just create a directory, put this php code into a file which is saved as a .jpg file. You need a real image, in my case called sig.jpg in the same directory, and a file called (in my case) siginfo22.txt – this must be chmod’d to 777. Obviously, file names etc can be different, but must also be changed in code below. Oh, and create a .htaccess, as shown at top of that code.

———-
The Script
———-
<?php /*
create a .htaccess file containing the following two lines:

Options All -Indexes
ForceType application/x-httpd-php

the first one means if someone tries to view directory, they are not
shown it, the second allows the script to work

*/
header(“Content-type: image/jpeg”);
$ip = getenv(“REMOTE_ADDR”);
$date = date(“d”) . ” ” . date(“F”) .
” ” . date(“Y”);
$ref = getenv(‘HTTP_REFERER’);
$ua = $_SERVER[‘HTTP_USER_AGENT’];
$intofile = $ip . ” || ” . $date . ” || ” . $ref
. ” || ” . $ua . “<br />”;
$hfile = fopen(“siginfo22.txt”, “a”);
fwrite($hfile, $intofile);
fclose($hfile);
$BGImage = imagecreatefromjpeg(“sig.jpg”);
imagejpeg($BGImage);
imagedestroy($BGImage);
?>



12 Responses to “Record the IPs of everyone who view a .jpg on your site”

  1. 1 deeplogger8

    Neat script – thanks for info much appriciated for educational purposes🙂

  2. 2 FunkyAshley

    I use this script alot!

    Simple and sweet!

    Ashley

  3. Hey! nice !

  4. Hi Blogger,
    I am collecting views of bloggers about the current crisis in the middle east. I wonder if you have a view and would care to share it with us.
    many thanks

  5. 5 Dodi

    thanks

  6. 6 bindassksm

    i wanna password hacker softwere plzz send me

  7. useful post

  8. 8 Vaibhav

    Thank you very much for providing the above information.
    I love to learn these kinds of tricks.
    If you’ve got any more please post in to my email.

  9. 9 iori

    hey can I use this code to record the number of people viewed my site

  10. interesting one

  11. really interesting


  1. 1 Record the IPs of everyone who view a .jpg on your site | Pc-aras

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: