Limiting download speed

All support enquiries for DFH go in here...

Limiting download speed

Postby theunreal » Wed Aug 24, 2011 10:34 am

Hello.
I want to make a Guest download and limit it to 500KB/S and VIP download with unlimited download.
How I can do such a thing and limit the download speed with DFH? I guess the rest I'll be able to to myself, I just have no idea how to limit the download speed.
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Re: Limiting download speed

Postby pmanth » Wed Aug 24, 2011 12:26 pm

I agree - Speed limiting would be good, so it doesn't drain all of my connection speed on my host :)
pmanth
Newbie Member
 
Posts: 3
Joined: Tue Aug 23, 2011 9:10 pm

Re: Limiting download speed

Postby theunreal » Fri Aug 26, 2011 12:37 pm

Hmm, Any help with this?
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Re: Limiting download speed

Postby SamEA » Fri Aug 26, 2011 6:04 pm

As soon as I'm near a PC, I'll example how to limit download speeds.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: Limiting download speed

Postby theunreal » Sun Aug 28, 2011 2:07 pm

SamEA wrote:As soon as I'm near a PC, I'll example how to limit download speeds.


Waiting for this
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Re: Limiting download speed

Postby theunreal » Mon Aug 29, 2011 9:26 pm

Still need help.
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Re: Limiting download speed

Postby theunreal » Wed Aug 31, 2011 4:39 pm

No one can help I guess..
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Re: Limiting download speed

Postby SamEA » Thu Sep 01, 2011 7:24 pm

I'm currently abroad at the moment and finding Internet access is limited. Patience is needed at such times. If however it's urgent, you may search on Google how to limit PHP download speeds and implement it in ./download2.php
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: Limiting download speed

Postby SamEA » Mon Sep 05, 2011 11:14 pm

Repalce ./download2.php with the following code:
Code: Select all
<?php
///////////////////////////////////////////////////////////////////////////
//  Product: Daddy's File Host               
//  Version: 1.2                       
//                       
// by DaddyScripts.com                 
//                               
// original source code by Jim (j-fx.ws) and Steven (galaxyscripts.com)
//////////////////////////////////////////////////////////////////////////

require_once("./config.php");

if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}

$bans=file("./secure/bans.dfh");
foreach($bans as $line)
{
  if ($line==$_SERVER['REMOTE_ADDR']){
?> <center><table style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top> <?
    echo "$lang[younallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }
}

if(!isset($_GET['a']) || !isset($_GET['b']))
{
  echo "<script>window.location = '".$scripturl."';</script>";
}

$validdownload = 0;


$filecrc = $_GET['a'];
$filecrctxt = $filecrc.".dfh";
if (file_exists("./files/".$filecrctxt)) {
   $fh = fopen ("./files/".$filecrctxt,r);
   $thisline= explode('|', fgets($fh));
   if ($thisline[0]==$_GET['a'] && md5($thisline[2].$_SERVER['REMOTE_ADDR'])==$_GET['b'])
      $validdownload=$thisline;
   fclose($fh);
}
if($validdownload==0) {
?> <center><table style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
<?
    echo "<center>$lang[inlink]</center>";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
}

$userip = $_SERVER['REMOTE_ADDR'];
$time = time();

$filesize = filesize("./storage/".$validdownload[0]);
$filesize = $filesize / 1048576;

if($filesize > $nolimitsize)
{
$newfile = "./downloader/".$userip.".dfh";
$f=fopen($newfile, "w");
fwrite ($f,$userip."|".$time."|");
fclose($f);
chmod($newfile,0777);
}


$validdownload[4] = time();

session_start();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==md5(md5($adminpass))) {
}
else {

// begin separate file mod
$newfile = "./files/$filecrc" . ".dfh";
$f=fopen($newfile, "w");
fwrite ($f,$validdownload[0]."|". $validdownload[1]."|". $validdownload[2]."|". $validdownload[3]."|". $validdownload[4]."|".($validdownload[5]+1)."|".$validdownload[6]."|".$validdownload[7]."|".$validdownload[8]."|\n");
fclose($f);
// end separate file mod
}

