Re: the real problem with the ip-to-country DB / phpweb

From: Date: Sun, 25 May 2003 14:14:12 +0000
Subject: Re: the real problem with the ip-to-country DB / phpweb
References: 1 2 3 4 5  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-18077@lists.php.net to get a copy of this message
OK; the server will sync in around 15 minutes. I'm taking a look at implementing some C code for the IP lookup to make it nice and fast; this could be deployed in www.php.net as a PHP extension, and we can fall back to the current scheme for other mirrors. You say the DB is screwed up; is the DB we have for php.net using the same data as the ip-to-country.txt file available in the .zip from the directi site? If so, is that data flawed also?
It is not that format. We have a custom format for easy fseek()ing. Fixed length records. And we have no country name, as we have a hash for that. So our data format is quite different from that TXT. The problem with the DB right now is that it has overlapping IP regions defined, which is against our original agreement, and against the examples provided on the directi site to get a country. As this way there can be more then one range containing an IP. One broader range, and one smaller one. Our code is not ready to handle that, and I don't think we should handle that. We cannot make assumptions on where are overlapping regions defined in the file, so we would need to check the whole DB, which is 1,5MB right now. So I would suggest to wait for a fix from directi (automatically deployed via a fecth script, as soon as it will be available). BTW there is no need to implement a custom PHP extension for this. You can put the data into a three column DB (range start, range end, country). The first 10 bytes in every record are the range starts padded with zeros from the left in our file. Similar ar the range ends, and 3 bytes are for the country codes. We can employ sqlite maybe for this search. PHP.net can put that DB into a table after rsync updated the data file. And then search can go on in that DB. That would also enable any sqlite having mirrors to have better lookup speeds :) Goba

« previous php.mirrors (#18077) next »