Reddit, as we all know, allows around 1 vote per ip address per link to avoid issues with spammers. I am working on a Slim application that will have a voting feature and I, quite frankly, have no idea how to implement system like this as I have no experience with cookies and native sessions. Also most of my functions have paths like (example) localhost:8888/myapp/voteup/item-to-vote.
2条回答 默认 最新
- douzi4766 2012-12-29 23:59关注
On my site I allow members to rate some code between 1 and 5 once every 24 hours. I stop spam by adding a hash code and using ajax to submit a vote. I haven't gotten any spam votes since I added it in June 2012. I used to get about 40 votes per day from bots, but now that has been eliminated for now.
For example this is what my link looks like:
http://phpsnips.com/process/vote.php?id=43&vote=3&enc=a560e4320af4e13e4170947cd42de18bWith that, enc is different every time the page loads, and once the vote is submitted it is changed again.
My steps
- Use a session to create an md5 hash
- place the hash on the link or form hidden field
- On the submission page test to make sure the session matches the link/field
- Reset the hash
- Redirect back to the original page (if not using ajax)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
- ¥50 分布式追踪trace异常问题
- ¥15 人在外地出差,速帮一点点
- ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
- ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
- ¥50 vue router 动态路由问题
- ¥15 关于#.net#的问题:End Function
- ¥15 无法import pycausal
- ¥15 weditor无法连接模拟器Local server not started, start with?
- ¥20 6-3 String类定义