Custom Tag: CF_IP2Country Version: 1.0 (c) 2007, MasRizal & Partners
CF_IP2Country is a quick solution to get country ID and name (ISO3166) from a given IP address. This tag doesn't require any RDBMS. Just put the tag in your CF working directory and you're done!
In addition, this tag runs ultra fast when being used in AppVar mode - using application variable as a data cache. Our Pentium IV 2GHz, 1GB RAM test machine shows that it only takes 0.38ms (0.00038 second) to lookup for a country based on given IP.
CF_IP2Country uses the IP-to-Country data provided by WebHosting.Info (http://www.webhosting.info), available from http://ip-to-country.webhosting.info.
Features
- Easy to use!
- Support both given IP address, or automatically gets IP from your visitor CGI information
- No RDBMS required. Effectively remove database overhead thus speed up access.
- Ultra fast query. Our test server shows that it takes only 0.38 millisecond to get country info *
- Latest IP data can be easily updated from http://ip-to-country.webhosting.info/node/view/6
- Plain CF custom tag. Shared hosting friendly.
Just copy this custom tag in your ColdFusion script directory, and you're set
Applications
|
This tag comes in handy when you want to know the country from a given IP address, such as the IP of your visitor. Particularly for applications that needs:
- Real Time Geo-Locating (Country)
- Fraud Detection (Credit Card Fraud, etc.)
- Country targeted ads.
- Digital Rights Management
- Web Server Log Analysis
- Auto-selection of fields on forms (country, currency, language, etc.)
- Filter access on basis of originating country
- Spam Filtering
- and many more
Usage
| <cf_ip2country |
IP="IP address to lookup using dot notation (xxx.xxx.xxx.xxx) or blank to get IP from your visitor CGI variable" |
| |
UseAppVar="1|0. 1 indicates use of application variable cache, 0 indicates read data file directly"> |
Upon successful call, the caller page will have below variables:
- IP2Country.Country -> holds the country name, or blank if the country can't be located (for example if the IP is a local address)
- IP2Country.Country2 -> holds 2 characters of country ID
- IP2Country.Country3 -> holds 3 characters of country ID
| | |
|