/IP2Location-PHP-Module

This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code and weather station name that any IP address or host name originates from.

Primary LanguagePHPMIT LicenseMIT

IP2Location (PHP Module)

Latest Stable Version Total Downloads

This is the official release maintained by IP2Location.com

This PHP module provides fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation, and usage type from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com.

This module can be used in many types of projects such as:

  1. select the geographically closest mirror
  2. analyze your web server logs to determine the countries of your visitors
  3. credit card fraud detection
  4. software export controls
  5. display native language and currency
  6. prevent password sharing and abuse of service
  7. geotargeting in advertisement

The database will be updated in monthly basis for the greater accuracy. Free sample database is available at /samples directory or download it from http://www.ip2location.com/developers.

The complete database is available at http://www.ip2location.com under Premium subscription package. This module also support IP2Location IPv6 version.

INSTALLATION

To install this module, unzip the package and copy the following files to your web folder.

  • IP2Location.php
  • example.php
  • databases/IP-COUNTRY-SAMPLE.BIN
  • databases/IPV6-COUNTRY-SAMPLE.BIN

To test this installation, please browse example.php using web browser.

USAGE

Below is the description of the functions available in this class

Function Name Descripton
Constructor Expect 2 input parameters:
  1. Full path of IP2Location BIN data file.
  2. File Open Mode
    • SHARED_MEMORY
    • MEMORY_CACHE
    • FILE_IO
For SHARED_MEMORY and MEMORY_CACHE, it will require your server to have sufficient memory to hold the BIN data, otherwise it will raise the errors during the object initialization.
getDate Return the database's compilation date as a string of the form 'YYYY-MM-DD'
getType Return the database's type, 1 to 24 respectively for DB1 to DB24. Please visit https://www.ip2location.com/databases for details.
getModuleVersion Return the version of module
getDatabaseVersion Return the version of database
lookup Return the IP information in array. Below is the information returned:
  • ipNumber
  • ipVersion
  • ipAddress
  • countryCode
  • countryName
  • regionName
  • cityName
  • latitude
  • longitude
  • areaCode
  • iddCode
  • weatherStationCode
  • weatherStationName
  • mcc
  • mnc
  • mobileCarrierName
  • usageType
  • elevation
  • netSpeed
  • timeZone
  • zipCode
  • domainName
  • isp
You can visit IP2Location for the description of each field. Note: although the above names are not exactly matched with the names given in this link, but they are self-described.

DEPENDENCIES (IP2LOCATION BIN DATA FILE)

This library requires IP2Location BIN data file to function. You may download the BIN data file at

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

COPYRIGHT AND LICENCE

Copyright (C) 2005-2017 by IP2Location.com

License under MIT