2 PHP Questions

  1. How can I set bandwidth (or download speed) limits on certain users to CERTAIN folders? I would be doing it with if they are logged in or not. I already have the code ready for logged in/not.
  2. FIXED

I had a problem in my ‘login_success.php’ page. I had the session names wrong. Thanks guys! Help on #1 would be appreciated.

Thanks for any help!![/code]

i don’t think its a good idea to hendle a speedlimit with php, but i u wanna do it:

untested example:
[php]<?php
$filename=basename($_GET[‘file’]);
header('Content-Type: '.mime_content_type($filename));

$starttime=time();
$speed=10; //KB per second
$submitted=0; //KB sent to the client

$file=fopen(‘folder/’.$filename,‘rb’);
while(!feof($file))
{
@time_sleep_until ($starttime + $submitted / $speed);
echo fread($file,1024);
flush();
$submitted++;
}
?>[/php]

to make all files in that folder beeing procesed by that file u’ll need a rewite rule.
.htaccess

RewriteEngine On RewriteRule folder/(.*) speedlimit.php?file=$1 [L]

Awesome thanks.

But when you said:

RewriteRule folder/(.*) speedlimit.php?file=$1 [L]

does that mean I place the speedlimit.php file in the same directory of the folder with restrictions wanted applied to?

both files (speedlimit.php and .htacces) are intended to be outside the folder (thats why folder is included in both files)

plz, give me some reply whether it is working.

Sponsor our Newsletter | Privacy Policy | Terms of Service