forked from metaregistrar/php-dns-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrootzone.php
46 lines (43 loc) · 1.08 KB
/
rootzone.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$ns = array();
$rootzone = file('https://www.internic.net/domain/root.zone',FILE_IGNORE_NEW_LINES);
foreach ($rootzone as $zone){
$array = explode("\t",$zone);
if (isset($array[4])) {
if ($array[4]=='IN') {
if ($array[5]=='NS') {
$type = $array[5];
$tld = strtolower($array[0]);
if (strlen($tld)>1) {
if ($tld{strlen($tld)-1}=='.') {
$tld = substr($tld,0,strlen($tld)-1);
}
$content = $array[6];
$ns[$tld][]=$content;
}
}
}
}
}
echo 'private $ns = array('."\n";
$tldcount = count($ns);
$tldteller = 0;
foreach ($ns as $index=>$tld) {
echo "'".$index."'=>array(";
$count = count($tld);
$teller = 0;
foreach ($tld as $content) {
echo "'".$content."'";
$teller++;
if ($teller < $count) {
echo ',';
}
}
echo ')';
$tldteller++;
if ($tldteller < $tldcount) {
echo ',';
}
echo"\n";
}
echo ");";