IP2Location library for CodeIgniter. Use IP2Location geolocation database to lookup the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type that any IP address or hostname originates from.

Overview

CodeIgniter IP2Location Library

This module enables users to retrieve below geolocation information from an IP address. It supports both the IPv4 and IPv6 address.

  • Country
  • Region
  • City
  • Latitude & Longitude
  • ZIP Code
  • Time Zone
  • Area Code
  • Net Speed
  • ISP
  • Domain
  • Mobile Information
  • Weather Station Information
  • Elevation
  • Usage Type
  • Address Type
  • Category

Installation

Upload controllers and libraries to CodeIgniter application folder.

Usage

This module is able to query the IP address information from either BIN database or web service. This section will explain how to use this extension to query from BIN database and web service.

Sample codes are given in this project, under controllers folder. You may run the sample code by using <your_domain>/index.php/ip2location_test.

BIN Database

Use following codes in your application for get geolocation information.

    // (optional) Define IP2Location database path. By default, the IP2LOCATION_DATABASE is pointed to *application/libraries/ip2location/IP2LOCATION-DB.BIN* if you choose not to change the original settings.
    define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');

    $ipl = new IP2Location_lib();
    $countryCode = $ipl->getCountryCode('8.8.8.8');

Below are the methods supported for BIN data file lookup.

    $countryCode = $ipl->getCountryCode($ip);
    $countryName = $ipl->getCountryName($ip);
    $regionName = $ipl->getRegionName($ip);
    $cityName = $ipl->getCityName($ip);
    $latitude = $ipl->getLatitude($ip);
    $longitude = $ipl->getLongitude($ip);
    $isp = $ipl->getISP($ip);
    $domainName = $ipl->getDomainName($ip);
    $zipCode = $ipl->getZIPCode($ip);
    $timeZone = $ipl->getTimeZone($ip);
    $netSpeed = $ipl->getNetSpeed($ip);
    $iddCode = $ipl->getIDDCode($ip);
    $areaCode = $ipl->getAreaCode($ip);
    $weatherStationCode = $ipl->getWeatherStationCode($ip);
    $weatherStationName = $ipl->getWeatherStationName($ip);
    $mcc = $ipl->getMCC($ip);
    $mnc = $ipl->getMNC($ip);
    $mobileCarrierName = $ipl->getMobileCarrierName($ip);
    $elevation = $ipl->getElevation($ip);
    $usageType = $ipl->getUsageType($ip);
    $addressType = $ipl->getAddressType($ip);
    $category = $ipl->getCategory($ip);

Web Service

Use following codes in your application for get geolocation information.

    // (required) Define IP2Location API key.
    define('IP2LOCATION_API_KEY', 'your_api_key');

    // (required) Define IP2Location Web service package of different granularity of return information.
    define('IP2LOCATION_PACKAGE', 'WS1');

    // (optional) Define to use https or http.
    define('IP2LOCATION_USESSL', false);

    // (optional) Define extra information in addition to the above-selected package. Refer to https://www.ip2location.com/web-service/ip2location for the list of available addons.
    define('IP2LOCATION_ADDONS', []);

    // (optional) Define Translation information. Refer to https://www.ip2location.com/web-service/ip2location for available languages.
    define('IP2LOCATION_LANGUAGE', 'zh-cn');

    $ipl = new IP2Location_lib();
    print_r ($ipl->getWebService('8.8.8.8'));

IPTools

