From 1ffa65c88b570aca2b5d3b9b7202e30beeee2fe7 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 Dec 2014 05:06:52 +0100 Subject: Made it ipv6 ready. --- .gitignore | 1 + down/ajax.php | 6 +++--- down/http.php | 10 +++++++++- down/view/templ-index.php | 16 ++++++++++------ header/index.php | 18 +++++++++++++++++- ifconfig/ifconfig.php | 10 ++++++++-- ifconfig/index.php | 5 +---- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index b8ce7ca..4fc2e91 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.swp *.db staging/ +uploaded/ diff --git a/down/ajax.php b/down/ajax.php index 63a63d1..f5a4ce6 100644 --- a/down/ajax.php +++ b/down/ajax.php @@ -11,9 +11,9 @@ if( !isset($_REQUEST["url"]) || $_REQUEST["url"] == "" ){ exit; } -function ipv6($host){ +function ipv6($ip){ - if ( filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { return true; } @@ -40,7 +40,7 @@ switch($_REQUEST["action"]){ 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"]) ){ + if( isUp($_REQUEST["url"], ipv6($_REQUEST["url"]) ) ){ $r["status"] = "Looks like it's up from here."; $r["data"] = 1; } else { diff --git a/down/http.php b/down/http.php index 9973cb4..5e0351d 100644 --- a/down/http.php +++ b/down/http.php @@ -1,7 +1,14 @@ - + @@ -44,7 +45,7 @@ } ?> - + @@ -116,10 +117,13 @@ $(".fa-spinner").addClass("fa-spin"); - }; + document.addEventListener('keydown', function(event) { + $("#url").focus(); + }); - function clean(id){ - $(id).val(''); - } + $("#clear").click(function(){ + $("#url").val('').focus(); + }) + }; diff --git a/header/index.php b/header/index.php index 056cde5..6fd41e0 100644 --- a/header/index.php +++ b/header/index.php @@ -42,6 +42,15 @@ if ( $set ){ require '../tools/class/redis.php'; + function ipv6($ip){ + + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { + return true; + } + + return false; + } + $redis = new Database(REDIS_CONNECT, 9); $key = md5( $url . $method . serialize($customHeader) ); @@ -51,7 +60,14 @@ if ( $set ){ } $agent = "Retrieve HTTP headers online. v0.1"; - $ch = curl_init($url); + $ch = curl_init(); + + if ( ipv6($url) ){ + $url = "[".$url."]"; + curl_setopt($ch,CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); + } + + curl_setopt ($ch, CURLOPT_URL,$url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); diff --git a/ifconfig/ifconfig.php b/ifconfig/ifconfig.php index cf1dc8f..33ec5ba 100644 --- a/ifconfig/ifconfig.php +++ b/ifconfig/ifconfig.php @@ -19,9 +19,15 @@ class Ifconfig { } public function getAllGeoipRecords(){ + $tmp = geoip_record_by_name( $this->ip ); - unset($tmp['dma_code']); - unset($tmp['area_code']); + if( $tmp ){ + unset($tmp['dma_code']); + unset($tmp['area_code']); + } else { + $tmp = array ( "status" => "Data not available"); + } + return $tmp; } diff --git a/ifconfig/index.php b/ifconfig/index.php index 83e03ed..a390ec2 100644 --- a/ifconfig/index.php +++ b/ifconfig/index.php @@ -1,12 +1,9 @@