diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
commit | 19985dbb8c0aa66dc4bf7905abc1148de909097d (patch) | |
tree | 2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /vendor/geoip2 | |
download | 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip |
Diffstat (limited to 'vendor/geoip2')
36 files changed, 2664 insertions, 0 deletions
diff --git a/vendor/geoip2/geoip2/CHANGELOG.md b/vendor/geoip2/geoip2/CHANGELOG.md new file mode 100644 index 0000000..9881b4d --- /dev/null +++ b/vendor/geoip2/geoip2/CHANGELOG.md @@ -0,0 +1,282 @@ +CHANGELOG
+=========
+
+2.10.0 (2019-12-12)
+-------------------
+
+* PHP 5.6 or greater is now required.
+* The `network` property was added to `GeoIp2\Record\Traits`,
+ `GeoIp2\Model\AnonymousIp`, `GeoIp2\Model\Asn`,
+ `GeoIp2\Model\ConnectionType`, `Geoip2\Model\Domain`,
+ and `GeoIp2\Model\Isp`. This is a string in CIDR format representing the
+ largest network where all of the properties besides `ipAddress` have the
+ same value.
+* Updated documentation of anonymizer properties - `isAnonymousVpn`
+ and `isHostingProvider` - to be more descriptive.
+* The `userCount` property was added to `GeoIp2\Record\Traits`. This is an
+ integer which indicates the estimated number of users sharing the
+ IP/network during the past 24 hours. This output is available from GeoIP2
+ Precision Insights.
+* The `staticIpScore` property was added to `GeoIp2\Record\Traits`. This is
+ a float which indicates how static or dynamic an IP address is. This
+ output is available from GeoIP2 Precision Insights.
+
+2.9.0 (2018-04-10)
+------------------
+
+* Refer to account IDs using the terminology "account" rather than "user".
+
+2.8.0 (2018-01-18)
+------------------
+
+* The `isInEuropeanUnion` property was added to `GeoIp2\Record\Country`
+ and `GeoIp2\Record\RepresentedCountry`. This property is `true` if the
+ country is a member state of the European Union.
+
+2.7.0 (2017-10-27)
+------------------
+
+* The following new anonymizer properties were added to `GeoIp2\Record\Traits`
+ for use with GeoIP2 Precision Insights: `isAnonymous`, `isAnonymousVpn`,
+ `isHostingProvider`, `isPublicProxy`, and `isTorExitNode`.
+
+2.6.0 (2017-07-10)
+-----------------
+
+* Code clean-up and tidying.
+* Set minimum required PHP version to 5.4 in `composer.json`. Previously,
+ 5.3 would work but was not tested. Now 5.4 is hard minimum version.
+
+2.5.0 (2017-05-08)
+------------------
+
+* Support for PHP 5.3 was dropped.
+* Added support for GeoLite2 ASN database.
+
+2.4.5 (2017-01-31)
+------------------
+
+* Additional error checking on the data returned from `MaxMind\Db\Reader`
+ was added to help detect corrupt databases. GitHub #83.
+
+2.4.4 (2016-10-11)
+------------------
+
+* `isset()` on `mostSpecificSubdivision` attribute now returns the
+ correct value. Reported by Juan Francisco Giordana. GitHub #81.
+
+2.4.3 (2016-10-11)
+------------------
+
+* `isset()` on `name` attribute now returns the correct value. Reported by
+ Juan Francisco Giordana. GitHub #79.
+
+2.4.2 (2016-08-17)
+------------------
+
+* Updated documentation to clarify what the accuracy radius refers to.
+* Upgraded `maxmind/web-service-common` to 0.3.0. This version uses
+ `composer/ca-bundle` rather than our own CA bundle. GitHub #75.
+* Improved PHP documentation generation.
+
+2.4.1 (2016-06-10)
+------------------
+
+* Corrected type annotations in documentation. GitHub #66.
+* Updated documentation to reflect that the accuracy radius is now included
+ in City.
+* Upgraded web service client, which supports setting a proxy. GitHub #59.
+
+2.4.0 (2016-04-15)
+------------------
+
+* Added support for the GeoIP2 Enterprise database.
+
+2.3.3 (2015-09-24)
+------------------
+
+* Corrected case on `JsonSerializable` interface. Reported by Axel Etcheverry.
+ GitHub #56.
+
+2.3.2 (2015-09-23)
+------------------
+
+* `JsonSerializable` compatibility interface was moved to `GeoIp2\Compat`
+ rather than the global namespace to prevent autoloading issues. Reported by
+ Tomas Buteler. GitHub #54.
+* Missing documentation for the `$postal` property was added to the
+ `GeoIp2\Model\City` class. Fix by Roy Sindre Norangshol. GitHub #51.
+* In the Phar distribution, source files for this module no longer have their
+ documentation stripped, allowing IDE introspection to work properly.
+ Reported by Dominic Black. GitHub #52.
+
+2.3.1 (2015-06-30)
+------------------
+
+* Updated `maxmind/web-service-common` to version with fixes for PHP 5.3 and
+ 5.4.
+
+2.3.0 (2015-06-29)
+------------------
+
+* Support for demographics fields `averageIncome` and `populationDensity` in
+ the `Location` record, returned by the Insights endpoint.
+* The `isAnonymousProxy` and `isSatelliteProvider` properties on
+ `GeoIP2\Record\Traits` have been deprecated. Please use our [GeoIP2
+ Anonymous IP database](https://www.maxmind.com/en/geoip2-anonymous-ip-database)
+ to determine whether an IP address is used by an anonymizing service.
+
+2.2.0-beta1 (2015-06-09)
+------------------------
+
+* Typo fix in documentation.
+
+2.2.0-alpha2 (2015-06-01)
+-------------------------
+
+* `maxmind-ws/web-service-common` was renamed to `maxmind/web-service-common`.
+
+2.2.0-alpha1 (2015-05-22)
+-------------------------
+
+* The library no longer uses Guzzle and instead uses curl directly.
+* Support for `timeout` and `connectTimout` were added to the `$options` array
+ passed to the `GeoIp2\WebService\Client` constructor. Pull request by Will
+ Bradley. GitHub #36.
+
+2.1.1 (2014-12-03)
+------------------
+
+* The 2.1.0 Phar builds included a shebang line, causing issues when loading
+ it as a library. This has been corrected. GitHub #33.
+
+2.1.0 (2014-10-29)
+------------------
+
+* Update ApiGen dependency to version that isn't broken on case sensitive
+ file systems.
+* Added support for the GeoIP2 Anonymous IP database. The
+ `GeoIP2\Database\Reader` class now has an `anonymousIp` method which returns
+ a `GeoIP2\Model\AnonymousIp` object.
+* Boolean attributes like those in the `GeoIP2\Record\Traits` class now return
+ `false` instead of `null` when they were not true.
+
+2.0.0 (2014-09-22)
+------------------
+
+* First production release.
+
+0.9.0 (2014-09-15)
+------------------
+
+* IMPORTANT: The deprecated `omni()` and `cityIspOrg()` methods have been
+ removed from `GeoIp2\WebService\Client`.
+
+0.8.1 (2014-09-12)
+------------------
+
+* The check added to the `GeoIP2\Database\Reader` lookup methods in 0.8.0 did
+ not work with the GeoIP2 City Database Subset by Continent with World
+ Countries. This has been fixed. Fixes GitHub issue #23.
+
+0.8.0 (2014-09-10)
+------------------
+
+* The `GeoIp2\Database\Reader` lookup methods (e.g., `city()`, `isp()`) now
+ throw a `BadMethodCallException` if they are used with a database that
+ does not match the method. In particular, doing a `city()` lookup on a
+ GeoIP2 Country database will result in an exception, and vice versa.
+* A `metadata()` method has been added to the `GeoIP2\Database\Reader` class.
+ This returns a `MaxMind\Db\Reader\Metadata` class with information about the
+ database.
+* The name attribute was missing from the RepresentedCountry class.
+
+0.7.0 (2014-07-22)
+------------------
+
+* The web service client API has been updated for the v2.1 release of the web
+ service. In particular, the `cityIspOrg` and `omni` methods on
+ `GeoIp2\WebService\Client` should be considered deprecated. The `city`
+ method now provides all of the data formerly provided by `cityIspOrg`, and
+ the `omni` method has been replaced by the `insights` method.
+* Support was added for GeoIP2 Connection Type, Domain and ISP databases.
+
+
+0.6.3 (2014-05-12)
+------------------
+
+* With the previous Phar builds, some users received `phar error: invalid url
+ or non-existent phar` errors. The correct alias is now used for the Phar,
+ and this should no longer be an issue.
+
+0.6.2 (2014-05-08)
+------------------
+
+* The Phar build was broken with Guzzle 3.9.0+. This has been fixed.
+
+0.6.1 (2014-05-01)
+------------------
+
+* This API now officially supports HHVM.
+* The `maxmind-db/reader` dependency was updated to a version that does not
+ require BC Math.
+* The Composer compatibility autoload rules are now targeted more narrowly.
+* A `box.json` file is included to build a Phar package.
+
+0.6.0 (2014-02-19)
+------------------
+
+* This API is now licensed under the Apache License, Version 2.0.
+* Model and record classes now implement `JsonSerializable`.
+* `isset` now works with model and record classes.
+
+0.5.0 (2013-10-21)
+------------------
+
+* Renamed $languages constructor parameters to $locales for both the Client
+ and Reader classes.
+* Documentation and code clean-up (Ben Morel).
+* Added the interface `GeoIp2\ProviderInterface`, which is implemented by both
+ `\GeoIp2\Database\Reader` and `\GeoIp2\WebService\Client`.
+
+0.4.0 (2013-07-16)
+------------------
+
+* This is the first release with the GeoIP2 database reader. Please see the
+ `README.md` file and the `\GeoIp2\Database\Reader` class.
+* The general exception classes were replaced with specific exception classes
+ representing particular types of errors, such as an authentication error.
+
+0.3.0 (2013-07-12)
+------------------
+
+* In namespaces and class names, "GeoIP2" was renamed to "GeoIp2" to improve
+ consistency.
+
+0.2.1 (2013-06-10)
+------------------
+
+* First official beta release.
+* Documentation updates and corrections.
+
+0.2.0 (2013-05-29)
+------------------
+
+* `GenericException` was renamed to `GeoIP2Exception`.
+* We now support more languages. The new languages are de, es, fr, and pt-BR.
+* The REST API now returns a record with data about your account. There is
+ a new `GeoIP\Records\MaxMind` class for this data.
+* The `continentCode` attribute on `Continent` was renamed to `code`.
+* Documentation updates.
+
+0.1.1 (2013-05-14)
+------------------
+
+* Updated Guzzle version requirement.
+* Fixed Composer example in README.md.
+
+
+0.1.0 (2013-05-13)
+------------------
+
+* Initial release.
diff --git a/vendor/geoip2/geoip2/LICENSE b/vendor/geoip2/geoip2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/vendor/geoip2/geoip2/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/geoip2/geoip2/README.md b/vendor/geoip2/geoip2/README.md new file mode 100644 index 0000000..e4a74dc --- /dev/null +++ b/vendor/geoip2/geoip2/README.md @@ -0,0 +1,409 @@ +# GeoIP2 PHP API # + +## Description ## + +This package provides an API for the GeoIP2 +[web services](https://dev.maxmind.com/geoip/geoip2/web-services) and +[databases](https://dev.maxmind.com/geoip/geoip2/downloadable). The API also +works with the free +[GeoLite2 databases](https://dev.maxmind.com/geoip/geoip2/geolite2/). + +## Install via Composer ## + +We recommend installing this package with [Composer](https://getcomposer.org/). + +### Download Composer ### + +To download Composer, run in the root directory of your project: + +```bash +curl -sS https://getcomposer.org/installer | php +``` + +You should now have the file `composer.phar` in your project directory. + +### Install Dependencies ### + +Run in your project root: + +``` +php composer.phar require geoip2/geoip2:~2.0 +``` + +You should now have the files `composer.json` and `composer.lock` as well as +the directory `vendor` in your project directory. If you use a version control +system, `composer.json` should be added to it. + +### Require Autoloader ### + +After installing the dependencies, you need to require the Composer autoloader +from your code: + +```php +require 'vendor/autoload.php'; +``` + +## Install via Phar ## + +Although we strongly recommend using Composer, we also provide a +[phar archive](https://php.net/manual/en/book.phar.php) containing most of the +dependencies for GeoIP2. Our latest phar archive is available on +[our releases page](https://github.com/maxmind/GeoIP2-php/releases). + +### Install Dependencies ### + +In order to use the phar archive, you must have the PHP +[Phar extension](https://php.net/manual/en/book.phar.php) installed and +enabled. + +If you will be making web service requests, you must have the PHP +[cURL extension](https://php.net/manual/en/book.curl.php) +installed to use this archive. For Debian based distributions, this can +typically be found in the the `php-curl` package. For other operating +systems, please consult the relevant documentation. After installing the +extension you may need to restart your web server. + +If you are missing this extension, you will see errors like the following: + +``` +PHP Fatal error: Uncaught Error: Call to undefined function MaxMind\WebService\curl_version() +``` + +### Require Package ### + +To use the archive, just require it from your script: + +```php +require 'geoip2.phar'; +``` + +## Optional C Extension ## + +The [MaxMind DB API](https://github.com/maxmind/MaxMind-DB-Reader-php) +includes an optional C extension that you may install to dramatically increase +the performance of lookups in GeoIP2 or GeoLite2 databases. To install, please +follow the instructions included with that API. + +The extension has no effect on web-service lookups. + +## IP Geolocation Usage ## + +IP geolocation is inherently imprecise. Locations are often near the center of +the population. Any location provided by a GeoIP2 database or web service +should not be used to identify a particular address or household. + +## Database Reader ## + +### Usage ### + +To use this API, you must create a new `\GeoIp2\Database\Reader` object with +the path to the database file as the first argument to the constructor. You +may then call the method corresponding to the database you are using. + +If the lookup succeeds, the method call will return a model class for the +record in the database. This model in turn contains multiple container +classes for the different parts of the data such as the city in which the +IP address is located. + +If the record is not found, a `\GeoIp2\Exception\AddressNotFoundException` +is thrown. If the database is invalid or corrupt, a +`\MaxMind\Db\InvalidDatabaseException` will be thrown. + +See the API documentation for more details. + +### City Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-City.mmdb'); + +// Replace "city" with the appropriate method for your database, e.g., +// "country". +$record = $reader->city('128.101.101.101'); + +print($record->country->isoCode . "\n"); // 'US' +print($record->country->name . "\n"); // 'United States' +print($record->country->names['zh-CN'] . "\n"); // '美国' + +print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' +print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' + +print($record->city->name . "\n"); // 'Minneapolis' + +print($record->postal->code . "\n"); // '55455' + +print($record->location->latitude . "\n"); // 44.9733 +print($record->location->longitude . "\n"); // -93.2323 + +print($record->traits->network . "\n"); // '128.101.101.101/32' + +``` + +### Anonymous IP Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Anonymous-IP.mmdb'); + +$record = $reader->anonymousIp('128.101.101.101'); + +if ($record->isAnonymous) { print "anon\n"; } +print($record->ipAddress . "\n"); // '128.101.101.101' +print($record->network . "\n"); // '128.101.101.101/32' + +``` + +### Connection-Type Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Connection-Type.mmdb'); + +$record = $reader->connectionType('128.101.101.101'); + +print($record->connectionType . "\n"); // 'Corporate' +print($record->ipAddress . "\n"); // '128.101.101.101' +print($record->network . "\n"); // '128.101.101.101/32' + +``` + +### Domain Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Domain.mmdb'); + +$record = $reader->domain('128.101.101.101'); + +print($record->domain . "\n"); // 'umn.edu' +print($record->ipAddress . "\n"); // '128.101.101.101' +print($record->network . "\n"); // '128.101.101.101/32' + +``` + +### Enterprise Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Enterprise.mmdb'); + +// Use the ->enterprise method to do a lookup in the Enterprise database +$record = $reader->enterprise('128.101.101.101'); + +print($record->country->confidence . "\n"); // 99 +print($record->country->isoCode . "\n"); // 'US' +print($record->country->name . "\n"); // 'United States' +print($record->country->names['zh-CN'] . "\n"); // '美国' + +print($record->mostSpecificSubdivision->confidence . "\n"); // 77 +print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' +print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' + +print($record->city->confidence . "\n"); // 60 +print($record->city->name . "\n"); // 'Minneapolis' + +print($record->postal->code . "\n"); // '55455' + +print($record->location->accuracyRadius . "\n"); // 50 +print($record->location->latitude . "\n"); // 44.9733 +print($record->location->longitude . "\n"); // -93.2323 + +print($record->traits->network . "\n"); // '128.101.101.101/32' + +``` + +### ISP Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\Database\Reader; + +// This creates the Reader object, which should be reused across +// lookups. +$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-ISP.mmdb'); + +$record = $reader->isp('128.101.101.101'); + +print($record->autonomousSystemNumber . "\n"); // 217 +print($record->autonomousSystemOrganization . "\n"); // 'University of Minnesota' +print($record->isp . "\n"); // 'University of Minnesota' +print($record->organization . "\n"); // 'University of Minnesota' + +print($record->ipAddress . "\n"); // '128.101.101.101' +print($record->network . "\n"); // '128.101.101.101/32' + +``` + +## Web Service Client ## + +### Usage ### + +To use this API, you must create a new `\GeoIp2\WebService\Client` +object with your `$accountId` and `$licenseKey`, then you call the method +corresponding to a specific end point, passing it the IP address you want to +look up. + +If the request succeeds, the method call will return a model class for the end +point you called. This model in turn contains multiple record classes, each of +which represents part of the data returned by the web service. + +If there is an error, a structured exception is thrown. + +See the API documentation for more details. + +### Example ### + +```php +<?php +require_once 'vendor/autoload.php'; +use GeoIp2\WebService\Client; + +// This creates a Client object that can be reused across requests. +// Replace "42" with your account ID and "license_key" with your license +// key. +$client = new Client(42, 'abcdef123456'); + +// Replace "city" with the method corresponding to the web service that +// you are using, e.g., "country", "insights". +$record = $client->city('128.101.101.101'); + +print($record->country->isoCode . "\n"); // 'US' +print($record->country->name . "\n"); // 'United States' +print($record->country->names['zh-CN'] . "\n"); // '美国' + +print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' +print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' + +print($record->city->name . "\n"); // 'Minneapolis' + +print($record->postal->code . "\n"); // '55455' + +print($record->location->latitude . "\n"); // 44.9733 +print($record->location->longitude . "\n"); // -93.2323 + +print($record->traits->network . "\n"); // '128.101.101.101/32' + +``` + +## Values to use for Database or Array Keys ## + +**We strongly discourage you from using a value from any `names` property as +a key in a database or array.** + +These names may change between releases. Instead we recommend using one of the +following: + +* `GeoIp2\Record\City` - `$city->geonameId` +* `GeoIp2\Record\Continent` - `$continent->code` or `$continent->geonameId` +* `GeoIp2\Record\Country` and `GeoIp2\Record\RepresentedCountry` - + `$country->isoCode` or `$country->geonameId` +* `GeoIp2\Record\Subdivision` - `$subdivision->isoCode` or `$subdivision->geonameId` + +### What data is returned? ### + +While many of the end points return the same basic records, the attributes +which can be populated vary between end points. In addition, while an end +point may offer a particular piece of data, MaxMind does not always have every +piece of data for any given IP address. + +Because of these factors, it is possible for any end point to return a record +where some or all of the attributes are unpopulated. + +See the +[GeoIP2 Precision web service docs](https://dev.maxmind.com/geoip/geoip2/web-services) +for details on what data each end point may return. + +The only piece of data which is always returned is the `ipAddress` +attribute in the `GeoIp2\Record\Traits` record. + +## Integration with GeoNames ## + +[GeoNames](https://www.geonames.org/) offers web services and downloadable +databases with data on geographical features around the world, including +populated places. They offer both free and paid premium data. Each +feature is unique identified by a `geonameId`, which is an integer. + +Many of the records returned by the GeoIP2 web services and databases +include a `geonameId` property. This is the ID of a geographical feature +(city, region, country, etc.) in the GeoNames database. + +Some of the data that MaxMind provides is also sourced from GeoNames. We +source things like place names, ISO codes, and other similar data from +the GeoNames premium data set. + +## Reporting data problems ## + +If the problem you find is that an IP address is incorrectly mapped, +please +[submit your correction to MaxMind](https://www.maxmind.com/en/correction). + +If you find some other sort of mistake, like an incorrect spelling, +please check the [GeoNames site](https://www.geonames.org/) first. Once +you've searched for a place and found it on the GeoNames map view, there +are a number of links you can use to correct data ("move", "edit", +"alternate names", etc.). Once the correction is part of the GeoNames +data set, it will be automatically incorporated into future MaxMind +releases. + +If you are a paying MaxMind customer and you're not sure where to submit +a correction, please +[contact MaxMind support](https://www.maxmind.com/en/support) for help. + +## Other Support ## + +Please report all issues with this code using the +[GitHub issue tracker](https://github.com/maxmind/GeoIP2-php/issues). + +If you are having an issue with a MaxMind service that is not specific +to the client API, please see +[our support page](https://www.maxmind.com/en/support). + +## Requirements ## + +This library requires PHP 5.6 or greater. + +This library also relies on the [MaxMind DB Reader](https://github.com/maxmind/MaxMind-DB-Reader-php). + +## Contributing ## + +Patches and pull requests are encouraged. All code should follow the PSR-2 +style guidelines. Please include unit tests whenever possible. You may obtain +the test data for the maxmind-db folder by running `git submodule update +--init --recursive` or adding `--recursive` to your initial clone, or from +https://github.com/maxmind/MaxMind-DB + +## Versioning ## + +The GeoIP2 PHP API uses [Semantic Versioning](https://semver.org/). + +## Copyright and License ## + +This software is Copyright (c) 2013-2019 by MaxMind, Inc. + +This is free software, licensed under the Apache License, Version 2.0. diff --git a/vendor/geoip2/geoip2/composer.json b/vendor/geoip2/geoip2/composer.json new file mode 100644 index 0000000..94669ff --- /dev/null +++ b/vendor/geoip2/geoip2/composer.json @@ -0,0 +1,31 @@ +{
+ "name": "geoip2/geoip2",
+ "description": "MaxMind GeoIP2 PHP API",
+ "keywords": ["geoip", "geoip2", "geolocation", "ip", "maxmind"],
+ "homepage": "https://github.com/maxmind/GeoIP2-php",
+ "type": "library",
+ "license": "Apache-2.0",
+ "authors": [
+ {
+ "name": "Gregory J. Oschwald",
+ "email": "goschwald@maxmind.com",
+ "homepage": "https://www.maxmind.com/"
+ }
+ ],
+ "require": {
+ "maxmind-db/reader": "~1.5",
+ "maxmind/web-service-common": "~0.6",
+ "php": ">=5.6",
+ "ext-json": "*"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "2.*",
+ "phpunit/phpunit": "5.*",
+ "squizlabs/php_codesniffer": "3.*"
+ },
+ "autoload": {
+ "psr-4": {
+ "GeoIp2\\": "src"
+ }
+ }
+}
diff --git a/vendor/geoip2/geoip2/examples/benchmark.php b/vendor/geoip2/geoip2/examples/benchmark.php new file mode 100644 index 0000000..7af2a5d --- /dev/null +++ b/vendor/geoip2/geoip2/examples/benchmark.php @@ -0,0 +1,25 @@ +<?php + +require __DIR__ . '/../vendor/autoload.php'; + +use GeoIp2\Database\Reader; + +srand(0); + +$reader = new Reader('GeoIP2-City.mmdb'); +$count = 500000; +$startTime = microtime(true); +for ($i = 0; $i < $count; ++$i) { + $ip = long2ip(rand(0, pow(2, 32) - 1)); + try { + $t = $reader->city($ip); + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { + } + if ($i % 10000 === 0) { + echo $i . ' ' . $ip . "\n"; + } +} +$endTime = microtime(true); + +$duration = $endTime - $startTime; +echo 'Requests per second: ' . $count / $duration . "\n"; diff --git a/vendor/geoip2/geoip2/src/Database/Reader.php b/vendor/geoip2/geoip2/src/Database/Reader.php new file mode 100644 index 0000000..9c33e3d --- /dev/null +++ b/vendor/geoip2/geoip2/src/Database/Reader.php @@ -0,0 +1,287 @@ +<?php
+
+namespace GeoIp2\Database;
+
+use GeoIp2\Exception\AddressNotFoundException;
+use GeoIp2\ProviderInterface;
+use MaxMind\Db\Reader as DbReader;
+use MaxMind\Db\Reader\InvalidDatabaseException;
+
+/**
+ * Instances of this class provide a reader for the GeoIP2 database format.
+ * IP addresses can be looked up using the database specific methods.
+ *
+ * ## Usage ##
+ *
+ * The basic API for this class is the same for every database. First, you
+ * create a reader object, specifying a file name. You then call the method
+ * corresponding to the specific database, passing it the IP address you want
+ * to look up.
+ *
+ * If the request succeeds, the method call will return a model class for
+ * the method you called. This model in turn contains multiple record classes,
+ * each of which represents part of the data returned by the database. If
+ * the database does not contain the requested information, the attributes
+ * on the record class will have a `null` value.
+ *
+ * If the address is not in the database, an
+ * {@link \GeoIp2\Exception\AddressNotFoundException} exception will be
+ * thrown. If an invalid IP address is passed to one of the methods, a
+ * SPL {@link \InvalidArgumentException} will be thrown. If the database is
+ * corrupt or invalid, a {@link \MaxMind\Db\Reader\InvalidDatabaseException}
+ * will be thrown.
+ */
+class Reader implements ProviderInterface
+{
+ private $dbReader;
+ private $dbType;
+ private $locales;
+
+ /**
+ * Constructor.
+ *
+ * @param string $filename the path to the GeoIP2 database file
+ * @param array $locales list of locale codes to use in name property
+ * from most preferred to least preferred
+ *
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ */
+ public function __construct(
+ $filename,
+ $locales = ['en']
+ ) {
+ $this->dbReader = new DbReader($filename);
+ $this->dbType = $this->dbReader->metadata()->databaseType;
+ $this->locales = $locales;
+ }
+
+ /**
+ * This method returns a GeoIP2 City model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\City
+ */
+ public function city($ipAddress)
+ {
+ return $this->modelFor('City', 'City', $ipAddress);
+ }
+
+ /**
+ * This method returns a GeoIP2 Country model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\Country
+ */
+ public function country($ipAddress)
+ {
+ return $this->modelFor('Country', 'Country', $ipAddress);
+ }
+
+ /**
+ * This method returns a GeoIP2 Anonymous IP model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\AnonymousIp
+ */
+ public function anonymousIp($ipAddress)
+ {
+ return $this->flatModelFor(
+ 'AnonymousIp',
+ 'GeoIP2-Anonymous-IP',
+ $ipAddress
+ );
+ }
+
+ /**
+ * This method returns a GeoLite2 ASN model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\Asn
+ */
+ public function asn($ipAddress)
+ {
+ return $this->flatModelFor(
+ 'Asn',
+ 'GeoLite2-ASN',
+ $ipAddress
+ );
+ }
+
+ /**
+ * This method returns a GeoIP2 Connection Type model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\ConnectionType
+ */
+ public function connectionType($ipAddress)
+ {
+ return $this->flatModelFor(
+ 'ConnectionType',
+ 'GeoIP2-Connection-Type',
+ $ipAddress
+ );
+ }
+
+ /**
+ * This method returns a GeoIP2 Domain model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\Domain
+ */
+ public function domain($ipAddress)
+ {
+ return $this->flatModelFor(
+ 'Domain',
+ 'GeoIP2-Domain',
+ $ipAddress
+ );
+ }
+
+ /**
+ * This method returns a GeoIP2 Enterprise model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\Enterprise
+ */
+ public function enterprise($ipAddress)
+ {
+ return $this->modelFor('Enterprise', 'Enterprise', $ipAddress);
+ }
+
+ /**
+ * This method returns a GeoIP2 ISP model.
+ *
+ * @param string $ipAddress an IPv4 or IPv6 address as a string
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address is
+ * not in the database
+ * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
+ * is corrupt or invalid
+ *
+ * @return \GeoIp2\Model\Isp
+ */
+ public function isp($ipAddress)
+ {
+ return $this->flatModelFor(
+ 'Isp',
+ 'GeoIP2-ISP',
+ $ipAddress
+ );
+ }
+
+ private function modelFor($class, $type, $ipAddress)
+ {
+ list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+
+ $record['traits']['ip_address'] = $ipAddress;
+ $record['traits']['prefix_len'] = $prefixLen;
+
+ $class = 'GeoIp2\\Model\\' . $class;
+
+ return new $class($record, $this->locales);
+ }
+
+ private function flatModelFor($class, $type, $ipAddress)
+ {
+ list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+
+ $record['ip_address'] = $ipAddress;
+ $record['prefix_len'] = $prefixLen;
+ $class = 'GeoIp2\\Model\\' . $class;
+
+ return new $class($record);
+ }
+
+ private function getRecord($class, $type, $ipAddress)
+ {
+ if (strpos($this->dbType, $type) === false) {
+ $method = lcfirst($class);
+ throw new \BadMethodCallException(
+ "The $method method cannot be used to open a {$this->dbType} database"
+ );
+ }
+ list($record, $prefixLen) = $this->dbReader->getWithPrefixLen($ipAddress);
+ if ($record === null) {
+ throw new AddressNotFoundException(
+ "The address $ipAddress is not in the database."
+ );
+ }
+ if (!\is_array($record)) {
+ // This can happen on corrupt databases. Generally,
+ // MaxMind\Db\Reader will throw a
+ // MaxMind\Db\Reader\InvalidDatabaseException, but occasionally
+ // the lookup may result in a record that looks valid but is not
+ // an array. This mostly happens when the user is ignoring all
+ // exceptions and the more frequent InvalidDatabaseException
+ // exceptions go unnoticed.
+ throw new InvalidDatabaseException(
+ "Expected an array when looking up $ipAddress but received: "
+ . \gettype($record)
+ );
+ }
+
+ return [$record, $prefixLen];
+ }
+
+ /**
+ * @throws \InvalidArgumentException if arguments are passed to the method
+ * @throws \BadMethodCallException if the database has been closed
+ *
+ * @return \MaxMind\Db\Reader\Metadata object for the database
+ */
+ public function metadata()
+ {
+ return $this->dbReader->metadata();
+ }
+
+ /**
+ * Closes the GeoIP2 database and returns the resources to the system.
+ */
+ public function close()
+ {
+ $this->dbReader->close();
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php new file mode 100644 index 0000000..4e60c28 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php @@ -0,0 +1,10 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents a generic error.
+ */
+class AddressNotFoundException extends GeoIp2Exception
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php new file mode 100644 index 0000000..5f5725f --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php @@ -0,0 +1,10 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents a generic error.
+ */
+class AuthenticationException extends GeoIp2Exception
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php new file mode 100644 index 0000000..b15e5f4 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php @@ -0,0 +1,10 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents a generic error.
+ */
+class GeoIp2Exception extends \Exception
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/HttpException.php b/vendor/geoip2/geoip2/src/Exception/HttpException.php new file mode 100644 index 0000000..c9fc8b8 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/HttpException.php @@ -0,0 +1,24 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents an HTTP transport error.
+ */
+class HttpException extends GeoIp2Exception
+{
+ /**
+ * The URI queried.
+ */
+ public $uri;
+
+ public function __construct(
+ $message,
+ $httpStatus,
+ $uri,
+ \Exception $previous = null
+ ) {
+ $this->uri = $uri;
+ parent::__construct($message, $httpStatus, $previous);
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php new file mode 100644 index 0000000..63b6e42 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php @@ -0,0 +1,26 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents an error returned by MaxMind's GeoIP2
+ * web service.
+ */
+class InvalidRequestException extends HttpException
+{
+ /**
+ * The code returned by the MaxMind web service.
+ */
+ public $error;
+
+ public function __construct(
+ $message,
+ $error,
+ $httpStatus,
+ $uri,
+ \Exception $previous = null
+ ) {
+ $this->error = $error;
+ parent::__construct($message, $httpStatus, $uri, $previous);
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php new file mode 100644 index 0000000..16dc7b8 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php @@ -0,0 +1,10 @@ +<?php
+
+namespace GeoIp2\Exception;
+
+/**
+ * This class represents a generic error.
+ */
+class OutOfQueriesException extends GeoIp2Exception
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Model/AbstractModel.php b/vendor/geoip2/geoip2/src/Model/AbstractModel.php new file mode 100644 index 0000000..50f24b0 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/AbstractModel.php @@ -0,0 +1,67 @@ +<?php
+
+namespace GeoIp2\Model;
+
+/**
+ * @ignore
+ */
+abstract class AbstractModel implements \JsonSerializable
+{
+ protected $raw;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ $this->raw = $raw;
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $field
+ */
+ protected function get($field)
+ {
+ if (isset($this->raw[$field])) {
+ return $this->raw[$field];
+ }
+ if (preg_match('/^is_/', $field)) {
+ return false;
+ }
+
+ return null;
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __get($attr)
+ {
+ if ($attr !== 'instance' && property_exists($this, $attr)) {
+ return $this->$attr;
+ }
+
+ throw new \RuntimeException("Unknown attribute: $attr");
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __isset($attr)
+ {
+ return $attr !== 'instance' && isset($this->$attr);
+ }
+
+ public function jsonSerialize()
+ {
+ return $this->raw;
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/AnonymousIp.php b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php new file mode 100644 index 0000000..bf05b88 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php @@ -0,0 +1,56 @@ +<?php
+
+namespace GeoIp2\Model;
+
+use GeoIp2\Util;
+
+/**
+ * This class provides the GeoIP2 Anonymous IP model.
+ *
+ * @property-read bool $isAnonymous This is true if the IP address belongs to
+ * any sort of anonymous network.
+ * @property-read bool $isAnonymousVpn This is true if the IP address is
+ * registered to an anonymous VPN provider. If a VPN provider does not
+ * register subnets under names associated with them, we will likely only
+ * flag their IP ranges using the isHostingProvider property.
+ * @property-read bool $isHostingProvider This is true if the IP address belongs
+ * to a hosting or VPN provider (see description of isAnonymousVpn property).
+ * @property-read bool $isPublicProxy This is true if the IP address belongs to
+ * a public proxy.
+ * @property-read bool $isTorExitNode This is true if the IP address is a Tor
+ * exit node.
+ * @property-read string $ipAddress The IP address that the data in the model is
+ * for.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ */
+class AnonymousIp extends AbstractModel
+{
+ protected $isAnonymous;
+ protected $isAnonymousVpn;
+ protected $isHostingProvider;
+ protected $isPublicProxy;
+ protected $isTorExitNode;
+ protected $ipAddress;
+ protected $network;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ parent::__construct($raw);
+
+ $this->isAnonymous = $this->get('is_anonymous');
+ $this->isAnonymousVpn = $this->get('is_anonymous_vpn');
+ $this->isHostingProvider = $this->get('is_hosting_provider');
+ $this->isPublicProxy = $this->get('is_public_proxy');
+ $this->isTorExitNode = $this->get('is_tor_exit_node');
+ $ipAddress = $this->get('ip_address');
+ $this->ipAddress = $ipAddress;
+ $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Asn.php b/vendor/geoip2/geoip2/src/Model/Asn.php new file mode 100644 index 0000000..09f746e --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Asn.php @@ -0,0 +1,43 @@ +<?php
+
+namespace GeoIp2\Model;
+
+use GeoIp2\Util;
+
+/**
+ * This class provides the GeoLite2 ASN model.
+ *
+ * @property-read int|null $autonomousSystemNumber The autonomous system number
+ * associated with the IP address.
+ * @property-read string|null $autonomousSystemOrganization The organization
+ * associated with the registered autonomous system number for the IP
+ * address.
+ * @property-read string $ipAddress The IP address that the data in the model is
+ * for.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ */
+class Asn extends AbstractModel
+{
+ protected $autonomousSystemNumber;
+ protected $autonomousSystemOrganization;
+ protected $ipAddress;
+ protected $network;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ parent::__construct($raw);
+ $this->autonomousSystemNumber = $this->get('autonomous_system_number');
+ $this->autonomousSystemOrganization =
+ $this->get('autonomous_system_organization');
+ $ipAddress = $this->get('ip_address');
+ $this->ipAddress = $ipAddress;
+ $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/City.php b/vendor/geoip2/geoip2/src/Model/City.php new file mode 100644 index 0000000..bf8e352 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/City.php @@ -0,0 +1,116 @@ +<?php
+
+namespace GeoIp2\Model;
+
+/**
+ * Model class for the data returned by GeoIP2 City web service and database.
+ *
+ * The only difference between the City and Insights model classes is which
+ * fields in each record may be populated. See
+ * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ *
+ * @property-read \GeoIp2\Record\City $city City data for the requested IP
+ * address.
+ * @property-read \GeoIp2\Record\Location $location Location data for the
+ * requested IP address.
+ * @property-read \GeoIp2\Record\Postal $postal Postal data for the
+ * requested IP address.
+ * @property-read array $subdivisions An array \GeoIp2\Record\Subdivision
+ * objects representing the country subdivisions for the requested IP
+ * address. The number and type of subdivisions varies by country, but a
+ * subdivision is typically a state, province, county, etc. Subdivisions
+ * are ordered from most general (largest) to most specific (smallest).
+ * If the response did not contain any subdivisions, this method returns
+ * an empty array.
+ * @property-read \GeoIp2\Record\Subdivision $mostSpecificSubdivision An object
+ * representing the most specific subdivision returned. If the response
+ * did not contain any subdivisions, this method returns an empty
+ * \GeoIp2\Record\Subdivision object.
+ */
+class City extends Country
+{
+ /**
+ * @ignore
+ */
+ protected $city;
+ /**
+ * @ignore
+ */
+ protected $location;
+ /**
+ * @ignore
+ */
+ protected $postal;
+ /**
+ * @ignore
+ */
+ protected $subdivisions = [];
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ * @param mixed $locales
+ */
+ public function __construct($raw, $locales = ['en'])
+ {
+ parent::__construct($raw, $locales);
+
+ $this->city = new \GeoIp2\Record\City($this->get('city'), $locales);
+ $this->location = new \GeoIp2\Record\Location($this->get('location'));
+ $this->postal = new \GeoIp2\Record\Postal($this->get('postal'));
+
+ $this->createSubdivisions($raw, $locales);
+ }
+
+ private function createSubdivisions($raw, $locales)
+ {
+ if (!isset($raw['subdivisions'])) {
+ return;
+ }
+
+ foreach ($raw['subdivisions'] as $sub) {
+ array_push(
+ $this->subdivisions,
+ new \GeoIp2\Record\Subdivision($sub, $locales)
+ );
+ }
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __get($attr)
+ {
+ if ($attr === 'mostSpecificSubdivision') {
+ return $this->$attr();
+ }
+
+ return parent::__get($attr);
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __isset($attr)
+ {
+ if ($attr === 'mostSpecificSubdivision') {
+ // We always return a mostSpecificSubdivision, even if it is the
+ // empty subdivision
+ return true;
+ }
+
+ return parent::__isset($attr);
+ }
+
+ private function mostSpecificSubdivision()
+ {
+ return empty($this->subdivisions) ?
+ new \GeoIp2\Record\Subdivision([], $this->locales) :
+ end($this->subdivisions);
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/ConnectionType.php b/vendor/geoip2/geoip2/src/Model/ConnectionType.php new file mode 100644 index 0000000..013e6c3 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/ConnectionType.php @@ -0,0 +1,39 @@ +<?php
+
+namespace GeoIp2\Model;
+
+use GeoIp2\Util;
+
+/**
+ * This class provides the GeoIP2 Connection-Type model.
+ *
+ * @property-read string|null $connectionType The connection type may take the
+ * following values: "Dialup", "Cable/DSL", "Corporate", "Cellular".
+ * Additional values may be added in the future.
+ * @property-read string $ipAddress The IP address that the data in the model is
+ * for.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ */
+class ConnectionType extends AbstractModel
+{
+ protected $connectionType;
+ protected $ipAddress;
+ protected $network;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ parent::__construct($raw);
+
+ $this->connectionType = $this->get('connection_type');
+ $ipAddress = $this->get('ip_address');
+ $this->ipAddress = $ipAddress;
+ $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Country.php b/vendor/geoip2/geoip2/src/Model/Country.php new file mode 100644 index 0000000..64d2650 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Country.php @@ -0,0 +1,71 @@ +<?php
+
+namespace GeoIp2\Model;
+
+/**
+ * Model class for the data returned by GeoIP2 Country web service and database.
+ *
+ * The only difference between the City and Insights model classes is which
+ * fields in each record may be populated. See
+ * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ *
+ * @property-read \GeoIp2\Record\Continent $continent Continent data for the
+ * requested IP address.
+ * @property-read \GeoIp2\Record\Country $country Country data for the requested
+ * IP address. This object represents the country where MaxMind believes the
+ * end user is located.
+ * @property-read \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
+ * account.
+ * @property-read \GeoIp2\Record\Country $registeredCountry Registered country
+ * data for the requested IP address. This record represents the country
+ * where the ISP has registered a given IP block and may differ from the
+ * user's country.
+ * @property-read \GeoIp2\Record\RepresentedCountry $representedCountry
+ * Represented country data for the requested IP address. The represented
+ * country is used for things like military bases. It is only present when
+ * the represented country differs from the country.
+ * @property-read \GeoIp2\Record\Traits $traits Data for the traits of the
+ * requested IP address.
+ */
+class Country extends AbstractModel
+{
+ protected $continent;
+ protected $country;
+ protected $locales;
+ protected $maxmind;
+ protected $registeredCountry;
+ protected $representedCountry;
+ protected $traits;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ * @param mixed $locales
+ */
+ public function __construct($raw, $locales = ['en'])
+ {
+ parent::__construct($raw);
+
+ $this->continent = new \GeoIp2\Record\Continent(
+ $this->get('continent'),
+ $locales
+ );
+ $this->country = new \GeoIp2\Record\Country(
+ $this->get('country'),
+ $locales
+ );
+ $this->maxmind = new \GeoIp2\Record\MaxMind($this->get('maxmind'));
+ $this->registeredCountry = new \GeoIp2\Record\Country(
+ $this->get('registered_country'),
+ $locales
+ );
+ $this->representedCountry = new \GeoIp2\Record\RepresentedCountry(
+ $this->get('represented_country'),
+ $locales
+ );
+ $this->traits = new \GeoIp2\Record\Traits($this->get('traits'));
+
+ $this->locales = $locales;
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Domain.php b/vendor/geoip2/geoip2/src/Model/Domain.php new file mode 100644 index 0000000..57982f7 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Domain.php @@ -0,0 +1,39 @@ +<?php
+
+namespace GeoIp2\Model;
+
+use GeoIp2\Util;
+
+/**
+ * This class provides the GeoIP2 Domain model.
+ *
+ * @property-read string|null $domain The second level domain associated with the
+ * IP address. This will be something like "example.com" or
+ * "example.co.uk", not "foo.example.com".
+ * @property-read string $ipAddress The IP address that the data in the model is
+ * for.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ */
+class Domain extends AbstractModel
+{
+ protected $domain;
+ protected $ipAddress;
+ protected $network;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ parent::__construct($raw);
+
+ $this->domain = $this->get('domain');
+ $ipAddress = $this->get('ip_address');
+ $this->ipAddress = $ipAddress;
+ $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Enterprise.php b/vendor/geoip2/geoip2/src/Model/Enterprise.php new file mode 100644 index 0000000..7f153fa --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Enterprise.php @@ -0,0 +1,14 @@ +<?php
+
+namespace GeoIp2\Model;
+
+/**
+ * Model class for the data returned by GeoIP2 Enterprise database lookups.
+ *
+ * The only difference between the City and Enterprise model classes is which
+ * fields in each record may be populated. See
+ * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ */
+class Enterprise extends City
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Insights.php b/vendor/geoip2/geoip2/src/Model/Insights.php new file mode 100644 index 0000000..df3a54c --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Insights.php @@ -0,0 +1,14 @@ +<?php
+
+namespace GeoIp2\Model;
+
+/**
+ * Model class for the data returned by GeoIP2 Precision: Insights web service.
+ *
+ * The only difference between the City and Insights model classes is which
+ * fields in each record may be populated. See
+ * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ */
+class Insights extends City
+{
+}
diff --git a/vendor/geoip2/geoip2/src/Model/Isp.php b/vendor/geoip2/geoip2/src/Model/Isp.php new file mode 100644 index 0000000..aa30f74 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Model/Isp.php @@ -0,0 +1,52 @@ +<?php
+
+namespace GeoIp2\Model;
+
+use GeoIp2\Util;
+
+/**
+ * This class provides the GeoIP2 ISP model.
+ *
+ * @property-read int|null $autonomousSystemNumber The autonomous system number
+ * associated with the IP address.
+ * @property-read string|null $autonomousSystemOrganization The organization
+ * associated with the registered autonomous system number for the IP
+ * address.
+ * @property-read string|null $isp The name of the ISP associated with the IP
+ * address.
+ * @property-read string|null $organization The name of the organization associated
+ * with the IP address.
+ * @property-read string $ipAddress The IP address that the data in the model is
+ * for.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ */
+class Isp extends AbstractModel
+{
+ protected $autonomousSystemNumber;
+ protected $autonomousSystemOrganization;
+ protected $isp;
+ protected $organization;
+ protected $ipAddress;
+ protected $network;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $raw
+ */
+ public function __construct($raw)
+ {
+ parent::__construct($raw);
+ $this->autonomousSystemNumber = $this->get('autonomous_system_number');
+ $this->autonomousSystemOrganization =
+ $this->get('autonomous_system_organization');
+ $this->isp = $this->get('isp');
+ $this->organization = $this->get('organization');
+
+ $ipAddress = $this->get('ip_address');
+ $this->ipAddress = $ipAddress;
+ $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/ProviderInterface.php b/vendor/geoip2/geoip2/src/ProviderInterface.php new file mode 100644 index 0000000..9162069 --- /dev/null +++ b/vendor/geoip2/geoip2/src/ProviderInterface.php @@ -0,0 +1,20 @@ +<?php
+
+namespace GeoIp2;
+
+interface ProviderInterface
+{
+ /**
+ * @param string $ipAddress an IPv4 or IPv6 address to lookup
+ *
+ * @return \GeoIp2\Model\Country a Country model for the requested IP address
+ */
+ public function country($ipAddress);
+
+ /**
+ * @param string $ipAddress an IPv4 or IPv6 address to lookup
+ *
+ * @return \GeoIp2\Model\City a City model for the requested IP address
+ */
+ public function city($ipAddress);
+}
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php new file mode 100644 index 0000000..64bff36 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php @@ -0,0 +1,66 @@ +<?php
+
+namespace GeoIp2\Record;
+
+abstract class AbstractPlaceRecord extends AbstractRecord
+{
+ private $locales;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $record
+ * @param mixed $locales
+ */
+ public function __construct($record, $locales = ['en'])
+ {
+ $this->locales = $locales;
+ parent::__construct($record);
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __get($attr)
+ {
+ if ($attr === 'name') {
+ return $this->name();
+ }
+
+ return parent::__get($attr);
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __isset($attr)
+ {
+ if ($attr === 'name') {
+ return $this->firstSetNameLocale() === null ? false : true;
+ }
+
+ return parent::__isset($attr);
+ }
+
+ private function name()
+ {
+ $locale = $this->firstSetNameLocale();
+
+ return $locale === null ? null : $this->names[$locale];
+ }
+
+ private function firstSetNameLocale()
+ {
+ foreach ($this->locales as $locale) {
+ if (isset($this->names[$locale])) {
+ return $locale;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php new file mode 100644 index 0000000..b2441ad --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php @@ -0,0 +1,61 @@ +<?php
+
+namespace GeoIp2\Record;
+
+abstract class AbstractRecord implements \JsonSerializable
+{
+ private $record;
+
+ /**
+ * @ignore
+ *
+ * @param mixed $record
+ */
+ public function __construct($record)
+ {
+ $this->record = isset($record) ? $record : [];
+ }
+
+ /**
+ * @ignore
+ *
+ * @param mixed $attr
+ */
+ public function __get($attr)
+ {
+ // XXX - kind of ugly but greatly reduces boilerplate code
+ $key = $this->attributeToKey($attr);
+
+ if ($this->__isset($attr)) {
+ return $this->record[$key];
+ } elseif ($this->validAttribute($attr)) {
+ if (preg_match('/^is_/', $key)) {
+ return false;
+ }
+
+ return null;
+ }
+ throw new \RuntimeException("Unknown attribute: $attr");
+ }
+
+ public function __isset($attr)
+ {
+ return $this->validAttribute($attr) &&
+ isset($this->record[$this->attributeToKey($attr)]);
+ }
+
+ private function attributeToKey($attr)
+ {
+ return strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
+ }
+
+ private function validAttribute($attr)
+ {
+ return \in_array($attr, $this->validAttributes, true);
+ }
+
+ public function jsonSerialize()
+ {
+ return $this->record;
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Record/City.php b/vendor/geoip2/geoip2/src/Record/City.php new file mode 100644 index 0000000..f2e1f61 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/City.php @@ -0,0 +1,29 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * City-level data associated with an IP address.
+ *
+ * This record is returned by all location services and databases besides
+ * Country.
+ *
+ * @property-read int|null $confidence A value from 0-100 indicating MaxMind's
+ * confidence that the city is correct. This attribute is only available
+ * from the Insights service and the GeoIP2 Enterprise database.
+ * @property-read int|null $geonameId The GeoName ID for the city. This attribute
+ * is returned by all location services and databases.
+ * @property-read string|null $name The name of the city based on the locales list
+ * passed to the constructor. This attribute is returned by all location
+ * services and databases.
+ * @property-read array|null $names A array map where the keys are locale codes
+ * and the values are names. This attribute is returned by all location
+ * services and databases.
+ */
+class City extends AbstractPlaceRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = ['confidence', 'geonameId', 'names'];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Continent.php b/vendor/geoip2/geoip2/src/Record/Continent.php new file mode 100644 index 0000000..8495713 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Continent.php @@ -0,0 +1,32 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the continent record associated with an IP address.
+ *
+ * This record is returned by all location services and databases.
+ *
+ * @property-read string|null $code A two character continent code like "NA" (North
+ * America) or "OC" (Oceania). This attribute is returned by all location
+ * services and databases.
+ * @property-read int|null $geonameId The GeoName ID for the continent. This
+ * attribute is returned by all location services and databases.
+ * @property-read string|null $name Returns the name of the continent based on the
+ * locales list passed to the constructor. This attribute is returned by all location
+ * services and databases.
+ * @property-read array|null $names An array map where the keys are locale codes
+ * and the values are names. This attribute is returned by all location
+ * services and databases.
+ */
+class Continent extends AbstractPlaceRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = [
+ 'code',
+ 'geonameId',
+ 'names',
+ ];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Country.php b/vendor/geoip2/geoip2/src/Record/Country.php new file mode 100644 index 0000000..5ff810d --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Country.php @@ -0,0 +1,40 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the country record associated with an IP address.
+ *
+ * This record is returned by all location services and databases.
+ *
+ * @property-read int|null $confidence A value from 0-100 indicating MaxMind's
+ * confidence that the country is correct. This attribute is only available
+ * from the Insights service and the GeoIP2 Enterprise database.
+ * @property-read int|null $geonameId The GeoName ID for the country. This
+ * attribute is returned by all location services and databases.
+ * @property-read bool $isInEuropeanUnion This is true if the country is a
+ * member state of the European Union. This attribute is returned by all
+ * location services and databases.
+ * @property-read string|null $isoCode The two-character ISO 3166-1 alpha code
+ * for the country. See https://en.wikipedia.org/wiki/ISO_3166-1. This
+ * attribute is returned by all location services and databases.
+ * @property-read string|null $name The name of the country based on the locales
+ * list passed to the constructor. This attribute is returned by all location
+ * services and databases.
+ * @property-read array|null $names An array map where the keys are locale codes
+ * and the values are names. This attribute is returned by all location
+ * services and databases.
+ */
+class Country extends AbstractPlaceRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = [
+ 'confidence',
+ 'geonameId',
+ 'isInEuropeanUnion',
+ 'isoCode',
+ 'names',
+ ];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Location.php b/vendor/geoip2/geoip2/src/Record/Location.php new file mode 100644 index 0000000..8de109f --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Location.php @@ -0,0 +1,52 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the location record associated with an IP address.
+ *
+ * This record is returned by all location services and databases besides
+ * Country.
+ *
+ * @property-read int|null $averageIncome The average income in US dollars
+ * associated with the requested IP address. This attribute is only available
+ * from the Insights service.
+ * @property-read int|null $accuracyRadius The approximate accuracy radius in
+ * kilometers around the latitude and longitude for the IP address. This is
+ * the radius where we have a 67% confidence that the device using the IP
+ * address resides within the circle centered at the latitude and longitude
+ * with the provided radius.
+ * @property-read float|null $latitude The approximate latitude of the location
+ * associated with the IP address. This value is not precise and should not be
+ * used to identify a particular address or household.
+ * @property-read float|null $longitude The approximate longitude of the location
+ * associated with the IP address. This value is not precise and should not be
+ * used to identify a particular address or household.
+ * @property-read int|null $populationDensity The estimated population per square
+ * kilometer associated with the IP address. This attribute is only available
+ * from the Insights service.
+ * @property-read int|null $metroCode The metro code of the location if the location
+ * is in the US. MaxMind returns the same metro codes as the
+ * Google AdWords API. See
+ * https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions.
+ * @property-read string|null $timeZone The time zone associated with location, as
+ * specified by the IANA Time Zone Database, e.g., "America/New_York". See
+ * https://www.iana.org/time-zones.
+ */
+class Location extends AbstractRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = [
+ 'averageIncome',
+ 'accuracyRadius',
+ 'latitude',
+ 'longitude',
+ 'metroCode',
+ 'populationDensity',
+ 'postalCode',
+ 'postalConfidence',
+ 'timeZone',
+ ];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/MaxMind.php b/vendor/geoip2/geoip2/src/Record/MaxMind.php new file mode 100644 index 0000000..0c2cdd3 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/MaxMind.php @@ -0,0 +1,19 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data about your account.
+ *
+ * This record is returned by all location services and databases.
+ *
+ * @property-read int|null $queriesRemaining The number of remaining queries you
+ * have for the service you are calling.
+ */
+class MaxMind extends AbstractRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = ['queriesRemaining'];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Postal.php b/vendor/geoip2/geoip2/src/Record/Postal.php new file mode 100644 index 0000000..5c65923 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Postal.php @@ -0,0 +1,26 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the postal record associated with an IP address.
+ *
+ * This record is returned by all location databases and services besides
+ * Country.
+ *
+ * @property-read string|null $code The postal code of the location. Postal codes
+ * are not available for all countries. In some countries, this will only
+ * contain part of the postal code. This attribute is returned by all location
+ * databases and services besides Country.
+ * @property-read int|null $confidence A value from 0-100 indicating MaxMind's
+ * confidence that the postal code is correct. This attribute is only
+ * available from the Insights service and the GeoIP2 Enterprise
+ * database.
+ */
+class Postal extends AbstractRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = ['code', 'confidence'];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php new file mode 100644 index 0000000..270da93 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php @@ -0,0 +1,26 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the represented country associated with an IP address.
+ *
+ * This class contains the country-level data associated with an IP address
+ * for the IP's represented country. The represented country is the country
+ * represented by something like a military base.
+ *
+ * @property-read string|null $type A string indicating the type of entity that is
+ * representing the country. Currently we only return <code>military</code>
+ * but this could expand to include other types in the future.
+ */
+class RepresentedCountry extends Country
+{
+ protected $validAttributes = [
+ 'confidence',
+ 'geonameId',
+ 'isInEuropeanUnion',
+ 'isoCode',
+ 'names',
+ 'type',
+ ];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Subdivision.php b/vendor/geoip2/geoip2/src/Record/Subdivision.php new file mode 100644 index 0000000..4ad4e7f --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Subdivision.php @@ -0,0 +1,40 @@ +<?php
+
+namespace GeoIp2\Record;
+
+/**
+ * Contains data for the subdivisions associated with an IP address.
+ *
+ * This record is returned by all location databases and services besides
+ * Country.
+ *
+ * @property-read int|null $confidence This is a value from 0-100 indicating
+ * MaxMind's confidence that the subdivision is correct. This attribute is
+ * only available from the Insights service and the GeoIP2 Enterprise
+ * database.
+ * @property-read int|null $geonameId This is a GeoName ID for the subdivision.
+ * This attribute is returned by all location databases and services besides
+ * Country.
+ * @property-read string|null $isoCode This is a string up to three characters long
+ * contain the subdivision portion of the ISO 3166-2 code. See
+ * https://en.wikipedia.org/wiki/ISO_3166-2. This attribute is returned by all
+ * location databases and services except Country.
+ * @property-read string|null $name The name of the subdivision based on the
+ * locales list passed to the constructor. This attribute is returned by all
+ * location databases and services besides Country.
+ * @property-read array|null $names An array map where the keys are locale codes
+ * and the values are names. This attribute is returned by all location
+ * databases and services besides Country.
+ */
+class Subdivision extends AbstractPlaceRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = [
+ 'confidence',
+ 'geonameId',
+ 'isoCode',
+ 'names',
+ ];
+}
diff --git a/vendor/geoip2/geoip2/src/Record/Traits.php b/vendor/geoip2/geoip2/src/Record/Traits.php new file mode 100644 index 0000000..f02c693 --- /dev/null +++ b/vendor/geoip2/geoip2/src/Record/Traits.php @@ -0,0 +1,140 @@ +<?php
+
+namespace GeoIp2\Record;
+
+use GeoIp2\Util;
+
+/**
+ * Contains data for the traits record associated with an IP address.
+ *
+ * This record is returned by all location services and databases.
+ *
+ * @property-read int|null $autonomousSystemNumber The autonomous system number
+ * associated with the IP address. See
+ * https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This attribute
+ * is only available from the City and Insights web service and the GeoIP2
+ * Enterprise database.
+ * @property-read string|null $autonomousSystemOrganization The organization
+ * associated with the registered autonomous system number for the IP address.
+ * See https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This
+ * attribute is only available from the City and Insights web service and the
+ * GeoIP2 Enterprise database.
+ * @property-read string|null $connectionType The connection type may take the
+ * following values: "Dialup", "Cable/DSL", "Corporate", "Cellular".
+ * Additional values may be added in the future. This attribute is only
+ * available in the GeoIP2 Enterprise database.
+ * @property-read string|null $domain The second level domain associated with the
+ * IP address. This will be something like "example.com" or "example.co.uk",
+ * not "foo.example.com". This attribute is only available from the
+ * City and Insights web service and the GeoIP2 Enterprise
+ * database.
+ * @property-read string $ipAddress The IP address that the data in the model
+ * is for. If you performed a "me" lookup against the web service, this
+ * will be the externally routable IP address for the system the code is
+ * running on. If the system is behind a NAT, this may differ from the IP
+ * address locally assigned to it. This attribute is returned by all end
+ * points.
+ * @property-read bool $isAnonymous This is true if the IP address belongs to
+ * any sort of anonymous network. This property is only available from GeoIP2
+ * Precision Insights.
+ * @property-read bool $isAnonymousProxy *Deprecated.* Please see our GeoIP2
+ * Anonymous IP database
+ * (https://www.maxmind.com/en/geoip2-anonymous-ip-database) to determine
+ * whether the IP address is used by an anonymizing service.
+ * @property-read bool $isAnonymousVpn This is true if the IP address is
+ * registered to an anonymous VPN provider. If a VPN provider does not register
+ * subnets under names associated with them, we will likely only flag their IP
+ * ranges using the isHostingProvider property. This property is only available
+ * from GeoIP2 Precision Insights.
+ * @property-read bool $isHostingProvider This is true if the IP address belongs
+ * to a hosting or VPN provider (see description of isAnonymousVpn property).
+ * This property is only available from GeoIP2 Precision Insights.
+ * @property-read bool $isLegitimateProxy This attribute is true if MaxMind
+ * believes this IP address to be a legitimate proxy, such as an internal
+ * VPN used by a corporation. This attribute is only available in the GeoIP2
+ * Enterprise database.
+ * @property-read bool $isPublicProxy This is true if the IP address belongs to
+ * a public proxy. This property is only available from GeoIP2 Precision
+ * Insights.
+ * @property-read bool $isSatelliteProvider *Deprecated.* Due to the
+ * increased coverage by mobile carriers, very few satellite providers now
+ * serve multiple countries. As a result, the output does not provide
+ * sufficiently relevant data for us to maintain it.
+ * @property-read bool $isTorExitNode This is true if the IP address is a Tor
+ * exit node. This property is only available from GeoIP2 Precision Insights.
+ * @property-read string|null $isp The name of the ISP associated with the IP
+ * address. This attribute is only available from the City and Insights web
+ * services and the GeoIP2 Enterprise database.
+ * @property-read string $network The network in CIDR notation associated with
+ * the record. In particular, this is the largest network where all of the
+ * fields besides $ipAddress have the same value.
+ * @property-read string|null $organization The name of the organization associated
+ * with the IP address. This attribute is only available from the City and
+ * Insights web services and the GeoIP2 Enterprise database.
+ * @property-read float|null $staticIPScore An indicator of how static or
+ * dynamic an IP address is. This property is only available from GeoIP2
+ * Precision Insights.
+ * @property-read int|null $userCount The estimated number of users sharing
+ * the IP/network during the past 24 hours. For IPv4, the count is for the
+ * individual IP. For IPv6, the count is for the /64 network. This property is
+ * only available from GeoIP2 Precision Insights.
+ * @property-read string|null $userType <p>The user type associated with the IP
+ * address. This can be one of the following values:</p>
+ * <ul>
+ * <li>business
+ * <li>cafe
+ * <li>cellular
+ * <li>college
+ * <li>content_delivery_network
+ * <li>dialup
+ * <li>government
+ * <li>hosting
+ * <li>library
+ * <li>military
+ * <li>residential
+ * <li>router
+ * <li>school
+ * <li>search_engine_spider
+ * <li>traveler
+ * </ul>
+ * <p>
+ * This attribute is only available from the Insights web service and the
+ * GeoIP2 Enterprise database.
+ * </p>
+ */
+class Traits extends AbstractRecord
+{
+ /**
+ * @ignore
+ */
+ protected $validAttributes = [
+ 'autonomousSystemNumber',
+ 'autonomousSystemOrganization',
+ 'connectionType',
+ 'domain',
+ 'ipAddress',
+ 'isAnonymous',
+ 'isAnonymousProxy',
+ 'isAnonymousVpn',
+ 'isHostingProvider',
+ 'isLegitimateProxy',
+ 'isp',
+ 'isPublicProxy',
+ 'isSatelliteProvider',
+ 'isTorExitNode',
+ 'network',
+ 'organization',
+ 'staticIpScore',
+ 'userCount',
+ 'userType',
+ ];
+
+ public function __construct($record)
+ {
+ if (!isset($record['network']) && isset($record['ip_address']) && isset($record['prefix_len'])) {
+ $record['network'] = Util::cidr($record['ip_address'], $record['prefix_len']);
+ }
+
+ parent::__construct($record);
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/Util.php b/vendor/geoip2/geoip2/src/Util.php new file mode 100644 index 0000000..ac6d14c --- /dev/null +++ b/vendor/geoip2/geoip2/src/Util.php @@ -0,0 +1,37 @@ +<?php
+
+namespace GeoIp2;
+
+class Util
+{
+ /**
+ * This returns the network in CIDR notation for the given IP and prefix
+ * length. This is for internal use only.
+ *
+ * @internal
+ * @ignore
+ *
+ * @param mixed $ipAddress
+ * @param mixed $prefixLen
+ */
+ public static function cidr($ipAddress, $prefixLen)
+ {
+ $ipBytes = inet_pton($ipAddress);
+ $networkBytes = str_repeat("\0", \strlen($ipBytes));
+
+ $curPrefix = $prefixLen;
+ for ($i = 0; $i < \strlen($ipBytes) && $curPrefix > 0; $i++) {
+ $b = $ipBytes[$i];
+ if ($curPrefix < 8) {
+ $shiftN = 8 - $curPrefix;
+ $b = \chr(0xFF & (\ord($b) >> $shiftN) << $shiftN);
+ }
+ $networkBytes[$i] = $b;
+ $curPrefix -= 8;
+ }
+
+ $network = inet_ntop($networkBytes);
+
+ return "$network/$prefixLen";
+ }
+}
diff --git a/vendor/geoip2/geoip2/src/WebService/Client.php b/vendor/geoip2/geoip2/src/WebService/Client.php new file mode 100644 index 0000000..bebca56 --- /dev/null +++ b/vendor/geoip2/geoip2/src/WebService/Client.php @@ -0,0 +1,239 @@ +<?php
+
+namespace GeoIp2\WebService;
+
+use GeoIp2\Exception\AddressNotFoundException;
+use GeoIp2\Exception\AuthenticationException;
+use GeoIp2\Exception\GeoIp2Exception;
+use GeoIp2\Exception\HttpException;
+use GeoIp2\Exception\InvalidRequestException;
+use GeoIp2\Exception\OutOfQueriesException;
+use GeoIp2\ProviderInterface;
+use MaxMind\WebService\Client as WsClient;
+
+/**
+ * This class provides a client API for all the GeoIP2 Precision web services.
+ * The services are Country, City, and Insights. Each service returns a
+ * different set of data about an IP address, with Country returning the
+ * least data and Insights the most.
+ *
+ * Each web service is represented by a different model class, and these model
+ * classes in turn contain multiple record classes. The record classes have
+ * attributes which contain data about the IP address.
+ *
+ * If the web service does not return a particular piece of data for an IP
+ * address, the associated attribute is not populated.
+ *
+ * The web service may not return any information for an entire record, in
+ * which case all of the attributes for that record class will be empty.
+ *
+ * ## Usage ##
+ *
+ * The basic API for this class is the same for all of the web service end
+ * points. First you create a web service object with your MaxMind `$accountId`
+ * and `$licenseKey`, then you call the method corresponding to a specific end
+ * point, passing it the IP address you want to look up.
+ *
+ * If the request succeeds, the method call will return a model class for
+ * the service you called. This model in turn contains multiple record
+ * classes, each of which represents part of the data returned by the web
+ * service.
+ *
+ * If the request fails, the client class throws an exception.
+ */
+class Client implements ProviderInterface
+{
+ private $locales;
+ private $client;
+ private static $basePath = '/geoip/v2.1';
+
+ const VERSION = 'v2.10.0';
+
+ /**
+ * Constructor.
+ *
+ * @param int $accountId your MaxMind account ID
+ * @param string $licenseKey your MaxMind license key
+ * @param array $locales list of locale codes to use in name property
+ * from most preferred to least preferred
+ * @param array $options array of options. Valid options include:
+ * * `host` - The host to use when querying the web service.
+ * * `timeout` - Timeout in seconds.
+ * * `connectTimeout` - Initial connection timeout in seconds.
+ * * `proxy` - The HTTP proxy to use. May include a schema, port,
+ * username, and password, e.g.,
+ * `http://username:password@127.0.0.1:10`.
+ */
+ public function __construct(
+ $accountId,
+ $licenseKey,
+ $locales = ['en'],
+ $options = []
+ ) {
+ $this->locales = $locales;
+
+ // This is for backwards compatibility. Do not remove except for a
+ // major version bump.
+ if (\is_string($options)) {
+ $options = ['host' => $options];
+ }
+
+ if (!isset($options['host'])) {
+ $options['host'] = 'geoip.maxmind.com';
+ }
+
+ $options['userAgent'] = $this->userAgent();
+
+ $this->client = new WsClient($accountId, $licenseKey, $options);
+ }
+
+ private function userAgent()
+ {
+ return 'GeoIP2-API/' . self::VERSION;
+ }
+
+ /**
+ * This method calls the GeoIP2 Precision: City service.
+ *
+ * @param string $ipAddress IPv4 or IPv6 address as a string. If no
+ * address is provided, the address that the web service is called
+ * from will be used.
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address you
+ * provided is not in our database (e.g., a private address).
+ * @throws \GeoIp2\Exception\AuthenticationException if there is a problem
+ * with the account ID or license key that you provided
+ * @throws \GeoIp2\Exception\OutOfQueriesException if your account is out
+ * of queries
+ * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
+ * invalid for some other reason. This may indicate an issue
+ * with this API. Please report the error to MaxMind.
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
+ *
+ * @return \GeoIp2\Model\City
+ */
+ public function city($ipAddress = 'me')
+ {
+ return $this->responseFor('city', 'City', $ipAddress);
+ }
+
+ /**
+ * This method calls the GeoIP2 Precision: Country service.
+ *
+ * @param string $ipAddress IPv4 or IPv6 address as a string. If no
+ * address is provided, the address that the web service is called
+ * from will be used.
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address you provided is not in our database (e.g.,
+ * a private address).
+ * @throws \GeoIp2\Exception\AuthenticationException if there is a problem
+ * with the account ID or license key that you provided
+ * @throws \GeoIp2\Exception\OutOfQueriesException if your account is out of queries
+ * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
+ * invalid for some other reason. This may indicate an
+ * issue with this API. Please report the error to MaxMind.
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
+ * code or message was returned. This could indicate a problem
+ * with the connection between your server and the web service
+ * or that the web service returned an invalid document or 500
+ * error code.
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent class to the above exceptions. It
+ * will be thrown directly if a 200 status code is returned but
+ * the body is invalid.
+ *
+ * @return \GeoIp2\Model\Country
+ */
+ public function country($ipAddress = 'me')
+ {
+ return $this->responseFor('country', 'Country', $ipAddress);
+ }
+
+ /**
+ * This method calls the GeoIP2 Precision: Insights service.
+ *
+ * @param string $ipAddress IPv4 or IPv6 address as a string. If no
+ * address is provided, the address that the web service is called
+ * from will be used.
+ *
+ * @throws \GeoIp2\Exception\AddressNotFoundException if the address you
+ * provided is not in our database (e.g., a private address).
+ * @throws \GeoIp2\Exception\AuthenticationException if there is a problem
+ * with the account ID or license key that you provided
+ * @throws \GeoIp2\Exception\OutOfQueriesException if your account is out
+ * of queries
+ * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
+ * invalid for some other reason. This may indicate an
+ * issue with this API. Please report the error to MaxMind.
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
+ *
+ * @return \GeoIp2\Model\Insights
+ */
+ public function insights($ipAddress = 'me')
+ {
+ return $this->responseFor('insights', 'Insights', $ipAddress);
+ }
+
+ private function responseFor($endpoint, $class, $ipAddress)
+ {
+ $path = implode('/', [self::$basePath, $endpoint, $ipAddress]);
+
+ try {
+ $body = $this->client->get('GeoIP2 ' . $class, $path);
+ } catch (\MaxMind\Exception\IpAddressNotFoundException $ex) {
+ throw new AddressNotFoundException(
+ $ex->getMessage(),
+ $ex->getStatusCode(),
+ $ex
+ );
+ } catch (\MaxMind\Exception\AuthenticationException $ex) {
+ throw new AuthenticationException(
+ $ex->getMessage(),
+ $ex->getStatusCode(),
+ $ex
+ );
+ } catch (\MaxMind\Exception\InsufficientFundsException $ex) {
+ throw new OutOfQueriesException(
+ $ex->getMessage(),
+ $ex->getStatusCode(),
+ $ex
+ );
+ } catch (\MaxMind\Exception\InvalidRequestException $ex) {
+ throw new InvalidRequestException(
+ $ex->getMessage(),
+ $ex->getErrorCode(),
+ $ex->getStatusCode(),
+ $ex->getUri(),
+ $ex
+ );
+ } catch (\MaxMind\Exception\HttpException $ex) {
+ throw new HttpException(
+ $ex->getMessage(),
+ $ex->getStatusCode(),
+ $ex->getUri(),
+ $ex
+ );
+ } catch (\MaxMind\Exception\WebServiceException $ex) {
+ throw new GeoIp2Exception(
+ $ex->getMessage(),
+ $ex->getCode(),
+ $ex
+ );
+ }
+
+ $class = 'GeoIp2\\Model\\' . $class;
+
+ return new $class($body, $this->locales);
+ }
+}
|