コード例 #1
0
ファイル: IPv6.php プロジェクト: martinsv/phpipam
 /**
 * Converts an IPv6 address from Hex into Binary representation.
 *
 * @param String $ip the IP to convert (a:b:c:d:e:f:g:h),
 *                   compressed IPs are allowed
 *
 * @return String the binary representation
 * @access private
 @ @since 1.1.0
 */
 protected static function _ip2Bin($ip)
 {
     $binstr = '';
     $ip = Net_IPv6::removeNetmaskSpec($ip);
     $ip = Net_IPv6::Uncompress($ip);
     $parts = explode(':', $ip);
     foreach ($parts as $v) {
         $str = base_convert($v, 16, 2);
         $binstr .= str_pad($str, 16, '0', STR_PAD_LEFT);
     }
     return $binstr;
 }
コード例 #2
0
ファイル: IPv6.php プロジェクト: pnagaraju25/fengoffice
 /**
  * Splits an IPv6 adress into the IPv6 and a possible IPv4 part
  *
  * RFC 2373 allows you to note the last two parts of an IPv6 adress as
  * an IPv4 compatible adress
  *
  * Example:  0:0:0:0:0:0:13.1.68.3
  *           0:0:0:0:0:FFFF:129.144.52.38
  *
  * @access public
  * @static
  * @param string $ip	a valid IPv6-adress (hex format)
  * @return array		[0] contains the IPv6 part, [1] the IPv4 part (hex format)
  */
 function SplitV64($ip)
 {
     $ip = Net_IPv6::Uncompress($ip);
     if (strstr($ip, '.')) {
         $pos = strrpos($ip, ':');
         $ip[$pos] = '_';
         $ipPart = explode('_', $ip);
         return $ipPart;
     } else {
         return array($ip, "");
     }
 }