[TYPO3-core] RFC: Bug 331: Support IPv6 addresses
Martin Kutschker
Martin.Kutschker at blackbox.net
Tue Mar 7 17:33:54 CET 2006
Franz Holzinger <franz at fholzinger.com> writes on
Tue, 07 Mar 2006 17:26:02 +0100 (MET):
> >
> 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;
> }
> }
If you're simply removing all ::, then there are easier ways, but I don't think it's right to drop them. AFAIR a :: is a shorthand, which would have to be expanded not dropped.
> However I could not test it. So tell me what's wrong or how to test.
How to test it? Easy just write a file with an array of valid an invalid IPv6 addresses. Run them all against your function and check the result.
Masi
More information about the TYPO3-team-core
mailing list