diff options
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); +} |
