abstracts
4 years ago
admin
4 years ago
blocks
5 years ago
cli
4 years ago
customizer
4 years ago
data-stores
4 years ago
emails
4 years ago
export
4 years ago
gateways
4 years ago
import
4 years ago
integrations
5 years ago
interfaces
4 years ago
legacy
5 years ago
libraries
6 years ago
log-handlers
5 years ago
payment-tokens
5 years ago
queue
5 years ago
rest-api
4 years ago
shipping
5 years ago
shortcodes
5 years ago
theme-support
5 years ago
tracks
4 years ago
traits
5 years ago
walkers
5 years ago
wccom-site
5 years ago
widgets
4 years ago
class-wc-ajax.php
4 years ago
class-wc-api.php
5 years ago
class-wc-auth.php
5 years ago
class-wc-autoloader.php
5 years ago
class-wc-background-emailer.php
5 years ago
class-wc-background-updater.php
5 years ago
class-wc-breadcrumb.php
5 years ago
class-wc-cache-helper.php
4 years ago
class-wc-cart-fees.php
5 years ago
class-wc-cart-session.php
5 years ago
class-wc-cart-totals.php
4 years ago
class-wc-cart.php
5 years ago
class-wc-checkout.php
4 years ago
class-wc-cli.php
4 years ago
class-wc-comments.php
5 years ago
class-wc-countries.php
4 years ago
class-wc-coupon.php
5 years ago
class-wc-customer-download-log.php
5 years ago
class-wc-customer-download.php
5 years ago
class-wc-customer.php
4 years ago
class-wc-data-exception.php
8 years ago
class-wc-data-store.php
6 years ago
class-wc-datetime.php
5 years ago
class-wc-deprecated-action-hooks.php
8 years ago
class-wc-deprecated-filter-hooks.php
7 years ago
class-wc-discounts.php
4 years ago
class-wc-download-handler.php
4 years ago
class-wc-emails.php
5 years ago
class-wc-embed.php
5 years ago
class-wc-form-handler.php
5 years ago
class-wc-frontend-scripts.php
4 years ago
class-wc-geo-ip.php
5 years ago
class-wc-geolite-integration.php
6 years ago
class-wc-geolocation.php
4 years ago
class-wc-https.php
5 years ago
class-wc-install.php
4 years ago
class-wc-integrations.php
5 years ago
class-wc-log-levels.php
5 years ago
class-wc-logger.php
5 years ago
class-wc-meta-data.php
7 years ago
class-wc-order-factory.php
5 years ago
class-wc-order-item-coupon.php
5 years ago
class-wc-order-item-fee.php
5 years ago
class-wc-order-item-meta.php
5 years ago
class-wc-order-item-product.php
5 years ago
class-wc-order-item-shipping.php
5 years ago
class-wc-order-item-tax.php
5 years ago
class-wc-order-item.php
5 years ago
class-wc-order-query.php
4 years ago
class-wc-order-refund.php
5 years ago
class-wc-order.php
4 years ago
class-wc-payment-gateways.php
4 years ago
class-wc-payment-tokens.php
5 years ago
class-wc-post-data.php
4 years ago
class-wc-post-types.php
4 years ago
class-wc-privacy-background-process.php
5 years ago
class-wc-privacy-erasers.php
4 years ago
class-wc-privacy-exporters.php
4 years ago
class-wc-privacy.php
4 years ago
class-wc-product-attribute.php
5 years ago
class-wc-product-download.php
4 years ago
class-wc-product-external.php
5 years ago
class-wc-product-factory.php
5 years ago
class-wc-product-grouped.php
8 years ago
class-wc-product-query.php
5 years ago
class-wc-product-simple.php
5 years ago
class-wc-product-variable.php
4 years ago
class-wc-product-variation.php
4 years ago
class-wc-query.php
4 years ago
class-wc-rate-limiter.php
5 years ago
class-wc-regenerate-images-request.php
5 years ago
class-wc-regenerate-images.php
5 years ago
class-wc-register-wp-admin-settings.php
4 years ago
class-wc-rest-authentication.php
5 years ago
class-wc-rest-exception.php
5 years ago
class-wc-session-handler.php
5 years ago
class-wc-shipping-rate.php
5 years ago
class-wc-shipping-zone.php
5 years ago
class-wc-shipping-zones.php
5 years ago
class-wc-shipping.php
5 years ago
class-wc-shortcodes.php
5 years ago
class-wc-structured-data.php
5 years ago
class-wc-tax.php
5 years ago
class-wc-template-loader.php
4 years ago
class-wc-tracker.php
4 years ago
class-wc-validation.php
5 years ago
class-wc-webhook.php
5 years ago
class-woocommerce.php
4 years ago
wc-account-functions.php
5 years ago
wc-attribute-functions.php
5 years ago
wc-cart-functions.php
5 years ago
wc-conditional-functions.php
5 years ago
wc-core-functions.php
4 years ago
wc-coupon-functions.php
5 years ago
wc-deprecated-functions.php
5 years ago
wc-formatting-functions.php
4 years ago
wc-notice-functions.php
5 years ago
wc-order-functions.php
4 years ago
wc-order-item-functions.php
5 years ago
wc-page-functions.php
5 years ago
wc-product-functions.php
4 years ago
wc-rest-functions.php
5 years ago
wc-stock-functions.php
5 years ago
wc-template-functions.php
4 years ago
wc-template-hooks.php
5 years ago
wc-term-functions.php
5 years ago
wc-update-functions.php
4 years ago
wc-user-functions.php
5 years ago
wc-webhook-functions.php
5 years ago
wc-widget-functions.php
5 years ago
class-wc-geo-ip.php
1815 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Geo IP class |
| 4 | * |
| 5 | * This class is a fork of GeoIP class from MaxMind LLC. |
| 6 | * |
| 7 | * @package WooCommerce\Classes |
| 8 | * @version 2.4.0 |
| 9 | * @deprecated 3.4.0 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * WC_Geo_IP Class. |
| 18 | * |
| 19 | * @deprecated 3.4.0 |
| 20 | */ |
| 21 | class WC_Geo_IP { |
| 22 | |
| 23 | const GEOIP_COUNTRY_BEGIN = 16776960; |
| 24 | const GEOIP_STATE_BEGIN_REV0 = 16700000; |
| 25 | const GEOIP_STATE_BEGIN_REV1 = 16000000; |
| 26 | const GEOIP_MEMORY_CACHE = 1; |
| 27 | const GEOIP_SHARED_MEMORY = 2; |
| 28 | const STRUCTURE_INFO_MAX_SIZE = 20; |
| 29 | const GEOIP_COUNTRY_EDITION = 1; |
| 30 | const GEOIP_PROXY_EDITION = 8; |
| 31 | const GEOIP_ASNUM_EDITION = 9; |
| 32 | const GEOIP_NETSPEED_EDITION = 10; |
| 33 | const GEOIP_REGION_EDITION_REV0 = 7; |
| 34 | const GEOIP_REGION_EDITION_REV1 = 3; |
| 35 | const GEOIP_CITY_EDITION_REV0 = 6; |
| 36 | const GEOIP_CITY_EDITION_REV1 = 2; |
| 37 | const GEOIP_ORG_EDITION = 5; |
| 38 | const GEOIP_ISP_EDITION = 4; |
| 39 | const SEGMENT_RECORD_LENGTH = 3; |
| 40 | const STANDARD_RECORD_LENGTH = 3; |
| 41 | const ORG_RECORD_LENGTH = 4; |
| 42 | const GEOIP_SHM_KEY = 0x4f415401; |
| 43 | const GEOIP_DOMAIN_EDITION = 11; |
| 44 | const GEOIP_COUNTRY_EDITION_V6 = 12; |
| 45 | const GEOIP_LOCATIONA_EDITION = 13; |
| 46 | const GEOIP_ACCURACYRADIUS_EDITION = 14; |
| 47 | const GEOIP_CITY_EDITION_REV1_V6 = 30; |
| 48 | const GEOIP_CITY_EDITION_REV0_V6 = 31; |
| 49 | const GEOIP_NETSPEED_EDITION_REV1 = 32; |
| 50 | const GEOIP_NETSPEED_EDITION_REV1_V6 = 33; |
| 51 | const GEOIP_USERTYPE_EDITION = 28; |
| 52 | const GEOIP_USERTYPE_EDITION_V6 = 29; |
| 53 | const GEOIP_ASNUM_EDITION_V6 = 21; |
| 54 | const GEOIP_ISP_EDITION_V6 = 22; |
| 55 | const GEOIP_ORG_EDITION_V6 = 23; |
| 56 | const GEOIP_DOMAIN_EDITION_V6 = 24; |
| 57 | |
| 58 | /** |
| 59 | * Flags. |
| 60 | * |
| 61 | * @var int |
| 62 | */ |
| 63 | public $flags; |
| 64 | |
| 65 | /** |
| 66 | * File handler. |
| 67 | * |
| 68 | * @var resource |
| 69 | */ |
| 70 | public $filehandle; |
| 71 | |
| 72 | /** |
| 73 | * Memory buffer. |
| 74 | * |
| 75 | * @var string |
| 76 | */ |
| 77 | public $memory_buffer; |
| 78 | |
| 79 | /** |
| 80 | * Database type. |
| 81 | * |
| 82 | * @var int |
| 83 | */ |
| 84 | public $databaseType; |
| 85 | |
| 86 | /** |
| 87 | * Database segments. |
| 88 | * |
| 89 | * @var int |
| 90 | */ |
| 91 | public $databaseSegments; |
| 92 | |
| 93 | /** |
| 94 | * Record length. |
| 95 | * |
| 96 | * @var int |
| 97 | */ |
| 98 | public $record_length; |
| 99 | |
| 100 | /** |
| 101 | * Shmid. |
| 102 | * |
| 103 | * @var string |
| 104 | */ |
| 105 | public $shmid; |
| 106 | |
| 107 | /** |
| 108 | * Two letters country codes. |
| 109 | * |
| 110 | * @var array |
| 111 | */ |
| 112 | public $GEOIP_COUNTRY_CODES = array( |
| 113 | '', |
| 114 | 'AP', |
| 115 | 'EU', |
| 116 | 'AD', |
| 117 | 'AE', |
| 118 | 'AF', |
| 119 | 'AG', |
| 120 | 'AI', |
| 121 | 'AL', |
| 122 | 'AM', |
| 123 | 'CW', |
| 124 | 'AO', |
| 125 | 'AQ', |
| 126 | 'AR', |
| 127 | 'AS', |
| 128 | 'AT', |
| 129 | 'AU', |
| 130 | 'AW', |
| 131 | 'AZ', |
| 132 | 'BA', |
| 133 | 'BB', |
| 134 | 'BD', |
| 135 | 'BE', |
| 136 | 'BF', |
| 137 | 'BG', |
| 138 | 'BH', |
| 139 | 'BI', |
| 140 | 'BJ', |
| 141 | 'BM', |
| 142 | 'BN', |
| 143 | 'BO', |
| 144 | 'BR', |
| 145 | 'BS', |
| 146 | 'BT', |
| 147 | 'BV', |
| 148 | 'BW', |
| 149 | 'BY', |
| 150 | 'BZ', |
| 151 | 'CA', |
| 152 | 'CC', |
| 153 | 'CD', |
| 154 | 'CF', |
| 155 | 'CG', |
| 156 | 'CH', |
| 157 | 'CI', |
| 158 | 'CK', |
| 159 | 'CL', |
| 160 | 'CM', |
| 161 | 'CN', |
| 162 | 'CO', |
| 163 | 'CR', |
| 164 | 'CU', |
| 165 | 'CV', |
| 166 | 'CX', |
| 167 | 'CY', |
| 168 | 'CZ', |
| 169 | 'DE', |
| 170 | 'DJ', |
| 171 | 'DK', |
| 172 | 'DM', |
| 173 | 'DO', |
| 174 | 'DZ', |
| 175 | 'EC', |
| 176 | 'EE', |
| 177 | 'EG', |
| 178 | 'EH', |
| 179 | 'ER', |
| 180 | 'ES', |
| 181 | 'ET', |
| 182 | 'FI', |
| 183 | 'FJ', |
| 184 | 'FK', |
| 185 | 'FM', |
| 186 | 'FO', |
| 187 | 'FR', |
| 188 | 'SX', |
| 189 | 'GA', |
| 190 | 'GB', |
| 191 | 'GD', |
| 192 | 'GE', |
| 193 | 'GF', |
| 194 | 'GH', |
| 195 | 'GI', |
| 196 | 'GL', |
| 197 | 'GM', |
| 198 | 'GN', |
| 199 | 'GP', |
| 200 | 'GQ', |
| 201 | 'GR', |
| 202 | 'GS', |
| 203 | 'GT', |
| 204 | 'GU', |
| 205 | 'GW', |
| 206 | 'GY', |
| 207 | 'HK', |
| 208 | 'HM', |
| 209 | 'HN', |
| 210 | 'HR', |
| 211 | 'HT', |
| 212 | 'HU', |
| 213 | 'ID', |
| 214 | 'IE', |
| 215 | 'IL', |
| 216 | 'IN', |
| 217 | 'IO', |
| 218 | 'IQ', |
| 219 | 'IR', |
| 220 | 'IS', |
| 221 | 'IT', |
| 222 | 'JM', |
| 223 | 'JO', |
| 224 | 'JP', |
| 225 | 'KE', |
| 226 | 'KG', |
| 227 | 'KH', |
| 228 | 'KI', |
| 229 | 'KM', |
| 230 | 'KN', |
| 231 | 'KP', |
| 232 | 'KR', |
| 233 | 'KW', |
| 234 | 'KY', |
| 235 | 'KZ', |
| 236 | 'LA', |
| 237 | 'LB', |
| 238 | 'LC', |
| 239 | 'LI', |
| 240 | 'LK', |
| 241 | 'LR', |
| 242 | 'LS', |
| 243 | 'LT', |
| 244 | 'LU', |
| 245 | 'LV', |
| 246 | 'LY', |
| 247 | 'MA', |
| 248 | 'MC', |
| 249 | 'MD', |
| 250 | 'MG', |
| 251 | 'MH', |
| 252 | 'MK', |
| 253 | 'ML', |
| 254 | 'MM', |
| 255 | 'MN', |
| 256 | 'MO', |
| 257 | 'MP', |
| 258 | 'MQ', |
| 259 | 'MR', |
| 260 | 'MS', |
| 261 | 'MT', |
| 262 | 'MU', |
| 263 | 'MV', |
| 264 | 'MW', |
| 265 | 'MX', |
| 266 | 'MY', |
| 267 | 'MZ', |
| 268 | 'NA', |
| 269 | 'NC', |
| 270 | 'NE', |
| 271 | 'NF', |
| 272 | 'NG', |
| 273 | 'NI', |
| 274 | 'NL', |
| 275 | 'NO', |
| 276 | 'NP', |
| 277 | 'NR', |
| 278 | 'NU', |
| 279 | 'NZ', |
| 280 | 'OM', |
| 281 | 'PA', |
| 282 | 'PE', |
| 283 | 'PF', |
| 284 | 'PG', |
| 285 | 'PH', |
| 286 | 'PK', |
| 287 | 'PL', |
| 288 | 'PM', |
| 289 | 'PN', |
| 290 | 'PR', |
| 291 | 'PS', |
| 292 | 'PT', |
| 293 | 'PW', |
| 294 | 'PY', |
| 295 | 'QA', |
| 296 | 'RE', |
| 297 | 'RO', |
| 298 | 'RU', |
| 299 | 'RW', |
| 300 | 'SA', |
| 301 | 'SB', |
| 302 | 'SC', |
| 303 | 'SD', |
| 304 | 'SE', |
| 305 | 'SG', |
| 306 | 'SH', |
| 307 | 'SI', |
| 308 | 'SJ', |
| 309 | 'SK', |
| 310 | 'SL', |
| 311 | 'SM', |
| 312 | 'SN', |
| 313 | 'SO', |
| 314 | 'SR', |
| 315 | 'ST', |
| 316 | 'SV', |
| 317 | 'SY', |
| 318 | 'SZ', |
| 319 | 'TC', |
| 320 | 'TD', |
| 321 | 'TF', |
| 322 | 'TG', |
| 323 | 'TH', |
| 324 | 'TJ', |
| 325 | 'TK', |
| 326 | 'TM', |
| 327 | 'TN', |
| 328 | 'TO', |
| 329 | 'TL', |
| 330 | 'TR', |
| 331 | 'TT', |
| 332 | 'TV', |
| 333 | 'TW', |
| 334 | 'TZ', |
| 335 | 'UA', |
| 336 | 'UG', |
| 337 | 'UM', |
| 338 | 'US', |
| 339 | 'UY', |
| 340 | 'UZ', |
| 341 | 'VA', |
| 342 | 'VC', |
| 343 | 'VE', |
| 344 | 'VG', |
| 345 | 'VI', |
| 346 | 'VN', |
| 347 | 'VU', |
| 348 | 'WF', |
| 349 | 'WS', |
| 350 | 'YE', |
| 351 | 'YT', |
| 352 | 'RS', |
| 353 | 'ZA', |
| 354 | 'ZM', |
| 355 | 'ME', |
| 356 | 'ZW', |
| 357 | 'A1', |
| 358 | 'A2', |
| 359 | 'O1', |
| 360 | 'AX', |
| 361 | 'GG', |
| 362 | 'IM', |
| 363 | 'JE', |
| 364 | 'BL', |
| 365 | 'MF', |
| 366 | 'BQ', |
| 367 | 'SS', |
| 368 | 'O1', |
| 369 | ); |
| 370 | |
| 371 | /** |
| 372 | * 3 letters country codes. |
| 373 | * |
| 374 | * @var array |
| 375 | */ |
| 376 | public $GEOIP_COUNTRY_CODES3 = array( |
| 377 | '', |
| 378 | 'AP', |
| 379 | 'EU', |
| 380 | 'AND', |
| 381 | 'ARE', |
| 382 | 'AFG', |
| 383 | 'ATG', |
| 384 | 'AIA', |
| 385 | 'ALB', |
| 386 | 'ARM', |
| 387 | 'CUW', |
| 388 | 'AGO', |
| 389 | 'ATA', |
| 390 | 'ARG', |
| 391 | 'ASM', |
| 392 | 'AUT', |
| 393 | 'AUS', |
| 394 | 'ABW', |
| 395 | 'AZE', |
| 396 | 'BIH', |
| 397 | 'BRB', |
| 398 | 'BGD', |
| 399 | 'BEL', |
| 400 | 'BFA', |
| 401 | 'BGR', |
| 402 | 'BHR', |
| 403 | 'BDI', |
| 404 | 'BEN', |
| 405 | 'BMU', |
| 406 | 'BRN', |
| 407 | 'BOL', |
| 408 | 'BRA', |
| 409 | 'BHS', |
| 410 | 'BTN', |
| 411 | 'BVT', |
| 412 | 'BWA', |
| 413 | 'BLR', |
| 414 | 'BLZ', |
| 415 | 'CAN', |
| 416 | 'CCK', |
| 417 | 'COD', |
| 418 | 'CAF', |
| 419 | 'COG', |
| 420 | 'CHE', |
| 421 | 'CIV', |
| 422 | 'COK', |
| 423 | 'CHL', |
| 424 | 'CMR', |
| 425 | 'CHN', |
| 426 | 'COL', |
| 427 | 'CRI', |
| 428 | 'CUB', |
| 429 | 'CPV', |
| 430 | 'CXR', |
| 431 | 'CYP', |
| 432 | 'CZE', |
| 433 | 'DEU', |
| 434 | 'DJI', |
| 435 | 'DNK', |
| 436 | 'DMA', |
| 437 | 'DOM', |
| 438 | 'DZA', |
| 439 | 'ECU', |
| 440 | 'EST', |
| 441 | 'EGY', |
| 442 | 'ESH', |
| 443 | 'ERI', |
| 444 | 'ESP', |
| 445 | 'ETH', |
| 446 | 'FIN', |
| 447 | 'FJI', |
| 448 | 'FLK', |
| 449 | 'FSM', |
| 450 | 'FRO', |
| 451 | 'FRA', |
| 452 | 'SXM', |
| 453 | 'GAB', |
| 454 | 'GBR', |
| 455 | 'GRD', |
| 456 | 'GEO', |
| 457 | 'GUF', |
| 458 | 'GHA', |
| 459 | 'GIB', |
| 460 | 'GRL', |
| 461 | 'GMB', |
| 462 | 'GIN', |
| 463 | 'GLP', |
| 464 | 'GNQ', |
| 465 | 'GRC', |
| 466 | 'SGS', |
| 467 | 'GTM', |
| 468 | 'GUM', |
| 469 | 'GNB', |
| 470 | 'GUY', |
| 471 | 'HKG', |
| 472 | 'HMD', |
| 473 | 'HND', |
| 474 | 'HRV', |
| 475 | 'HTI', |
| 476 | 'HUN', |
| 477 | 'IDN', |
| 478 | 'IRL', |
| 479 | 'ISR', |
| 480 | 'IND', |
| 481 | 'IOT', |
| 482 | 'IRQ', |
| 483 | 'IRN', |
| 484 | 'ISL', |
| 485 | 'ITA', |
| 486 | 'JAM', |
| 487 | 'JOR', |
| 488 | 'JPN', |
| 489 | 'KEN', |
| 490 | 'KGZ', |
| 491 | 'KHM', |
| 492 | 'KIR', |
| 493 | 'COM', |
| 494 | 'KNA', |
| 495 | 'PRK', |
| 496 | 'KOR', |
| 497 | 'KWT', |
| 498 | 'CYM', |
| 499 | 'KAZ', |
| 500 | 'LAO', |
| 501 | 'LBN', |
| 502 | 'LCA', |
| 503 | 'LIE', |
| 504 | 'LKA', |
| 505 | 'LBR', |
| 506 | 'LSO', |
| 507 | 'LTU', |
| 508 | 'LUX', |
| 509 | 'LVA', |
| 510 | 'LBY', |
| 511 | 'MAR', |
| 512 | 'MCO', |
| 513 | 'MDA', |
| 514 | 'MDG', |
| 515 | 'MHL', |
| 516 | 'MKD', |
| 517 | 'MLI', |
| 518 | 'MMR', |
| 519 | 'MNG', |
| 520 | 'MAC', |
| 521 | 'MNP', |
| 522 | 'MTQ', |
| 523 | 'MRT', |
| 524 | 'MSR', |
| 525 | 'MLT', |
| 526 | 'MUS', |
| 527 | 'MDV', |
| 528 | 'MWI', |
| 529 | 'MEX', |
| 530 | 'MYS', |
| 531 | 'MOZ', |
| 532 | 'NAM', |
| 533 | 'NCL', |
| 534 | 'NER', |
| 535 | 'NFK', |
| 536 | 'NGA', |
| 537 | 'NIC', |
| 538 | 'NLD', |
| 539 | 'NOR', |
| 540 | 'NPL', |
| 541 | 'NRU', |
| 542 | 'NIU', |
| 543 | 'NZL', |
| 544 | 'OMN', |
| 545 | 'PAN', |
| 546 | 'PER', |
| 547 | 'PYF', |
| 548 | 'PNG', |
| 549 | 'PHL', |
| 550 | 'PAK', |
| 551 | 'POL', |
| 552 | 'SPM', |
| 553 | 'PCN', |
| 554 | 'PRI', |
| 555 | 'PSE', |
| 556 | 'PRT', |
| 557 | 'PLW', |
| 558 | 'PRY', |
| 559 | 'QAT', |
| 560 | 'REU', |
| 561 | 'ROU', |
| 562 | 'RUS', |
| 563 | 'RWA', |
| 564 | 'SAU', |
| 565 | 'SLB', |
| 566 | 'SYC', |
| 567 | 'SDN', |
| 568 | 'SWE', |
| 569 | 'SGP', |
| 570 | 'SHN', |
| 571 | 'SVN', |
| 572 | 'SJM', |
| 573 | 'SVK', |
| 574 | 'SLE', |
| 575 | 'SMR', |
| 576 | 'SEN', |
| 577 | 'SOM', |
| 578 | 'SUR', |
| 579 | 'STP', |
| 580 | 'SLV', |
| 581 | 'SYR', |
| 582 | 'SWZ', |
| 583 | 'TCA', |
| 584 | 'TCD', |
| 585 | 'ATF', |
| 586 | 'TGO', |
| 587 | 'THA', |
| 588 | 'TJK', |
| 589 | 'TKL', |
| 590 | 'TKM', |
| 591 | 'TUN', |
| 592 | 'TON', |
| 593 | 'TLS', |
| 594 | 'TUR', |
| 595 | 'TTO', |
| 596 | 'TUV', |
| 597 | 'TWN', |
| 598 | 'TZA', |
| 599 | 'UKR', |
| 600 | 'UGA', |
| 601 | 'UMI', |
| 602 | 'USA', |
| 603 | 'URY', |
| 604 | 'UZB', |
| 605 | 'VAT', |
| 606 | 'VCT', |
| 607 | 'VEN', |
| 608 | 'VGB', |
| 609 | 'VIR', |
| 610 | 'VNM', |
| 611 | 'VUT', |
| 612 | 'WLF', |
| 613 | 'WSM', |
| 614 | 'YEM', |
| 615 | 'MYT', |
| 616 | 'SRB', |
| 617 | 'ZAF', |
| 618 | 'ZMB', |
| 619 | 'MNE', |
| 620 | 'ZWE', |
| 621 | 'A1', |
| 622 | 'A2', |
| 623 | 'O1', |
| 624 | 'ALA', |
| 625 | 'GGY', |
| 626 | 'IMN', |
| 627 | 'JEY', |
| 628 | 'BLM', |
| 629 | 'MAF', |
| 630 | 'BES', |
| 631 | 'SSD', |
| 632 | 'O1', |
| 633 | ); |
| 634 | |
| 635 | /** |
| 636 | * Contry names. |
| 637 | * |
| 638 | * @var array |
| 639 | */ |
| 640 | public $GEOIP_COUNTRY_NAMES = array( |
| 641 | '', |
| 642 | 'Asia/Pacific Region', |
| 643 | 'Europe', |
| 644 | 'Andorra', |
| 645 | 'United Arab Emirates', |
| 646 | 'Afghanistan', |
| 647 | 'Antigua and Barbuda', |
| 648 | 'Anguilla', |
| 649 | 'Albania', |
| 650 | 'Armenia', |
| 651 | 'Curacao', |
| 652 | 'Angola', |
| 653 | 'Antarctica', |
| 654 | 'Argentina', |
| 655 | 'American Samoa', |
| 656 | 'Austria', |
| 657 | 'Australia', |
| 658 | 'Aruba', |
| 659 | 'Azerbaijan', |
| 660 | 'Bosnia and Herzegovina', |
| 661 | 'Barbados', |
| 662 | 'Bangladesh', |
| 663 | 'Belgium', |
| 664 | 'Burkina Faso', |
| 665 | 'Bulgaria', |
| 666 | 'Bahrain', |
| 667 | 'Burundi', |
| 668 | 'Benin', |
| 669 | 'Bermuda', |
| 670 | 'Brunei Darussalam', |
| 671 | 'Bolivia', |
| 672 | 'Brazil', |
| 673 | 'Bahamas', |
| 674 | 'Bhutan', |
| 675 | 'Bouvet Island', |
| 676 | 'Botswana', |
| 677 | 'Belarus', |
| 678 | 'Belize', |
| 679 | 'Canada', |
| 680 | 'Cocos (Keeling) Islands', |
| 681 | 'Congo, The Democratic Republic of the', |
| 682 | 'Central African Republic', |
| 683 | 'Congo', |
| 684 | 'Switzerland', |
| 685 | "Cote D'Ivoire", |
| 686 | 'Cook Islands', |
| 687 | 'Chile', |
| 688 | 'Cameroon', |
| 689 | 'China', |
| 690 | 'Colombia', |
| 691 | 'Costa Rica', |
| 692 | 'Cuba', |
| 693 | 'Cape Verde', |
| 694 | 'Christmas Island', |
| 695 | 'Cyprus', |
| 696 | 'Czech Republic', |
| 697 | 'Germany', |
| 698 | 'Djibouti', |
| 699 | 'Denmark', |
| 700 | 'Dominica', |
| 701 | 'Dominican Republic', |
| 702 | 'Algeria', |
| 703 | 'Ecuador', |
| 704 | 'Estonia', |
| 705 | 'Egypt', |
| 706 | 'Western Sahara', |
| 707 | 'Eritrea', |
| 708 | 'Spain', |
| 709 | 'Ethiopia', |
| 710 | 'Finland', |
| 711 | 'Fiji', |
| 712 | 'Falkland Islands (Malvinas)', |
| 713 | 'Micronesia, Federated States of', |
| 714 | 'Faroe Islands', |
| 715 | 'France', |
| 716 | 'Sint Maarten (Dutch part)', |
| 717 | 'Gabon', |
| 718 | 'United Kingdom', |
| 719 | 'Grenada', |
| 720 | 'Georgia', |
| 721 | 'French Guiana', |
| 722 | 'Ghana', |
| 723 | 'Gibraltar', |
| 724 | 'Greenland', |
| 725 | 'Gambia', |
| 726 | 'Guinea', |
| 727 | 'Guadeloupe', |
| 728 | 'Equatorial Guinea', |
| 729 | 'Greece', |
| 730 | 'South Georgia and the South Sandwich Islands', |
| 731 | 'Guatemala', |
| 732 | 'Guam', |
| 733 | 'Guinea-Bissau', |
| 734 | 'Guyana', |
| 735 | 'Hong Kong', |
| 736 | 'Heard Island and McDonald Islands', |
| 737 | 'Honduras', |
| 738 | 'Croatia', |
| 739 | 'Haiti', |
| 740 | 'Hungary', |
| 741 | 'Indonesia', |
| 742 | 'Ireland', |
| 743 | 'Israel', |
| 744 | 'India', |
| 745 | 'British Indian Ocean Territory', |
| 746 | 'Iraq', |
| 747 | 'Iran, Islamic Republic of', |
| 748 | 'Iceland', |
| 749 | 'Italy', |
| 750 | 'Jamaica', |
| 751 | 'Jordan', |
| 752 | 'Japan', |
| 753 | 'Kenya', |
| 754 | 'Kyrgyzstan', |
| 755 | 'Cambodia', |
| 756 | 'Kiribati', |
| 757 | 'Comoros', |
| 758 | 'Saint Kitts and Nevis', |
| 759 | "Korea, Democratic People's Republic of", |
| 760 | 'Korea, Republic of', |
| 761 | 'Kuwait', |
| 762 | 'Cayman Islands', |
| 763 | 'Kazakhstan', |
| 764 | "Lao People's Democratic Republic", |
| 765 | 'Lebanon', |
| 766 | 'Saint Lucia', |
| 767 | 'Liechtenstein', |
| 768 | 'Sri Lanka', |
| 769 | 'Liberia', |
| 770 | 'Lesotho', |
| 771 | 'Lithuania', |
| 772 | 'Luxembourg', |
| 773 | 'Latvia', |
| 774 | 'Libya', |
| 775 | 'Morocco', |
| 776 | 'Monaco', |
| 777 | 'Moldova, Republic of', |
| 778 | 'Madagascar', |
| 779 | 'Marshall Islands', |
| 780 | 'Macedonia', |
| 781 | 'Mali', |
| 782 | 'Myanmar', |
| 783 | 'Mongolia', |
| 784 | 'Macau', |
| 785 | 'Northern Mariana Islands', |
| 786 | 'Martinique', |
| 787 | 'Mauritania', |
| 788 | 'Montserrat', |
| 789 | 'Malta', |
| 790 | 'Mauritius', |
| 791 | 'Maldives', |
| 792 | 'Malawi', |
| 793 | 'Mexico', |
| 794 | 'Malaysia', |
| 795 | 'Mozambique', |
| 796 | 'Namibia', |
| 797 | 'New Caledonia', |
| 798 | 'Niger', |
| 799 | 'Norfolk Island', |
| 800 | 'Nigeria', |
| 801 | 'Nicaragua', |
| 802 | 'Netherlands', |
| 803 | 'Norway', |
| 804 | 'Nepal', |
| 805 | 'Nauru', |
| 806 | 'Niue', |
| 807 | 'New Zealand', |
| 808 | 'Oman', |
| 809 | 'Panama', |
| 810 | 'Peru', |
| 811 | 'French Polynesia', |
| 812 | 'Papua New Guinea', |
| 813 | 'Philippines', |
| 814 | 'Pakistan', |
| 815 | 'Poland', |
| 816 | 'Saint Pierre and Miquelon', |
| 817 | 'Pitcairn Islands', |
| 818 | 'Puerto Rico', |
| 819 | 'Palestinian Territory', |
| 820 | 'Portugal', |
| 821 | 'Palau', |
| 822 | 'Paraguay', |
| 823 | 'Qatar', |
| 824 | 'Reunion', |
| 825 | 'Romania', |
| 826 | 'Russian Federation', |
| 827 | 'Rwanda', |
| 828 | 'Saudi Arabia', |
| 829 | 'Solomon Islands', |
| 830 | 'Seychelles', |
| 831 | 'Sudan', |
| 832 | 'Sweden', |
| 833 | 'Singapore', |
| 834 | 'Saint Helena', |
| 835 | 'Slovenia', |
| 836 | 'Svalbard and Jan Mayen', |
| 837 | 'Slovakia', |
| 838 | 'Sierra Leone', |
| 839 | 'San Marino', |
| 840 | 'Senegal', |
| 841 | 'Somalia', |
| 842 | 'Suriname', |
| 843 | 'Sao Tome and Principe', |
| 844 | 'El Salvador', |
| 845 | 'Syrian Arab Republic', |
| 846 | 'Swaziland', |
| 847 | 'Turks and Caicos Islands', |
| 848 | 'Chad', |
| 849 | 'French Southern Territories', |
| 850 | 'Togo', |
| 851 | 'Thailand', |
| 852 | 'Tajikistan', |
| 853 | 'Tokelau', |
| 854 | 'Turkmenistan', |
| 855 | 'Tunisia', |
| 856 | 'Tonga', |
| 857 | 'Timor-Leste', |
| 858 | 'Turkey', |
| 859 | 'Trinidad and Tobago', |
| 860 | 'Tuvalu', |
| 861 | 'Taiwan', |
| 862 | 'Tanzania, United Republic of', |
| 863 | 'Ukraine', |
| 864 | 'Uganda', |
| 865 | 'United States Minor Outlying Islands', |
| 866 | 'United States', |
| 867 | 'Uruguay', |
| 868 | 'Uzbekistan', |
| 869 | 'Holy See (Vatican City State)', |
| 870 | 'Saint Vincent and the Grenadines', |
| 871 | 'Venezuela', |
| 872 | 'Virgin Islands, British', |
| 873 | 'Virgin Islands, U.S.', |
| 874 | 'Vietnam', |
| 875 | 'Vanuatu', |
| 876 | 'Wallis and Futuna', |
| 877 | 'Samoa', |
| 878 | 'Yemen', |
| 879 | 'Mayotte', |
| 880 | 'Serbia', |
| 881 | 'South Africa', |
| 882 | 'Zambia', |
| 883 | 'Montenegro', |
| 884 | 'Zimbabwe', |
| 885 | 'Anonymous Proxy', |
| 886 | 'Satellite Provider', |
| 887 | 'Other', |
| 888 | 'Aland Islands', |
| 889 | 'Guernsey', |
| 890 | 'Isle of Man', |
| 891 | 'Jersey', |
| 892 | 'Saint Barthelemy', |
| 893 | 'Saint Martin', |
| 894 | 'Bonaire, Saint Eustatius and Saba', |
| 895 | 'South Sudan', |
| 896 | 'Other', |
| 897 | ); |
| 898 | |
| 899 | /** |
| 900 | * 2 letters continent codes. |
| 901 | * |
| 902 | * @var array |
| 903 | */ |
| 904 | public $GEOIP_CONTINENT_CODES = array( |
| 905 | '--', |
| 906 | 'AS', |
| 907 | 'EU', |
| 908 | 'EU', |
| 909 | 'AS', |
| 910 | 'AS', |
| 911 | 'NA', |
| 912 | 'NA', |
| 913 | 'EU', |
| 914 | 'AS', |
| 915 | 'NA', |
| 916 | 'AF', |
| 917 | 'AN', |
| 918 | 'SA', |
| 919 | 'OC', |
| 920 | 'EU', |
| 921 | 'OC', |
| 922 | 'NA', |
| 923 | 'AS', |
| 924 | 'EU', |
| 925 | 'NA', |
| 926 | 'AS', |
| 927 | 'EU', |
| 928 | 'AF', |
| 929 | 'EU', |
| 930 | 'AS', |
| 931 | 'AF', |
| 932 | 'AF', |
| 933 | 'NA', |
| 934 | 'AS', |
| 935 | 'SA', |
| 936 | 'SA', |
| 937 | 'NA', |
| 938 | 'AS', |
| 939 | 'AN', |
| 940 | 'AF', |
| 941 | 'EU', |
| 942 | 'NA', |
| 943 | 'NA', |
| 944 | 'AS', |
| 945 | 'AF', |
| 946 | 'AF', |
| 947 | 'AF', |
| 948 | 'EU', |
| 949 | 'AF', |
| 950 | 'OC', |
| 951 | 'SA', |
| 952 | 'AF', |
| 953 | 'AS', |
| 954 | 'SA', |
| 955 | 'NA', |
| 956 | 'NA', |
| 957 | 'AF', |
| 958 | 'AS', |
| 959 | 'AS', |
| 960 | 'EU', |
| 961 | 'EU', |
| 962 | 'AF', |
| 963 | 'EU', |
| 964 | 'NA', |
| 965 | 'NA', |
| 966 | 'AF', |
| 967 | 'SA', |
| 968 | 'EU', |
| 969 | 'AF', |
| 970 | 'AF', |
| 971 | 'AF', |
| 972 | 'EU', |
| 973 | 'AF', |
| 974 | 'EU', |
| 975 | 'OC', |
| 976 | 'SA', |
| 977 | 'OC', |
| 978 | 'EU', |
| 979 | 'EU', |
| 980 | 'NA', |
| 981 | 'AF', |
| 982 | 'EU', |
| 983 | 'NA', |
| 984 | 'AS', |
| 985 | 'SA', |
| 986 | 'AF', |
| 987 | 'EU', |
| 988 | 'NA', |
| 989 | 'AF', |
| 990 | 'AF', |
| 991 | 'NA', |
| 992 | 'AF', |
| 993 | 'EU', |
| 994 | 'AN', |
| 995 | 'NA', |
| 996 | 'OC', |
| 997 | 'AF', |
| 998 | 'SA', |
| 999 | 'AS', |
| 1000 | 'AN', |
| 1001 | 'NA', |
| 1002 | 'EU', |
| 1003 | 'NA', |
| 1004 | 'EU', |
| 1005 | 'AS', |
| 1006 | 'EU', |
| 1007 | 'AS', |
| 1008 | 'AS', |
| 1009 | 'AS', |
| 1010 | 'AS', |
| 1011 | 'AS', |
| 1012 | 'EU', |
| 1013 | 'EU', |
| 1014 | 'NA', |
| 1015 | 'AS', |
| 1016 | 'AS', |
| 1017 | 'AF', |
| 1018 | 'AS', |
| 1019 | 'AS', |
| 1020 | 'OC', |
| 1021 | 'AF', |
| 1022 | 'NA', |
| 1023 | 'AS', |
| 1024 | 'AS', |
| 1025 | 'AS', |
| 1026 | 'NA', |
| 1027 | 'AS', |
| 1028 | 'AS', |
| 1029 | 'AS', |
| 1030 | 'NA', |
| 1031 | 'EU', |
| 1032 | 'AS', |
| 1033 | 'AF', |
| 1034 | 'AF', |
| 1035 | 'EU', |
| 1036 | 'EU', |
| 1037 | 'EU', |
| 1038 | 'AF', |
| 1039 | 'AF', |
| 1040 | 'EU', |
| 1041 | 'EU', |
| 1042 | 'AF', |
| 1043 | 'OC', |
| 1044 | 'EU', |
| 1045 | 'AF', |
| 1046 | 'AS', |
| 1047 | 'AS', |
| 1048 | 'AS', |
| 1049 | 'OC', |
| 1050 | 'NA', |
| 1051 | 'AF', |
| 1052 | 'NA', |
| 1053 | 'EU', |
| 1054 | 'AF', |
| 1055 | 'AS', |
| 1056 | 'AF', |
| 1057 | 'NA', |
| 1058 | 'AS', |
| 1059 | 'AF', |
| 1060 | 'AF', |
| 1061 | 'OC', |
| 1062 | 'AF', |
| 1063 | 'OC', |
| 1064 | 'AF', |
| 1065 | 'NA', |
| 1066 | 'EU', |
| 1067 | 'EU', |
| 1068 | 'AS', |
| 1069 | 'OC', |
| 1070 | 'OC', |
| 1071 | 'OC', |
| 1072 | 'AS', |
| 1073 | 'NA', |
| 1074 | 'SA', |
| 1075 | 'OC', |
| 1076 | 'OC', |
| 1077 | 'AS', |
| 1078 | 'AS', |
| 1079 | 'EU', |
| 1080 | 'NA', |
| 1081 | 'OC', |
| 1082 | 'NA', |
| 1083 | 'AS', |
| 1084 | 'EU', |
| 1085 | 'OC', |
| 1086 | 'SA', |
| 1087 | 'AS', |
| 1088 | 'AF', |
| 1089 | 'EU', |
| 1090 | 'EU', |
| 1091 | 'AF', |
| 1092 | 'AS', |
| 1093 | 'OC', |
| 1094 | 'AF', |
| 1095 | 'AF', |
| 1096 | 'EU', |
| 1097 | 'AS', |
| 1098 | 'AF', |
| 1099 | 'EU', |
| 1100 | 'EU', |
| 1101 | 'EU', |
| 1102 | 'AF', |
| 1103 | 'EU', |
| 1104 | 'AF', |
| 1105 | 'AF', |
| 1106 | 'SA', |
| 1107 | 'AF', |
| 1108 | 'NA', |
| 1109 | 'AS', |
| 1110 | 'AF', |
| 1111 | 'NA', |
| 1112 | 'AF', |
| 1113 | 'AN', |
| 1114 | 'AF', |
| 1115 | 'AS', |
| 1116 | 'AS', |
| 1117 | 'OC', |
| 1118 | 'AS', |
| 1119 | 'AF', |
| 1120 | 'OC', |
| 1121 | 'AS', |
| 1122 | 'EU', |
| 1123 | 'NA', |
| 1124 | 'OC', |
| 1125 | 'AS', |
| 1126 | 'AF', |
| 1127 | 'EU', |
| 1128 | 'AF', |
| 1129 | 'OC', |
| 1130 | 'NA', |
| 1131 | 'SA', |
| 1132 | 'AS', |
| 1133 | 'EU', |
| 1134 | 'NA', |
| 1135 | 'SA', |
| 1136 | 'NA', |
| 1137 | 'NA', |
| 1138 | 'AS', |
| 1139 | 'OC', |
| 1140 | 'OC', |
| 1141 | 'OC', |
| 1142 | 'AS', |
| 1143 | 'AF', |
| 1144 | 'EU', |
| 1145 | 'AF', |
| 1146 | 'AF', |
| 1147 | 'EU', |
| 1148 | 'AF', |
| 1149 | '--', |
| 1150 | '--', |
| 1151 | '--', |
| 1152 | 'EU', |
| 1153 | 'EU', |
| 1154 | 'EU', |
| 1155 | 'EU', |
| 1156 | 'NA', |
| 1157 | 'NA', |
| 1158 | 'NA', |
| 1159 | 'AF', |
| 1160 | '--', |
| 1161 | ); |
| 1162 | |
| 1163 | /** @var WC_Logger Logger instance */ |
| 1164 | public static $log = false; |
| 1165 | |
| 1166 | /** |
| 1167 | * Logging method. |
| 1168 | * |
| 1169 | * @param string $message Log message. |
| 1170 | * @param string $level Optional. Default 'info'. |
| 1171 | * emergency|alert|critical|error|warning|notice|info|debug |
| 1172 | */ |
| 1173 | public static function log( $message, $level = 'info' ) { |
| 1174 | if ( empty( self::$log ) ) { |
| 1175 | self::$log = wc_get_logger(); |
| 1176 | } |
| 1177 | self::$log->log( $level, $message, array( 'source' => 'geoip' ) ); |
| 1178 | } |
| 1179 | |
| 1180 | /** |
| 1181 | * Open geoip file. |
| 1182 | * |
| 1183 | * @param string $filename |
| 1184 | * @param int $flags |
| 1185 | */ |
| 1186 | public function geoip_open( $filename, $flags ) { |
| 1187 | $this->flags = $flags; |
| 1188 | if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1189 | $this->shmid = @shmop_open( self::GEOIP_SHM_KEY, 'a', 0, 0 ); |
| 1190 | } else { |
| 1191 | if ( $this->filehandle = fopen( $filename, 'rb' ) ) { |
| 1192 | if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { |
| 1193 | $s_array = fstat( $this->filehandle ); |
| 1194 | $this->memory_buffer = fread( $this->filehandle, $s_array['size'] ); |
| 1195 | } |
| 1196 | } else { |
| 1197 | $this->log( 'GeoIP API: Can not open ' . $filename, 'error' ); |
| 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | $this->_setup_segments(); |
| 1202 | } |
| 1203 | |
| 1204 | /** |
| 1205 | * Setup segments. |
| 1206 | * |
| 1207 | * @return WC_Geo_IP instance |
| 1208 | */ |
| 1209 | private function _setup_segments() { |
| 1210 | $this->databaseType = self::GEOIP_COUNTRY_EDITION; |
| 1211 | $this->record_length = self::STANDARD_RECORD_LENGTH; |
| 1212 | |
| 1213 | if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1214 | $offset = @shmop_size( $this->shmid ) - 3; |
| 1215 | |
| 1216 | for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) { |
| 1217 | $delim = @shmop_read( $this->shmid, $offset, 3 ); |
| 1218 | $offset += 3; |
| 1219 | |
| 1220 | if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) { |
| 1221 | $this->databaseType = ord( @shmop_read( $this->shmid, $offset, 1 ) ); |
| 1222 | |
| 1223 | if ( $this->databaseType >= 106 ) { |
| 1224 | $this->databaseType -= 105; |
| 1225 | } |
| 1226 | |
| 1227 | $offset++; |
| 1228 | |
| 1229 | if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) { |
| 1230 | $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0; |
| 1231 | } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) { |
| 1232 | $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1; |
| 1233 | } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType ) |
| 1234 | || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) |
| 1235 | || ( self::GEOIP_ORG_EDITION == $this->databaseType ) |
| 1236 | || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) |
| 1237 | || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) |
| 1238 | || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) |
| 1239 | || ( self::GEOIP_ISP_EDITION == $this->databaseType ) |
| 1240 | || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) |
| 1241 | || ( self::GEOIP_USERTYPE_EDITION == $this->databaseType ) |
| 1242 | || ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType ) |
| 1243 | || ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType ) |
| 1244 | || ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType ) |
| 1245 | || ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType ) |
| 1246 | || ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType ) |
| 1247 | || ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType ) |
| 1248 | || ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType ) |
| 1249 | || ( self::GEOIP_ASNUM_EDITION == $this->databaseType ) |
| 1250 | || ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType ) |
| 1251 | ) { |
| 1252 | $this->databaseSegments = 0; |
| 1253 | $buf = @shmop_read( $this->shmid, $offset, self::SEGMENT_RECORD_LENGTH ); |
| 1254 | |
| 1255 | for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) { |
| 1256 | $this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) ); |
| 1257 | } |
| 1258 | |
| 1259 | if ( ( self::GEOIP_ORG_EDITION == $this->databaseType ) |
| 1260 | || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) |
| 1261 | || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) |
| 1262 | || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) |
| 1263 | || ( self::GEOIP_ISP_EDITION == $this->databaseType ) |
| 1264 | || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) |
| 1265 | ) { |
| 1266 | $this->record_length = self::ORG_RECORD_LENGTH; |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | break; |
| 1271 | } else { |
| 1272 | $offset -= 4; |
| 1273 | } |
| 1274 | } |
| 1275 | if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType ) |
| 1276 | || ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType ) |
| 1277 | || ( self::GEOIP_PROXY_EDITION == $this->databaseType ) |
| 1278 | || ( self::GEOIP_NETSPEED_EDITION == $this->databaseType ) |
| 1279 | ) { |
| 1280 | $this->databaseSegments = self::GEOIP_COUNTRY_BEGIN; |
| 1281 | } |
| 1282 | } else { |
| 1283 | $filepos = ftell( $this->filehandle ); |
| 1284 | fseek( $this->filehandle, -3, SEEK_END ); |
| 1285 | |
| 1286 | for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) { |
| 1287 | |
| 1288 | $delim = fread( $this->filehandle, 3 ); |
| 1289 | if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) { |
| 1290 | |
| 1291 | $this->databaseType = ord( fread( $this->filehandle, 1 ) ); |
| 1292 | if ( $this->databaseType >= 106 ) { |
| 1293 | $this->databaseType -= 105; |
| 1294 | } |
| 1295 | |
| 1296 | if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) { |
| 1297 | $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0; |
| 1298 | } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) { |
| 1299 | $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1; |
| 1300 | } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType ) |
| 1301 | || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) |
| 1302 | || ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType ) |
| 1303 | || ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType ) |
| 1304 | || ( self::GEOIP_ORG_EDITION == $this->databaseType ) |
| 1305 | || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) |
| 1306 | || ( self::GEOIP_ISP_EDITION == $this->databaseType ) |
| 1307 | || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) |
| 1308 | || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) |
| 1309 | || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) |
| 1310 | || ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType ) |
| 1311 | || ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType ) |
| 1312 | || ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType ) |
| 1313 | || ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType ) |
| 1314 | || ( self::GEOIP_USERTYPE_EDITION == $this->databaseType ) |
| 1315 | || ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType ) |
| 1316 | || ( self::GEOIP_ASNUM_EDITION == $this->databaseType ) |
| 1317 | || ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType ) |
| 1318 | ) { |
| 1319 | $this->databaseSegments = 0; |
| 1320 | $buf = fread( $this->filehandle, self::SEGMENT_RECORD_LENGTH ); |
| 1321 | |
| 1322 | for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) { |
| 1323 | $this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) ); |
| 1324 | } |
| 1325 | |
| 1326 | if ( ( self::GEOIP_ORG_EDITION == $this->databaseType ) |
| 1327 | || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) |
| 1328 | || ( self::GEOIP_ISP_EDITION == $this->databaseType ) |
| 1329 | || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) |
| 1330 | || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) |
| 1331 | || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) |
| 1332 | ) { |
| 1333 | $this->record_length = self::ORG_RECORD_LENGTH; |
| 1334 | } |
| 1335 | } |
| 1336 | |
| 1337 | break; |
| 1338 | } else { |
| 1339 | fseek( $this->filehandle, -4, SEEK_CUR ); |
| 1340 | } |
| 1341 | } |
| 1342 | |
| 1343 | if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType ) |
| 1344 | || ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType ) |
| 1345 | || ( self::GEOIP_PROXY_EDITION == $this->databaseType ) |
| 1346 | || ( self::GEOIP_NETSPEED_EDITION == $this->databaseType ) |
| 1347 | ) { |
| 1348 | $this->databaseSegments = self::GEOIP_COUNTRY_BEGIN; |
| 1349 | } |
| 1350 | |
| 1351 | fseek( $this->filehandle, $filepos, SEEK_SET ); |
| 1352 | } |
| 1353 | |
| 1354 | return $this; |
| 1355 | } |
| 1356 | |
| 1357 | /** |
| 1358 | * Close geoip file. |
| 1359 | * |
| 1360 | * @return bool |
| 1361 | */ |
| 1362 | public function geoip_close() { |
| 1363 | if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1364 | return true; |
| 1365 | } |
| 1366 | |
| 1367 | return fclose( $this->filehandle ); |
| 1368 | } |
| 1369 | |
| 1370 | /** |
| 1371 | * Common get record. |
| 1372 | * |
| 1373 | * @param string $seek_country |
| 1374 | * @return WC_Geo_IP_Record instance |
| 1375 | */ |
| 1376 | private function _common_get_record( $seek_country ) { |
| 1377 | // workaround php's broken substr, strpos, etc handling with |
| 1378 | // mbstring.func_overload and mbstring.internal_encoding |
| 1379 | $mbExists = extension_loaded( 'mbstring' ); |
| 1380 | if ( $mbExists ) { |
| 1381 | $enc = mb_internal_encoding(); |
| 1382 | mb_internal_encoding( 'ISO-8859-1' ); |
| 1383 | } |
| 1384 | |
| 1385 | $record_pointer = $seek_country + ( 2 * $this->record_length - 1 ) * $this->databaseSegments; |
| 1386 | |
| 1387 | if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { |
| 1388 | $record_buf = substr( $this->memory_buffer, $record_pointer, FULL_RECORD_LENGTH ); |
| 1389 | } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1390 | $record_buf = @shmop_read( $this->shmid, $record_pointer, FULL_RECORD_LENGTH ); |
| 1391 | } else { |
| 1392 | fseek( $this->filehandle, $record_pointer, SEEK_SET ); |
| 1393 | $record_buf = fread( $this->filehandle, FULL_RECORD_LENGTH ); |
| 1394 | } |
| 1395 | |
| 1396 | $record = new WC_Geo_IP_Record(); |
| 1397 | $record_buf_pos = 0; |
| 1398 | $char = ord( substr( $record_buf, $record_buf_pos, 1 ) ); |
| 1399 | $record->country_code = $this->GEOIP_COUNTRY_CODES[ $char ]; |
| 1400 | $record->country_code3 = $this->GEOIP_COUNTRY_CODES3[ $char ]; |
| 1401 | $record->country_name = $this->GEOIP_COUNTRY_NAMES[ $char ]; |
| 1402 | $record->continent_code = $this->GEOIP_CONTINENT_CODES[ $char ]; |
| 1403 | $str_length = 0; |
| 1404 | |
| 1405 | $record_buf_pos++; |
| 1406 | |
| 1407 | // Get region |
| 1408 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1409 | while ( 0 != $char ) { |
| 1410 | $str_length++; |
| 1411 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1412 | } |
| 1413 | |
| 1414 | if ( $str_length > 0 ) { |
| 1415 | $record->region = substr( $record_buf, $record_buf_pos, $str_length ); |
| 1416 | } |
| 1417 | |
| 1418 | $record_buf_pos += $str_length + 1; |
| 1419 | $str_length = 0; |
| 1420 | |
| 1421 | // Get city |
| 1422 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1423 | while ( 0 != $char ) { |
| 1424 | $str_length++; |
| 1425 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1426 | } |
| 1427 | |
| 1428 | if ( $str_length > 0 ) { |
| 1429 | $record->city = substr( $record_buf, $record_buf_pos, $str_length ); |
| 1430 | } |
| 1431 | |
| 1432 | $record_buf_pos += $str_length + 1; |
| 1433 | $str_length = 0; |
| 1434 | |
| 1435 | // Get postal code |
| 1436 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1437 | while ( 0 != $char ) { |
| 1438 | $str_length++; |
| 1439 | $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); |
| 1440 | } |
| 1441 | |
| 1442 | if ( $str_length > 0 ) { |
| 1443 | $record->postal_code = substr( $record_buf, $record_buf_pos, $str_length ); |
| 1444 | } |
| 1445 | |
| 1446 | $record_buf_pos += $str_length + 1; |
| 1447 | |
| 1448 | // Get latitude and longitude |
| 1449 | $latitude = 0; |
| 1450 | $longitude = 0; |
| 1451 | for ( $j = 0; $j < 3; ++$j ) { |
| 1452 | $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); |
| 1453 | $latitude += ( $char << ( $j * 8 ) ); |
| 1454 | } |
| 1455 | |
| 1456 | $record->latitude = ( $latitude / 10000 ) - 180; |
| 1457 | |
| 1458 | for ( $j = 0; $j < 3; ++$j ) { |
| 1459 | $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); |
| 1460 | $longitude += ( $char << ( $j * 8 ) ); |
| 1461 | } |
| 1462 | |
| 1463 | $record->longitude = ( $longitude / 10000 ) - 180; |
| 1464 | |
| 1465 | if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) { |
| 1466 | $metroarea_combo = 0; |
| 1467 | if ( 'US' === $record->country_code ) { |
| 1468 | for ( $j = 0; $j < 3; ++$j ) { |
| 1469 | $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); |
| 1470 | $metroarea_combo += ( $char << ( $j * 8 ) ); |
| 1471 | } |
| 1472 | |
| 1473 | $record->metro_code = $record->dma_code = floor( $metroarea_combo / 1000 ); |
| 1474 | $record->area_code = $metroarea_combo % 1000; |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | if ( $mbExists ) { |
| 1479 | mb_internal_encoding( $enc ); |
| 1480 | } |
| 1481 | |
| 1482 | return $record; |
| 1483 | } |
| 1484 | |
| 1485 | /** |
| 1486 | * Get record. |
| 1487 | * |
| 1488 | * @param int $ipnum |
| 1489 | * @return WC_Geo_IP_Record instance |
| 1490 | */ |
| 1491 | private function _get_record( $ipnum ) { |
| 1492 | $seek_country = $this->_geoip_seek_country( $ipnum ); |
| 1493 | if ( $seek_country == $this->databaseSegments ) { |
| 1494 | return null; |
| 1495 | } |
| 1496 | |
| 1497 | return $this->_common_get_record( $seek_country ); |
| 1498 | } |
| 1499 | |
| 1500 | /** |
| 1501 | * Seek country IPv6. |
| 1502 | * |
| 1503 | * @param int $ipnum |
| 1504 | * @return string |
| 1505 | */ |
| 1506 | public function _geoip_seek_country_v6( $ipnum ) { |
| 1507 | // arrays from unpack start with offset 1 |
| 1508 | // yet another php mystery. array_merge work around |
| 1509 | // this broken behaviour |
| 1510 | $v6vec = array_merge( unpack( 'C16', $ipnum ) ); |
| 1511 | |
| 1512 | $offset = 0; |
| 1513 | for ( $depth = 127; $depth >= 0; --$depth ) { |
| 1514 | if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { |
| 1515 | $buf = $this->_safe_substr( |
| 1516 | $this->memory_buffer, |
| 1517 | 2 * $this->record_length * $offset, |
| 1518 | 2 * $this->record_length |
| 1519 | ); |
| 1520 | } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1521 | $buf = @shmop_read( |
| 1522 | $this->shmid, |
| 1523 | 2 * $this->record_length * $offset, |
| 1524 | 2 * $this->record_length |
| 1525 | ); |
| 1526 | } else { |
| 1527 | if ( 0 != fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) ) { |
| 1528 | break; |
| 1529 | } |
| 1530 | |
| 1531 | $buf = fread( $this->filehandle, 2 * $this->record_length ); |
| 1532 | } |
| 1533 | $x = array( 0, 0 ); |
| 1534 | for ( $i = 0; $i < 2; ++$i ) { |
| 1535 | for ( $j = 0; $j < $this->record_length; ++$j ) { |
| 1536 | $x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 ); |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | $bnum = 127 - $depth; |
| 1541 | $idx = $bnum >> 3; |
| 1542 | $b_mask = 1 << ( $bnum & 7 ^ 7 ); |
| 1543 | if ( ( $v6vec[ $idx ] & $b_mask ) > 0 ) { |
| 1544 | if ( $x[1] >= $this->databaseSegments ) { |
| 1545 | return $x[1]; |
| 1546 | } |
| 1547 | $offset = $x[1]; |
| 1548 | } else { |
| 1549 | if ( $x[0] >= $this->databaseSegments ) { |
| 1550 | return $x[0]; |
| 1551 | } |
| 1552 | $offset = $x[0]; |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | $this->log( 'GeoIP API: Error traversing database - perhaps it is corrupt?', 'error' ); |
| 1557 | |
| 1558 | return false; |
| 1559 | } |
| 1560 | |
| 1561 | /** |
| 1562 | * Seek country. |
| 1563 | * |
| 1564 | * @param int $ipnum |
| 1565 | * @return string |
| 1566 | */ |
| 1567 | private function _geoip_seek_country( $ipnum ) { |
| 1568 | $offset = 0; |
| 1569 | for ( $depth = 31; $depth >= 0; --$depth ) { |
| 1570 | if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { |
| 1571 | $buf = $this->_safe_substr( |
| 1572 | $this->memory_buffer, |
| 1573 | 2 * $this->record_length * $offset, |
| 1574 | 2 * $this->record_length |
| 1575 | ); |
| 1576 | } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { |
| 1577 | $buf = @shmop_read( |
| 1578 | $this->shmid, |
| 1579 | 2 * $this->record_length * $offset, |
| 1580 | 2 * $this->record_length |
| 1581 | ); |
| 1582 | } else { |
| 1583 | if ( 0 != fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) ) { |
| 1584 | break; |
| 1585 | } |
| 1586 | |
| 1587 | $buf = fread( $this->filehandle, 2 * $this->record_length ); |
| 1588 | } |
| 1589 | |
| 1590 | $x = array( 0, 0 ); |
| 1591 | for ( $i = 0; $i < 2; ++$i ) { |
| 1592 | for ( $j = 0; $j < $this->record_length; ++$j ) { |
| 1593 | $x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 ); |
| 1594 | } |
| 1595 | } |
| 1596 | if ( $ipnum & ( 1 << $depth ) ) { |
| 1597 | if ( $x[1] >= $this->databaseSegments ) { |
| 1598 | return $x[1]; |
| 1599 | } |
| 1600 | |
| 1601 | $offset = $x[1]; |
| 1602 | } else { |
| 1603 | if ( $x[0] >= $this->databaseSegments ) { |
| 1604 | return $x[0]; |
| 1605 | } |
| 1606 | |
| 1607 | $offset = $x[0]; |
| 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | $this->log( 'GeoIP API: Error traversing database - perhaps it is corrupt?', 'error' ); |
| 1612 | |
| 1613 | return false; |
| 1614 | } |
| 1615 | |
| 1616 | /** |
| 1617 | * Record by addr. |
| 1618 | * |
| 1619 | * @param string $addr |
| 1620 | * |
| 1621 | * @return WC_Geo_IP_Record |
| 1622 | */ |
| 1623 | public function geoip_record_by_addr( $addr ) { |
| 1624 | if ( null == $addr ) { |
| 1625 | return 0; |
| 1626 | } |
| 1627 | |
| 1628 | $ipnum = ip2long( $addr ); |
| 1629 | return $this->_get_record( $ipnum ); |
| 1630 | } |
| 1631 | |
| 1632 | /** |
| 1633 | * Country ID by addr IPv6. |
| 1634 | * |
| 1635 | * @param string $addr |
| 1636 | * @return int|bool |
| 1637 | */ |
| 1638 | public function geoip_country_id_by_addr_v6( $addr ) { |
| 1639 | if ( ! defined( 'AF_INET6' ) ) { |
| 1640 | $this->log( 'GEOIP (geoip_country_id_by_addr_v6): PHP was compiled with --disable-ipv6 option' ); |
| 1641 | return false; |
| 1642 | } |
| 1643 | $ipnum = inet_pton( $addr ); |
| 1644 | return $this->_geoip_seek_country_v6( $ipnum ) - self::GEOIP_COUNTRY_BEGIN; |
| 1645 | } |
| 1646 | |
| 1647 | /** |
| 1648 | * Country ID by addr. |
| 1649 | * |
| 1650 | * @param string $addr |
| 1651 | * @return int |
| 1652 | */ |
| 1653 | public function geoip_country_id_by_addr( $addr ) { |
| 1654 | $ipnum = ip2long( $addr ); |
| 1655 | return $this->_geoip_seek_country( $ipnum ) - self::GEOIP_COUNTRY_BEGIN; |
| 1656 | } |
| 1657 | |
| 1658 | /** |
| 1659 | * Country code by addr IPv6. |
| 1660 | * |
| 1661 | * @param string $addr |
| 1662 | * @return string |
| 1663 | */ |
| 1664 | public function geoip_country_code_by_addr_v6( $addr ) { |
| 1665 | $country_id = $this->geoip_country_id_by_addr_v6( $addr ); |
| 1666 | if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) { |
| 1667 | return $this->GEOIP_COUNTRY_CODES[ $country_id ]; |
| 1668 | } |
| 1669 | |
| 1670 | return false; |
| 1671 | } |
| 1672 | |
| 1673 | /** |
| 1674 | * Country code by addr. |
| 1675 | * |
| 1676 | * @param string $addr |
| 1677 | * @return string |
| 1678 | */ |
| 1679 | public function geoip_country_code_by_addr( $addr ) { |
| 1680 | if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) { |
| 1681 | $record = $this->geoip_record_by_addr( $addr ); |
| 1682 | if ( false !== $record ) { |
| 1683 | return $record->country_code; |
| 1684 | } |
| 1685 | } else { |
| 1686 | $country_id = $this->geoip_country_id_by_addr( $addr ); |
| 1687 | if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) { |
| 1688 | return $this->GEOIP_COUNTRY_CODES[ $country_id ]; |
| 1689 | } |
| 1690 | } |
| 1691 | |
| 1692 | return false; |
| 1693 | } |
| 1694 | |
| 1695 | /** |
| 1696 | * Encode string. |
| 1697 | * |
| 1698 | * @param string $string |
| 1699 | * @param int $start |
| 1700 | * @param int $length |
| 1701 | * @return string |
| 1702 | */ |
| 1703 | private function _safe_substr( $string, $start, $length ) { |
| 1704 | // workaround php's broken substr, strpos, etc handling with |
| 1705 | // mbstring.func_overload and mbstring.internal_encoding |
| 1706 | $mb_exists = extension_loaded( 'mbstring' ); |
| 1707 | |
| 1708 | if ( $mb_exists ) { |
| 1709 | $enc = mb_internal_encoding(); |
| 1710 | mb_internal_encoding( 'ISO-8859-1' ); |
| 1711 | } |
| 1712 | |
| 1713 | $buf = substr( $string, $start, $length ); |
| 1714 | |
| 1715 | if ( $mb_exists ) { |
| 1716 | mb_internal_encoding( $enc ); |
| 1717 | } |
| 1718 | |
| 1719 | return $buf; |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | /** |
| 1724 | * Geo IP Record class. |
| 1725 | */ |
| 1726 | class WC_Geo_IP_Record { |
| 1727 | |
| 1728 | /** |
| 1729 | * Country code. |
| 1730 | * |
| 1731 | * @var string |
| 1732 | */ |
| 1733 | public $country_code; |
| 1734 | |
| 1735 | /** |
| 1736 | * 3 letters country code. |
| 1737 | * |
| 1738 | * @var string |
| 1739 | */ |
| 1740 | public $country_code3; |
| 1741 | |
| 1742 | /** |
| 1743 | * Country name. |
| 1744 | * |
| 1745 | * @var string |
| 1746 | */ |
| 1747 | public $country_name; |
| 1748 | |
| 1749 | /** |
| 1750 | * Region. |
| 1751 | * |
| 1752 | * @var string |
| 1753 | */ |
| 1754 | public $region; |
| 1755 | |
| 1756 | /** |
| 1757 | * City. |
| 1758 | * |
| 1759 | * @var string |
| 1760 | */ |
| 1761 | public $city; |
| 1762 | |
| 1763 | /** |
| 1764 | * Postal code. |
| 1765 | * |
| 1766 | * @var string |
| 1767 | */ |
| 1768 | public $postal_code; |
| 1769 | |
| 1770 | /** |
| 1771 | * Latitude |
| 1772 | * |
| 1773 | * @var int |
| 1774 | */ |
| 1775 | public $latitude; |
| 1776 | |
| 1777 | /** |
| 1778 | * Longitude. |
| 1779 | * |
| 1780 | * @var int |
| 1781 | */ |
| 1782 | public $longitude; |
| 1783 | |
| 1784 | /** |
| 1785 | * Area code. |
| 1786 | * |
| 1787 | * @var int |
| 1788 | */ |
| 1789 | public $area_code; |
| 1790 | |
| 1791 | /** |
| 1792 | * DMA Code. |
| 1793 | * |
| 1794 | * Metro and DMA code are the same. |
| 1795 | * Use metro code instead. |
| 1796 | * |
| 1797 | * @var float |
| 1798 | */ |
| 1799 | public $dma_code; |
| 1800 | |
| 1801 | /** |
| 1802 | * Metro code. |
| 1803 | * |
| 1804 | * @var float |
| 1805 | */ |
| 1806 | public $metro_code; |
| 1807 | |
| 1808 | /** |
| 1809 | * Continent code. |
| 1810 | * |
| 1811 | * @var string |
| 1812 | */ |
| 1813 | public $continent_code; |
| 1814 | } |
| 1815 |