[TYPO3-core] RFC: Bug 331: Support IPv6 addresses

Michael Stucki michael at typo3.org
Tue Mar 7 21:01:47 CET 2006


Hi Franz and Andreas,

thanks for your comments, but I have currently no more time to work on this.
If you want to optimize things, feel free to do that later.

For now we should just quickly decide whether we want IPv6 support in 4.0 or
not!

Regards, michael

Franz Holzinger wrote:

> Hello Michael,
> 
>>  
>>
>>>>+     function validIPv6($ip) {
>>>>+             $uppercaseIP = strtoupper($ip);
>>>>+
>>>>+             $regex = "/^(";
>>>>+             $regex.= "(([\dA-F]{1,4}:){7}[\dA-F]{1,4})|";
>>>>+             $regex.=
>>>>"(([\dA-F]{1,4}){1}::([\dA-F]{1,4}:){1,5}[\dA-F]{1,4})|";
>>>>+             $regex.=
>>>>"(([\dA-F]{1,4}:){2}:([\dA-F]{1,4}:){1,4}[\dA-F]{1,4})|";
>>>>+             $regex.=
>>>>"(([\dA-F]{1,4}:){3}:([\dA-F]{1,4}:){1,3}[\dA-F]{1,4})|";
>>>>+             $regex.=
>>>>"(([\dA-F]{1,4}:){4}:([\dA-F]{1,4}:){1,2}[\dA-F]{1,4})|";
>>>>+             $regex.=
>>>>"(([\dA-F]{1,4}:){5}:([\dA-F]{1,4}:){0,1}[\dA-F]{1,4})|";
>>>>+             $regex.= "(::([\dA-F]{1,4}:){0,6}[\dA-F]{1,4})";
>>>>+             $regex.= ")$/";
>>>> 
>>>>
>>>>      
>>>>
>>>I think it should be possible to find a more simple regular expression
>>>for that.
>>>    
>>>
>>
>>How? Please make a suggestion if you know how to optimize this.
>>
>>  
>>
> What about this?
> 
> 
>     function validIPv6($ip)    {
>         $bValid = true;
>         $ipTest = $ip;
> 
>             // check for more than one '::'
>         $ddpos = strpos ($ipTest, '::');
>         if (!$ddpos===FALSE)    {
>             $tmpIp = substr ($ipTest, $ddpos);
>             $tmppos = strpos ($tmpIp, '::');
>             if ($tmppos === FALSE)    {
>                 // remove '::'
>                 $ipTest = substr ($ipTest, 0, $ddpos);
>                 $ipTest .= substr ($ipTest, $ddpos + 2);
>             } else {
>                 $bValid = false;
>             }
>         }
> 
>             // check colon at the end
>         if (substr($ipTest,-1,1) == ':')
>             $bValid = false;
>         // dummy colon at the end
>         $ipTest .= ':';
>         if ($bValid)    {
>             $regex = "/^(";
>             $regex.= "(([\dA-F]{1,4}:){1,8})";
>             $regex.= ")$/i";
>             if (!preg_match($regex, $ipTest))
>                 $bValid = false;
>         }
>         return $bValid;
> 
> 
> 
> However I could not test it. So tell me what's wrong or how to test.
> 
> 
> Greets,
> 
> Franz

-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/



More information about the TYPO3-team-core mailing list