Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

ddrv/php-iptool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP Tool

Define data by IP Address

Install

Add to composer.json:

{
    "require": {
        "ddrv/iptool":"*"
    }
}

And run

php composer.phar install

Create your IP addresses database

See examples for create database:

  • Geo from Maxmind GeoLite2 Country examples/geoFromMaxmindCountry.php

Use

/**
 * Initialization IP Tool
 */
$iptool = new \Ddrv\Iptool\Iptool('/path/to/iptool.database');
/**
 * Get information about created database
 */
print_r($iptool->about());
Array
(
    [created] => 1507199627
    [author] => Ivan Dudarev
    [license] => MIT
    [networks] => Array
        (
            [count] => 276148
            [data] => Array
                (
                    [country] => Array
                        (
                            [0] => code
                            [1] => name
                        )

                )

        )

)
/**
 * Search IP Address data
 */
print_r($iptool->find('81.32.17.89'));
Array
(
    [network] => Array
        (
            [0] => 81.32.0.0
            [1] => 81.48.0.0
        )

    [data] => Array
        (
            [country] => Array
                (
                    [code] => es
                    [name] => Spain
                )

        )

)