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 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程