Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Teste de velocidade de conexão
- Por: TDmaiao
- */
- <div id="transferencia" />
- <?php
- $kbs = 10000;
- if(isset($_GET['teste'])) {
- echo str_repeat("x", 1024 * $kbs) ;
- }
- else {
- ?>
- <script>
- var finalizou = 0;
- var inicializou = 0;
- var velocidade = 0;
- xmlhttp= (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
- xmlhttp.onreadystatechange = function()
- {
- if (xmlhttp.readyState==4 && xmlhttp.status== 200)
- {
- finalizou = new Date().getTime();
- velocidade = (<?php echo $kbs * 1000; ?>/(finalizou - inicializou)) >> 0;
- document.getElementById("transferencia").innerHTML = ("Taxa de download: <b>" +velocidade+" kbps</b>");
- }
- }
- iniciarTeste = function() {
- document.getElementById("transferencia").innerHTML = "<br/><img src=\"http://www.steinhaus.com.br/images/aguarde2.gif\" />";
- inicializou = new Date().getTime();
- xmlhttp.open("GET","testecliente.php?teste",true);
- xmlhttp.send();
- return true;
- }
- iniciarTeste();
- </script>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement