Gist Boards > Technology & Web/Internet
IP Location Script
(1/1)
flukky01:
Do you want to know where your Internet visitors are coming from? Which country? Which state? Which city? Which ISP? Which domain name? Which connection type? Which ZIP code? Mobile Carrier Information?
IP2Location is a geo IP solution to help you to identify visitor’s geographical location, i.e. country, region, city, latitude, longitude, ZIP code, time zone, connection speed, ISP and domain name, IDD country code, area code, weather station code and name, and mobile carrier information using a proprietary IP address lookup database and technology without invading the Internet user’s privacy. The database is also being used by Fortune 500 companies.
There are API and Source codes for major languages for the use with the demo database. Download the language scripts below….
PHP Library
Ruby Library
Python Library
For other language API and Source codes, Please visit vendor site at http://www.ip2location.com/default.aspx
Sample Code: PHP
Installation: download the PHP Module and host the files on your server. Open the sample.php file (it should look like the script below). change the getALL(<ipaddress>) to reflect the IP you want to check and thats it.
To make the code more flexible, you could use the HTTP POST/GET in the ip address line script e.g $record = $ip->getAll($_POST['ipaddress']);
<?php
require_once(‘ip2location.class.php’);
$ip = new ip2location;
$ip->open(‘./databases/IP-COUNTRY-SAMPLE.BIN’);
$record = $ip->getAll(’80.248.10.174‘);
echo ‘IP Address: ‘ . $record->ipAddress;
echo ‘IP Number: ‘ . $record->ipNumber;
echo ‘Country Short: ‘ . $record->countryShort;
echo ‘Country Long: ‘ . $record->countryLong;
echo ‘Region: ‘ . $record->region;
?>
Cheers…
Navigation
[0] Message Index
Go to full version