echo "Test: " . $row['kunden_website'] . "<br/>"; flush();
$fp = fsockopen($row['kunden_website'], 80, $errno, $errstr, 5);
echo "<pre>";
var_dump($fp, $errno, $errstr);
echo "</pre>";
$match = array(); $onoffline = "";
if (!$fp) {
echo "Nicht erreichbar<br/>"; flush();
$onoffline = "offline";
} else {
$out = "HEAD / HTTP/1.1\r\n";
$out .= "Host: ".$row['kunden_website']."\r\n";
$out .= "Connection: Close\r\n\r\n";
echo "Sende<br/>"; flush();
fputs($fp, $out);
while (!feof($fp))
{
$s = fgets($fp);
if(preg_match('@HTTP/1\.1 ([1-5]\d{2}) @', $s,$match))
{
echo "Empfange: " . $s . "<br/>"; flush();
echo "Status: " . $match[1] . "<br/>"; flush();
$onoffline=($match[1]>=400)?'offline':'online';
break;
}
}
echo "Ergebnis: " .$onoffline . "<br/>"; flush();
fclose($fp);
}