--- functions.php.orig Mon Aug 20 10:12:23 2007 +++ functions.php Thu Aug 23 09:54:54 2007 @@ -186,6 +186,8 @@ if($type == 'S') return 'SOA'; if($type == 'N') return 'NS'; if($type == 'A') return 'A'; + if($type == '3') return 'AAAA'; + if($type == '6') return 'AAAA+PTR'; if($type == 'M') return 'MX'; if($type == 'P') return 'PTR'; if($type == 'T') return 'TXT'; @@ -198,6 +200,8 @@ if($type == 'SOA') return 'S'; if($type == 'NS') return 'N'; if($type == 'A') return 'A'; + if($type == 'AAAA') return '3'; + if($type == 'AAAA+PTR') return '6'; if($type == 'MX') return 'M'; if($type == 'PTR') return 'P'; if($type == 'TXT') return 'T'; @@ -227,6 +231,28 @@ return $return; } +function validate_ipv6($ip) { + $class = new Net_IPv6; + return $class->checkIPv6($ip); +} + +function uncompress_ipv6($ip) { + $class = new Net_IPv6; + $ip = $class->uncompress($ip); + $splitip = explode(":", $ip); + for ($i=0, $max=sizeOf($splitip); $i<$max; $i++) { + $chunk =& $splitip[$i]; + $length = strlen($chunk); + if ($length<4) { + $filler=""; + for ($i=0; $i<(4-$length); $i++) $filler .= "0"; + $chunk = $filler.$chunk; + } + } + $ip = implode(":", $splitip); + return $ip; +} + function verify_record($name,$type,$address,$distance,$ttl) { // convert type to single character format @@ -246,6 +272,26 @@ } } + // verify AAAA record + if($type == 'AAAA') { + if(validate_ipv6ip($address) == FALSE) { + return "\"$address\" is not a valid AAAA record address"; + } + if(check_domain_name_format($name) == FALSE) { + return "\"$name\" is not a valid AAAA record name"; + } + } + + // verify AAAA+PTR record + if($type == 'AAAA+PTR') { + if(validate_ipv6ip($address) == FALSE) { + return "\"$address\" is not a valid AAAA+PTR record address"; + } + if(check_domain_name_format($name) == FALSE) { + return "\"$name\" is not a valid AAAA+PTR record name"; + } + } + // verify NS record if($type == 'N') { if(validate_ip($address) != FALSE) { @@ -364,6 +410,10 @@ if($row['type'] == 'A') { $s = "+".$row['host'].":".$row['val'].":".$row['ttl']."\n"; + } else if($row['type'] == '6') { + $s = "6".$row['host'].":".str_replace(":",'', $row['val']).":".$row['ttl']."\n"; + } else if($row['type'] == '3') { + $s = "3".$row['host'].":".str_replace(":",'', $row['val']).":".$row['ttl']."\n"; } else if($row['type'] == 'M') { $s = "@".$row['host']."::".$row['val'].":".$row['distance'].":".$row['ttl']."\n"; } else if($row['type'] == 'N') {