Hello,
I am trying to write a bandwidth php scrp, that obtains the bandwidth of each user, an automatically disables the user who goes over an amount of bandwidth.
The script should be automatic.
Please reply if you have any ideas how I can write it. Thanks
Bandwidth Script help please!
Moderator: General Moderators
Use output buffering, then before you ouput your data measure the length in bytes, then output the content.
After you output the content write to the database about which user the content was rendered for and the length in bytes, at the beginning of each page view obtain the sum of a user's bandwidth from the database and if it is greater then your threshold, output an error message and terminate the script with a die();
After you output the content write to the database about which user the content was rendered for and the length in bytes, at the beginning of each page view obtain the sum of a user's bandwidth from the database and if it is greater then your threshold, output an error message and terminate the script with a die();
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
i would add the date time to that as well so each time the page is requested it does what jshpro2 said and writes to the db but it should count the amount of bandwidth that that user used since a certain time so you can set limits like a user can only use 1 mgb every 5 minutes or somthing, make the restrictions and time whatever you want but if you just go and update the db with the new amount a user will quickly be out of bandwidth because there is no way to have the badwith meter go back down for that user