RE: ip-to-country - summary

From: Date: Mon, 28 Apr 2003 13:13:35 +0000
Subject: RE: ip-to-country - summary
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17133@lists.php.net to get a copy of this message
Hi, Now that we have the db in the format that we require, we need to build an index of the same and test it out. We also need to build a method by which we can rebuild the index each time that the db is updated. Goba: how do you think we should proceed from here. - Div > -----Original Message----- > From: Sandeep S. [mailto:sandeep.s@directi.com] > Sent: Sunday, April 27, 2003 8:08 PM > To: gabor@hojtsy.hu > Cc: php-mirrors@lists.php.net > Subject: RE: ip-to-country - summary > > > -----Original Message----- > >From: Gabor Hojtsy [mailto:gabor@hojtsy.hu] > > >Well, I was unable to come up with anything better, then my > indexable > >text file idea. What we need with this format: > > > - three fields: iprange from and to and three letter countrycode > > - have all fields padded to a fixed length (actually only > the first two > > are related, and they should be padded with zeros added to the > > left to let PHP recognized them as numbers, if they need to act in > > a comparision) > > - no char to separate the fields. This is not needed because of the > > fixed width nature of the data > > - \n (one byte) linending > > > I have uploaded a file in the above format at the following > location for you'll to try out: > http://beta.ip-to-country.com/php.net/ip-to-country.zip > > The > first two fields are 10 bytes each, > therefore the fixed size of each record is (2*10+3+1) bytes. > The file that was used to map the 2 letter alpha country > codes to 3 letter alpha country codes is available at: http://beta.ip-to-country.com/php.net/Alpha2_to_Alpha3.txt >This way, one record will be (2*ipnumber_length+3+1) bytes. So we can >build up an index for the IP numbers. This would mean that we need to >define a step, with which we index the IP list. So something like: > $where_to_start_for_ip_search = array( > 0 => 0, > 10000 => 15, > 20000 => 23, > [...] > ); >This is a mapping between where (at what record) to start to search for >an IP above that number. Then we can fseek() to that position, as we >know the fixed >size of records. From there we can start a normal linear search, that >would probably be sufficient. Please feel free to contact me for additional information. Sandeep -- sandeep.s@directi.com

« previous php.mirrors (#17133) next »