A PHP class library for importing IP2Location data. A sample driver (updateIP2Location.php) is included.
This is a class library that can be used with a simple driver to update a MySQL database with the monthly updates of DB5 from IP2Location's no cost service (https://lite.ip2location.com/). Once imported, the data can easily be referenced to provide latitude/longitude/city/country data to visualize network activity (like with Smashing). The library includes functions to allow you to setup the database, download new data, stage it, activate it, and roll it back if necessary.
- Clone or copy the class library and driver from this project.
- Satisfy PHP dependencies. At least unzip and curl are required (maybe more, I forget).
- Enable LOAD DATA INFILE in MySQL through the
mysqld.cnf
directives. - Enable the user of LOAD DATA INFILE in
php.ini
. - Create a database for the IP2Location data (optional)
- Configure the driver for an administrative user that has at least the
CREATE TABLE
privilege. - Use the createTableSet() functions to create the tables and optionally, a dedicated user for them.
- Reconfigure the driver for the non-privileged user just created.
Use the driver to update the IP2Location tables with the update
argument. If you need to rerun it, use the optional -reimport
flag to skip the download.
There is very little except comments in the code.