Connecting Tech Pros Worldwide Forums | Help | Site Map

Bandwidth/Download Limit

Nicolas C.
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello,

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.

I can also put a download limit (after n download per day the script
deny download). Any idea or known script doing that?

Thank you in advance,

Nicolas


Daniel Tryba
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Bandwidth/Download Limit


Nicolas C. <cuicui.NO-SPAM.@noos.fr> wrote:[color=blue]
> 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.[/color]

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

Closed Thread