Update jQuery UI to 1.11.0, GeoIPv6 and IP library

This commit is contained in:
Jano Slota 2014-06-30 15:58:26 +02:00 committed by czaks
parent 6a3dbe5c98
commit dca7570b32
9 changed files with 1757 additions and 584 deletions

View File

@ -254,7 +254,9 @@ class CIDR
* and the starting IP is not on a valid network boundrary (eg: Displaying
* an IP from an interface).
*
* @return string IP in CIDR notation "ipaddr/prefix"
* <b>Note: The CIDR block returned is NOT always bit aligned.</b>
*
* @return string IP in CIDR notation "start_ip/prefix"
*/
public function getCidr()
{
@ -262,6 +264,22 @@ class CIDR
}
/**
* Get the TRUE cidr notation for the subnet block.
*
* This is useful for when you want a string representation of the IP/prefix
* and the starting IP is not on a valid network boundrary (eg: Displaying
* an IP from an interface).
*
* <b>Note: The CIDR block returned is ALWAYS bit aligned.</b>
*
* @return string IP in CIDR notation "network/prefix"
*/
public function getTrueCidr()
{
return $this->getNetwork() . '/' . $this->prefix;
}
/**
* Get the [low,high] range of the CIDR block
*
* Prefix sensitive.
@ -382,8 +400,9 @@ class CIDR
{
// use fixed length HEX strings so we can easily do STRING comparisons
// instead of using slower bccomp() math.
list($lo,$hi) = array_map(function($v){ return sprintf("%032s", IP::inet_ptoh($v)); }, CIDR::cidr_to_range($ip));
list($min,$max) = array_map(function($v){ return sprintf("%032s", IP::inet_ptoh($v)); }, CIDR::cidr_to_range($cidr));
$map = function($v){ return sprintf("%032s", IP::inet_ptoh($v)); };
list($lo,$hi) = array_map($map, CIDR::cidr_to_range($ip));
list($min,$max) = array_map($map, CIDR::cidr_to_range($cidr));
/** visualization of logic used below
lo-hi = $ip to check
@ -447,7 +466,8 @@ class CIDR
}
// force bit length to 32 or 128 depending on type of IP
$bitlen = (false === filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) ? 128 : 32;
$version = IP::isIPv4($ip) ? 4 : 6;
$bitlen = $version == 4 ? 32 : 128;
if ($bits === null) {
// if no prefix is given use the length of the binary string which
@ -469,7 +489,7 @@ class CIDR
// calculate "broadcast" (not technically a broadcast in IPv6)
$ip2 = BC::bcor($ip1, BC::bcnot($netmask));
return array(IP::inet_dtop($ip1), IP::inet_dtop($ip2));
return array(IP::inet_dtop($ip1, $version), IP::inet_dtop($ip2, $version));
}
/**

View File

@ -26,6 +26,10 @@ abstract class IP
{
// shortcut for IPv4 addresses
if (strpos($ip, ':') === false && strpos($ip, '.') !== false) {
// remove any cidr block notation
if (($o = strpos($ip, '/')) !== false) {
$ip = substr($ip, 0, $o);
}
return sprintf('%u', ip2long($ip));
}
@ -55,8 +59,11 @@ abstract class IP
/**
* Convert a decimal string into a human readable IP address.
*
* @param decimal $decimal Decimal number to convert into presentational IP string.
* @param integer $version Force IP version to 4 or 6. Leave null for automatic.
*/
public static function inet_dtop($decimal, $expand = false)
public static function inet_dtop($decimal, $version = null)
{
$parts = array();
$parts[1] = bcdiv($decimal, '79228162514264337593543950336', 0); // >> 96
@ -74,25 +81,27 @@ abstract class IP
$part = (int) $part;
}
// if the first 96bits is all zeros then we can safely assume we
// actually have an IPv4 address. Even though it's technically possible
// you're not really ever going to see an IPv6 address in the range:
// ::0 - ::ffff
// It's feasible to see an IPv6 address of "::", in which case the
// caller is going to have to account for that on their own.
if (($parts[1] | $parts[2] | $parts[3]) == 0) {
if (!$version) {
// if the first 96bits is all zeros then we can safely assume we
// actually have an IPv4 address. Even though it's technically possible
// you're not really ever going to see an IPv6 address in the range:
// ::0 - ::ffff
// It's feasible to see an IPv6 address of "::", in which case the
// caller is going to have to account for that on their own (or
// pass $version to this function).
if (($parts[1] | $parts[2] | $parts[3]) == 0) {
$version = 4;
}
}
if ($version == 4) {
$ip = long2ip($parts[4]);
} else {
$packed = pack('N4', $parts[1], $parts[2], $parts[3], $parts[4]);
$ip = inet_ntop($packed);
}
// Turn IPv6 to IPv4 if it's IPv4
if (preg_match('/^::\d+\./', $ip)) {
return substr($ip, 2);
}
return $expand ? self::inet_expand($ip) : $ip;
return $ip;
}
/**
@ -107,8 +116,11 @@ abstract class IP
/**
* Convert a human readable (presentational) IP address into a BINARY string.
*/
public static function inet_ptob($ip, $bits = 128)
public static function inet_ptob($ip, $bits = null)
{
if ($bits === null) {
$bits = self::isIPv4($ip) ? 32 : 128;
}
return BC::bcdecbin(self::inet_ptod($ip), $bits);
}
@ -157,7 +169,7 @@ abstract class IP
* One use-case for this is IP 6to4 tunnels used in networking.
*
* @example
* to_ipv4("10.10.10.10") == a0a:a0a
* to_ipv6("10.10.10.10") == a0a:a0a
*
* @param string $ip IPv4 address.
* @param boolean $mapped If true a Full IPv6 address is returned within the

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
/*! jQuery UI - v1.10.4 - 2014-02-09
* http://jqueryui.com
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}

View File

@ -1,5 +0,0 @@
/*! jQuery UI - v1.10.4 - 2014-02-09
* http://jqueryui.com
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}

View File

@ -1,5 +0,0 @@
/*! jQuery UI - v1.10.4 - 2014-02-09
* http://jqueryui.com
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}

View File

@ -1,5 +0,0 @@
/*! jQuery UI - v1.10.4 - 2014-02-11
* http://jqueryui.com
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}