Index of /LTWSinfo_Bkup/themes/mystique/lib/ip2c/
| Name | Last Modified | Size |
|---|---|---|
| 2010-03-11 16:19 | 13k | |
| 2010-03-11 16:19 | 67k | |
| 2010-03-11 16:19 | 18k | |
| 2010-03-11 16:19 | 648k | |
| 2010-03-11 16:19 | 8k |
IP2C 2.0.0 - Copyright (C) 2006 Omry Yadan (omry@yadan.net), all rights reserved
--------------------------------------------------------------------------------------------------
IP2C is an efficient library that resolves the country of an IP address based on a binary database.
Two database sources are supported:
Webhosting.info : http://ip-to-country.webhosting.info/
Software77 : http://software77.net/cgi-bin/ip-country/geo-ip.pl
Currently, IP2C is shipped with a database from Webhosting.info.
Home page:
http://firestats.cc/wiki/ip2c
== Supports ==
* Command line
* Java
* PHP
== Command line (requires java in path) ==
Usage :
To resolve an IP address:
java -jar ip2c.jar -r ip-address
Output format:
if not found:
UNKNOWN
if found:
2C 3C NAME
Example:
java -jar ip2c.jar 85.64.225.159
Outputs:
IL ISR ISRAEL
To build binary file from CSV:
java -jar ip2c -c csv_file [bin_file]
bin_file is optional, if not specified, file.csv will be converted to file.bin.
== Java code ==
String ip = 85.64.225.159;
int caching1 = IP2Country.NO_CACHE; // Straight on file, Fastest startup, slowest queries
int caching2 = IP2Country.MEMORY_MAPPED; // Memory mapped file, fast startup, fast quries.
int caching3 = IP2Country.MEMORY_CACHE; // load file into memory, slowerst startup, fastest queries
IP2Country ip2c = new IP2Country(caching1);
Country c = ip2c.getCountry(ip);
if (c == null)
{
System.out.println("UNKNOWN");
}
else
{
// will output IL ISR ISRAEL
System.out.println(c.get2cStr() + " " + c.get3cStr() + " " + c.getName());
}
== PHP ==
Install the ip2c.php and the binary file in the same directroy.
<?php
require_once('ip2c.php');
$ip2c = new ip2country();
$res = $ip2c->get_country("85.64.225.159");
if ($res == false)
echo "not found";
else
{
$o2c = $res['id2'];
$o3c = $res['id3'];
$oname = $res['name'];
echo "$o2c $o3c $oname"; // will output IL ISR ISRAEL
}
?>
== Acknowledgment ==
IP2C uses the IP-to-Country Database
provided by WebHosting.Info (http://www.webhosting.info),
available from http://ip-to-country.webhosting.info.
Proudly Served by LiteSpeed Web Server at rebeccasplayspace.com Port 443