summaryrefslogtreecommitdiff
path: root/down/ajax.php
diff options
context:
space:
mode:
authorroot2014-12-07 00:33:54 +0100
committerroot2014-12-07 00:33:54 +0100
commit6ec371bff3d3eda0c535fe773c292f66bd746a7a (patch)
treebbca16b736bae30363b34eebdcdfcb94ebda0148 /down/ajax.php
parent60070877e8e0d862bf342b5c83fd011819ebcdea (diff)
downloadtools.iamfabulous.de-6ec371bff3d3eda0c535fe773c292f66bd746a7a.tar.gz
Bug fixed and added warning for HTTP status codes.
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;