Re: Bandwidth/Download Limit

From: Daniel Tryba (news_comp.lang.php_at_canopus.nl)
Date: 11/01/03


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


Relevant Pages

  • Re: Php5 port and Apache Module
    ... possible to install php5 from the packages .. ... in any way of justifying removing the apache module from the default setting ... people installing php do so for use as an apache module. ...
    (freebsd-questions)
  • Re: Extension files not loading
    ... If an Apache module doesn't use those files it is not necessary to load ... the newsgroup - and it's way too long for a newsgroup, ... You want to use more than one PHP version? ... along with PHP and they both have LibMySQL.dll in distro. ...
    (comp.lang.php)
  • Re: What are the pros and cons of running php as a regular CGI
    ... Personally I would not accept these "drawbacks". ... company to offer PHP as an Apache module so I can have the FULL power of ... Apache and PHP at my disposal. ... > regular CGI by default. ...
    (comp.lang.php)
  • Re: does the phpinfo() command ever lie?
    ... > If you are using PHP as an Apache module, ... > module AND the CGI). ... I'm dealing with an Apache module version of PHP? ...
    (comp.lang.php)
  • Re: PHP5beta2 - anyone successfully installed in
    ... At any case, the apache2 and PHP4 now are running, but without MySQL ... You mentioned to run php in cgi mode, what's the different with running it ... > To install successfully as apache module, ... > Then make changes in the config files and copy php.ini in {WINDOWS} ...
    (comp.lang.php)