Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 4th February 2007, 15:03
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,033
Thanks: 260
Thanked 145 Times in 127 Posts
Default Managing download speed per user?

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?
Reply With Quote
Sponsored Links
  #2  
Old 5th February 2007, 13:17
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Take a look at the Bf_Download package: http://phpclasses.php-start.de/browse/package/3220.html

It can handle bandwidth limiting.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 5th February 2007, 15:03
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,033
Thanks: 260
Thanked 145 Times in 127 Posts
Default

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.
Reply With Quote
  #4  
Old 6th February 2007, 13:58
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Quote:
Originally Posted by edge
Problem is the sleep(1). It should sleep for one sec. but for some reason it's not really doing this.
How do you know? Have you tried with higher values (e.g. sleep(10)) to see if it really slows down?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 6th February 2007, 14:47
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,033
Thanks: 260
Thanked 145 Times in 127 Posts
 
Default

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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Statistic not working mzo Installation/Configuration 49 20th April 2011 12:19
Anything I can do against illegal login-requests? schmidtedv Installation/Configuration 17 7th November 2008 09:25
Anon-FTP not creating user danie.robberts General 29 24th April 2007 18:35
Manage Apache Download Speed And Traffic Limits With mod_cband & centOS 4.4 ThE-LyNX HOWTO-Related Questions 1 12th January 2007 02:25
Mail Login, simple user names??? Kernal Panic Installation/Configuration 1 16th June 2006 02:45


All times are GMT +2. The time now is 09:27.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.