PHP Forums Archive

Limit the number of downloads per client

Tags: download, IP address, limit, bandmwidth

maKhaliq posted on 2009-10-26 11:03:45 #

Hello there,

This is a nice script. Could you please advise me how do I amend/edit it to suit my need which is described below:

I want people to have free access to the website but restrict the amount /number
of downloads in order to avoid the overuse of bandwidth. Currently, the problem
with the overuse of bandwidth is being caused by someone deliberately. This someone downloads the same file over and over untill the website goes off-line because of the overuse of bandwidth per hour. The downloadable content is only pdf files of sizes ranging from 8MB to 95MB.

Your help in solving this problem will be greatly appreciated.

Comments / discussions

Olaf posted on 2009-10-26 11:57:03 #

Hi,
best way is to log the IP addresses for each downloaded file (this is how the code from the tutorial works). The problem is that it's difficult to check if the client has downloaded the file for 100%.

Another option is to squeeze the to total bandwidth to 2-3mbit (instead of 10 or 100mbit)

There are also apache mods, check Google for them (never tried one).

The limited bandwidth is the best option, but you need an extra server (VPS) for this.

maKhaliq posted on 2009-10-26 22:00:58 #

Hello Olaf,

Thanks for your reply to my enquiry.

The pdf files contain scanned images and their sizes can't be reduced further without deteriorating the quality. Not sure what you exactly meant by squeezing the total bandwidth though.

Please note that the website is on a shared server.

I would like to use the code from your tutorial. I can allow the download of 2 or 3 files at a time to ensure that client downloads at least one file completely.

As I am not very familiar with the coding, could you please tell me exactly what do I need to add or remove from your php file that I have downloaded for this purpose.

Many thanks.

Olaf posted on 2009-10-26 22:08:22 #

If you're on a shared host, your account is not really safe for this kind of abuse behaviors. I'm not sure why you think that people will "eat" all your bandwidth but if this happens because of hot-linking, you should move to your own server. There is not so much possible on a shared host.

My code works for sites where you can trust your visitors :)

Maybe you can ask your provider if he has installed something against hot-linking or bandwidth / download abuse protection.

maKhaliq posted on 2009-10-27 15:50:04 #

Thanks