From d943b02bb84e07b041f3c1baac57727e42bd4e14 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Sat, 9 Apr 2011 21:09:42 +0000 Subject: [PATCH] Fix everything. --- exec/load/geoip.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/exec/load/geoip.js b/exec/load/geoip.js index 550a02af8d..ddacc47cf7 100644 --- a/exec/load/geoip.js +++ b/exec/load/geoip.js @@ -3,6 +3,13 @@ if(!js.global || js.global.HTTPRequest==undefined) load("http.js"); +var geoipAPIKey='a1ddc4963461ca20bffd54bb926ce74dc1ecbb8a421122cdc3cdfef616f5aad1'; // Enter your API info here! + +if(geoipAPIKey==undefined) { + log("You need to get a key from http://ipinfodb.com/register.php"); + exit; +} + function get_geoip(host, countryonly) { var GeoIP; @@ -37,24 +44,25 @@ function get_geoip(host, countryonly) // Get the best URL if(countryonly) { if(isarray) - geoip_url='http://ipinfodb.com/ip_query2_country.php?output=json&ip='+encodeURIComponent(host.join(',')); + geoip_url='http://api.ipinfodb.com/v3/ip-country/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host.join(',')); else if(ishost) - geoip_url='http://ipinfodb.com/ip_query2_country.php?output=json&ip='+encodeURIComponent(host); + geoip_url='http://api.ipinfodb.com/v3/ip-country/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host); else - geoip_url='http://ipinfodb.com/ip_query_country.php?output=json&ip='+encodeURIComponent(host); + geoip_url='http://api.ipinfodb.com/v3/ip-country/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host); } else { if(isarray) - geoip_url='http://ipinfodb.com/ip_query2.php?output=json&ip='+encodeURIComponent(host.join(',')); + geoip_url='http://api.ipinfodb.com/v3/ip-city/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host.join(',')); else if(ishost) - geoip_url='http://ipinfodb.com/ip_query2.php?output=json&ip='+encodeURIComponent(host); + geoip_url='http://api.ipinfodb.com/v3/ip-city/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host); else - geoip_url='http://ipinfodb.com/ip_query.php?output=json&ip='+encodeURIComponent(host); + geoip_url='http://api.ipinfodb.com/v3/ip-city/?key='+geoipAPIKey+'&format=json&ip='+encodeURIComponent(host); } - try { - result='ret='+new HTTPRequest().Get(geoip_url); - GeoIP=js.eval(result); + do { + result='ret='+new HTTPRequest().Get(geoip_url); + GeoIP=js.eval(result); + } while(GeoIP==undefined); if(GeoIP.Locations != undefined) { if(isarray) return GeoIP.Locations; -- GitLab