/**
  * Create the object and add the clients IP address to it
  * Determine if the client is IPv6
  **/
 function __construct()
 {
     self::$ClientIP = $_SERVER['REMOTE_ADDR'];
     // If no colons we have an IPv4 address for sure
     if (strpos(self::$ClientIP, ':') === false) {
         self::$IsIPv6 = false;
         return 0;
     }
     // We could have an IPv4 address in disguise
     // it is either an ISATAP or embedded address
     // ::5EFE:a.b.c.d, ::0200:5EFE:a.b.c.d, ::ffff:a.b.c.d
     if (strpos(self::$ClientIP, '.') === 0) {
         return 0;
     }
     // So we have an IPv4 hidden in here
     self::$ClientIP = substr(self::$ClientIP, strrpos(self::$ClientIP, ':') + 1);
     self::$IsIPv6 = false;
     return 0;
 }
 /**
  * Set a valid range of IP numbers for a source
  *
  * @param string $sourceid Source ID
  * @param mixed  $netmasks Array or string of "network/netmask"
  *                         like (192.168.0.0/24 or 192.168.0.0/255.255.255.0)
  */
 public static function setValidAddress($sourceid, $netmasks)
 {
     self::$authsources["{$sourceid}"]['valid_client'] = false;
     $valid_network = new AuthNetworkAddress();
     if (is_array($netmasks)) {
         foreach ($netmasks as $netmask) {
             if ($valid_network->applyNetmask($netmask)) {
                 self::$authsources["{$sourceid}"]['valid_client'] = true;
                 self::AuthLog('Client IP ' . $valid_network->getClientIP() . ' is in ' . $netmask);
             } else {
                 self::AuthLog('Client IP ' . $valid_network->getClientIP() . ' is NOT in ' . $netmask);
             }
         }
     } else {
         if ($valid_network->applyNetmask($netmasks)) {
             self::$authsources["{$sourceid}"]['valid_client'] = true;
             self::AuthLog('Client IP ' . $valid_network->getClientIP() . ' is in ' . $netmasks);
         } else {
             self::AuthLog('Client IP ' . $valid_network->getClientIP() . ' is NOT in ' . $netmasks);
         }
     }
 }