Handle hostnames with upper-case letters
[webmin.git] / cluster-usermin / edit_host.cgi
1 #!/usr/local/bin/perl
2 # edit_host.cgi
3 # Show details of a managed host, and all the modules on it
4
5 require './cluster-usermin-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'host_title'}, "");
8
9 @hosts = &list_usermin_hosts();
10 ($host) = grep { $_->{'id'} eq $in{'id'} } @hosts;
11 $server = &foreign_call("servers", "get_server", $in{'id'});
12 @modules = @{$host->{'modules'}};
13 @themes = @{$host->{'themes'}};
14 @users = @{$host->{'users'}};
15 @groups = @{$host->{'groups'}};
16
17 # Show host details
18 print "<input type=hidden name=id value=$in{'id'}>\n";
19 print "<table border width=100%>\n";
20 print "<tr $tb> <td><b>$text{'host_header'}</b></td> </tr>\n";
21 print "<tr $cb> <td><table width=100%>\n";
22
23 print "<tr> <td><b>$text{'host_name'}</b></td>\n";
24 if ($server->{'id'}) {
25         printf "<td>%s</td>\n",
26                 $server->{'desc'} ? $server->{'desc'} : $server->{'host'};
27         }
28 else {
29         print "<td>$text{'this_server'}</td>\n";
30         }
31
32 if ($server->{'id'}) {
33         print "<td><b>$text{'host_type'}</b></td> <td>\n";
34         foreach $t (@servers::server_types) {
35                 print $t->[1] if ($t->[0] eq $server->{'type'});
36                 }
37         print "</td>\n";
38         }
39 print "</tr>\n";
40
41 print "<tr> <td><b>$text{'host_count'}</b></td>\n";
42 printf "<td>%d</td>\n", scalar(@modules);
43
44 print "<td><b>$text{'host_tcount'}</b></td>\n";
45 printf "<td>%d</td> </tr>\n", scalar(@themes);
46
47 print "<tr> <td><b>$text{'host_os'}</b></td>\n";
48 print "<td>$host->{'real_os_type'} $host->{'real_os_version'}</td>\n";
49
50 print "<td><b>$text{'host_version'}</b></td>\n";
51 printf "<td>%s</td> </tr>\n", $host->{'version'};
52
53 print "</table></td></tr></table>\n";
54
55 # Show delete and refresh buttons
56 print "<table width=100%><tr>\n";
57 print "<form action=delete_host.cgi>\n";
58 print "<input type=hidden name=id value=$in{'id'}>\n";
59 print "<td><input type=submit value='$text{'host_delete'}'></td>\n";
60 print "</form>\n";
61
62 print "<form action=refresh.cgi>\n";
63 print "<input type=hidden name=id value=$in{'id'}>\n";
64 print "<td align=right><input type=submit value='$text{'host_refresh'}'></td>\n";
65 print "</form>\n";
66 print "</tr></table>\n";
67
68 # Show table of modules and themes
69 print "<table border width=100%>\n";
70 print "<tr $tb> <td><b>$text{'host_header_m'}</b></td> </tr>\n";
71 print "<tr $cb> <td><table width=100%>\n";
72
73 $i = 0;
74 foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } @modules) {
75         print "<tr>\n" if ($i%3 == 0);
76         print "<td width=33%><a href='edit_mod.cgi?mod=$m->{'dir'}&host=$in{'id'}'>",$m->{'desc'},"</td>\n";
77         print "</tr>\n" if ($i%3 == 2);
78         $i++;
79         }
80 if (@themes) {
81         $i = 0;
82         print "</table></td></tr>\n";
83         print "<tr $tb> <td><b>$text{'host_header_t'}</b></td> </tr>\n";
84         print "<tr $cb> <td><table width=100%>\n";
85         foreach $t (sort { $a->{'desc'} cmp $b->{'desc'} } @themes) {
86                 print "<tr>\n" if ($i%3 == 0);
87                 print "<td width=33%><a href='edit_mod.cgi?theme=$t->{'dir'}$in{'id'}'>",$t->{'desc'},"</td>\n";
88                 print "</tr>\n" if ($i%3 == 2);
89                 $i++;
90                 }
91         }
92 print "</table></td></tr></table><br>\n";
93
94 &ui_print_footer("", $text{'index_return'});
95