Beschreibung
===========================

Dieses Addon errechnet die Downloadzeit einer Datei fuer folgende Bandbreiten:
DSL16000: 16384 kb/s
DSL6000: 6164 kb/s
DSL2000: 2048 kb/s
DSL1000: 1024 kb/s
ISDN: 64 kb/s
Modem: 56 kb/s


Inhalt des Addons
===========================

pkinc/publictpl/content/download_times.htm

Zu bearbeitende Dateien
===========================

pkinc/func/default.php
pkinc/public/download.php
pkinc/publictpl/content/download.htm


Voraussetzung
===========================

PHPKIT 1.6.4


Installation
===========================

Oeffnet die Datei pkinc/func/default.php und fuegt am Ende vor dem ?> das ein:

/*****************************************************
// Berechnung der Downloadzeit
// Umsetzung und Copyright: msycho || www.codea.de
// Stand: 16.01.2008
// Version: 1.0
*****************************************************/ 
if(!function_exists('getDownloadTime'))
{
  function getDownloadTime($dlpath, $files)
  {
    $divisors = array("DSL16000" => 16384, 
                    "DSL6000" => 6164,
                    "DSL2000" => 2048, 
                    "DSL1000" => 1024, 
                    "ISDN" => 64,
                    "Modem" => 56);
    $hms = array();
    $file_path;
    $file_size;
    $file_ok = false;
    
    if(empty($dlpath)) {
      return false;      
    }
    else {
      $file_path = $dlpath."/";
    }
    
    $files = explode("\n", $files);
    foreach($files as $file) {
      $file = trim($file);
      if(!empty($file)) {
        $file_path = $file_path.$file;
        $file_ok = true;
        break;
      }
    }
    
    if(!$file_ok) {
      return false;      
    }
    else {
      if(file_exists($file_path)) {      
        $file_size = filesize($file_path);
      }
      else {
        return false;        
      }
    }
    
    if($file_size <= 0) {      
      return false;      
    }
    else {    
      $bits = $file_size*8;
      
      $i = 0;
      foreach($divisors as $type=>$divisor) {
        $seconds[$i] = floor($bits/($divisor*1024));
        $hours[$i]   = floor($seconds[$i]/3600);
        $minutes[$i] = floor($seconds[$i]/60) % 60;
        $seconds[$i] = $seconds[$i] % 60;
        $hms[$i]     = sprintf("%s (%d kbps): %02d:%02d:%02d", $type, $divisor, $hours[$i], $minutes[$i], $seconds[$i]);
        $i++;
      } 

      return $hms;
    }
  } 
}

#############################################

Oeffnet jetzt die Datei pkinc/public/download.php.

Suche:

  eval("\$content_catimage= \"".pkTpl("content/download_catimage")."\";");
}

Fuege danach ein:

/*****************************************************
// Berechnung der Downloadzeit
// Umsetzung und Copyright: msycho || www.codea.de
// Stand: 16.01.2008
// Version: 1.0
  *****************************************************/ 
$downloadTime = getDownloadTime($config['content_downloadpath'], $contentinfo['content_altdat']);   

if(!$downloadTime) {                            
  $i = 0;
  $divisors = array("DSL16000" => 16384, "DSL6000" => 6164, "DSL2000" => 2048, "DSL1000" => 1024, "ISDN" => 64, "Modem" => 56);
  foreach($divisors as $type=>$divisor) {
    $downloadTime[$i] = sprintf("%s (%d kbps): 00:00:00", $type, $divisor);
    $downloadTimeRes .= '<tr><td>'.$downloadTime[$i].'</td></tr>';
    $i++;
  }                      
}
else {
  for($i=0; $i<count($downloadTime); $i++) {
    $downloadTimeRes .= '<tr><td>'.$downloadTime[$i].'</td></tr>';
  }
}
eval ("\$dl_times= \"".pkTpl("content/download_times")."\";");
// ### Berechnung der Downloadzeit ###

#############################################

Nun die Datei pkinc/publictpl/content/download.htm oeffnen.

Suche:

<table class="standard" border="0" cellspacing="1" cellpadding="1" width="100%">
  <tr>
    <td class="heads" align="right"><font class="headssmall">Downloadserver</font></td>
  </tr>
  <tr>
    <td class="standard">
      <table border="0" cellspacing="0" cellpadding="2" width="100%">	   
        $download_links	 
      </table>
    </td>	  
  </tr>
</table>

Fuege danach ein:

<!-- Berechnung der Downloadzeit || by msycho -- www.codea.de -->
$dl_times
<!-- ### Berechnung der Downloadzeit || by msycho -- www.codea.de ### -->

#############################################

Zum Schluss die bearbeitetenden Dateien wieder hochladen und auch die neue Datei pkinc/publictpl/content/download_times.htm mithochladen.


Hinweis
===========================

Fuer eventuell aufkommende Fehler uebernehme ich keine Verantwortung. 
Fuer die Installation des Addons seit ausschlielich ihr verantwortlich.
Die hier veroeffentlichten Dateien unterliegen dem Urheberrecht.
Copyrighthinweise duerfen nicht unkenntlich gemacht oder gar entfernt werden. 
Eine Weitergabe der Dateien oder des Inhalts ohne vorherige Genehmigung durch den Autor ist untersagt. 
Zuwiderhandlungen koennen sowohl zivil- als auch strafrechtlich verfolgt werden.

Autor und Copyright: msycho
Kontakt: http://www.codea.de/
Stand: 16.01.2008
Version: 1.0