cvs: phpweb /include ip-to-country.inc
| From: | Jacques Marneweck | Date: | Sat, 24 May 2003 20:51:41 +0000 |
| Subject: | cvs: phpweb /include ip-to-country.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-18041@lists.php.net to get a copy of this message | ||
jacques Sat May 24 16:51:41 2003 EDT
Modified files:
/phpweb/include ip-to-country.inc
Log:
- 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.
Index: phpweb/include/ip-to-country.inc
diff -u phpweb/include/ip-to-country.inc:1.14 phpweb/include/ip-to-country.inc:1.15
--- phpweb/include/ip-to-country.inc:1.14 Sat May 24 16:32:44 2003
+++ phpweb/include/ip-to-country.inc Sat May 24 16:51:41 2003
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: ip-to-country.inc,v 1.14 2003/05/24 20:32:44 alindeman Exp $
+// $Id: ip-to-country.inc,v 1.15 2003/05/24 20:51:41 jacques Exp $
/*
@@ -65,10 +65,16 @@
$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;