PDA

View Full Version : Terminating access to a folder after bandwidth limit reached...Anyway to do it?



esa1234
July 16th, 2005, 03:07 AM
I'm sorry for posting here if this isn't the correct forum to post in, but server-side seemed like the right place.

I'm trying to figure out a way to prevent access to a folder on an Apache server after a certain amount of data has been downloaded from it. My skills with xml, php, etc. are novice at best, and I have no idea how, or if, this can be done. If there's no way to count bandwidth, then how about simply counting hyperlink requests, and then blocking access via htconfig after a set number of requests?? This is just a guess, though....

I've tried searching for an answer, but I can't seem to find anything about it. It seems like someone must have tried this before.

Thanks so much for any help!
e.s.a.

Ilija Studen
July 16th, 2005, 03:57 AM
One way that can be easaly implemented is to use mod_rewrite to pass all request for files in specific directory to one PHP file that will grab the file, get and save its size and than return the file to the user. In that way you can have max bendwidth over one directory calculated (max because you are asumin that users have downloaded full files, without quiting the download).

In that PHP file you can put simple IF that will check if max bendwidth is reached and serve the request or return error. Simple as that :)

esa1234
July 18th, 2005, 11:39 PM
That does sound pretty simple, THANK YOU. Now all I have to do is try and learn php to do it myself!

Cheers,
esa

esa1234
July 19th, 2005, 06:56 PM
That does sound pretty simple, THANK YOU. Now all I have to do is try and learn php to do it myself!

Cheers,
esa

So, I've tried for the past many hours to write this code, and I seem to be having no luck. I'm sure it's because I'm completely alien to php code. Might someone here be willing to just get me started in the right direction??

Thanks,
e.s.a.

Ilija Studen
July 20th, 2005, 10:59 AM
Problem with "the right direction" is that you will need to know few things:

1. how to get and forward file
2. how to save data with PHP
3. how to use mod_rewrite

So, there is not just one direction ;)

Take a look at file system functions (for saving and forwarding) and at the mod_rewrite documentation.

PS: I think that this script is not good for begginers... Try to find someone with more expirience.