如何保存使用随机生成IP的用户IP?

发布于 2024-09-24 12:17:09 字数 648 浏览 0 评论 0原文

在我的项目中,我只需要允许用户评级系统一次。 我的数据库中有一个表,其中存储所有 IP 地址,并且我检查,如果用户的 IP 不在数据库中,我允许评级。

但现在我遇到了一个问题。

有一些提供商会在用户每次重新启动计算机时生成随机 IP 地址。

因此,当我调用 $ip=$_SERVER['REMOTE_ADDR']; 时,每次它都会从同一台计算机返回不同的结果。

我也尝试过类似的方法

if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
        $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
        $ip=$_SERVER['REMOTE_ADDR'];
    }

,但没有帮助。

我该如何解决这个问题?

非常感谢

in my project i need to allow rating system for users only once.
i have a table in my database, where i store all ip addresses, and i check, if the user's ip is not in database, i allow rating.

But now i met a problem.

There are providers, that generate random ip addresses every time user restart computer.

So when i call $ip=$_SERVER['REMOTE_ADDR'];, every time it returns different result from the same computer.

I also tried something like

if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
        $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
        $ip=$_SERVER['REMOTE_ADDR'];
    }

But it doesn't help.

How can i solve this problem?

Thanks much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

寄与心 2024-10-01 12:17:10

有效解决此问题的唯一方法是使用独特的登录系统,但即使如此,用户也可以创建多个帐户。

The only way to effectively combat this is to use a unique login system, but even then, users can create multiple accounts.

满身野味 2024-10-01 12:17:10

除了 ip 检查之外,您还可以实施 cookie,这不是一个完美的解决方案,但是,如果用户不删除它,您可以利用第二次检查来查找重复的投票尝试

In addition to the ip check you can implement a cookie, it is not a perfect solution but, if user don't erase it you can leverage on this second check to find duplicate voting attempts

狂之美人 2024-10-01 12:17:10

最好的选择是强迫他们注册,以便进行评分/投票。

否则没有绝对的方法可以跟踪它们。

Best option would be to force them to register, in order to rate/vote.

There is no absolute way you'll be able to keep track of them otherwise.

剑心龙吟 2024-10-01 12:17:10

无法从服务器超级全局获取用户的旧 IP。

Cookie 也可以工作,但对于单一的评级系统来说并不真正可行。

There is no way of getting the users old IP from the server superglobal.

Cookies could also work, but not really feasible for a sinple rating system.

流年已逝 2024-10-01 12:17:10

您可以使用 setcookie 在投票后将 cookie 写入用户的硬盘。当然,对于精明的用户来说,删除它并投票两次是很容易的。

You could use setcookie to write a cookie to a user's hard drive following a vote. Of course it would be easy for savvy users to remove this and vote twice.

久光 2024-10-01 12:17:10

您可以结合使用在客户端设置 cookie 和存储 IP 地址,您还可以获得公共代理的副本并将 IP 地址列入黑名单,以及电子邮件验证。

这就是最大程度,如果该人清理了缓存并拥有动态 IP,则不能完全证明,但您可以减慢垃圾邮件发送者的速度。

You can use combination of both setting a cookie on client and storing IP address, you can also get a copy of public proxies and blacklist the ip address, plus email verification.

thats the maximum extent, its not full proof if the person cleans the cache and has a dynamic IP but you can slow down the spammer.

独享拥抱 2024-10-01 12:17:09

您必须接受某些用户会更改 IP 的情况。

如果您的投票系统很重要,请考虑添加注册、电子邮件验证以及 I​​P 检查以过滤掉原始作弊行为。

再说一次,尽管在这些类型的系统上作弊总是很容易(例如网络代理)

You have to accept that some users will have changing IP's.

If your voting system is important, consider adding registration, email verification along with IP checks to filter out primitive cheats.

Again though it's always quite easy to cheat on those sorts of systems (web proxies for example)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文