summaryrefslogtreecommitdiff
path: root/isup/http.php
diff options
context:
space:
mode:
Diffstat (limited to 'isup/http.php')
-rw-r--r--isup/http.php31
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;
+}