lookupLocation($ip); } } // Lookup by DNS hostname else if(!empty($_GET['dns'])) { $host = filter_var($_GET['dns'], FILTER_SANITIZE_STRING); if ($host) { require_once('Net/DNS.php'); $resolver = new Net_DNS_Resolver(); //$resolver->debug = 1; // Useful for debugging DNS issues $resolver->nameservers = array('YOUR.FIRST.DNS.HERE','YOUR.SECOND.DNS.HERE','YOUR.THIRD.DNS.HERE'); $response = $resolver->query($host); //var_dump($response); // Also useful for debugging $n = 0; if ($response) { foreach ($response->answer as $rr) { if ($n == 0) { $ip = $rr->address; if (!empty($ip)) { $location = $geoip->lookupLocation($ip); $n++; } } else { $n++; } } } } } // By default, lookup the IP address of the client else { $ip = $_SERVER['REMOTE_ADDR']; $location = $geoip->lookupLocation($ip); } // Restore the character encoding mb_internal_encoding($oldmbenc); ?> '; echo ' '; } else { echo ''; } ?>
IP Address:
Domain:
IP: City: city.", ".$location->region.", ".$location->countryCode; ?> Coords: latitude.", ".$location->longitude; ?>