Ver Mensaje Individual
  #7 (permalink)  
Antiguo 20/03/2015, 13:49
Jose789
 
Fecha de Ingreso: diciembre-2012
Ubicación: Murcia
Mensajes: 329
Antigüedad: 12 años, 1 mes
Puntos: 4
Respuesta: No consigo que en la web me aparezca el estado del servidor.

Prueba haber que tal
Código PHP:
Ver original
  1. function check($ip, $port)
  2. {
  3.     $starttime  = microtime(true);
  4.     $file = fsockopen($ip, $port, $errno, $errstr, 2);
  5.     $stoptime   = microtime(true);
  6.     $status     = 0;
  7.     if(!$file) $status = -1;  // Site is down
  8.     else
  9.     {
  10.         fclose($file);
  11.         $status = ($stoptime - $starttime) * 1000;
  12.         $status = floor($status);
  13.     }
  14.     return $status;
  15. }
  16.  
  17. if(check("IP", "PUERTO") != -1)
  18.     {
  19.         echo "online";
  20.     }
  21.     else
  22.     {
  23.         echo "offline";
  24.     }