Jump to content

Geolocation by IPv6 address


junejune

Recommended Posts

IP2Location PHP module supports IPv6 queries now.

<?php
require_once('IP2Location.php');

// Standard lookup with no cache
$loc = new IP2Location('databases/DB24.BIN');

/*
   Cache whole database into system memory and share among other scripts & websites
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
//$loc = new IP2Location('databases/DB24.BIN', IP2Location::SHARED_MEMORY);

/*
   Cache the database into memory to accelerate lookup speed
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
//$loc = new IP2Location(ROOT . 'databases/DB24.BIN', IP2Location::MEMORY_CACHE);

$ip = $_SERVER['REMOTE_ADDR'];
$record = $loc->lookup($ip, IP2Location::ALL);

echo 'IP Address: ' . $record->ipAddress . '<br />';
echo 'IP Number: ' . $record->ipNumber . '<br />';
echo 'ISO Country Code: ' . $record->countryCode . '<br />';
echo 'Country Name: ' . $record->countryName . '<br />';
echo 'Region Name: ' . $record->regionName . '<br />';
echo 'City Name: ' . $record->cityName . '<br />';
echo 'Latitude: ' . $record->latitude . '<br />';
echo 'Longitude: ' . $record->longitude . '<br />';
echo 'ZIP Code: ' . $record->zipCode . '<br />';
echo 'Time Zone: ' . $record->timeZone . '<br />';
echo 'ISP Name: ' . $record->isp . '<br />';
echo 'Domain Name: ' . $record->domainName . '<br />';
echo 'Net Speed: ' . $record->netSpeed . '<br />';
echo 'IDD Code: ' . $record->iddCode . '<br />';
echo 'Area Code: ' . $record->areaCode . '<br />';
echo 'Weather Station Code: ' . $record->weatherStationCode . '<br />';
echo 'Weather Station Name: ' . $record->weatherStationName . '<br />';
echo 'MCC: ' . $record->mcc . '<br />';
echo 'MNC: ' . $record->mnc . '<br />';
echo 'Mobile Carrier Name: ' . $record->mobileCarrierName . '<br />';
echo 'Elevation: ' . $record->elevation . '<br />';
echo 'Usage Type: ' . $record->usageType . '<br />';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.