Forum Moderators: coopster

Message Too Old, No Replies

Throttling user down-loads

How to?

         

pashley

2:51 pm on Apr 20, 2009 (gmt 0)

10+ Year Member



I'm setting up the infrastructure for a website that will, in part, allow downloads of files (gaming site).

I would like to be able to throttle (control the rate at which) the file downloads. Instead of perhaps a normal 300k rate, throttle it to 30k, for example. This is done to encourage them to pay a subscription fee to access the full download speed - a common practice in my gaming genre.

I am currently on a shared hosting website; not ideal, I know, and will eventually migrate over to my own server. I'm guessing this might make throttling impossible?

I am running the website on the popular Content Management System, Joomla (which is PHP based).

I see other websites doing it - how do I implement it?

I'm guessing that it would be a stand-alone program that works inside Apache to do this? I'm not a programmer by any stretch, and would have to probably have it outsourced out; I'm just wondering how it is done, and what I need to make it happen.

Any light you can shed on this would be very helpful!

bkeep

4:45 pm on Apr 20, 2009 (gmt 0)

10+ Year Member



I found this I don't know if it works but you can try it out
"php download limit htaccess" was what I Googled for


<?php
$file = "/path/to/file"; // path to file
$speed = 16; // 16 kb/s download rate limit

header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: filename=$file" . "%20");

flush();
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, round($speed*1024));
flush();
sleep(1);
}
fclose ($fd);
?>