12-12-2009, 01:54 PM
What's Up?
OK, So New to PHP, And have a quick and hopefully easy question.
Basically when the same user comes to me PHP ip logger script their IP gets logged, But if they come twice it makes a whole new line, So i set about figuring out how to clean up multiple entry's. Heres my source.
Now that works fine, When a the same person comes it just updates the time, But, When a new IP comes it clears the last IP and puta the new one their. Example.
So the IP 127.0.0.1 gets logged first.And when it comes again
So every things fine, When the new IP comes though this happens.
What happened the the last IP's entry?
Anyone Know?
Thanks Bye.
OK, So New to PHP, And have a quick and hopefully easy question.
Basically when the same user comes to me PHP ip logger script their IP gets logged, But if they come twice it makes a whole new line, So i set about figuring out how to clean up multiple entry's. Heres my source.
Code:
<?php
$logfile= 'make1.html';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "a");
fwrite($fp, $logdetails);
fwrite($fp, "<br>");
fclose($fp);
$data1 = file("make1.html");
$data2 = file("make2.html");
file_put_contents('Database.html', implode('', array_unique(array_merge($data1,$data2))));
unlink('make1.html');
unlink('make2.html');
$ourFileName = "make1.html";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
$ourFileName = "make2.html";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
?>
So the IP 127.0.0.1 gets logged first.
Code:
December 12, 2009, 2:55 pm: 127.0.0.1
Code:
December 12, 2009, 3:00 pm: 127.0.0.1
Code:
December 12, 2009, 3:02 pm: 74.63.89.20
Anyone Know?
Thanks Bye.