This module provides local based ip geolocation based on SypexGeo City database. It is fully free and has frequently updates.
At first you must download and install module as usual. Then you need to download SypexGeo PHP library and SypexGeo City database. You can do it in two ways:
-
Go to download page.
-
Download "Sypex Geo для PHP 5.2+".
2.1 Put
SxGeo.php
file toPATH_TO_SITE_INSTALLATION/sites/all/libraries/sypexgeo
.2.2 File must be available at
/sites/all/libraries/sypexgeo/SxGeo.php
. -
Download "Sypex Geo City" UTF-8 edition.
3.1 Navigate to
/admin/config/regional/sypexgeo
.3.2 Upload
SxGeoCity.dat
file and save it. -
You're done.
- Install all you needs with just single command
drush sypexgeo
. - It will ask you, what you want to install, choose it and thats it.
Yes, you can also update SypexGeo database with drush. Just use second option when you want to make database fresh.
This example cover all your needs, it's wrapper for all functions in a module.
Params:
$ip
an array of IP's for check.$type
a string determines which data you will receive. Can be: city, country, full (default). Scroll down to look what info it store.
$result = sypexgeo_get_ip_info_multiple(array('127.0.0.1')), 'city');
$result = sypexgeo_get_ip_info_multiple(array('127.0.0.1', '127.0.0.2')));
Same as Example 1, just for single IP address. This is just wrapper for Example 1.
$result = sypexgeo_get_ip_info('127.0.0.1'); // full
$result = sypexgeo_get_ip_info('127.0.0.1', 'city');
Returns full information about IP. Equals 'full' from first two examples.
$result = sypexgeo_get_ip_city_full('127.0.0.1');
Returns information about city. Equals 'city' from first two examples.
$result = sypexgeo_get_ip_city('127.0.0.1');
Returns ISO 3166-1 alpha-2 (two symbols) country name. F.e. RU, US, GB. Equals 'country' from first two examples.
$result = sypexgeo_get_ip_country('127.0.0.1');