diff options
| author | Horus3 | 2014-12-04 14:34:24 +0100 |
|---|---|---|
| committer | Horus3 | 2014-12-04 14:34:24 +0100 |
| commit | bbe481a7fa159db107c7005f8b024bf4657c0bd6 (patch) | |
| tree | 8f40683e61db3d8ac774820163e67ce6d1701439 /isup/ping.php | |
| parent | 33affa31742f0bc9d735349763f639087ea4e7ff (diff) | |
| download | tools.iamfabulous.de-bbe481a7fa159db107c7005f8b024bf4657c0bd6.tar.gz | |
Backend for checking uptime
Diffstat (limited to 'isup/ping.php')
| -rw-r--r-- | isup/ping.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/isup/ping.php b/isup/ping.php new file mode 100644 index 0000000..4c1bea7 --- /dev/null +++ b/isup/ping.php @@ -0,0 +1,26 @@ +<?php + +function ping($host, $ipv6){ + + if ( $ipv6 ) + $ping = "/usr/bin/fping6"; + else + $ping = "/usr/bin/fping"; + + system($ping . " " . $host . " > /dev/null 2>&1", $ret); + + if ( $ret != 0 ) + return false; + + return true; +} + +function sanitizeHost($host){ + + if ( preg_match("|^[a-zA-Z]+://|", $host, $match) ) + $host = str_replace($match[0], "", $host); + if ( preg_match("|(?<query>/.*)|", $host, $match) ) + $host = str_replace($match["query"], "", $host); + + return escapeshellarg($host); +} |
