note 90222 deleted from function.getenv by danbrown

From: Date: Fri, 10 Apr 2009 23:37:05 +0000
Subject: note 90222 deleted from function.getenv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153068@lists.php.net to get a copy of this message
Note Submitter: joe at anime dot com dot pl ---- A few remarks to estarapapax at gmail dot com. 1. Your idea of converting IP address from a dotted string to an integer is unnecessarily complex. There is a special function for it called ip2long(). 2. Even if there was no ip2long() function you could do it much better. For example you should replace multiplications with bit shifts. $ip << 24 is much faster than $ip * 16777216. 3. Why do all the complex conversions each time you want to check an IP address? You should store the CSV file in a processed form (sorted and with IPs converted to integers). 4. All the information you need to map an IP address to a country is stored in whois databases. If you query the whois servers directly you'll always have up to date information. Of course you can (and should) use local file to cache the results. 5. Not to mention that using a database to store IP data would be much better idea.

« previous php.notes (#153068) next »