When I run this code every time it is run in a firefox browser it seems to run twice and it records 2 entires, I have tried different machines and also different versions of FF but each time I run this. in my log file I see the following
In Chrome and IE I just get a single entry in my log.html file
<?php
// Create a new image instance
$im = imagecreatetruecolor(70, 20);
// Make the background white
imagefilledrectangle($im, 0, 0, 70, 20, 0xFFFFFF);
$font = imageloadfont('arial.gdf');
// Draw a text string on the image
imagestring($im, $font, 0, 0, 'Hello World', 0x000000);
// Output the image to browser
header('Content-Type: image/gif');
imagegif($im);
imagedestroy($im);
// Get server variables
$address = $_SERVER['REMOTE_ADDR'];
$referer = isset($_SERVER['HTTP_REFERER']) ?
$_SERVER['HTTP_REFERER'] : '';
$browser = $_SERVER['HTTP_USER_AGENT'];
// Do not log the full IP address replace the last 2 octets
$address = preg_replace('/\.\d+\.\d+$/', '.xxx.xxx', $address);
//Set time zone and date format
date_default_timezone_set('Australia/Sydney');
$accessTime = date("jS F Y g:i:s a");
//Open log file
$file = fopen("log.html",'a');
//write collected data to file
fwrite($file, "<b>Time:</b> $accessTime<br />");
if( $address != null)
fwrite($file,"<b>IP Address:</b> $address<br />");
if($referer != null)
fwrite($file,"<b>Referer:<b> $referer<br />");
fwrite($file,"<b>Browser:</b> $browser<hr>");
// save file and close
fclose($file);
?>