Jump to content

Code appears to run twice when used with Firefox


JohnDeer

Recommended Posts

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

 

Time: 27th February 2012 10:55:09 am

IP Address: 173.195.xxx.xxx

Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

 

Time: 27th February 2012 10:55:10 am

IP Address: 173.195.xxx.xxx

Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

 

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);


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.