跟踪文件完整下载
我有一个文件托管网站,用户可以通过下载获得奖励。所以我想知道是否有一种方法可以跟踪访问者是否下载了整个文件,这样就不会为了奖励而进行虚假的部分下载。
谢谢。
I have a file hosting site and users earn a reward for downloads. So I wanted to know is there a way I can track whether the visitor downloaded whole file so that there are no fake partial downloads just for rewards.
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以监视 Web 服务器返回的 HTTP 响应代码并将它们与生成它们的会话联系起来,那么您就可以开展业务了。
响应代码 206 表明系统已传送部分信息,但不是全部。当文件的最后一块发出时,它不应该有响应代码 206。
如果您可以通过将会话代码放入 URL 中来将其与用户会话联系起来,那么您可以根据简单的日志聚合来给出分数。
If you could monitor the HTTP response codes returned by your web server and tie them back to the sessions that generated them, you would be in business.
A response code of 206 shows that the system has delivered some of the information but not all of it. When the final chunk of the file goes out, it should not have a response code of 206.
If you can tie this to user sessions by putting the session code inside the URL, then you could give points based on a simple log aggregation.
我在文件托管网站上实现了类似的解决方案。
您想要做的是使用 register_shutdown_function 回调,它允许您检测 php 脚本执行的结束,无论结果如何。
然后,您希望将文件放在服务器上的非网络可访问位置,并通过 php: 进行下载:想法是您希望能够跟踪已传递给客户端的字节数。
这是实现的基本方法(例如:)
显然有改进的方法,所以如果您需要更多细节或其他行为,请告诉我!
I implemented a similar solution on a file hosting website.
What you want to do is use the register_shutdown_function callback that allows you to detect the end of execution of a php script regardless of the outcome.
Then you want to have your file in a non-web accessible location on your server(s), and have your downloads go through php: idea being that you want to be able to track how many bytes have been passed to the client.
Here's a basic way of implementing (eg:)
There are obviously ways to improve, so if you need more details or another behaviour, please let me know!