怎么实现不同IP地址的浏览次数统计

如何实现不同IP地址的浏览次数统计

<?php
// 访客计数器函数
function counter() {
!empty($_GET['weburl'])  ||  die('weburl不能为空');
$weburl = $_GET['weburl'];

$file = '/usr/local/apache/htdocs/MyTests/counter.txt';
if (! file_exists($file)) {
$num = 1;
$cf = fopen($file, 'w');
fwrite($cf, $weburl.' '.$num);
fclose($cf);
} else {
$cf = fopen($file, 'rw');
$num = fgets($cf);
$num = substr($num, 15);
fclose($cf);

++$num;
$cf = fopen($file, 'w');
fwrite($cf, $num);
fclose($cf);
}
}

?>
<html>
<head>
<title>访客计数器</title>
</head>
<body>
<center>
<h1>欢迎访问</h1><br />
<form action="counter()" name="url-form" method="get">
<div>
<input type="text" name="weburl" size="15" />
&nbsp;
<input type="submit" name="Submit" value="提交" />
</div>
</form>
<hr />
<font size="7" color="red">
您是第<?php //echo counter() ?>位访客
</font>
</center>
</body>
</html>




怎么实现不同IP地址的浏览次数统计

我想实现一个输入不同的IP地址并提交后,在“您是第...位访客”中显示相应IP访问了多少次。。。我用一个TXT文件存储IP地址与浏览次数,格式如下:
例:
192.168.0.22 5
192.168.5.44 10
......

这个程序应该如何修改?
存储 PHP HTML 函数 Color

------解决方案--------------------
为什么不存数据库呢?   写文件的不太懂  帮顶下.
------解决方案--------------------
<?php
// 访客计数器函数
function counter() {
!empty($_GET['weburl'])  
------解决方案--------------------
  die('weburl不能为空');