防止作弊
我目前正在制作 Facemash 模拟,我发现它很容易作弊 ^^ 如果您在浏览器中多次输入以下内容: http://domain.com/rate.php?winner=1&loser=2,您可以让照片 1 成为获胜者。我知道可以通过 cookie 和 ip 阻止来阻止它,但我不知道具体如何操作。请帮我。谢谢!
这是一个例子(不是我的): http://facemash.moefelt.dk/
UPD 如果需要,我可以提供源代码。
UPD 1rate.php http://jsfiddle.net/6xLR6/ index.php http://jsfiddle.net/AvF4M/1/
I'm currently making a facemash analog and I found out that it's very easy to cheat ^^ If you type this in your browser several times: http://domain.com/rate.php?winner=1&loser=2, you can make photo №1 a winner. I know that it's possible to prevent it with cookies and ip-blocking, but I don't know how exactly. Please help me. Thanks!
Thant's an example (not mine):
http://facemash.moefelt.dk/
UPD I can provide a source code if needed.
UPD 1 rate.php http://jsfiddle.net/6xLR6/
index.php http://jsfiddle.net/AvF4M/1/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你可以简单地使用 $_POST 代替 $_GET,作弊会更难!
cookies可以保存在缓存中,但如果用户每次都清理它,它可能就没用了。
编辑:
在rate.php中:
我认为你现在已经得到了你想要的一切;-)
you can simply use $_POST instread of $_GET, the cheat would be harder !
cookies can be saved in cache but if the user clean it everytime, it could be useless.
EDIT :
In rate.php :
I think that you got all that you want right now ;-)
不要使用查询参数。用户 POST 请求将数据发送到服务器。
Don't use query parameters. User POST request to send data to server.
你可以试试这个:
You can try this one:
第一个问题是您要防止的攻击是什么?如果只是为了确保有人在提交答案之前加载页面,您需要:
但是,这并不能阻止有人编写一个机器人来多次投票。
如果您想确保真正的人点击了每个负载,您需要执行上述操作,并添加一个验证码来验证点击的人是否是人类。
First question is what is the attack you want to prevent? If it's simply to make sure someone loads the page before submitting an answer, you'll need to:
However, this doesn't stop someone writing a bot to vote lots of times.
If you want to make sure that a genuine human has clicked on each load, you'll need to do the above and also include a captcha to verify that the person clicking is human.