From 0883c55d3a7698cc42e1e9a95cf23128efa88bfa Mon Sep 17 00:00:00 2001 From: Jacques Marneweck Date: Sat, 24 May 2003 20:51:41 +0000 Subject: [PATCH] - Another better fix seeing that it does not process more of the ip-to-country database file than necessary as well as adding a failsafe so we only do a max of 3 lookups and move the index down each time by one. --- include/ip-to-country.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/ip-to-country.inc b/include/ip-to-country.inc index f83ed77a2..365370b18 100644 --- a/include/ip-to-country.inc +++ b/include/ip-to-country.inc @@ -65,10 +65,16 @@ function i2c_go() $idx = i2c_search_in_index($ipn); // For some odd reason I need to remove 2 from the idx value to // get the country of rasmus and various other IP's to lookup. - $idx-=2; + $country = "NA"; + $count = 1; - // Search in the database from the given index - $country = i2c_search_in_db($ipn, $idx); + // Search in the database from the given index and if not found + // we attempt 3 lookups in total moving the index down one. + while ($country == "NA" && $count < 4) { + $country = i2c_search_in_db($ipnum, $idx); + $idx--; + $count++; + } // Set global variable for further usage $COUNTRY = $country;