All Projects → ip2location → ip2location-cakephp

ip2location / ip2location-cakephp

Licence: MIT license
IP2Location CakePHP plugin enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, IP address type and IAB advertising category from IP address using IP2Location database.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ip2location-cakephp

ip2location-piwik
Use IP2Location geolocation database to lookup for accurate visitor location in Matomo (Piwik) 3.x. It enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, address type and IAB category that any IP address o…
Stars: ✭ 26 (+52.94%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation, ip2location, ip-database
ip2location-nginx
This is IP2Location Nginx module that enables the user to find the country, region (state), city, latitude, longitude, zip code, time zone, ISP, domain name, connection type, area code, weather, mobile network, elevation, usage type, address type and IAB category by IP address or hostname originates from.
Stars: ✭ 38 (+123.53%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation, ip2location, ip-database
IP2Country
Ip to country mapping
Stars: ✭ 39 (+129.41%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation, ip2location
ip2location-iata-icao
This list contains the airport codes of IATA airport code and ICAO airport code together with country code and region name supported in IP2Location geolocation database.
Stars: ✭ 39 (+129.41%)
Mutual labels:  geolocation, ip-geolocation, ip2location, ip-address-database
ipapi-python
Python bindings for https://ipapi.co (IP Address Location) - Use with python / django / flask for IP address location lookup
Stars: ✭ 42 (+147.06%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation
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, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (+805.88%)
Mutual labels:  geolocation, ip-lookup, ip2location
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (+117.65%)
Mutual labels:  geolocation, ip-lookup, ip2location
ip2location-lua
Use IP2Location geolocation database to lookup the geolocation information with IP2Location Lua Package. It can be used to determine country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, address type and IAB category that any IP address …
Stars: ✭ 14 (-17.65%)
Mutual labels:  geolocation, ip-geolocation, ip2location
ip2location-nginx
Nginx module that allows user to lookup for geolocation information using IP2Location database.
Stars: ✭ 33 (+94.12%)
Mutual labels:  geolocation, ip-lookup, ip2location
ip2location-csv-converter
This PHP script converts IP2Location CSV database into IP range or CIDR format.
Stars: ✭ 26 (+52.94%)
Mutual labels:  geolocation, ip-geolocation, ip2location
WordPress-IP-Geo-Block
A WordPress plugin that will blocks any comment, pingback and trackback spams posted from outside your nation. And it will also protect against malicious access to the login form, admin area and XML-RPC from undesired countries.
Stars: ✭ 26 (+52.94%)
Mutual labels:  ip-geolocation, ip2location
Geolocate-IP-Browser-Extension
A browser extension, which shows you the origin of your IP address.
Stars: ✭ 21 (+23.53%)
Mutual labels:  geolocation, ip-geolocation
django
Official Django Library for IPinfo API (IP geolocation and other types of IP data)
Stars: ✭ 36 (+111.76%)
Mutual labels:  ip-geolocation, ip-database
Freegeoip
IP geolocation web server
Stars: ✭ 4,812 (+28205.88%)
Mutual labels:  geolocation, ip-database
ipinfodb-php
PHP library to query free IPInfoDB API service.
Stars: ✭ 15 (-11.76%)
Mutual labels:  geolocation, ip2location
mmdb-server
mmdb-server is an open source fast API server to lookup IP addresses for their geographic location.
Stars: ✭ 69 (+305.88%)
Mutual labels:  geolocation, ip-geolocation
cli
Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data)
Stars: ✭ 1,279 (+7423.53%)
Mutual labels:  ip-lookup, ip-geolocation
ip-location-db
ip to location database by ASN, GeoFeed, Whois, iptoasn.com, db-ip lite, GeoLite2
Stars: ✭ 160 (+841.18%)
Mutual labels:  ip-geolocation, ip2location
ruby
Official Ruby client library for IPinfo API (IP geolocation and other types of IP data)
Stars: ✭ 42 (+147.06%)
Mutual labels:  ip-geolocation, ip-database
geolocation
A laravel integration for using the IPInfoDB and Ip2Location services
Stars: ✭ 38 (+123.53%)
Mutual labels:  geolocation, ip2location

IP2Location CakePHP Plugin

Latest Stable Version Total Downloads

IP2Location CakePHP plugin enables the user to find 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 typ, IP address type and IAB advertising category from IP address using IP2Location database. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Location BIN databases or web service for applications written using CakePHP.

INSTALLATION

For CakePHP 4.x

  1. Run the command: composer require ip2location/ip2location-cakephp to download the plugin into the CakePHP 4 platform.
  2. Download latest IP2Location BIN database
  3. Unzip and copy the BIN file into /vendor/ip2location/ip2location-cakephp/src/Data folder.
  4. Rename the BIN file to IP2LOCATION.BIN.

Note: The plugin has included an old BIN database for your testing and development purpose. You may want to download a latest copy of BIN database as the URL stated above. The BIN database refers to the binary file ended with .BIN extension, but not the CSV format. Please select the right package for download.

USAGE

In this tutorial, we will show you on how to create a TestsController to display the IP information.

  1. Create a TestsController in CakePHP 4 using the below command line
php bin/cake bake controller Tests
  1. Create a Tests folder in /cakephp/templates if not exists.
  2. Create an empty index.php file in /cakephp/templates/Tests folder.
  3. Open the cakephp/src/Controller/TestsController.php in any text editor.
  4. Remove the contents in TestsController.php and add the below lines into the controller file.

Note: You just need to load the IP2Location library with use IP2LocationCakePHP\Controller\IP2LocationCoresController to use the functions.

<?php
namespace App\Controller;

use App\Controller\AppController;
use IP2LocationCakePHP\Controller\IP2LocationCoresController;

// (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', 'en');

/**
 * Tests Controller
 */
class TestsController extends AppController
{

    /**
     * Index method
     *
     * @return \Cake\Http\Response|void
     */
    public function index()
    {
        $IP2Location = new IP2LocationCoresController();

        $record = $IP2Location->get('8.8.8.8');
        echo 'Result from BIN Database:<br>';
        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>';
        echo 'Address Type: ' . $record['addressType'] . '<br>';
        echo 'Category: ' . $record['category'] . '<br>';

        $record = $IP2Location->getWebService('8.8.8.8');
        echo 'Result from Web service:<br>';
        echo '<pre>';
        print_r ($record);
        echo '</pre>';

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

}
  1. Enter the URL /Tests and run. You should see the information of 8.8.8.8 IP address.

DEPENDENCIES

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].