Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace GeoIp2\Model;
   6  
   7  use GeoIp2\Util;
   8  
   9  /**
  10   * This class provides the GeoIP2 Anonymous IP model.
  11   *
  12   * @property-read bool $isAnonymous This is true if the IP address belongs to
  13   *     any sort of anonymous network.
  14   * @property-read bool $isAnonymousVpn This is true if the IP address is
  15   *     registered to an anonymous VPN provider. If a VPN provider does not
  16   *     register subnets under names associated with them, we will likely only
  17   *     flag their IP ranges using the isHostingProvider property.
  18   * @property-read bool $isHostingProvider This is true if the IP address belongs
  19   *     to a hosting or VPN provider (see description of isAnonymousVpn property).
  20   * @property-read bool $isPublicProxy This is true if the IP address belongs to
  21   *     a public proxy.
  22   * @property-read bool $isResidentialProxy This is true if the IP address is
  23   *     on a suspected anonymizing network and belongs to a residential ISP.
  24   * @property-read bool $isTorExitNode This is true if the IP address is a Tor
  25   *     exit node.
  26   * @property-read string $ipAddress The IP address that the data in the model is
  27   *     for.
  28   * @property-read string $network The network in CIDR notation associated with
  29   *      the record. In particular, this is the largest network where all of the
  30   *      fields besides $ipAddress have the same value.
  31   */
  32  class AnonymousIp extends AbstractModel
  33  {
  34      protected $isAnonymous;
  35      protected $isAnonymousVpn;
  36      protected $isHostingProvider;
  37      protected $isPublicProxy;
  38      protected $isResidentialProxy;
  39      protected $isTorExitNode;
  40      protected $ipAddress;
  41      protected $network;
  42  
  43      /**
  44       * @ignore
  45       */
  46      public function __construct(array $raw)
  47      {
  48          parent::__construct($raw);
  49  
  50          $this->isAnonymous = $this->get('is_anonymous');
  51          $this->isAnonymousVpn = $this->get('is_anonymous_vpn');
  52          $this->isHostingProvider = $this->get('is_hosting_provider');
  53          $this->isPublicProxy = $this->get('is_public_proxy');
  54          $this->isResidentialProxy = $this->get('is_residential_proxy');
  55          $this->isTorExitNode = $this->get('is_tor_exit_node');
  56          $ipAddress = $this->get('ip_address');
  57          $this->ipAddress = $ipAddress;
  58          $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
  59      }
  60  }