diff options
| author | root | 2014-12-04 17:10:49 +0100 |
|---|---|---|
| committer | root | 2014-12-04 17:10:49 +0100 |
| commit | bf3847219714d71e59bfa04569089ab52f852960 (patch) | |
| tree | 1eaa8255ea1a522c16f7267cf3639bb1681279c9 /isup | |
| parent | bbe481a7fa159db107c7005f8b024bf4657c0bd6 (diff) | |
| download | tools.iamfabulous.de-bf3847219714d71e59bfa04569089ab52f852960.tar.gz | |
Finished tool for checking downtime
Diffstat (limited to 'isup')
| -rw-r--r-- | isup/ajax.php | 48 | ||||
| -rw-r--r-- | isup/http.php | 31 | ||||
| -rw-r--r-- | isup/index.php | 25 | ||||
| -rw-r--r-- | isup/ping.php | 26 |
4 files changed, 0 insertions, 130 deletions
diff --git a/isup/ajax.php b/isup/ajax.php deleted file mode 100644 index 3e21a20..0000000 --- a/isup/ajax.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -if( !isset($_REQUEST["action"]) || $_REQUEST["action"] == "" ){ - header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request"); - header("X-Debug: Please define a action."); - exit; -} -if( !isset($_REQUEST["url"]) || $_REQUEST["url"] == "" ){ - header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request"); - header("X-Debug: Please define a valid host."); - exit; -} - -function ipv6($host){ - - if ( filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { - return true; - } - - return false; -} - -switch($_REQUEST["action"]){ - case("ping"): - require 'ping.php'; - if ( ping( sanitizeHost($_REQUEST["url"]), ipv6($_REQUEST["url"]) ) ){ - echo "up"; - } else { - echo "down"; - } - 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"]) ){ - echo "up"; - } else { - echo "down"; - } - } - break; - default: - header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request"); - header("X-Debug: Please define a valid action."); - break; -} diff --git a/isup/http.php b/isup/http.php deleted file mode 100644 index 9973cb4..0000000 --- a/isup/http.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -function isUp($url){ - $agent = "Just checking if you are up or not."; - $ch=curl_init(); - curl_setopt ($ch, CURLOPT_URL,$url ); - curl_setopt($ch, CURLOPT_USERAGENT, $agent); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt ($ch,CURLOPT_VERBOSE,false); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); - curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch,CURLOPT_SSLVERSION,3); - curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE); - $page=curl_exec($ch); - $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); - - if($httpcode>=200 && $httpcode<400 ) - return true; - else - return false; -} - -function sanitizeUrl($url){ - if ( ! preg_match("|^[a-zA-Z]+://|", $url) ) - $url = "http://" . $url; - if ( preg_match("|^[a-zA-Z]+://.+\.[a-zA-Z]+(?<query>/.*)|", $url, $match) ) - $url = str_replace($match["query"], "", $url); - - return $url; -} diff --git a/isup/index.php b/isup/index.php deleted file mode 100644 index 9c856c8..0000000 --- a/isup/index.php +++ /dev/null @@ -1,25 +0,0 @@ -<!doctype html> -<html> -<head> - <meta charset="utf-8"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> - <style> - <?php echo file_get_contents("../tools/style.css"); ?> - </style> - <noscript><style>.navbar{margin-bottom:0;}</style></noscript> - <title>IsUP | iamfabulous.de</title> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'> -</head> -<body> - <?php require("../tools/navbar.php"); ?> -<div class="container"> - <div class="text-center"> - <div class="row"> - - </div> - </div> -</div> - - <?php require("../tools/footer.php"); ?> diff --git a/isup/ping.php b/isup/ping.php deleted file mode 100644 index 4c1bea7..0000000 --- a/isup/ping.php +++ /dev/null @@ -1,26 +0,0 @@ -<?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); -} |
