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

From: Date: Sun, 25 May 2003 11:17:36 +0000
Subject: the real problem with the ip-to-country DB / phpweb
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-18057@lists.php.net to get a copy of this message
Hi! I have checked the indexing code, the index and the DB, and Rasmus' IP seems to trigger the problem. He has 12.235.53.226 which is 0216741346 when converted to an IP number. The problematic part of the DB looks like: 0184549376 0218103807 USA 0205500988 0205500991 CAN 0205502668 0205502671 USA 0214858656 0214858671 NLD 0218103808 0234881023 USA [I have added spaces for better readability]. As you can see the first range defines a long range from 018.... to 0218... in which Rasmus' IP is. The coming ranges define the exceptions [and the last one I have included is the next range]. However, based on our previous agreement with Directi, ranges should not overlap!!! The indexing code is based on the assumption that there are no overlaping ranges, and ranges come in an incremental order. Our indexing / search code finds that Rasmus's IP is the range shown on the last line, [IPnumber / 10^7 == 021] however it is not. If the database would be in the format we agreed on there would be no problem. This way many IPs are not found. While lookin at the code and changes made by Jacques, I know I found the thing which caused php.net go down. He modified the search to run several times. While my original speed tests were based on a 400k db file, the current file is 1.5MB, and so the search is much slower. I'll add blocking code to not search in ranges where the index says that results should not appear. This will make the speed much better even for IPs which cannot be found right now. Divyank, can you please look at this ASAP? We are highly in need of a correct country detection database (and index) right now, as we redirect guys to mirror sites. Goba

« previous php.mirrors (#18057) next »