Use following codes in your application for get IPTools class information.

    $ipl = new IP2Location_lib();
    var_dump($ipl->isIpv4('8.8.8.8'));echo '<br>';
    var_dump($ipl->isIpv6('2001:4860:4860::8888'));echo '<br>';
    print_r($ipl->ipv4ToDecimal('8.8.8.8'));echo '<br>';
    print_r($ipl->decimalToIpv4(134744072));echo '<br>';
    print_r($ipl->ipv6ToDecimal('2001:4860:4860::8888'));echo '<br>';
    print_r($ipl->decimalToIpv6('42541956123769884636017138956568135816'));echo '<br>';
    print_r($ipl->ipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '<br>';
    print_r($ipl->cidrToIpv4('8.0.0.0/8'));echo '<br>';
    print_r($ipl->ipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '<br>';
    print_r($ipl->cidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '<br>';
    print_r($ipl->compressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';
    print_r($ipl->expandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';

Dependencies

This module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at

An outdated BIN database was provided in this release for your testing. You are recommended to visit the above links to download the latest BIN database.

For the BIN database update, you can just rename the downloaded BIN database to IP2LOCATION-DB.BIN and replace the copy in application/libraries/ip2location/ (if you didn't change the default IP2LOCATION_DATABASE constant as described in the Usage section).

You can also sign up for IP2Location Web Service to get one free API key.

IPv4 BIN vs IPv6 BIN

  • Use the IPv4 BIN file if you just need to query IPv4 addresses.
  • Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

SUPPORT

Email: [email protected]

Website: https://www.ip2location.com

You might also like...
CRUD  Build a system to insert student name information, grade the class name, and edit and delete this information
CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

Yclas Self Hosted is a powerful script that can transform any domain into a fully customizable classifieds site within a few seconds.

Yclas 4.4.0. Description Yclas self-hosted is a powerful script that can transform any domain into a fully customizable classifieds site within a few

DiscordLookup | Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more...
DiscordLookup | Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more...

DiscordLookup Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more... Website Getting Help Tool

Quick package/plugin/component (repo) lookup for your favourite package managers
Quick package/plugin/component (repo) lookup for your favourite package managers

Package Managers (Download latest release) Package Repo Search Quick package/plugin/component (repo) lookup for your favourite package managers.

Tool for easy selection and export of user files in ZIP format.

Personal data export Idea Tool for easy selection and export of user files in ZIP format. Within a single selector, you choose all user data (much of

Magento 2 Italian Language Pack is special gift for Magento 2 Community Edition. The data of the translation is supplied by Magento 2 Translation Project of Crowdin site, on which you will contribute into the project and download the zip file to install on your own store. This knowledge base will include full of the clear guides that supports you to convert the default language (English) into Italian language on your entire store.
Simple, fast, isolated way to download+assimilate ZIP/TAR files

Composer Downloads Plugin The "Downloads" plugin allows you to download extra files (*.zip or *.tar.gz) and extract them within your package. This is

Small class to extract + compress .zip, .gz, .rar archives via browser.
Small class to extract + compress .zip, .gz, .rar archives via browser.

The Unzipper The Unzipper extracts .zip and .rar archives or .gz/tar.gz files on webservers. It detects .zip/.rar/.tar.gz/.gz archives and let you cho

An open-source Laravel 8 online store, client area, and billing software specially made for Pterodactyl panel
An open-source Laravel 8 online store, client area, and billing software specially made for Pterodactyl panel

PteroBilling An open-source Laravel 8 online store, client area, and billing software specially made for Pterodactyl panel           Announcement: An

Comments
  • It's not working

    It's not working

    I tried with DB1LITEBIN on Codeigniter 3.1

    Message: unpack(): Type V: not enough input, need 4, have 0

    Filename: ip2location/IP2Location.php

    Line Number: 1106

    opened by toanlk 4
Releases(1.4.0)
Owner
IP2Location
IP geolocation solution. Determine geographical location information such as county, city, zipcode, mobile network information by IP address.
IP2Location
Laravel-Weather let you get weather info from qweather.com

Laravel Weather Weather info system for Laravel. Installing composer require layoute/laravel-weather -vvv Configuration and Migrations php artisan ven

Layoute 1 May 26, 2022
Track any ip address with IP-Tracer. IP-Tracer is developed for Linux and Termux. you can retrieve any ip address information using IP-Tracer.

IP-Tracer is used to track an ip address. IP-Tracer is developed for Termux and Linux based systems. you can easily retrieve ip address information using IP-Tracer. IP-Tracer use ip-api to track ip address.

Rajkumar Dusad 1.2k Dec 1, 2022
This script allows to bypass Oracle Cloud Infrastructure 'Out of host capacity' error immediately when additional OCI capacity will appear in your Home Region / Availability domain.

Resolving Oracle Cloud "Out of Capacity" issue and getting free VPS with 4 ARM cores / 24GB of memory Very neat and useful configuration was recently

Alexander Hitrov 295 Dec 6, 2022
A hacky PHP script to download posts, images, videos and framework grading from Parent Zone

ParentZoneDownloader A hacky PHP script to download posts, images, videos and framework grading from Parent Zone Pre-Requisites Tested on PHP 7.4, but

null 2 Sep 6, 2021
Free ZIP Code API - Free Access to Worldwide Postal Code Data

About Zipcodebase - Free Zip Code API Zipcodebase is a zip code API that was founded in 2019 to solve common issues with postal code data. As we have

SaaS Industries 2 Nov 26, 2022
A script to retrieve data from a Netatmo weather station and display it in a Mac menu bar.

weathermenu A script to retrieve data from a Netatmo weather station and display it in a Mac menu bar. Intended for use with SwiftBar. Configuration N

Dan Moren 4 Nov 4, 2021
Uses internet-connectable temperature sensors to provide cooling/heating assist for small buildings, as well as weather data

ambient-hvac Uses internet-connectable temperature sensors to provide cooling/heating assist for houses and other small buildings, as well as weather

null 3 Nov 25, 2021
Mobile detect change theme and redirect based on device type. Magento 2 module.

Magento 2 Mobile Detect Theme Change Magento 2 Mobile detect system can be used to load different themes base on the client device (desktop, tablet, m

EAdesign 27 Jul 5, 2022
CaraCracha - a captive portal project made for ISPs on my old city

CaraCracha - a captive portal project made for ISPs on my old city, Sobradinho, state of Bahia, Brazil. I found its code recently and hope it could be useful for someone.

Laudivan Freire de Almeida 2 Mar 9, 2022
Install a brand new, shiny website.

Deutsch English Svenska Install 0.8.76 Install a brand new, shiny website. How to install a website Installing is unzipping one file and you are ready

Anna 2 Nov 4, 2022