summaryrefslogtreecommitdiff
path: root/down/ping.php
diff options
context:
space:
mode:
authorroot2014-12-04 17:10:49 +0100
committerroot2014-12-04 17:10:49 +0100
commitbf3847219714d71e59bfa04569089ab52f852960 (patch)
tree1eaa8255ea1a522c16f7267cf3639bb1681279c9 /down/ping.php
parentbbe481a7fa159db107c7005f8b024bf4657c0bd6 (diff)
downloadtools.iamfabulous.de-bf3847219714d71e59bfa04569089ab52f852960.tar.gz
Finished tool for checking downtime
Diffstat (limited to 'down/ping.php')
-rw-r--r--down/ping.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/down/ping.php b/down/ping.php
new file mode 100644
index 0000000..4c1bea7
--- /dev/null
+++ b/down/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);
+}