PHP Class Horde_Nls_Geoip, horde

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 Copyright 2003 MaxMind LLC Copyright 2003-2016 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 COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Michael Slusarz ([email protected])
Datei anzeigen Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_countryCodes array Country list.
$_datafile string The location of the GeoIP database.
$_fh resource The open filehandle to the GeoIP database.

Public Methods

Method Description
__construct ( string $datafile ) Constructor.
countryCodeByAddr ( string $addr ) : integer Returns the country abbreviation (2-letter) for an IP Address.
countryCodeByName ( string $name ) : integer Returns the country abbreviation (2-letter) for a hostname.
countryIdByAddr ( string $addr ) : integer Returns the country ID for an IP Address.
countryIdByName ( string $name ) : integer Returns the country ID for a hostname.
countryNameByAddr ( string $addr ) : mixed Returns the country name for an IP address.
countryNameByName ( string $name ) : integer Returns the country name for a hostname.
getCountryInfo ( string $name ) : mixed Returns the country ID and Name for a given hostname.

Protected Methods

Method Description
_getName ( string $code ) : string Given a 2-letter country code, returns a country string.
_open ( ) : boolean Open the GeoIP database.
_seekCountry ( string $ipnum ) : mixed Finds a country by IP Address in the GeoIP database.

Method Details

__construct() public method

Constructor.
public __construct ( string $datafile )
$datafile string The location of the GeoIP database.

_getName() protected method

Given a 2-letter country code, returns a country string.
protected _getName ( string $code ) : string
$code string The country code.
return string The country string.

_open() protected method

Open the GeoIP database.
protected _open ( ) : boolean
return boolean False on error.

_seekCountry() protected method

Finds a country by IP Address in the GeoIP database.
protected _seekCountry ( string $ipnum ) : mixed
$ipnum string The IP Address to search for.
return mixed The country ID or false if not found.

countryCodeByAddr() public method

Returns the country abbreviation (2-letter) for an IP Address.
public countryCodeByAddr ( string $addr ) : integer
$addr string The IP Address.
return integer The country abbreviation.

countryCodeByName() public method

Returns the country abbreviation (2-letter) for a hostname.
public countryCodeByName ( string $name ) : integer
$name string The hostname.
return integer The country abbreviation.

countryIdByAddr() public method

Returns the country ID for an IP Address.
public countryIdByAddr ( string $addr ) : integer
$addr string The IP Address.
return integer The GeoIP country ID.

countryIdByName() public method

Returns the country ID for a hostname.
public countryIdByName ( string $name ) : integer
$name string The hostname.
return integer The GeoIP country ID.

countryNameByAddr() public method

Returns the country name for an IP address.
public countryNameByAddr ( string $addr ) : mixed
$addr string The IP address.
return mixed The country name.

countryNameByName() public method

Returns the country name for a hostname.
public countryNameByName ( string $name ) : integer
$name string The hostname.
return integer The country name.

getCountryInfo() public method

Returns the country ID and Name for a given hostname.
public getCountryInfo ( string $name ) : mixed
$name string The hostname.
return mixed An array with 'code' as the country code and 'name' as the country name, or false if not found.

Property Details

$_countryCodes protected_oe property

Country list.
protected array $_countryCodes
return array

$_datafile protected_oe property

The location of the GeoIP database.
protected string $_datafile
return string

$_fh protected_oe property

The open filehandle to the GeoIP database.
protected resource $_fh
return resource