From bf3847219714d71e59bfa04569089ab52f852960 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 4 Dec 2014 17:10:49 +0100 Subject: Finished tool for checking downtime --- down/ajax.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 down/ajax.php (limited to 'down/ajax.php') diff --git a/down/ajax.php b/down/ajax.php new file mode 100644 index 0000000..63a63d1 --- /dev/null +++ b/down/ajax.php @@ -0,0 +1,60 @@ + $_REQUEST["url"]); + +switch($_REQUEST["action"]){ + case("ping"): + require 'ping.php'; + if ( ping( sanitizeHost($_REQUEST["url"]), ipv6($_REQUEST["url"]) ) ){ + $r["status"] = "Looks like it's up from here."; + $r["data"] = 1; + } else { + $r["status"] = "Seems down. :("; + $r["data"] = 0; + } + break; + case("http"): + require 'http.php'; + if ( !ipv6($_REQUEST["url"]) && filter_var(sanitizeUrl($_REQUEST["url"]), FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) === false ){ + echo "not valid"; + } else { + if( isUp($_REQUEST["url"]) ){ + $r["status"] = "Looks like it's up from here."; + $r["data"] = 1; + } else { + $r["status"] = "Seems down. :("; + $r["data"] = 0; + } + } + break; + default: + header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request"); + header("X-Debug: Please define a valid action."); + $r["status"] = "not valid"; + $r["data"] = 0; + break; +} + +echo json_encode($r); -- cgit v1.2.3