diff options
| author | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
| commit | 25b7d2aab61ae6421398d3abae5da6ffe590333d (patch) | |
| tree | 611985ec78bb2d94099c9fd5dd687f5c9cee6f3e /includes/vendor/geoip2 | |
| parent | Initial commit (diff) | |
| download | crack.cf-backup-master.tar.xz crack.cf-backup-master.zip | |
Diffstat (limited to 'includes/vendor/geoip2')
31 files changed, 2104 insertions, 0 deletions
diff --git a/includes/vendor/geoip2/geoip2/README.md b/includes/vendor/geoip2/geoip2/README.md new file mode 100644 index 0000000..03b269b --- /dev/null +++ b/includes/vendor/geoip2/geoip2/README.md @@ -0,0 +1,401 @@ +# GeoIP2 PHP API # + +## Description ## + +This package provides an API for the GeoIP2 +[web services](http://dev.maxmind.com/geoip/geoip2/web-services) and +[databases](http://dev.maxmind.com/geoip/geoip2/downloadable). The API also +works with the free +[GeoLite2 databases](http://dev.maxmind.com/geoip/geoip2/geolite2/). + +## Install via Composer ## + +We recommend installing this package with [Composer](http://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](http://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](http://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](http://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 + +``` + +### 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' + +``` + +### 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' + +``` + +### 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' + +``` + +### 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 + +``` + +### 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' + +``` + +## 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 + +``` + +## 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](http://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](http://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](http://www.maxmind.com/en/correction). + +If you find some other sort of mistake, like an incorrect spelling, +please check the [GeoNames site](http://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](http://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](http://www.maxmind.com/en/support). + +## Requirements ## + +This library requires PHP 5.4 or greater. This library works and is tested +with HHVM. + +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](http://semver.org/). + +## Copyright and License ## + +This software is Copyright (c) 2013-2018 by MaxMind, Inc. + +This is free software, licensed under the Apache License, Version 2.0. + diff --git a/includes/vendor/geoip2/geoip2/src/Database/Reader.php b/includes/vendor/geoip2/geoip2/src/Database/Reader.php new file mode 100644 index 0000000..84cf2be --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Database/Reader.php @@ -0,0 +1,283 @@ +<?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 $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->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) + { + $record = $this->getRecord($class, $type, $ipAddress); + + $record['traits']['ip_address'] = $ipAddress; + $class = 'GeoIp2\\Model\\' . $class; + + return new $class($record, $this->locales); + } + + private function flatModelFor($class, $type, $ipAddress) + { + $record = $this->getRecord($class, $type, $ipAddress); + + $record['ip_address'] = $ipAddress; + $class = 'GeoIp2\\Model\\' . $class; + + return new $class($record); + } + + private function getRecord($class, $type, $ipAddress) + { + if (strpos($this->metadata()->databaseType, $type) === false) { + $method = lcfirst($class); + throw new \BadMethodCallException( + "The $method method cannot be used to open a " + . $this->metadata()->databaseType . ' database' + ); + } + $record = $this->dbReader->get($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; + } + + /** + * @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/includes/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php b/includes/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php new file mode 100644 index 0000000..d548338 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php b/includes/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php new file mode 100644 index 0000000..2a8b592 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php b/includes/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php new file mode 100644 index 0000000..7c4d745 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Exception/HttpException.php b/includes/vendor/geoip2/geoip2/src/Exception/HttpException.php new file mode 100644 index 0000000..62ec707 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php b/includes/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php new file mode 100644 index 0000000..6464bcb --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php b/includes/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php new file mode 100644 index 0000000..87a6ade --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Model/AbstractModel.php b/includes/vendor/geoip2/geoip2/src/Model/AbstractModel.php new file mode 100644 index 0000000..d4b9b70 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Model/AnonymousIp.php b/includes/vendor/geoip2/geoip2/src/Model/AnonymousIp.php new file mode 100644 index 0000000..bdaeb89 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/AnonymousIp.php @@ -0,0 +1,46 @@ +<?php + +namespace GeoIp2\Model; + +/** + * 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 belongs to + * an anonymous VPN system. + * @property-read bool $isHostingProvider This is true if the IP address belongs + * to a hosting provider. + * @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. + */ +class AnonymousIp extends AbstractModel +{ + protected $isAnonymous; + protected $isAnonymousVpn; + protected $isHostingProvider; + protected $isPublicProxy; + protected $isTorExitNode; + protected $ipAddress; + + /** + * @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'); + $this->ipAddress = $this->get('ip_address'); + } +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/Asn.php b/includes/vendor/geoip2/geoip2/src/Model/Asn.php new file mode 100644 index 0000000..4144142 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/Asn.php @@ -0,0 +1,35 @@ +<?php + +namespace GeoIp2\Model; + +/** + * 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. + */ +class Asn extends AbstractModel +{ + protected $autonomousSystemNumber; + protected $autonomousSystemOrganization; + protected $ipAddress; + + /** + * @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->ipAddress = $this->get('ip_address'); + } +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/City.php b/includes/vendor/geoip2/geoip2/src/Model/City.php new file mode 100644 index 0000000..3285903 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/City.php @@ -0,0 +1,133 @@ +<?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 + * http://dev.maxmind.com/geoip/geoip2/web-services more details. + * + * @property-read \GeoIp2\Record\City $city City data for the requested IP + * address. + * @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\Location $location Location data for the + * requested IP address. + * @property-read \GeoIp2\Record\Postal $postal Postal data for the + * requested IP address. + * @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 array $subdivisions An array of {@link \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 + * {@link \GeoIp2\Record\Subdivision} object. + * @property-read \GeoIp2\Record\Traits $traits Data for the traits of the + * requested IP address. + */ +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/includes/vendor/geoip2/geoip2/src/Model/ConnectionType.php b/includes/vendor/geoip2/geoip2/src/Model/ConnectionType.php new file mode 100644 index 0000000..169e7c1 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/ConnectionType.php @@ -0,0 +1,31 @@ +<?php + +namespace GeoIp2\Model; + +/** + * 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. + */ +class ConnectionType extends AbstractModel +{ + protected $connectionType; + protected $ipAddress; + + /** + * @ignore + * + * @param mixed $raw + */ + public function __construct($raw) + { + parent::__construct($raw); + + $this->connectionType = $this->get('connection_type'); + $this->ipAddress = $this->get('ip_address'); + } +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/Country.php b/includes/vendor/geoip2/geoip2/src/Model/Country.php new file mode 100644 index 0000000..17833a1 --- /dev/null +++ b/includes/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 + * http://dev.maxmind.com/geoip/geoip2/web-services 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/includes/vendor/geoip2/geoip2/src/Model/Domain.php b/includes/vendor/geoip2/geoip2/src/Model/Domain.php new file mode 100644 index 0000000..f452e86 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/Domain.php @@ -0,0 +1,31 @@ +<?php + +namespace GeoIp2\Model; + +/** + * 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. + */ +class Domain extends AbstractModel +{ + protected $domain; + protected $ipAddress; + + /** + * @ignore + * + * @param mixed $raw + */ + public function __construct($raw) + { + parent::__construct($raw); + + $this->domain = $this->get('domain'); + $this->ipAddress = $this->get('ip_address'); + } +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/Enterprise.php b/includes/vendor/geoip2/geoip2/src/Model/Enterprise.php new file mode 100644 index 0000000..6b98c05 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/Enterprise.php @@ -0,0 +1,47 @@ +<?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 + * http://dev.maxmind.com/geoip/geoip2/web-services more details. + * + * @property-read \GeoIp2\Record\City $city City data for the requested IP + * address. + * @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\Location $location Location data for the + * requested IP address. + * @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 array $subdivisions An array of {@link \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 + * {@link \GeoIp2\Record\Subdivision} object. + * @property-read \GeoIp2\Record\Traits $traits Data for the traits of the + * requested IP address. + */ +class Enterprise extends City +{ +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/Insights.php b/includes/vendor/geoip2/geoip2/src/Model/Insights.php new file mode 100644 index 0000000..cefcfb9 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/Insights.php @@ -0,0 +1,47 @@ +<?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 + * http://dev.maxmind.com/geoip/geoip2/web-services more details. + * + * @property-read \GeoIp2\Record\City $city City data for the requested IP + * address. + * @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\Location $location Location data for the + * requested IP address. + * @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 array $subdivisions An array of {@link \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 + * {@link \GeoIp2\Record\Subdivision} object. + * @property-read \GeoIp2\Record\Traits $traits Data for the traits of the + * requested IP address. + */ +class Insights extends City +{ +} diff --git a/includes/vendor/geoip2/geoip2/src/Model/Isp.php b/includes/vendor/geoip2/geoip2/src/Model/Isp.php new file mode 100644 index 0000000..51e0b68 --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Model/Isp.php @@ -0,0 +1,44 @@ +<?php + +namespace GeoIp2\Model; + +/** + * 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. + */ +class Isp extends AbstractModel +{ + protected $autonomousSystemNumber; + protected $autonomousSystemOrganization; + protected $isp; + protected $organization; + protected $ipAddress; + + /** + * @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'); + + $this->ipAddress = $this->get('ip_address'); + } +} diff --git a/includes/vendor/geoip2/geoip2/src/ProviderInterface.php b/includes/vendor/geoip2/geoip2/src/ProviderInterface.php new file mode 100644 index 0000000..44851b0 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php b/includes/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php new file mode 100644 index 0000000..1e079c6 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/AbstractRecord.php b/includes/vendor/geoip2/geoip2/src/Record/AbstractRecord.php new file mode 100644 index 0000000..5d8cb0b --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/City.php b/includes/vendor/geoip2/geoip2/src/Record/City.php new file mode 100644 index 0000000..7f495ad --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/Continent.php b/includes/vendor/geoip2/geoip2/src/Record/Continent.php new file mode 100644 index 0000000..c6b1705 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/Country.php b/includes/vendor/geoip2/geoip2/src/Record/Country.php new file mode 100644 index 0000000..477bc1d --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Record/Country.php @@ -0,0 +1,41 @@ +<?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 + * {@link * http://en.wikipedia.org/wiki/ISO_3166-1 two-character ISO 3166-1 alpha + * code} for the country. 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/includes/vendor/geoip2/geoip2/src/Record/Location.php b/includes/vendor/geoip2/geoip2/src/Record/Location.php new file mode 100644 index 0000000..9b81adf --- /dev/null +++ b/includes/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 + * {@link * https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions + * Google AdWords API}. + * @property-read string|null $timeZone The time zone associated with location, as + * specified by the {@link http://www.iana.org/time-zones IANA Time Zone + * Database}, e.g., "America/New_York". + */ +class Location extends AbstractRecord +{ + /** + * @ignore + */ + protected $validAttributes = [ + 'averageIncome', + 'accuracyRadius', + 'latitude', + 'longitude', + 'metroCode', + 'populationDensity', + 'postalCode', + 'postalConfidence', + 'timeZone', + ]; +} diff --git a/includes/vendor/geoip2/geoip2/src/Record/MaxMind.php b/includes/vendor/geoip2/geoip2/src/Record/MaxMind.php new file mode 100644 index 0000000..2e2cc00 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/Postal.php b/includes/vendor/geoip2/geoip2/src/Record/Postal.php new file mode 100644 index 0000000..69508c7 --- /dev/null +++ b/includes/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/includes/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php b/includes/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php new file mode 100644 index 0000000..13082dd --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php @@ -0,0 +1,39 @@ +<?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 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. + * @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 {@link http://en.wikipedia.org/wiki/ISO_3166-1 + * two-character ISO 3166-1 alpha code} for the country. + * @property-read string|null $name The name of the country based on the locales list + * passed to the constructor. + * @property-read array|null $names An array map where the keys are locale codes and + * the values are names. + * @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/includes/vendor/geoip2/geoip2/src/Record/Subdivision.php b/includes/vendor/geoip2/geoip2/src/Record/Subdivision.php new file mode 100644 index 0000000..386c68d --- /dev/null +++ b/includes/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 + * {@link * http://en.wikipedia.org/wiki/ISO_3166-2 ISO 3166-2 code}. 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/includes/vendor/geoip2/geoip2/src/Record/Traits.php b/includes/vendor/geoip2/geoip2/src/Record/Traits.php new file mode 100644 index 0000000..bc5f07d --- /dev/null +++ b/includes/vendor/geoip2/geoip2/src/Record/Traits.php @@ -0,0 +1,114 @@ +<?php + +namespace GeoIp2\Record; + +/** + * 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 + * {@link * http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous + * system number} associated with the IP address. 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 {@link * http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous + * system number} for the IP address. 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 + * {@link * https://www.maxmind.com/en/geoip2-anonymous-ip-database 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 belongs to + * an anonymous VPN system. This property is only available from GeoIP2 + * Precision Insights. + * @property-read bool $isHostingProvider This is true if the IP address belongs + * to a hosting provider. 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|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 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', + 'organization', + 'userType', + ]; +} diff --git a/includes/vendor/geoip2/geoip2/src/WebService/Client.php b/includes/vendor/geoip2/geoip2/src/WebService/Client.php new file mode 100644 index 0000000..1a1ccf1 --- /dev/null +++ b/includes/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.9.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:[email protected]: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); + } +} |