Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/05/2011, 12:04
Avatar de fekaa11
fekaa11
 
Fecha de Ingreso: abril-2011
Ubicación: Córdoba / Argentina
Mensajes: 115
Antigüedad: 12 años, 10 meses
Puntos: 34
Respuesta: error en file_get_contents

Estuve haciendo pruebas para ver donde estaba el error.

Cambia $_REQUEST['url']; por $_POST['url'];; verás que el error desaparece. Código completo:

HTML :
Código HTML:
Ver original
  1. <head><title> velocidad </title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
  2. <!--
  3. body {
  4. background-color: #669900;
  5. }
  6. .Estilo1 {
  7. color: #CC0033;
  8. font-weight: bold;
  9. }
  10. -->
  11. </style></head>
  12. <center><h1><strong> </strong></h1>
  13. <h2>MENU VELOCIDAD DESCARGA WEBS </h2>
  14. <p>&nbsp;</p>
  15. <table width="84%" border="2" cellspacing="1" cellpadding="5">
  16. <tr>
  17. <td width="36%" height="57"><div align="center">INTRODUCCION NOMBRE P&Aacute;GINA </div></td>
  18. <td width="64%">
  19. <form name="form1" method="post" action="veloc_descarga.php">
  20. <p>Nombre de la p&aacute;gina WEB
  21. <input type="text" name="url" >
  22. escriba asi http://www.google.com
  23. </p>
  24. <p>
  25. <input type="submit" name="Submit" value="Enviar">
  26. </p>
  27. <p>&nbsp; </p>
  28. </form></td>
  29. </tr>
  30. <tr>
  31. <td height="64">ESTADISTICAS</td>
  32. <td>&nbsp;</td>
  33. </tr>
  34. <h1 class="Estilo1">&nbsp;</h1>
  35. <p class="Estilo1">&nbsp;</p>
  36. <p class="Estilo1">&nbsp;</p>
  37. <p class="Estilo1">&nbsp;</p>
  38. <hr>
  39. </center>
  40. </body>
  41. </html>

PHP:

Código PHP:
Ver original
  1. <?php
  2. $direccion=$_POST['url'];
  3.  
  4. if($direccion){
  5. echo $direccion;
  6. //Veloc (bits / segundo) = bits / (TFin - TComienzo)
  7. //carácter CUALQUIERA siempre tendrá un tamaño de 1 Byte, es decir 8 impulsos electrónicos ( 8 Bit)
  8. $tmicro[1]= microtime();
  9. $q_espacios = explode(" ",$tmicro[1]);
  10. $tiempo_[1]= $q_espacios[1]+$q_espacios[0];
  11.  
  12. //file_get_contents — Transmite un archivo entero a una cadena
  13. $pagina=file_get_contents($direccion);
  14. $tamanoKB= strlen($pagina)/1024;
  15. //for ($i=0;$i<$tamanoKB;$i++){
  16. //for ($i=0;$i<srtlen($pagina);$i++){
  17. //$line = fget($pagina);
  18. //}
  19. //$tamanoKB= strlen($pagina)/1024;
  20.  
  21. echo $tamanoKB ."<br>";
  22.  
  23. $tiempo_micro[2] = microtime();
  24. $q_espacios= explode(" ",$t_micro[2]);
  25. $tiempo_[2] =$q_espacios[1] + $q_espacios[0];
  26. $timeutilizado = number_format(($tiempo_[2] - $tiempo_[1]),2, "." ,","); //Format a number with grouped thousands
  27.  
  28. $velocdescarga= round($tamanoKB/$timeutilizado,3);
  29.  
  30. echo 'velocidad de conexión es de: '.$velocdescarga.' Kbps <br /> Se enviarón:'.$tamanoKB.
  31. ' Kb, Tiempo utilizado: '.$timeutilizado.' Segundos <hr>';
  32. }
  33. ?>

Saludos !
__________________
Pedir perdón es de hombres inteligentes. Perdonar es de sabios.