Limiting download speed

All support enquiries for DFH go in here...

Re: Limiting download speed

Postby SamEA » Fri Sep 09, 2011 8:21 pm

Don't add onto the download2.php file, but instead replace all of the above code with the present one.
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 » Sat Sep 10, 2011 9:27 am

SamEA wrote:Don't add onto the download2.php file, but instead replace all of the above code with the present one.

I know.. I replaced all of it..
maybe your code is the premium version of the dfh script?
'cuz im using the free one for now..
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 » Sun Sep 11, 2011 7:00 pm

Try this:

Copy all of this code and replace it with the current code in ./download2.php
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);

?>


SamEA
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 » Tue Sep 13, 2011 2:23 pm

SamEA wrote:Try this:

Copy all of this code and replace it with the current code in ./download2.php
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);

?>


SamEA


Still, a big mess of errors. I replaced 100% of the file.
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 » Tue Sep 13, 2011 9:23 pm

I do not receive any error messages when using the above modification. Try using the mod using a fresh install of the latest version of DFH.
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 16, 2011 1:03 pm

SamEA wrote:I do not receive any error messages when using the above modification. Try using the mod using a fresh install of the latest version of DFH.

I reinstalled everything and it's working great, i have no idea why i had this errors. Thank you very much, Sam!
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 » Sat Sep 17, 2011 11:28 am

Glad to hear that it's working with you now. :)
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 craigibhoy1 » Mon Sep 26, 2011 2:59 pm

theres only one speed rate in this so i set it at 500kb , is there not 2, one for guests so i can give them 500kb/s and members 1mbps speeds
craigibhoy1
Newbie Member
 
Posts: 4
Joined: Sat Sep 24, 2011 5:42 pm

Re: Limiting download speed

Postby SamEA » Mon Sep 26, 2011 4:36 pm

You'll have to add an IF statement for members. Pseudo code: If equals member then speed = 1024kbs else speed = 500kbs end if.
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 Tyler.S » Tue Feb 07, 2012 1:42 am

I have updated the code to include the IF statement which searches for a logged in user session...works great for me:

Here is the new code:
Code: Select all
if ($_SESSION['islogged'] <> true) {

//Guest Speed
$speed_rate = 50;
//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);

}else{

//Member Speed   
$speed_rate = 10240;
//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);

}


Here is the FULL download2.php with the above modification installed (Just copy and paste 8-) ):

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
}

if ($_SESSION['islogged'] <> true) {

//Guest Speed
$speed_rate = 50;
//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);

}else{

//Member Speed   
$speed_rate = 10240;
//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);

}
?>


Hope this helps
Tyler.S
Premium
 
Posts: 10
Joined: Mon Feb 06, 2012 7:42 am
Location: Ontario, Canada

Previous

Return to Daddy's File Host v1.X

Who is online

Users browsing this forum: No registered users and 11 guests

cron