Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
$address = 'www.test.de';
$sock =fsockopen( $address, 80, $errno, $errstr, 5 );
if( ! $sock ) die( $errstr );
$http_header = "GET / HTTP/1.1\r\n" .
"Host: $address\r\n" .
"Connection: Close\r\n\r\n";
if( fwrite( $sock, $http_header ) != strlen( $http_header ) ) {
die( "Send request short write - could not send the header correctly" );
}
while ( ! feof( $sock ) ) {
$response_line = fgets( $sock, 128 );
// Just for debug:
echo $response_line . "<br/>";
// Here the response line has to be analyzed
}
function online($url) {
if (filter_var ( $url, FILTER_VALIDATE_URL ) == true) {
$connection = curl_init();
curl_setopt ( $connection, CURLOPT_URL, $url );
curl_setopt ( $connection, CURLOPT_USERAGENT, $_SERVER ["HTTP_USER_AGENT"] );
curl_setopt ( $connection, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $connection, CURLOPT_VERBOSE, false );
curl_setopt ( $connection, CURLOPT_CONNECTTIMEOUT, "5" );
curl_setopt ( $connection, CURLOPT_TIMEOUT, "5" );
curl_exec( $connection );
$status = curl_getinfo ( $connection );
curl_close( $connection );
if (($status ["http_code"] >= "200") && ($status ["http_code"] < "300")) {
return true;
} else {
return false;
}
} else {
return false;
}
}
if (online ( "http://www.google.de" ) == true) {
echo "Online";
} else {
echo "Offline";
}