Jump to content

Image IP Logger


Lol5916

Recommended Posts

I'm making an Image IP loggers, here's the code:

(I call this file 1.php)

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
# SETTINGS:
$imagelink = "http://mysite.com/dir/l.gif";
# END SETTINGS

$fp = fopen('logs.txt', 'a');  # File will be created if (!exist) :-)

$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$port = $_SERVER['REMOTE_PORT'];
$file = $_SERVER['HTTP_REFERER'];   # External page (viewed from this page)

fwrite($fp, " Ip: ".$ip);
fwrite($fp, " User-Agent: ".$agent);
fwrite($fp, " Port: ".$port);
fwrite($fp, " File: ".$file);
fwrite($fp, "\n");
fclose($fp);

header("content-type: image/gif");
$image = ImageCreateFromGIF($imagelink);
imagegif($image);
ImageDestroy($image);

exit(); # Force exit (Reason: forum keeps loading)
?>

 

Here's the error:

The image “http://mysite.com/dir/1.php” cannot be displayed, because it contains errors.

 

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/128465-image-ip-logger/
Share on other sites

probably errors

try commenting out the header( line; and see if an error appears

here a quick re-write

<?php
ob_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
# SETTINGS:
$imagelink = "http://mysite.com/dir/l.gif";
# END SETTINGS

$fp = fopen('logs.txt', 'a');  # File will be created if (!exist) :-)

$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$port = $_SERVER['REMOTE_PORT'];
$file = $_SERVER['HTTP_REFERER'];   # External page (viewed from this page)

fwrite($fp, " Ip: ".$ip);
fwrite($fp, " User-Agent: ".$agent);
fwrite($fp, " Port: ".$port);
fwrite($fp, " File: ".$file);
fwrite($fp, "\n");
fclose($fp);
ob_end_clean();
if(!file_exists($imagelink))
{
die("Fail to load file");
}
header("content-type: image/gif");
$image = ImageCreateFromGIF($imagelink);
imagegif($image);
ImageDestroy($image);
exit(); # Force exit (Reason: forum keeps loading)
?>

Link to comment
https://forums.phpfreaks.com/topic/128465-image-ip-logger/#findComment-665741
Share on other sites

When I comment that out I get this:


Warning: imagecreatefromgif() [function.imagecreatefromgif]: 'l.gif' is not a valid GIF file in /home/****/public_html/mysite.com/dir/1.php on line 28

Warning: imagegif(): supplied argument is not a valid Image resource in /home/****/public_html/mysite.com/dir/1.php on line 29

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/****/public_html/mysite.com/dir/1.php on line 30

Link to comment
https://forums.phpfreaks.com/topic/128465-image-ip-logger/#findComment-665754
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.