diff options
| author | Horus3 | 2014-12-04 14:34:24 +0100 |
|---|---|---|
| committer | Horus3 | 2014-12-04 14:34:24 +0100 |
| commit | bbe481a7fa159db107c7005f8b024bf4657c0bd6 (patch) | |
| tree | 8f40683e61db3d8ac774820163e67ce6d1701439 /isup/http.php | |
| parent | 33affa31742f0bc9d735349763f639087ea4e7ff (diff) | |
| download | tools.iamfabulous.de-bbe481a7fa159db107c7005f8b024bf4657c0bd6.tar.gz | |
Backend for checking uptime
Diffstat (limited to 'isup/http.php')
| -rw-r--r-- | isup/http.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/isup/http.php b/isup/http.php new file mode 100644 index 0000000..9973cb4 --- /dev/null +++ b/isup/http.php @@ -0,0 +1,31 @@ +<?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; +} |
