note 90222 added to function.getenv
| From: | joe at anime dot com dot pl | Date: | Fri, 10 Apr 2009 23:35:23 +0000 |
| Subject: | note 90222 added to function.getenv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153067@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 82.177.164.100
Probable Submitter: 83.9.246.37
----
Manual Page -- http://www.php.net/manual/en/function.getenv.php
Edit -- https://master.php.net/note/edit/90222
Del: integrated -- https://master.php.net/note/delete/90222/integrated
Del: useless -- https://master.php.net/note/delete/90222/useless
Del: bad code -- https://master.php.net/note/delete/90222/bad+code
Del: spam -- https://master.php.net/note/delete/90222/spam
Del: non-english -- https://master.php.net/note/delete/90222/non-english
Del: in docs -- https://master.php.net/note/delete/90222/in+docs
Del: other reasons-- https://master.php.net/note/delete/90222
Reject -- https://master.php.net/note/reject/90222
Search -- https://master.php.net/manage/user-notes.php