// 访客计数器函数
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);
}
}
?>
访客计数器
欢迎访问
您是第位访客

我想实现一个输入不同的IP地址并提交后,在“您是第...位访客”中显示相应IP访问了多少次。。。我用一个TXT文件存储IP地址与浏览次数,格式如下:
例:
192.168.0.22 5
192.168.5.44 10
......
这个程序应该如何修改? 存储 PHP HTML 函数 Color 分享到:
------解决方案--------------------
为什么不存数据库呢? 写文件的不太懂 帮顶下.
------解决方案--------------------
// 访客计数器函数
function counter() {
!empty($_GET['weburl'])
------解决方案--------------------
die('weburl不能为空');