26 lines
488 B
PHP
26 lines
488 B
PHP
<?php
|
|
|
|
if (pingServer($_GET['SERVER'])) {
|
|
echo "Server ".$_GET['SERVER']." ist erreichbar.";
|
|
} else {
|
|
echo "Server ".$_GET['SERVER']." ist NICHT erreichbar.";
|
|
}
|
|
|
|
|
|
function pingServer($host, $count = 1)
|
|
{
|
|
$output = [];
|
|
$status = null;
|
|
|
|
// Windows oder Unix ping
|
|
$pingCmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
|
|
? "ping -n {$count} {$host}"
|
|
: "ping -c {$count} {$host}";
|
|
|
|
exec($pingCmd, $output, $status);
|
|
|
|
return $status === 0;
|
|
}
|
|
|
|
|
|
?>
|