I've just finished a filehosting script / site, and now I'm thinking of adding a "premium" account part. The Non premium users get a slower download speed. I was thinking of using "mod_bandwidth" or "mod_cband", but I do not think that this will work! (I also have no clue how to set this with PHP) Anyone here who might have an idea on how I could set a "custom" download speed per IP?
Take a look at the Bf_Download package: http://phpclasses.php-start.de/browse/package/3220.html It can handle bandwidth limiting.
Thanks Falko, I'll have a look at it.. I'm now doing it this way Code: $speed = 10; //in KB $file2push = fopen($file,'r'); while($temp = fread($file2push,round($speed*1024))){ echo $temp; flush(); sleep(1); } fclose($file2push); Problem is the sleep(1). It should sleep for one sec. but for some reason it's not really doing this.
The above script is working fine from 1KB ($speed = 1) till arround 15KB ($speed = 15) Problem is when I set the $speed = to lets say 100 The file should download at 100 KB, but it does not get above +/- 15KB. Even when I set $speed to lets say 200.. The download does not get above +/- 15KB Now when I change the sleep(1); to usleep(78000); (78000 micro seconds), and the $speed = 100 the download does speed up to arround 100KB