问题
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