|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct ($filename=null, $flags=null) | |
| open ($filename, $flags=null) | |
| close () | |
| lookupCountryCode ($addr) | |
| lookupCountryName ($addr) | |
| lookupOrg ($addr) | |
| lookupRegion ($addr) | |
| lookupLocation ($addr) | |
Static Public Member Functions | |
| static | getInstance ($filename=null, $flags=null) |
Data Fields | |
| const | ERR_INVALID_IP = 218624992 |
| const | ERR_DB_FORMAT = 866184008 |
| const | STANDARD = 0 |
| const | MEMORY_CACHE = 1 |
| const | SHARED_MEMORY = 2 |
| const | COUNTRY_BEGIN = 16776960 |
| const | STATE_BEGIN_REV0 = 16700000 |
| const | STATE_BEGIN_REV1 = 16000000 |
| const | STRUCTURE_INFO_MAX_SIZE = 20 |
| const | DATABASE_INFO_MAX_SIZE = 100 |
| const | COUNTRY_EDITION = 106 |
| const | REGION_EDITION_REV0 = 112 |
| const | REGION_EDITION_REV1 = 3 |
| const | CITY_EDITION_REV0 = 111 |
| const | CITY_EDITION_REV1 = 2 |
| const | ORG_EDITION = 110 |
| const | SEGMENT_RECORD_LENGTH = 3 |
| const | STANDARD_RECORD_LENGTH = 3 |
| const | ORG_RECORD_LENGTH = 4 |
| const | MAX_RECORD_LENGTH = 4 |
| const | MAX_ORG_RECORD_LENGTH = 300 |
| const | FULL_RECORD_LENGTH = 50 |
| const | US_OFFSET = 1 |
| const | CANADA_OFFSET = 677 |
| const | WORLD_OFFSET = 1353 |
| const | FIPS_RANGE = 360 |
| const | SHM_KEY = 0x4f415401 |
Static Public Attributes | |
| static | $COUNTRY_CODES |
| static | $COUNTRY_CODES3 |
| static | $COUNTRY_NAMES |
Protected Member Functions | |
| loadSharedMemory ($filename) | |
| setupSegments () | |
| lookupCountryId ($addr) | |
| seekCountry ($ipnum) | |
| getOrg ($ipnum) | |
| getRegion ($ipnum) | |
| getRecord ($ipnum) | |
| __construct | ( | $ | filename = null, |
| $ | flags = null |
||
| ) |
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.
| string | $filename | Path to binary geoip database. |
| int | $flags | Flags |
Definition at line 333 of file GeoIP.php.

| close | ( | ) |
| static getInstance | ( | $ | filename = null, |
| $ | flags = null |
||
| ) | [static] |
Calls the close() function to free any resources.
COMMENTED OUT TO ADDRESS BUG IN PHP 5.0.4, 5.0.5dev. THIS RESOURCE SHOULD AUTOMATICALLY BE FREED AT SCRIPT CLOSE, SO A DESTRUCTOR IS A GOOD IDEA BUT NOT NECESSARILY A NECESSITY. public function __destruct() { $this->close(); } 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: // create new instance with memory_cache enabled $geoip = Net_GeoIP::getInstance('C:.dat', Net_GeoIP::MEMORY_CACHE); ....
// later in code, request instance with no flags specified. $geoip = Net_GeoIP::getInstance('C:.dat');
// Normally this means no MEMORY_CACHE but since an instance // with memory cache enabled has already been created for 'C:.dat', the // existing instance (with memory cache) will be returned.
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.
| string | $filename | Filename |
| int | $flags | Flags that control class behavior. + Net_GeoIp::SHARED_MEMORY Use SHMOP to share a db among multiple PHP instances. NOTE: ONLY ONE GEOIP INSTANCE CAN USE SHARED MEMORY!!! + Net_GeoIp::MEMORY_CACHE Store the full contents of the database in memory for current script. This is useful if you access the database several times in a script. + Net_GeoIp::STANDARD [default] standard no-cache version. |
Definition at line 392 of file GeoIP.php.

| getOrg | ( | $ | ipnum | ) | [protected] |
| getRecord | ( | $ | ipnum | ) | [protected] |
Seek and populate Net_GeoIP_Location object for converted IP addr. Note: this
| int | $ipnum | Converted IP address. |
Definition at line 812 of file GeoIP.php.


| getRegion | ( | $ | ipnum | ) | [protected] |
Seek and return the region info (array containing country code and region name) for converted IP addr.
| int | $ipnum | Converted IP address. |
Definition at line 772 of file GeoIP.php.


