Handle hostnames with upper-case letters
[webmin.git] / net / list_dns.cgi
1 #!/usr/local/bin/perl
2 # list_dns.cgi
3 # Display the DNS client configuration
4
5 require './net-lib.pl';
6 $access{'dns'} || &error($text{'dns_ecannot'});
7 &ui_print_header(undef, $text{'dns_title'}, "");
8 $dns = &get_dns_config();
9
10 # Start of the form
11 print &ui_form_start("save_dns.cgi");
12 print &ui_table_start($text{'dns_options'}, "width=100%", 4);
13
14 # Find hostname in /etc/hosts, offer to fix
15 @hosts = &list_hosts();
16 foreach $h (@hosts) {
17         foreach $n (@{$h->{'hosts'}}) {
18                 $found++ if ($n eq &get_hostname());
19                 }
20         }
21
22 # System's hostname
23 print &ui_table_row($text{'dns_hostname'},
24         &ui_textbox("hostname", &get_hostname(), 40).
25         ($found ? "<br>".&ui_checkbox("hosts", 1, $text{'dns_hoststoo'}, 1)
26                 : ""), 3);
27
28 # DNS resolution order
29 $order = &order_input($dns);
30 if ($order) {
31         print &ui_table_row($text{'dns_order'}, $order, 3);
32         }
33
34 # Check if hostname is set from DHCP
35 # XXX not done yet
36 #$dhost = defined(&get_dhcp_hostname) ? &get_dhcp_hostname() : -1;
37 #if ($dhost != -1) {
38 #       print "<tr> <td></td>\n";
39 #       print "<td>",&ui_checkbox("dhcp", 1, $text{'dns_dhcp'}, $dhost),
40 #             "</td> </tr>\n";
41 #       }
42
43 # DNS servers
44 @nslist = ( );
45 for($i=0; $i<$max_dns_servers || $i<@{$dns->{'nameserver'}}+1; $i++) {
46         push(@nslist, &ui_textbox("nameserver_$i",
47                                   $dns->{'nameserver'}->[$i], 15));
48         }
49 print &ui_table_row($text{'dns_servers'}.
50                     ($dns->{'name'} ? " ".$dns->{'name'}[0] : ""),
51         join("<br>", @nslist));
52 print &ui_hidden("name0", $dns->{'name'}[0]) if ($dns->{'name'});
53
54 # Additional DNS servers, as seen on Windows
55 if (@{$dns->{'name'}} > 1) {
56     for ($j=1; $j<@{$dns->{'name'}}; $j++) {
57         @nslist = ( );
58         for ($i=0; $i<$max_dns_servers; $i++) {
59                 push(@nslist, &ui_textbox("nameserver${j}_$i",
60                                           $dns->{"nameserver$j"}->[$i], 15));
61                 }
62         print &ui_table_row($text{'dns_servers'}." ".$dns->{'name'}[$j],
63                 join("<br>", @nslist));
64         print &ui_hidden("name$j", $dns->{'name'}[$j]);
65         }
66     }
67
68 # DNS search domains
69 print &ui_table_row($text{'dns_search'},
70         &ui_radio("domain_def", $dns->{'domain'} ? 0 : 1,
71                   [ [ 1, $text{'dns_none'} ],
72                     [ 0, $text{'dns_listed'} ] ])."<br>".
73         &ui_textarea("domain", join("\n", @{$dns->{'domain'}}), 3, 30));
74
75 # End of the form
76 print &ui_table_end();
77 if ($access{'dns'} == 2) {
78         print &ui_form_end([ [ undef, $text{'save'} ] ]);
79         }
80 else {
81         print &ui_form_end();
82         }
83
84 &ui_print_footer("", $text{'index_return'});
85