Lol5916 Posted October 15, 2008 Share Posted October 15, 2008 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 More sharing options...
MadTechie Posted October 15, 2008 Share Posted October 15, 2008 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 More sharing options...
Lol5916 Posted October 15, 2008 Author Share Posted October 15, 2008 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 More sharing options...
MadTechie Posted October 15, 2008 Share Posted October 15, 2008 'l.gif' is not a valid GIF file make sure that image is a GIF or change to a JPEG file and update gif command to jpg command ie header("content-type: image/jpeg"); $image = ImageCreateFromJPEG($imagelink); imagejpeg($image); Link to comment https://forums.phpfreaks.com/topic/128465-image-ip-logger/#findComment-665759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.