Blesta Source Documentation

NetGeoIp uses Container

NetGeoIP component that wraps Maxmind's GeoIP system. Requires mbstring extension to be enabled with PHP (due to poor coding standards on MaxMind's part).

Table of Contents

Properties

$api
$geo_ip2_db_filename
$geo_ip_db_filename

Methods

__construct() Create a new GeoIP instance using the given database file
getCountryCode() Returns the 2-character country code where the IP resides
getCountryName() Returns the name of the country where the IP resides
getGeoIpDatabaseFilename() Gets the name of the database file expected for the given version
getLocation() Fetches an array of information about the location of the IP address, including longitude and latitude.
getOrg() Get the organization or ISP that owns the IP address. Requires a premium database.
getRegion() Get the region (e.g. state) of the given IP address.
getFromContainer() Fetch an item from the container
call() Makes a call to the API
currentIp() Returns the currently set IP address
setIp() Sets the IP address for the API
Properties

$api

private AbstractGeoIp $api

The API interface through which to fetch data

$geo_ip2_db_filename

private string $geo_ip2_db_filename = 'GeoLite2-City.mmdb'

The expected path to the GeoIP database

$geo_ip_db_filename

private string $geo_ip_db_filename = 'GeoLiteCity.dat'

The expected path to the GeoIP database

Methods

__construct()

Create a new GeoIP instance using the given database file

public __construct() : mixed

getCountryCode()

Returns the 2-character country code where the IP resides

public getCountryCode([string $ip = null ]) : string
Parameters
$ip : string = null

The IP address to lookup, if null will use user's IP

Tags
see
NetGeoIp::getLocation()
Return values
string

The 2-character country code where the IP resides

getCountryName()

Returns the name of the country where the IP resides

public getCountryName([string $ip = null ]) : string
Parameters
$ip : string = null

The IP address to lookup, if null will use user's IP

Tags
see
NetGeoIp::getLocation()
Return values
string

The name of the country where the IP resides

getGeoIpDatabaseFilename()

Gets the name of the database file expected for the given version

public getGeoIpDatabaseFilename([string $version = '2' ]) : string
Parameters
$version : string = '2'

The GeoIp version to get the filename for

Return values
string

The name of the database file

getLocation()

Fetches an array of information about the location of the IP address, including longitude and latitude.

public getLocation([string $ip = null ]) : array<string|int, mixed>
Parameters
$ip : string = null

The IP address to lookup, if null will use user's IP

Return values
array<string|int, mixed>

An array of information about the location of the IP address

getOrg()

Get the organization or ISP that owns the IP address. Requires a premium database.

public getOrg([string $ip = null ]) : string
Parameters
$ip : string = null

The IP address to lookup, if null will use user's IP

Return values
string

The oraganization the IP address belongs to

getRegion()

Get the region (e.g. state) of the given IP address.

public getRegion([string $ip = null ]) : string
Parameters
$ip : string = null

The IP address to lookup, if null will use user's IP

Tags
see
NetGeoIp::getLocation()
Return values
string

The region the IP address resides in

getFromContainer()

Fetch an item from the container

protected getFromContainer(string $service) : mixed
Parameters
$service : string

The name of the service from the container to fetch

Return values
mixed

The service if found, otherwise null

call()

Makes a call to the API

private call(string $method) : mixed
Parameters
$method : string

The method of the API to call

Return values
mixed

The return value for the API call, or an empty string if no API call can be made

currentIp()

Returns the currently set IP address

private currentIp([string $ip = null ]) : string
Parameters
$ip : string = null

If non-null, will be the returned value, else will use user's IP

Return values
string

The IP given in $ip, or the user's IP if $ip was null.

setIp()

Sets the IP address for the API

private setIp([string $ip = null ]) : mixed
Parameters
$ip : string = null

The IP to set (optional)

Tags
subpackage

components.net.net_geo_ip

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results