Search code examples
phpdownloadbandwidth

Limits and wait times like Rapidshare


I have an open environment, no logins, where a number of files can be downloaded. I'm now trying to set up a wait time feature and a bandwidth limit per visitor per period of time type thing (similar to what Rapidshare has if you've ever used them before).

Any ideas how I should go about implementing this? I'm on PHP so all its restrictions/advantages (if any in this case) apply.

Thank you all.


Solution

  • Without a login system the best you can do is restrict to one download per IP address in a fixed amount of time. I believe this is what Rapidshare does as well.

    The easiest way to implement this is to record the time that an IP address starts a download, either in a flat-file format or a database. If the time elapsed from the previous download time is less than the required wait time, then redirect the user to an error page. Otherwise, redirect the user to the download link.

    The nifty counter is just a Javascript trick. You can easily write one using Javascript timers but it's just for show. The actual download ability should always be determined serverside (in PHP in your case).