Horde_Nls_Geoip
in package
Horde optimized interface to the MaxMind IP Address->Country listing.
Based on PHP geoip.inc library by MaxMind LLC: http://www.maxmind.com/download/geoip/api/php/
Originally based on php version of the geoip library written in May 2002 by jim winstead jimw@apache.org
Copyright 2003 MaxMind LLC Copyright 2003-2017 Horde LLC (http://www.horde.org/)
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Tags
Table of Contents
- GEOIP_COUNTRY_BEGIN = 16776960
- STANDARD_RECORD_LENGTH = 3
- STRUCTURE_INFO_MAX_SIZE = 20
- $_countryCodes : array<string|int, mixed>
- Country list.
- $_datafile : string
- The location of the GeoIP database.
- $_fh : resource
- The open filehandle to the GeoIP database.
- __construct() : mixed
- Constructor.
- countryCodeByAddr() : int
- Returns the country abbreviation (2-letter) for an IP Address.
- countryCodeByName() : int
- Returns the country abbreviation (2-letter) for a hostname.
- countryIdByAddr() : int
- Returns the country ID for an IP Address.
- countryIdByName() : int
- Returns the country ID for a hostname.
- countryNameByAddr() : mixed
- Returns the country name for an IP address.
- countryNameByName() : int
- Returns the country name for a hostname.
- getCountryInfo() : mixed
- Returns the country ID and Name for a given hostname.
- _getName() : string
- Given a 2-letter country code, returns a country string.
- _open() : bool
- Open the GeoIP database.
- _seekCountry() : mixed
- Finds a country by IP Address in the GeoIP database.
Constants
GEOIP_COUNTRY_BEGIN
public
mixed
GEOIP_COUNTRY_BEGIN
= 16776960
STANDARD_RECORD_LENGTH
public
mixed
STANDARD_RECORD_LENGTH
= 3
STRUCTURE_INFO_MAX_SIZE
public
mixed
STRUCTURE_INFO_MAX_SIZE
= 20
Properties
$_countryCodes
Country list.
protected
array<string|int, mixed>
$_countryCodes
= array('', 'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'FX', 'GA', 'UK', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TP', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'YU', 'ZA', 'ZM', 'ZR', 'ZW', 'A1', 'A2', 'O1')
$_datafile
The location of the GeoIP database.
protected
string
$_datafile
$_fh
The open filehandle to the GeoIP database.
protected
resource
$_fh
Methods
__construct()
Constructor.
public
__construct(string $datafile) : mixed
Parameters
- $datafile : string
-
The location of the GeoIP database.
Return values
mixed —countryCodeByAddr()
Returns the country abbreviation (2-letter) for an IP Address.
public
countryCodeByAddr(string $addr) : int
Parameters
- $addr : string
-
The IP Address.
Return values
int —The country abbreviation.
countryCodeByName()
Returns the country abbreviation (2-letter) for a hostname.
public
countryCodeByName(string $name) : int
Parameters
- $name : string
-
The hostname.
Return values
int —The country abbreviation.
countryIdByAddr()
Returns the country ID for an IP Address.
public
countryIdByAddr(string $addr) : int
Parameters
- $addr : string
-
The IP Address.
Return values
int —The GeoIP country ID.
countryIdByName()
Returns the country ID for a hostname.
public
countryIdByName(string $name) : int
Parameters
- $name : string
-
The hostname.
Return values
int —The GeoIP country ID.
countryNameByAddr()
Returns the country name for an IP address.
public
countryNameByAddr(string $addr) : mixed
Parameters
- $addr : string
-
The IP address.
Return values
mixed —The country name.
countryNameByName()
Returns the country name for a hostname.
public
countryNameByName(string $name) : int
Parameters
- $name : string
-
The hostname.
Return values
int —The country name.
getCountryInfo()
Returns the country ID and Name for a given hostname.
public
getCountryInfo(string $name) : mixed
Parameters
- $name : string
-
The hostname.
Return values
mixed —An array with 'code' as the country code and 'name' as the country name, or false if not found.
_getName()
Given a 2-letter country code, returns a country string.
protected
_getName(string $code) : string
Parameters
- $code : string
-
The country code.
Return values
string —The country string.
_open()
Open the GeoIP database.
protected
_open() : bool
Return values
bool —False on error.
_seekCountry()
Finds a country by IP Address in the GeoIP database.
protected
_seekCountry(string $ipnum) : mixed
Parameters
- $ipnum : string
-
The IP Address to search for.
Return values
mixed —The country ID or false if not found.