mirror of
https://github.com/php/web-php.git
synced 2026-03-24 07:12:16 +01:00
- 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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user