JohnDeer Posted February 26, 2012 Share Posted February 26, 2012 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/257842-code-appears-to-run-twice-when-used-with-firefox/ Share on other sites More sharing options...
Pikachu2000 Posted February 27, 2012 Share Posted February 27, 2012 With Firebug installed, Firefox is known to do that. I'm not sure about any other add-ons that may cause that behavior. Quote Link to comment https://forums.phpfreaks.com/topic/257842-code-appears-to-run-twice-when-used-with-firefox/#findComment-1321540 Share on other sites More sharing options...
JohnDeer Posted February 27, 2012 Author Share Posted February 27, 2012 How could I set so that the script would only log one record per users ip address a day so as to stop this double logging Quote Link to comment https://forums.phpfreaks.com/topic/257842-code-appears-to-run-twice-when-used-with-firefox/#findComment-1321692 Share on other sites More sharing options...
litebearer Posted February 27, 2012 Share Posted February 27, 2012 A starting point... http://www.tutorialspoint.com/mysql/mysql-handling-duplicates.htm Quote Link to comment https://forums.phpfreaks.com/topic/257842-code-appears-to-run-twice-when-used-with-firefox/#findComment-1321696 Share on other sites More sharing options...
Zane Posted February 27, 2012 Share Posted February 27, 2012 Update Firebug... and Firefox if you haven't already. Quote Link to comment https://forums.phpfreaks.com/topic/257842-code-appears-to-run-twice-when-used-with-firefox/#findComment-1321699 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.