Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
array_unique
#1
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.
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);
?>
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.
Code:
December 12, 2009, 2:55 pm: 127.0.0.1
And when it comes again
Code:
December 12, 2009, 3:00 pm: 127.0.0.1
So every things fine, When the new IP comes though this happens.
Code:
December 12, 2009, 3:02 pm: 74.63.89.20
What happened the the last IP's entry?

Anyone Know?

Thanks Bye.
[Image: Scorpion-Sig3.png]
Reply


Messages In This Thread
array_unique - by Scorpion - 12-12-2009, 01:54 PM
RE: array_unique - by Socrates - 12-12-2009, 01:56 PM
RE: array_unique - by Scorpion - 12-12-2009, 02:06 PM
RE: array_unique - by Gaijin - 12-12-2009, 02:14 PM
RE: array_unique - by Scorpion - 12-12-2009, 02:24 PM
RE: array_unique - by Gaijin - 12-12-2009, 02:33 PM
RE: array_unique - by Scorpion - 12-13-2009, 07:58 AM
RE: array_unique - by Gaijin - 12-13-2009, 08:13 AM
RE: array_unique - by Scorpion - 12-13-2009, 10:46 AM
RE: array_unique - by Gaijin - 12-13-2009, 11:11 AM

Forum Jump:


Users browsing this thread: 13 Guest(s)