| loadSharedMemory | ( | $ | filename | ) | [protected] |
Loads the database file into shared memory.
| string | $filename | Path to database file to read into shared memory. |
| PEAR_Exception | - if unable to read the db file. |
Definition at line 446 of file GeoIP.php.

| lookupCountryCode | ( | $ | addr | ) |
Returns 2-letter country code (e.g. 'CA') for specified IP address. Use this method if you have a Country database.
| string | $addr | IP address (hostname not allowed). |
| PEAR_Exception | (see lookupCountryId()) |
Definition at line 609 of file GeoIP.php.

| lookupCountryId | ( | $ | addr | ) | [protected] |
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.
| string | $addr | IP address (hostname not allowed) |
| PEAR_Exception | - if IP address is invalid.
|
Definition at line 586 of file GeoIP.php.


| lookupCountryName | ( | $ | addr | ) |
Returns full country name for specified IP address. Use this method if you have a Country database.
| string | $addr | IP address (hostname not allowed). |
| PEAR_Exception | (see lookupCountryId()) |
Definition at line 624 of file GeoIP.php.

| lookupLocation | ( | $ | addr | ) |
Lookup the location record for given IP address. Use this method if you have a City database.
| string | $addr | IP address (hostname not allowed). |
| PEAR_Exception | - if IP address is invalid. |
Definition at line 728 of file GeoIP.php.

| lookupOrg | ( | $ | addr | ) |
Lookup the organization (or ISP) for given IP address. Use this method if you have an Organization/ISP database.
| string | $addr | IP address (hostname not allowed). |
| PEAR_Exception | - if IP address is invalid.
|
Definition at line 684 of file GeoIP.php.

| lookupRegion | ( | $ | addr | ) |
Lookup the region for given IP address. Use this method if you have a Region database.
| string | $addr | IP address (hostname not allowed). |
| PEAR_Exception | - if IP address is invalid. |
Definition at line 706 of file GeoIP.php.

| open | ( | $ | filename, |
| $ | flags = null |
||
| ) |
Opens geoip database at filename and with specified flags.
| string | $filename | File to open |
| int | $flags | Flags |
| PEAR_Exception | if unable to open specified file or shared memory. |
Definition at line 410 of file GeoIP.php.


| seekCountry | ( | $ | ipnum | ) | [protected] |
Using the record length and appropriate start points, seek to the country that corresponds to the converted IP address integer.
| int | $ipnum | Result of ip2long() conversion. |
| PEAR_Exception | - if fseek() fails on the file or no results after traversing the database (indicating corrupt db). |
Definition at line 638 of file GeoIP.php.

| setupSegments | ( | ) | [protected] |
$COUNTRY_CODES [static] |
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", "GB", "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", "TL", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", "AX", "GG", "IM", "JE", "BL", "MF" )
$COUNTRY_CODES3 [static] |
array( "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG", "ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI", "BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC", "COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV", "CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH", "ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD", "GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM", "GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO", "IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA", "PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU", "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC", "MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL", "NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER", "PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT", "REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM", "SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF", "TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA", "UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT", "WLF","WSM","YEM","YT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1", "ALA","GGY","IMN","JEY","BLM","MAF" )
| const CANADA_OFFSET = 677 |
| const CITY_EDITION_REV0 = 111 |
| const CITY_EDITION_REV1 = 2 |
| const COUNTRY_BEGIN = 16776960 |
| const COUNTRY_EDITION = 106 |
| const DATABASE_INFO_MAX_SIZE = 100 |
| const ERR_DB_FORMAT = 866184008 |
| const ERR_INVALID_IP = 218624992 |
| const FIPS_RANGE = 360 |
| const FULL_RECORD_LENGTH = 50 |
| const MAX_ORG_RECORD_LENGTH = 300 |
| const MAX_RECORD_LENGTH = 4 |
| const MEMORY_CACHE = 1 |
| const ORG_EDITION = 110 |
| const ORG_RECORD_LENGTH = 4 |
| const REGION_EDITION_REV0 = 112 |
| const REGION_EDITION_REV1 = 3 |
| const SEGMENT_RECORD_LENGTH = 3 |
| const SHARED_MEMORY = 2 |
| const STANDARD_RECORD_LENGTH = 3 |
| const STATE_BEGIN_REV0 = 16700000 |
| const STATE_BEGIN_REV1 = 16000000 |
| const STRUCTURE_INFO_MAX_SIZE = 20 |
| const WORLD_OFFSET = 1353 |