dtnwm4807 2014-12-15 05:36
浏览 53
已采纳

$ _SERVER ['REMOTE_ADDR']让我只托管IP,而不是用户的IP。 为什么?

Recently I've needed to change my counter code in my blog site. That is why some attackers manipulate counter numbers of my articles, using a program or anything else.

They can increment the counter to 4000 in a day. So I've changed the counter algorithm. Now I'm using a counter based on IP address. But I have a question about this. I know that $_SERVER['REMOTE_ADDR'] gives us the IP address from which the user is viewing the current page.

I taked this explanation from: http://php.net/manual/en/reserved.variables.server.php. But this command didn't give me users' IP addresses. It always gave me just hosting IP address. Why?

Could anyone explain this situation, please? Fortunately, I've found a code snippet from the github, and I can use this new counter. (https://gist.github.com/cballou/2201933)

Why just the $_SERVER['REMOTE_ADDR'] doesn't work?

  • 写回答

1条回答 默认 最新

  • douzhan1238 2014-12-15 05:42
    关注

    Because some other piece of software on the server is initiating the request. This can be caused by e.g. reverse proxies or load balancers, or it may be a result of being hacked. One of the 'HTTP_*' elements of the same array should give you the real address if the bounced request is legitimate, otherwise it's time to back up all your data, wipe the server, and start over.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端