Re: Bandwidth/Download Limit
From: Daniel Tryba (news_comp.lang.php_at_canopus.nl)
Date: 11/01/03
- Next message: Eto Demerzel: "Re: retrieve windows username in php"
- Previous message: Nicolas C.: "Bandwidth/Download Limit"
- In reply to: Nicolas C.: "Bandwidth/Download Limit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 1 Nov 2003 15:15:04 +0000 (UTC)
Nicolas C. <cuicui.NO-SPAM.@noos.fr> wrote:
> I'd like to make some download speed limitation on some of my files
> using PHP. I know that an Apache module can do that, but i cannot access
> my ISP Apache configuration.
>
> My idea was to put the file into a .htaccess protected diretory and to
> build a "proxy" with PHP.
Perfectly possible. Keep the files in a protected area, create an array
with locations and call a php script with an array index to get the
file. Read the file in a buffer (eg 4k) and sleep 1 sec, my simple logic
says that the browser will get a max transfer of 4kb/s in this example:
$fp=fopen($file,'r')
while(!feof($fp))
{
echo fgets($fp,4096);
sleep(1);
}
fclose($fp);
BTW don't forget to set an appropriate mimetype, and do extensive
errorcatching.
-- Daniel Tryba
- Next message: Eto Demerzel: "Re: retrieve windows username in php"
- Previous message: Nicolas C.: "Bandwidth/Download Limit"
- In reply to: Nicolas C.: "Bandwidth/Download Limit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|