<?php error_reporting(0); ob_start(); function pingSite($webserver) { foreach ($webserver as $key => $host) { $fp = curl_init($host['url']); curl_setopt($fp,CURLOPT_TIMEOUT,10); curl_setopt($fp,CURLOPT_FAILONERROR,1); curl_setopt($fp,CURLOPT_RETURNTRANSFER,1); curl_exec($fp); if (curl_errno($fp) != 0) { $webserver[$key]['status'] = false; } else { $webserver[$key]['status'] = true; } curl_close($fp); } return $webserver; } $webserver[0]['name'] = 'lima-city'; $webserver[0]['url'] = 'http://webfreclan.lima-city.de'; $webserver = pingSite($webserver); ?> <html> <head> <title>Server Check</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?PHP foreach ($webserver as $key => $host) { if(!$host['status']) { echo 'Die Server sind zurzeit offline!'; Header("Location: http://www3.wronnay.tk"); } else { echo 'Die Server sind zurzeit online!'; Header("Location: http://webfreclan.lima-city.de"); } } ?> </body> </html> <?php ob_end_flush(); ?> |
Dieser Code überprüft, ob der Server „http://webfreclan.lima-city.de“ online ist und leitet im Fall, dass er offline ist, auf http://www3.wronnay.tk weiter.