Re: cvs: phpweb /include ip-to-country.inc
| From: | Gabor Hojtsy | Date: | Sun, 25 May 2003 09:29:23 +0000 |
| Subject: | Re: cvs: phpweb /include ip-to-country.inc | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-18049@lists.php.net to get a copy of this message | ||
I am still very much confident that you are fixing at the wrong place. This stuff should not step backwards. The whole index is to be built with linear forward searching in mind. That was the intention. So it would be better to look at the indexing code don't you think, instead of adding workarounds.
Goba
Jacques Marneweck írta:
jacques Sat May 24 16:51:41 2003 EDTModified files: /phpweb/include ip-to-country.inc Log:- Another better fix seeing that it does not process more of theip-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.incdiff -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;