1 | <?php |
|||||||||||
2 | ||||||||||||
3 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ |
|||||||||||
4 | /* geoip.inc |
|||||||||||
5 | * |
|||||||||||
6 | * Copyright (C) 2004 MaxMind LLC |
|||||||||||
7 | * |
|||||||||||
8 | * This library is free software; you can redistribute it and/or |
|||||||||||
9 | * modify it under the terms of the GNU Lesser General Public |
|||||||||||
10 | * License as published by the Free Software Foundation; either |
|||||||||||
11 | * version 2.1 of the License, or (at your option) any later version. |
|||||||||||
12 | * |
|||||||||||
13 | * This library is distributed in the hope that it will be useful, |
|||||||||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||||||||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||||||||||
16 | * Lesser General Public License for more details. |
|||||||||||
17 | * |
|||||||||||
18 | * You should have received a copy of the GNU Lesser General Public |
|||||||||||
19 | * License along with this library; if not, write to the Free Software |
|||||||||||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||||||||||
21 | */ |
|||||||||||
22 | ||||||||||||
23 | /* |
|||||||||||
24 | * Changelog: |
|||||||||||
25 | * |
|||||||||||
26 | * 2005-01-13 Andrew Hill, Awarez Ltd. (http://www.awarez.net) |
|||||||||||
27 | * Formatted file according to PEAR library standards. |
|||||||||||
28 | * Moved $GEOIP_COUNTRY_CODE_TO_NUMBER, $GEOIP_COUNTRY_CODES, |
|||||||||||
29 | * $GEOIP_COUNTRY_CODES3 and $GEOIP_COUNTRY_NAMES into the |
|||||||||||
30 | * GeoIP class, so that library will still work even when |
|||||||||||
31 | * not included in the $GLOBAL context. |
|||||||||||
32 | */ |
|||||||||||
33 | ||||||||||||
34 | define("GEOIP_COUNTRY_BEGIN", 16776960); |
|||||||||||
35 | define("GEOIP_STATE_BEGIN_REV0", 16700000); |
|||||||||||
36 | define("GEOIP_STATE_BEGIN_REV1", 16000000); |
|||||||||||
37 | define("GEOIP_STANDARD", 0); |
|||||||||||
38 | define("GEOIP_MEMORY_CACHE", 1); |
|||||||||||
39 | define("GEOIP_SHARED_MEMORY", 2); |
|||||||||||
40 | define("STRUCTURE_INFO_MAX_SIZE", 20); |
|||||||||||
41 | define("DATABASE_INFO_MAX_SIZE", 100); |
|||||||||||
42 | define("GEOIP_COUNTRY_EDITION", 106); |
|||||||||||
43 | define("GEOIP_PROXY_EDITION", 8); |
|||||||||||
44 | define("GEOIP_ASNUM_EDITION", 9); |
|||||||||||
45 | define("GEOIP_NETSPEED_EDITION", 10); |
|||||||||||
46 | define("GEOIP_REGION_EDITION_REV0", 112); |
|||||||||||
47 | define("GEOIP_REGION_EDITION_REV1", 3); |
|||||||||||
48 | define("GEOIP_CITY_EDITION_REV0", 111); |
|||||||||||
49 | define("GEOIP_CITY_EDITION_REV1", 2); |
|||||||||||
50 | define("GEOIP_ORG_EDITION", 110); |
|||||||||||
51 | define("GEOIP_ISP_EDITION", 4); |
|||||||||||
52 | define("SEGMENT_RECORD_LENGTH", 3); |
|||||||||||
53 | define("STANDARD_RECORD_LENGTH", 3); |
|||||||||||
54 | define("ORG_RECORD_LENGTH", 4); |
|||||||||||
55 | define("MAX_RECORD_LENGTH", 4); |
|||||||||||
56 | define("MAX_ORG_RECORD_LENGTH", 300); |
|||||||||||
57 | define("GEOIP_SHM_KEY", 0x4f415401); |
|||||||||||
58 | define("US_OFFSET", 1); |
|||||||||||
59 | define("CANADA_OFFSET", 677); |
|||||||||||
60 | define("WORLD_OFFSET", 1353); |
|||||||||||
61 | define("FIPS_RANGE", 360); |
|||||||||||
62 | define("GEOIP_UNKNOWN_SPEED", 0); |
|||||||||||
63 | define("GEOIP_DIALUP_SPEED", 1); |
|||||||||||
64 | define("GEOIP_CABLEDSL_SPEED", 2); |
|||||||||||
65 | define("GEOIP_CORPORATE_SPEED", 3); |
|||||||||||
66 | ||||||||||||
67 | class GeoIP { |
|||||||||||
68 | var $flags; |
|||||||||||
69 | var $filehandle; |
|||||||||||
70 | var $memory_buffer; |
|||||||||||
71 | var $databaseType; |
|||||||||||
72 | var $databaseSegments; |
|||||||||||
73 | var $record_length; |
|||||||||||
74 | var $shmid; |
|||||||||||
75 | var $GEOIP_COUNTRY_CODE_TO_NUMBER = array( |
|||||||||||
76 | "" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5, |
|||||||||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
||||||||||||
77 | "AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "AN" => 10, "AO" => 11, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
78 | "AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
79 | "AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
80 | "BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
81 | "BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
82 | "BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
83 | "CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
84 | "CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
85 | "CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
86 | "DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
87 | "ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
88 | "FM" => 72, "FO" => 73, "FR" => 74, "FX" => 75, "GA" => 76, "GB" => 77, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
89 | "GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
90 | "GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
91 | "GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
92 | "HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
93 | "IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
94 | "IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
95 | "KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
96 | "KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
97 | "LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
98 | "LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
99 | "MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
100 | "MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
101 | "MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
102 | "NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
103 | "NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
104 | "PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
105 | "PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
106 | "PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
107 | "RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
108 | "SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
109 | "SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
110 | "SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
111 | "TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
112 | "TP" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
113 | "UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
114 | "VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
115 | "VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "CS" => 239, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
116 | "ZA" => 240, "ZM" => 241, "ZR" => 242, "ZW" => 243, "A1" => 244, "A2" => 245, |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
117 | "O1" => 246 |
|||||||||||
118 | ); |
|||||||||||
119 | var $GEOIP_COUNTRY_CODES = array( |
|||||||||||
120 | "", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
121 | "AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
122 | "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
123 | "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
124 | "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
125 | "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
126 | "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
127 | "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
128 | "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
129 | "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
130 | "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
131 | "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
132 | "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
133 | "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
134 | "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
135 | "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
136 | "TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TP", "TR", "TT", "TV", "TW", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
137 | "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
138 | "VU", "WF", "WS", "YE", "YT", "CS", "ZA", "ZM", "ZR", "ZW", "A1", "A2", "O1" |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
139 | ); |
|||||||||||
140 | var $GEOIP_COUNTRY_CODES3 = array( |
|||||||||||
141 | "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
142 | "ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
143 | "BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
144 | "COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
145 | "CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
146 | "ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
147 | "GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
148 | "GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
149 | "IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
150 | "PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
151 | "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
152 | "MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
153 | "NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
154 | "PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
155 | "REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
156 | "SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
157 | "TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
158 | "UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
159 | "WLF","WSM","YEM","YT","SCG","ZAF","ZMB","ZR","ZWE","A1","A2","O1" |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
160 | ); |
|||||||||||
161 | var $GEOIP_COUNTRY_NAMES = array( |
|||||||||||
162 | "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
163 | "Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
164 | "Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
165 | "Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
166 | "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
167 | "Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
168 | "Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
169 | "Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
170 | "Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
171 | Islands", "Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
172 | Verde", "Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
173 | "Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
174 | "Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
175 | "Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
176 | Islands", "France", "France, Metropolitan", "Gabon", "United Kingdom", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
177 | "Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
178 | "Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
179 | and the South Sandwich Islands", "Guatemala", "Guam", "Guinea-Bissau", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
180 | "Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
181 | "Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
182 | "British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
183 | "Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
184 | "Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
185 | People's Republic of", "Korea, Republic of", "Kuwait", "Cayman Islands", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
186 | "Kazakstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
187 | "Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
188 | "Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
189 | of", "Madagascar", "Marshall Islands", "Macedonia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
190 | "Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
191 | "Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
192 | "Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
193 | "Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
194 | "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
195 | Polynesia", "Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
196 | Pierre and Miquelon", "Pitcairn Islands", "Puerto Rico", "Palestinian Territory", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
197 | "Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
198 | "Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
199 | "Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
200 | "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
201 | "Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
202 | Republic", "Swaziland", "Turks and Caicos Islands", "Chad", "French Southern |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
203 | Territories", "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
204 | "Tunisia", "Tonga", "East Timor", "Turkey", "Trinidad and Tobago", "Tuvalu", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
205 | "Taiwan", "Tanzania, United Republic of", "Ukraine", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
206 | "Uganda", "United States Minor Outlying Islands", "United States", "Uruguay", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
207 | "Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
208 | Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
209 | "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
210 | "Serbia and Montenegro", "South Africa", "Zambia", "Zaire", "Zimbabwe", |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
211 | "Anonymous Proxy","Satellite Provider","Other" |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
212 | ); |
|||||||||||
213 | } |
|||||||||||
214 | function geoip_load_shared_mem ($file) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
215 | ||||||||||||
216 | $fp = fopen($file, "rb"); |
|||||||||||
217 | if (!$fp) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
218 | print "error opening $file: $php_errormsg\n"; |
|||||||||||
219 | exit; |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
220 | } |
|||||||||||
221 | $s_array = fstat($fp); |
|||||||||||
222 | $size = $s_array['size']; |
|||||||||||
223 | if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) { |
|||||||||||
224 | shmop_delete ($shmid); |
|||||||||||
225 | shmop_close ($shmid); |
|||||||||||
226 | } |
|||||||||||
227 | $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size); |
|||||||||||
228 | shmop_write ($shmid, fread($fp, $size), 0); |
|||||||||||
229 | shmop_close ($shmid); |
|||||||||||
230 | } |
|||||||||||
231 | ||||||||||||
232 | function _setup_segments($gi){ |
|||||||||||
233 | $gi->databaseType = GEOIP_COUNTRY_EDITION; |
|||||||||||
234 | $gi->record_length = STANDARD_RECORD_LENGTH; |
|||||||||||
235 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|||||||||||
236 | $offset = @shmop_size ($gi->shmid) - 3; |
|||||||||||
237 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
|||||||||||
238 | $delim = @shmop_read ($gi->shmid, $offset, 3); |
|||||||||||
239 | $offset += 3; |
|||||||||||
240 | if ($delim == (chr(255).chr(255).chr(255))) { |
|||||||||||
241 | $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1)); |
|||||||||||
242 | $offset++; |
|||||||||||
243 | ||||||||||||
244 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|||||||||||
245 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
|||||||||||
246 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|||||||||||
247 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
|||||||||||
248 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
249 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) |
|||||||||||
250 | || ($gi->databaseType == GEOIP_ORG_EDITION) |
|||||||||||
251 | || ($gi->databaseType == GEOIP_ISP_EDITION) |
|||||||||||
252 | || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|||||||||||
253 | $gi->databaseSegments = 0; |
|||||||||||
254 | $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
|||||||||||
255 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
256 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
|||||||||||
257 | } |
|||||||||||
258 | if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
259 | ($gi->databaseType == GEOIP_ISP_EDITION)) { |
|||||||||||
260 | $gi->record_length = ORG_RECORD_LENGTH; |
|||||||||||
261 | } |
|||||||||||
262 | } |
|||||||||||
263 | break; |
|||||||||||
264 | } else { |
|||||||||||
265 | $offset -= 4; |
|||||||||||
266 | } |
|||||||||||
267 | } |
|||||||||||
268 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
269 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
270 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|||||||||||
271 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
|||||||||||
272 | } |
|||||||||||
273 | } else { |
|||||||||||
274 | $filepos = ftell($gi->filehandle); |
|||||||||||
275 | fseek($gi->filehandle, -3, SEEK_END); |
|||||||||||
276 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
|||||||||||
277 | $delim = fread($gi->filehandle,3); |
|||||||||||
278 | if ($delim == (chr(255).chr(255).chr(255))){ |
|||||||||||
279 | $gi->databaseType = ord(fread($gi->filehandle,1)); |
|||||||||||
280 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|||||||||||
281 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
|||||||||||
282 | } |
|||||||||||
283 | else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|||||||||||
284 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
|||||||||||
285 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|||||||||||
286 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || |
|||||||||||
287 | ($gi->databaseType == GEOIP_ORG_EDITION) || |
|||||||||||
288 | ($gi->databaseType == GEOIP_ISP_EDITION) || |
|||||||||||
289 | ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|||||||||||
290 | $gi->databaseSegments = 0; |
|||||||||||
291 | $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); |
|||||||||||
292 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
293 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
|||||||||||
294 | } |
|||||||||||
295 | if ($gi->databaseType == GEOIP_ORG_EDITION) { |
|||||||||||
296 | $gi->record_length = ORG_RECORD_LENGTH; |
|||||||||||
297 | } |
|||||||||||
298 | } |
|||||||||||
299 | break; |
|||||||||||
300 | } else { |
|||||||||||
301 | fseek($gi->filehandle, -4, SEEK_CUR); |
|||||||||||
302 | } |
|||||||||||
303 | } |
|||||||||||
304 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
305 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
306 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|||||||||||
307 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
|||||||||||
308 | } |
|||||||||||
309 | fseek($gi->filehandle,$filepos,SEEK_SET); |
|||||||||||
310 | } |
|||||||||||
311 | return $gi; |
|||||||||||
312 | } |
|||||||||||
313 | ||||||||||||
314 | function geoip_open($filename, $flags) { |
|||||||||||
315 | $gi = new GeoIP; |
|||||||||||
316 | $gi->flags = $flags; |
|||||||||||
317 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|||||||||||
318 | $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0); |
|||||||||||
319 | } else { |
|||||||||||
320 | $gi->filehandle = fopen($filename,"rb"); |
|||||||||||
321 | if ($gi->flags & GEOIP_MEMORY_CACHE) { |
|||||||||||
322 | $s_array = fstat($gi->filehandle); |
|||||||||||
323 | $gi->memory_buffer = fread($gi->filehandle, $s_array[size]); |
|||||||||||
324 | } |
|||||||||||
325 | } |
|||||||||||
326 | ||||||||||||
327 | $gi = _setup_segments($gi); |
|||||||||||
328 | return $gi; |
|||||||||||
329 | } |
|||||||||||
330 | ||||||||||||
331 | function geoip_close($gi) { |
|||||||||||
332 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|||||||||||
333 | return true; |
|||||||||||
334 | } |
|||||||||||
335 | ||||||||||||
336 | return fclose($gi->filehandle); |
|||||||||||
337 | } |
|||||||||||
338 | ||||||||||||
339 | function geoip_country_id_by_name($gi, $name) { |
|||||||||||
340 | $addr = gethostbyname($name); |
|||||||||||
341 | if (!$addr || $addr == $name) { |
|||||||||||
342 | return false; |
|||||||||||
343 | } |
|||||||||||
344 | return geoip_country_id_by_addr($gi, $addr); |
|||||||||||
345 | } |
|||||||||||
346 | ||||||||||||
347 | function geoip_country_code_by_name($gi, $name) { |
|||||||||||
348 | $country_id = geoip_country_id_by_name($gi,$name); |
|||||||||||
349 | if ($country_id !== false) { |
|||||||||||
350 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
|||||||||||
351 | } |
|||||||||||
352 | return false; |
|||||||||||
353 | } |
|||||||||||
354 | ||||||||||||
355 | function geoip_country_name_by_name($gi, $name) { |
|||||||||||
356 | $country_id = geoip_country_id_by_name($gi,$name); |
|||||||||||
357 | if ($country_id !== false) { |
|||||||||||
358 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
|||||||||||
359 | } |
|||||||||||
360 | return false; |
|||||||||||
361 | } |
|||||||||||
362 | ||||||||||||
363 | function geoip_country_id_by_addr($gi, $addr) { |
|||||||||||
364 | $ipnum = ip2long($addr); |
|||||||||||
365 | return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN; |
|||||||||||
366 | } |
|||||||||||
367 | ||||||||||||
368 | function geoip_country_code_by_addr($gi, $addr) { |
|||||||||||
369 | $country_id = geoip_country_id_by_addr($gi,$addr); |
|||||||||||
370 | if ($country_id !== false) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
371 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
|||||||||||
372 | } |
|||||||||||
373 | return false; |
|||||||||||
374 | } |
|||||||||||
375 | ||||||||||||
376 | function geoip_country_name_by_addr($gi, $addr) { |
|||||||||||
377 | $country_id = geoip_country_id_by_addr($gi,$addr); |
|||||||||||
378 | if ($country_id !== false) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
379 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
|||||||||||
380 | } |
|||||||||||
381 | return false; |
|||||||||||
382 | } |
|||||||||||
383 | ||||||||||||
384 | function _geoip_seek_country($gi, $ipnum) { |
|||||||||||
385 | $offset = 0; |
|||||||||||
386 | for ($depth = 31; $depth >= 0; --$depth) { |
|||||||||||
387 | if ($gi->flags & GEOIP_MEMORY_CACHE) { |
|||||||||||
388 | $buf = substr($gi->memory_buffer, |
|||||||||||
389 | 2 * $gi->record_length * $offset, |
|||||||||||
390 | 2 * $gi->record_length); |
|||||||||||
391 | } elseif ($gi->flags & GEOIP_SHARED_MEMORY) { |
|||||||||||
392 | $buf = @shmop_read ($gi->shmid, |
|||||||||||
393 | 2 * $gi->record_length * $offset, |
|||||||||||
394 | 2 * $gi->record_length ); |
|||||||||||
395 | } else { |
|||||||||||
396 | fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0 |
|||||||||||
397 | or die("fseek failed"); |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
or instead of || is generally not recommended.
PHP has two types of connecting operators (logical operators, and boolean operators):
The difference between these is the order in which they are executed. In most cases,
you would want to use a boolean operator like Let’s take a look at a few examples: // Logical operators have lower precedence:
$f = false or true;
// is executed like this:
($f = false) or true;
// Boolean operators have higher precedence:
$f = false || true;
// is executed like this:
$f = (false || true);
Logical Operators are used for Control-FlowOne case where you explicitly want to use logical operators is for control-flow such as this: $x === 5
or die('$x must be 5.');
// Instead of
if ($x !== 5) {
die('$x must be 5.');
}
Since // The following is currently a parse error.
$x === 5
or throw new RuntimeException('$x must be 5.');
These limitations lead to logical operators rarely being of use in current PHP code. ![]() |
||||||||||||
398 | $buf = fread($gi->filehandle, 2 * $gi->record_length); |
|||||||||||
399 | } |
|||||||||||
400 | $x = array(0,0); |
|||||||||||
401 | for ($i = 0; $i < 2; ++$i) { |
|||||||||||
402 | for ($j = 0; $j < $gi->record_length; ++$j) { |
|||||||||||
403 | $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8); |
|||||||||||
404 | } |
|||||||||||
405 | } |
|||||||||||
406 | if ($ipnum & (1 << $depth)) { |
|||||||||||
407 | if ($x[1] >= $gi->databaseSegments) { |
|||||||||||
408 | return $x[1]; |
|||||||||||
409 | } |
|||||||||||
410 | $offset = $x[1]; |
|||||||||||
411 | } else { |
|||||||||||
412 | if ($x[0] >= $gi->databaseSegments) { |
|||||||||||
413 | return $x[0]; |
|||||||||||
414 | } |
|||||||||||
415 | $offset = $x[0]; |
|||||||||||
416 | } |
|||||||||||
417 | } |
|||||||||||
418 | trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR); |
|||||||||||
419 | return false; |
|||||||||||
420 | } |
|||||||||||
421 | ||||||||||||
422 | function _get_org($gi,$ipnum){ |
|||||||||||
423 | $seek_org = _geoip_seek_country($gi,$ipnum); |
|||||||||||
424 | if ($seek_org == $gi->databaseSegments) { |
|||||||||||
425 | return NULL; |
|||||||||||
426 | } |
|||||||||||
427 | $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; |
|||||||||||
428 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|||||||||||
429 | $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH); |
|||||||||||
430 | } else { |
|||||||||||
431 | fseek($gi->filehandle, $record_pointer, SEEK_SET); |
|||||||||||
432 | $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH); |
|||||||||||
433 | } |
|||||||||||
434 | $org_buf = substr($org_buf, 0, strpos($org_buf, 0)); |
|||||||||||
435 | return $org_buf; |
|||||||||||
436 | } |
|||||||||||
437 | ||||||||||||
438 | function geoip_org_by_addr ($gi,$addr) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
439 | if ($addr == NULL) { |
|||||||||||
440 | return 0; |
|||||||||||
441 | } |
|||||||||||
442 | $ipnum = ip2long($addr); |
|||||||||||
443 | return _get_org($gi, $ipnum); |
|||||||||||
444 | } |
|||||||||||
445 | ||||||||||||
446 | function _get_region($gi,$ipnum){ |
|||||||||||
447 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|||||||||||
448 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; |
|||||||||||
449 | if ($seek_region >= 1000){ |
|||||||||||
450 | $country_code = "US"; |
|||||||||||
451 | $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
|||||||||||
452 | } else { |
|||||||||||
453 | $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region]; |
|||||||||||
454 | $region = ""; |
|||||||||||
455 | } |
|||||||||||
456 | return array ($country_code,$region); |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
457 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|||||||||||
458 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; |
|||||||||||
459 | //print $seek_region; |
|||||||||||
460 | if ($seek_region < US_OFFSET){ |
|||||||||||
461 | $country_code = ""; |
|||||||||||
462 | $region = ""; |
|||||||||||
463 | } else if ($seek_region < CANADA_OFFSET) { |
|||||||||||
464 | $country_code = "US"; |
|||||||||||
465 | $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65); |
|||||||||||
466 | } else if ($seek_region < WORLD_OFFSET) { |
|||||||||||
467 | $country_code = "CA"; |
|||||||||||
468 | $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65); |
|||||||||||
469 | } else { |
|||||||||||
470 | $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE]; |
|||||||||||
471 | $region = ""; |
|||||||||||
472 | } |
|||||||||||
473 | return array ($country_code,$region); |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
474 | } |
|||||||||||
475 | } |
|||||||||||
476 | ||||||||||||
477 | function geoip_region_by_addr ($gi,$addr) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
478 | if ($addr == NULL) { |
|||||||||||
479 | return 0; |
|||||||||||
480 | } |
|||||||||||
481 | $ipnum = ip2long($addr); |
|||||||||||
482 | return _get_region($gi, $ipnum); |
|||||||||||
483 | } |
|||||||||||
484 | ||||||||||||
485 | function getdnsattributes ($l,$ip){ |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
486 | $r = new Net_DNS_Resolver(); |
|||||||||||
0 ignored issues
–
show
The type
Net_DNS_Resolver was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
||||||||||||
487 | $r->nameservers = array("ws1.maxmind.com"); |
|||||||||||
488 | $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |
|||||||||||
489 | $str = is_object($p->answer[0])?$p->answer[0]->string():''; |
|||||||||||
490 | ereg("\"(.*)\"",$str,$regs); |
|||||||||||
491 | $str = $regs[1]; |
|||||||||||
492 | return $str; |
|||||||||||
493 | } |
|||||||||||
494 | ||||||||||||
495 | ?> |
|||||||||||
496 |