summaryrefslogtreecommitdiff
path: root/down/ajax.php
diff options
context:
space:
mode:
Diffstat (limited to 'down/ajax.php')
-rw-r--r--down/ajax.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/down/ajax.php b/down/ajax.php
index f5a4ce6..7ebc334 100644
--- a/down/ajax.php
+++ b/down/ajax.php
@@ -29,23 +29,29 @@ switch($_REQUEST["action"]){
require 'ping.php';
if ( ping( sanitizeHost($_REQUEST["url"]), ipv6($_REQUEST["url"]) ) ){
$r["status"] = "Looks like it's up from here.";
- $r["data"] = 1;
+ $r["resp_code"] = 2;
} else {
$r["status"] = "Seems down. :(";
- $r["data"] = 0;
+ $r["resp_code"] = 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";
+ $r["status"] = "Host not valid";
+ $r["resp_code"] = 0;
} else {
- if( isUp($_REQUEST["url"], ipv6($_REQUEST["url"]) ) ){
+ $status = isUp($_REQUEST["url"], ipv6($_REQUEST["url"]));
+ if ( $status == 2 ) {
$r["status"] = "Looks like it's up from here.";
- $r["data"] = 1;
- } else {
+ $r["resp_code"] = 2;
+ } else if ($status >= 400) {
+ $r["status"] = "Site responded with a ".$status." code.";
+ $r["resp_code"] = 1;
+ }
+ else {
$r["status"] = "Seems down. :(";
- $r["data"] = 0;
+ $r["resp_code"] = 0;
}
}
break;