Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function tamanho($conexao, $arquivo){
- if($conexao == "56"){$kbps = "56 Kbps";}
- if($conexao == "128"){$kbps = "128 Kbps";}
- if($conexao == "256"){$kbps = "256 Kbps";}
- if($conexao == "512"){$kbps = "512 Kbps";}
- if($conexao == "1024"){$kbps = "1 Mbps";}
- if($conexao == "2048"){$kbps = "2 Mbps";}
- if($conexao == "4096"){$kbps = "4 Mbps";}
- if(preg_match("/ B/", $arquivo)){$bytes = "1";}
- if(preg_match("/ KB/", $arquivo)){$bytes = "1024";}
- if(preg_match("/ MB/", $arquivo)){$bytes = "1048576";}
- if(preg_match("/ GB/", $arquivo)){$bytes = "1073741824";}
- $arquivo = str_replace(",", ".", $arquivo);
- $arquivo = preg_replace("/B|KB|MB|GB/", "", $arquivo);
- $seconds = ($arquivo * $bytes) / ($conexao * 1000 / 8);$units = array("segundo" => "60", "minuto" => "60", "hora" => "24", "dia" => "365", "ano" => "9999");$time = "";
- // var array = [];
- if($seconds > 0 and $seconds < .001){$time = "1 segundo";}else{if($seconds < 1){$time = round($seconds * 1000)." segundos";}else{if($seconds < 60){$time = number_format($seconds, 2, ".", "")." segundos";}else{$seconds = round($seconds);
- // for(var unit in units){
- // var n = $seconds % units[unit];
- // $seconds -= n;
- // $seconds /= units[unit];
- // array.unshift(n + ' ' + unit + (n != 1 ? 's' : ''));
- // if($seconds == 0){break;}
- // }
- // $time = array.slice(0, 3).join(', ');
- //
- }}}
- return$time;}
- echo tamanho("2048", "20 MB");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement