X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Uplink%2FIPAddr.class.php;h=b1912e8926c3c503d395415aa0b2b46c275ba707;hp=2370cf66e48fab506177595eec9a74ad9edd3611;hb=cba81599e819e50231c50c531cca7964667a8b0e;hpb=8be3a6c1707de83881176d789145a6c175e35dc2 diff --git a/Uplink/IPAddr.class.php b/Uplink/IPAddr.class.php index 2370cf6..b1912e8 100644 --- a/Uplink/IPAddr.class.php +++ b/Uplink/IPAddr.class.php @@ -28,6 +28,7 @@ class IPAddr { private static $pattern_IPv4 = '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(|\/[0-9]{1,2})$/'; private $ip6 = array(); private $addr_is_ipv6 = false; + private $is_server_addr = false; public function __construct($initial_value) { for($i = 0; $i < 8; $i++) { @@ -97,7 +98,15 @@ class IPAddr { return $this->addr_is_ipv6; } - public function isLocalAddress() { + public function setServerAddr($serverAddr) { + $this->is_server_addr = $serverAddr; + } + + public function isServerAddr() { + return $this->is_server_addr; + } + + public function isLocalAddress($serverAddr = false) { /* checks if address is out of: * 127.0.0.1/32 * 10.0.0.0/8 @@ -105,6 +114,8 @@ class IPAddr { * 172.16.0.0/12 * ::1/128 * fc00::/7 + * + * if $serverAddr is true also return true for server IP's */ if($this->addr_is_ipv6) { if( @@ -122,6 +133,8 @@ class IPAddr { ) return true; } + if($serverAddr && $this->is_server_addr) + return true; return false; }