..::Problemas con variable::..

[email protected] ("Alfonso Alejandro Reyes Jimenez")
Newsgroups php.general.es
Message-ID <4082A43D9A6C9D42B70BD8DB21F8514406429747@mailmexbe.mex.scitum.com.mx>
Hola  a todos.

Les envio este correo para ver si alguien me ayuda a encontrar el problema, el código es simple, sin embargo me marca un error de variable cuando llega a la parte del loop while. Ya lo revise y no parece tener problemas, pero el problema sigue, estoy pensando que tal vez hay una manera de hacerlo mas eficiente y es por eso que no esta corriendo bien.

Les anexo el código:

<?php
function check($host, $find) {
    $fp = fsockopen($host, 80, $errno, $errstr, 10);
    if (!$fp) {
        echo "$errstr ($errno)\n";
    } else {
       $header = "GET / HTTP/1.1\r\n";
       $header .= "Host: $host\r\n";
       $header .= "Connection: close\r\n\r\n";
       fputs($fp, $header);
       while (!feof($fp)) {
           $str .= fgets($fp, 1024); # <- aqui manda el error de variable.
       }
       fclose($fp);
       return (strpos($str, $find) !== false);
    }
}
function alert($host) {
    mail('[email protected]', 'Monitoring', $host.' down'); }

$host = 'www.domain.com';
$find = 'Domain';
if (!check($host, $find)) alert($host);
?>

Cualquier consejo seria bienvenido, gracias de antemano.

Saludos. 
  
Alfonso.              
 
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.