Remove all the too long lines
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3266 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -10,7 +10,8 @@ class ipaddresses
|
||||
public function validIPAddress ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"),
|
||||
500);
|
||||
$rc = $this->validIPv4Address ($ip);
|
||||
if ($rc === TRUE)
|
||||
return TRUE;
|
||||
@@ -22,7 +23,8 @@ class ipaddresses
|
||||
public function validIPv4Address ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv4 address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv4 address"),
|
||||
500);
|
||||
$rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
if ($rc ===FALSE)
|
||||
return FALSE;
|
||||
@@ -33,22 +35,24 @@ class ipaddresses
|
||||
public function validIPv6Address ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"),
|
||||
500);
|
||||
$rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
if ($rc ===FALSE)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Return the IPv6 uncompressed (all the fields exists). They are not filled by
|
||||
zeros
|
||||
/** Return the IPv6 uncompressed (all the fields exists). They are not filled
|
||||
by zeros
|
||||
If the provided IP is IPv4, there is no change applied
|
||||
Return False if the parameter is invalid
|
||||
Based on http://www.weberdev.com/get_example.php3?ExampleID=3921 */
|
||||
public function uncompressIPv6 ($ip)
|
||||
{
|
||||
if (! is_string ($ip) || $ip === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"),
|
||||
500);
|
||||
if (strstr ($ip,"::"))
|
||||
{
|
||||
$e = explode (":", $ip);
|
||||
@@ -84,9 +88,11 @@ class ipaddresses
|
||||
public function groupIPv6 ($ipv6)
|
||||
{
|
||||
if (! is_string ($ipv6) || $ipv6 === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"),
|
||||
500);
|
||||
if (substr_count ($ipv6, ".") !== 31)
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IPv6 address"),
|
||||
500);
|
||||
$ipv6 = str_replace (".", "", $ipv6);
|
||||
$new = "";
|
||||
for ($i = 0 ; $i < 32 ; $i++)
|
||||
@@ -101,11 +107,13 @@ class ipaddresses
|
||||
}
|
||||
|
||||
/* Return the IP adddress with filling the fields with the missing zeros.
|
||||
Valid only on IPv6 (but don't change anything if the provided address is IPv4) */
|
||||
Valid only on IPv6 (but don't change anything if the provided address is
|
||||
IPv4) */
|
||||
public function completeAddressWithZero ($ip)
|
||||
{
|
||||
if (! is_string ($ip) || $ip === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"),
|
||||
500);
|
||||
$ip = $this->uncompressIPv6 ($ip);
|
||||
if (substr_count ($ip, ":") === 7)
|
||||
{
|
||||
@@ -192,7 +200,8 @@ class ipaddresses
|
||||
function reverseIPAddress ($ipReverse)
|
||||
{
|
||||
if (!is_string ($ipReverse) || $ipReverse === "")
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"),
|
||||
500);
|
||||
$ipReverse = $this->completeAddressWithZero ($ipReverse);
|
||||
if (substr_count ($ipReverse, ":") === 7 && strlen ($ipReverse) == 39)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user