$speed_rate = 100;
//Speed is in KB/s (Kilobytes per second).

header('Cache-control: private');
header('Content-type: application/octetstream');
header('Content-Length: ' . filesize("./storage/".$validdownload[0]));
header('Content-Disposition: filename='.$validdownload[1]);

flush();

$dfile = fopen("./storage/".$validdownload[0], "r");

while (!feof($dfile)){
print fread($dfile, round($speed_rate * 1024));
flush();
sleep(1);
}

fclose($dfile);

?>


To adjust the speed rate of the download, modify the speed_rate variable.

Note: The above script might cause DFH to use more resources than normal.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: Limiting download speed

Postby theunreal » Fri Sep 09, 2011 4:51 pm

SamEA wrote:Repalce ./download2.php with the following code:
Code: Select all
<?php
///////////////////////////////////////////////////////////////////////////
//  Product: Daddy's File Host               
//  Version: 1.2                       
//                       
// by DaddyScripts.com                 
//                               
// original source code by Jim (j-fx.ws) and Steven (galaxyscripts.com)
//////////////////////////////////////////////////////////////////////////

require_once("./config.php");

if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}

$bans=file("./secure/bans.dfh");
foreach($bans as $line)
{
  if ($line==$_SERVER['REMOTE_ADDR']){
?> <center><table style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top> <?
    echo "$lang[younallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }
}

if(!isset($_GET['a']) || !isset($_GET['b']))
{
  echo "<script>window.location = '".$scripturl."';</script>";
}

$validdownload = 0;


$filecrc = $_GET['a'];
$filecrctxt = $filecrc.".dfh";
if (file_exists("./files/".$filecrctxt)) {
   $fh = fopen ("./files/".$filecrctxt,r);
   $thisline= explode('|', fgets($fh));
   if ($thisline[0]==$_GET['a'] && md5($thisline[2].$_SERVER['REMOTE_ADDR'])==$_GET['b'])
      $validdownload=$thisline;
   fclose($fh);
}
if($validdownload==0) {
?> <center><table style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
<?
    echo "<center>$lang[inlink]</center>";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
}

$userip = $_SERVER['REMOTE_ADDR'];
$time = time();

$filesize = filesize("./storage/".$validdownload[0]);
$filesize = $filesize / 1048576;

if($filesize > $nolimitsize)
{
$newfile = "./downloader/".$userip.".dfh";
$f=fopen($newfile, "w");
fwrite ($f,$userip."|".$time."|");
fclose($f);
chmod($newfile,0777);
}


$validdownload[4] = time();

session_start();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==md5(md5($adminpass))) {
}
else {

// begin separate file mod
$newfile = "./files/$filecrc" . ".dfh";
$f=fopen($newfile, "w");
fwrite ($f,$validdownload[0]."|". $validdownload[1]."|". $validdownload[2]."|". $validdownload[3]."|". $validdownload[4]."|".($validdownload[5]+1)."|".$validdownload[6]."|".$validdownload[7]."|".$validdownload[8]."|\n");
fclose($f);
// end separate file mod
}

$speed_rate = 100;
//Speed is in KB/s (Kilobytes per second).

header('Cache-control: private');
header('Content-type: application/octetstream');
header('Content-Length: ' . filesize("./storage/".$validdownload[0]));
header('Content-Disposition: filename='.$validdownload[1]);

flush();

$dfile = fopen("./storage/".$validdownload[0], "r");

while (!feof($dfile)){
print fread($dfile, round($speed_rate * 1024));
flush();
sleep(1);
}

fclose($dfile);

?>


To adjust the speed rate of the download, modify the speed_rate variable.

Note: The above script might cause DFH to use more resources than normal.


Need to add ) in the last line of the code you gave me, and even after i added it - it has so many errors when i'm trying to download a file..
Love catching Pokemon using Pokemon GO IV Calculator!
theunreal
Standard Member
 
Posts: 18
Joined: Sat Jul 23, 2011 12:03 pm

Next

Return to Daddy's File Host v1.X

Who is online

Users browsing this forum: No registered users and 17 guests

cron