Track User Bandwidth With PHP Application

旧街凉风 提交于 2019-12-24 10:16:02

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/7427657/track-user-bandwidth-with-php-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!