Skip to main content

Posts

Showing posts from February, 2014

Image IP Logger

We will need : 
- image.php
- image.jpg
- .htaccess

image.php



<?php
$ip = $_SERVER["REMOTE_ADDR"];
$date = date("d-m-y / H:i:s");
$refer = $_SERVER["HTTP_REFERER"];
$agent = $_SERVER["HTTP_USER_AGENT"];
$BR = "<br>"; $HR = "<hr>";
$IPS = @fopen("log.html",'a');
$s = "<b>ip: </b> ".$ip. $BR . "<b>Date: </b>".$date. $BR ."<b>Refer: </b>". $refer. $BR ."<b>Agent: </b>". $agent. $BR . $HR;
fwrite($IPS, $s, strlen($s));
fclose($IPS);
header('Content-Type: image/jpeg');
$imgpath="image.jpg";
// Get image from file
$img = imagecreatefromjpeg($imgpath);
// Output the image
imagejpeg($img);
?>
We could use an gif image then use imagecreatefromgif instead of imagecreatefromjpeg

.htaccess




RewriteEngine On RewriteRule ^coolimage.jpg image.php

coolimage.jpg would be the image in url:
http://site/coolimgage.jpg