I have been trying to figure this out:
I am creating a filehosting site with PHP and I would like to know how to limit user to 10Gb of bandwidth per day, so that they can download – just like RapidShare, until their session is expired. They will be then credited back with 25Gb.
What type of cap can I use to monitor their session of downloading (including resuming) their file?
I know I have to do something with chunk data, or the total chunks completed, and then I can calculate their total chunks.
Best Answer
You could store the users' session IDs in a database along with an amount of data they've downloaded. Each time they download a file, check that their
current_usage + size_of_file < 100mb
. If it is, allow the download, otherwise present them with an error. Each day reset everyone'scurrent_usage
to0
.