gitlez

Untitled

Jun 29th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. function dltest ($filename=NULL) {
  4.     Global $dltime_min,$dltime_sec;
  5.     // $filesize = (filesize($filename)/1024);
  6.     $filesize = 120012304 / 1024;
  7.     $speeds = Array( 0.05,0.1,0.2,0.3,0.5,0.75,0.9,1,1.5,2,5,10,20); // MBps
  8.     echo "Filesize: {$filesize} MB<br />The download will take:<br /> ";
  9.     foreach($speeds as $kb){
  10.         $kb *= 1024;
  11.         $calc = $filesize/$kb;
  12.         $dltime_min = round($calc / 60, 0);
  13.         $dltime_sec = round($calc % 60, 0);
  14.         if($kb > 1024){
  15.             $unit = 'MBps';
  16.             $kb /= 1024;
  17.         }else{
  18.             $unit = 'KBps';
  19.         }
  20.         echo $dltime_min . " minutes and " . $dltime_sec . " seconds. @ {$kb} {$unit}<br />";
  21.     }
  22. }
  23. dltest();
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment