计数不同IP的页面访问计数器 [英] Page Access Counter counting different IPs

查看:94
本文介绍了计数不同IP的页面访问计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在浏览互联网,了解如何创建php页面访问计数器。我发现的许多php访问计数器都是基于计算不同的IP。



1)它是唯一的方法还是最好的方法来计算它?



我对此感到疑惑......如果同一台计算机网络中有两台不同本地ips的计算机连接到该页面,会发生什么?它们将具有相同的全局IP,因为它们具有相同的路由器,对吧?那么计数器会将这两台计算机识别为一台?



这是我找到的代码并重新写入我的脚本:

Hi,
I was browsing the internet to find out how to create php page access counter. Many of php access counter I have found were based on counting different IPs.

1) Is it the only way or the best way how to count it?

I was wondering about it... What will happen if two computers from the same computer network with different local ips connect to the page? They will have the same global ip, because they have the same router, right? So the counter will recognize these two computers as one?

Here is a code I have found and rewrited to my script:

$ipaddress = "";
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
    $ipaddress = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])[0];
else
    $ipaddress = $_SERVER["REMOTE_ADDR"];





2 )所以,我想修复它以通过mac识别来自同一网络的不同计算机,或者如果它始终无法正常工作我不知道如何改进代码,因为我已经读过这将无法正常工作。



感谢您的回复!

Pepin z Hane



2) So, I would like to fix it to recognize different computers from the same network by mac or I don't know how and improve the code if it does not work correctly always, because I have read that this will not work correctly always.

Thanks for replies!
Pepin z Hane

推荐答案

ipaddress = ;
if(isset(
ipaddress = ""; if(isset(


_SERVER [ HTTP_X_FORWARDED_FOR]))
_SERVER["HTTP_X_FORWARDED_FOR"]))


ipaddress = explode(' ,'
ipaddress = explode(',',


这篇关于计数不同IP的页面访问计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