使用 PHP 应用程序跟踪用户带宽
我正在使用 PHP 和 CodeIgniter 进行校园项目。
这只是我的任务的一个项目。
然后我必须限制用户(应用程序的,而不是 Linux 用户)使用的带宽。
我不知道如何实现这个。
我想知道是否有人知道其中的逻辑或曾经从事过类似的任务。
我基本上需要的是,如何跟踪该用户(系统用户,而不是 Linux 用户)带宽?
我应该计算该用户的每个请求和响应吗?
如何统计特定用户系统的图像和静态文件下载?
非常感谢任何提示。
谢谢
伊万
I'm working on campus project using PHP and CodeIgniter.
It's only a project for my assignment.
Then it comes that i have to limit bandwidth used by user (of app, not linux user).
And i have no idea to implement this.
I wonder if someone know the logic or ever work on the similar tasks.
What basically i need is, how to track that user (system user, not linux user) bandwidth?
Should i count every requests and responses for that user?
How to count for imagse and static files download for specific user system?
Any hints is greatly appreciated.
Thaks
Ivan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一方法之一(使用 php)是解析网络服务器的 access.log,并添加每个客户端的带宽。
下次加载页面并且客户端达到设定限制时,您可以运行您想要的任何代码。
解析每个页面加载的日志似乎确实很耗时。
这就是一些网站统计程序获取该信息的方式。
编辑
此外,一些日志文件会在某些时间点进行存档,例如我的日志文件每周日早上 6 点都会重新开始,因此如果用户在那段时间浏览,他们的访问历史记录将在 6 点后消失,因此在数据库中保存客户端带宽是一种方法始终保留该信息
One of the only ways I can think of (using php) is to parse the access.log of the webserver, and add up the bandwidth for each client.
The next time a page is loaded and the client has reached a set limit you can then run what ever code you want.
Parsing the log each page load though does seem like it would be time consuming.
Thats how some website statistic programs get that info.
EDIT
Also some log files get archived at certain points, like mine gets a fresh start every Sunday at 6am so if a user was browsing during that time, their access history would disapear after 6, so saving the clients bandwidth in a database is a way to keep that information all the time