io mi ero scritto questa:

codice:
  function isValidURL($url) {

    $urlPieces = parse_url($url);

    $start = time();

    $sock = @fsockopen($urlPieces['host'], 80, $errno, $errstr, 30);

    $end = time();

    if($sock) {

      fputs($sock,"HEAD {$urlPieces['path']} HTTP/1.1\r\nHost: {$urlPieces['host']}\r\n\r\n");

      while($line=fgets($sock)) {

         $linee[] = $line;

      }

      $risp = $linee[0];

      if(strpos($risp, "200") || strpos($risp, "302") || strpos($risp, "304")) {

        return true;

      } else {

        return false;

      }

    } else {

      return false;

    }


  }