Rev 1028 Rev 4987
1 <?php 1 <?php
2   2  
3 // Funkce pro třídění 3 // Funkce pro třídění
4 function sortf($a,$b) 4 function sortf($a,$b)
5 { 5 {
6 $a=preg_split("/\s+/",$a,4); 6 $a=preg_split("/\s+/",$a,4);
7 $b=preg_split("/\s+/",$b,4); 7 $b=preg_split("/\s+/",$b,4);
8 return strcmp($b[3],$a[3]); 8 return strcmp($b[3],$a[3]);
9 } 9 }
10 10
11 function GetDNS($Domain) 11 function GetDNS($Domain)
12 { 12 {
13 // Vytáhni informace z DNS programem "host" 13 // Vytáhni informace z DNS programem "host"
14 if(isset($x)) unset($x); 14 if(isset($x)) unset($x);
15 @Exec("host -a -l $Domain ns.forpsi.cz",$x); 15 @Exec("host -a -l $Domain ns.forpsi.cz",$x);
16 //echo implode("\n",$x); 16 //echo implode("\n",$x);
17 17
18 // Ukousni začátek až po sekci odpovědi 18 // Ukousni začátek až po sekci odpovědi
19 reset($x); 19 reset($x);
20 while($y=each($x)) 20 while($y=each($x))
21 { 21 {
22 if(eregi(";; ANSWER SECTION:",$y[value])) break; 22 if(preg_match('#;; ANSWER SECTION:#mi',$y[\VALUE])) break;
23 } 23 }
24 $x=array_slice($x,$y[key]+1); 24 $x=array_slice($x,$y[\KEY]+1);
25 25
26 // Vyhoď prázdné řádky a komentáře 26 // Vyhoď prázdné řádky a komentáře
27 reset($x); 27 reset($x);
28 while($y=each($x)) 28 while($y=each($x))
29 { 29 {
30 if(eregi("^$",$y[value])) 30 if(preg_match('#^$#mi',$y[\VALUE]))
31 unset($x[$y[key]]); 31 unset($x[$y[\KEY]]);
32 if(eregi("^;.*$",$y[value])) 32 if(preg_match('#^;.*$#mi',$y[\VALUE]))
33 unset($x[$y[key]]); 33 unset($x[$y[\KEY]]);
34 if(eregi("^Received .*$",$y[value])) 34 if(preg_match('#^Received .*$#mi',$y[\VALUE]))
35 unset($x[$y[key]]); 35 unset($x[$y[\KEY]]);
36 } 36 }
37 37
38 // Setřiď podle abecedy 38 // Setřiď podle abecedy
39 usort($x,"sortf"); 39 usort($x,"sortf");
40 40
41 // Výsledek 41 // Výsledek
42 $x=implode("\n",$x); 42 $x=implode("\n",$x);
43 if ($x=="") $x="No Data\n"; 43 if ($x=="") $x="No Data\n";
44   44  
45 return $x; 45 return $x;
46 } 46 }
47 ?> 47 ?>
48   48  
49 <h1> DNS Records for MLAB </h1> 49 <h1> DNS Records for MLAB </h1>
50 <pre> 50 <pre>
51 <?php 51 <?php
52 echo GetDNS('mlab.cz.'); 52 echo GetDNS('mlab.cz.');
53 ?> 53 ?>
54 </pre> 54 </pre>
55   55  
56 <h1> DNS Records for UST </h1> 56 <h1> DNS Records for UST </h1>
57 <pre> 57 <pre>
58 <?php 58 <?php
59 echo GetDNS('ust.cz.'); 59 echo GetDNS('ust.cz.');
60 ?> 60 ?>
61 </pre> 61 </pre>