[ Index ] |
PHP Cross Reference of Unnamed Project |
[Source view] [Print] [Project Stats]
+----------------------------------------------------------------------+ | PHP version 5 | +----------------------------------------------------------------------+ | Copyright (C) 2004 MaxMind LLC | +----------------------------------------------------------------------+ | 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. | | | | This library is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | Lesser General Public License for more details. | | | | You should have received a copy of the GNU Lesser General Public | | License along with this library; if not, write to the Free Software | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | | USA, or view it online at http://www.gnu.org/licenses/lgpl.txt. | +----------------------------------------------------------------------+ | Authors: Jim Winstead <jimw@apache.org> (original Maxmind version) | | Hans Lellelid <hans@xmpl.org> | +----------------------------------------------------------------------+
Author: | Jim Winstead <jimw@apache.org> (original Maxmind PHP API) |
Author: | Hans Lellelid <hans@xmpl.org> |
License: | LGPL http://www.gnu.org/licenses/lgpl.txt |
File Size: | 904 lines (37 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Net_GeoIP:: (16 methods):
__construct()
getInstance()
open()
loadSharedMemory()
setupSegments()
close()
lookupCountryId()
lookupCountryCode()
lookupCountryName()
seekCountry()
lookupOrg()
lookupRegion()
lookupLocation()
getOrg()
getRegion()
getRecord()
__construct($filename = null, $flags = null) X-Ref |
Construct a Net_GeoIP instance. You should use the getInstance() method if you plan to use multiple databases or the same database from several different places in your script. param: string $filename Path to binary geoip database. param: int $flags Flags |
getInstance($filename = null, $flags = null) X-Ref |
Singleton method, use this to get an instance and avoid re-parsing the db. Unique instances are instantiated based on the filename of the db. The flags are ignored -- in that requests to for instance with same filename but different flags will return the already-instantiated instance. For example: <code> // create new instance with memory_cache enabled $geoip = Net_GeoIP::getInstance('C:\mydb.dat', Net_GeoIP::MEMORY_CACHE); .... // later in code, request instance with no flags specified. $geoip = Net_GeoIP::getInstance('C:\mydb.dat'); // Normally this means no MEMORY_CACHE but since an instance // with memory cache enabled has already been created for 'C:\mydb.dat', the // existing instance (with memory cache) will be returned. </code> NOTE: You can only use SHARED_MEMORY flag for one instance! Any subsquent instances that attempt to use the SHARED_MEMORY will use the *same* shared memory, which will break your script. param: string $filename Filename param: int $flags Flags that control class behavior. return: Net_GeoIP |
open($filename, $flags = null) X-Ref |
Opens geoip database at filename and with specified flags. param: string $filename File to open param: int $flags Flags return: void |
loadSharedMemory($filename) X-Ref |
Loads the database file into shared memory. param: string $filename Path to database file to read into shared memory. return: void |
setupSegments() X-Ref |
Parses the database file to determine what kind of database is being used and setup segment sizes and start points that will be used by the seek*() methods later. return: void |
close() X-Ref |
Closes the geoip database. return: int Status of close command. |
lookupCountryId($addr) X-Ref |
Get the country index. This method is called by the lookupCountryCode() and lookupCountryName() methods. It lookups up the index ('id') for the country which is the key for the code and name. param: string $addr IP address (hostname not allowed) return: string ID for the country |
lookupCountryCode($addr) X-Ref |
Returns 2-letter country code (e.g. 'CA') for specified IP address. Use this method if you have a Country database. param: string $addr IP address (hostname not allowed). return: string 2-letter country code |
lookupCountryName($addr) X-Ref |
Returns full country name for specified IP address. Use this method if you have a Country database. param: string $addr IP address (hostname not allowed). return: string Country name |
seekCountry($ipnum) X-Ref |
Using the record length and appropriate start points, seek to the country that corresponds to the converted IP address integer. param: int $ipnum Result of ip2long() conversion. return: int Offset of start of record. |
lookupOrg($addr) X-Ref |
Lookup the organization (or ISP) for given IP address. Use this method if you have an Organization/ISP database. param: string $addr IP address (hostname not allowed). return: string The organization |
lookupRegion($addr) X-Ref |
Lookup the region for given IP address. Use this method if you have a Region database. param: string $addr IP address (hostname not allowed). return: array Array containing country code and region: array($country_code, $region) |
lookupLocation($addr) X-Ref |
Lookup the location record for given IP address. Use this method if you have a City database. param: string $addr IP address (hostname not allowed). return: Net_GeoIP_Location The full location record. |
getOrg($ipnum) X-Ref |
Seek and return organization (or ISP) name for converted IP addr. param: int $ipnum Converted IP address. return: string The organization |
getRegion($ipnum) X-Ref |
Seek and return the region info (array containing country code and region name) for converted IP addr. param: int $ipnum Converted IP address. return: array Array containing country code and region: array($country_code, $region) |
getRecord($ipnum) X-Ref |
Seek and populate Net_GeoIP_Location object for converted IP addr. Note: this param: int $ipnum Converted IP address. return: Net_GeoIP_Location |
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |