Handle hostnames with upper-case letters
[webmin.git] / msctheme-enhanced / index.cgi
1 #!/usr/local/bin/perl
2
3 require './web-lib.pl';
4 @available = ("webmin", "system", "servers", "cluster", "hardware", "", "net");
5 &init_config();
6 $hostname = &get_system_hostname();
7 $ver = &get_webmin_version();
8 &get_miniserv_config(\%miniserv);
9 if ($gconfig{'real_os_type'}) {
10         if ($gconfig{'os_version'} eq "*") {
11                 $ostr = $gconfig{'real_os_type'};
12                 }
13         else {
14                 $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
15                 }
16         }
17 else {
18         $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
19         }
20 &ReadParse();
21
22 # Redirect if the user has only one module
23 @msc_modules = &get_available_module_infos()
24         if (!scalar(@msc_modules));
25 if (@msc_modules == 1 && $gconfig{'gotoone'}) {
26         &redirect("$msc_modules[0]->{'dir'}/");
27         exit;
28         }
29
30 # Show standard header
31 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
32 $theme_index_page = 1;
33 &header($gconfig{'nohostname'} ? $text{'main_title2'} :
34         &text('main_title', $ver, $hostname, $ostr), "",
35         undef, undef, 1, 1);
36
37 if (!@msc_modules) {
38         # use has no modules!
39         print "<p><b>$text{'main_none'}</b><p>\n";
40         }
41 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
42     $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
43         # Generate main menu with all modules on one page
44         print "<center><table cellpadding=0>\n";
45         $pos = 0;
46         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
47         $per = 100.0 / $cols;
48         foreach $m (@msc_modules) {
49                 if ($pos % $cols == 0) { print "<tr>\n"; }
50                 print "<td valign=top align=center>\n";
51                 print "<table border><tr><td><a href=/$m->{'dir'}/>",
52                       "<img src=$m->{'dir'}/images/icon.gif border=0 ",
53                       "width=48 height=48></a></td></tr></table>\n";
54                 print "<a href=/$m->{'dir'}/>$m->{'desc'}</a></td>\n";
55                 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
56                 $pos++;
57                 }
58         print "</table></center><p><table width='100%' bgcolor='#FFFFFF'><tr><td></td></tr></table><br>\n";
59         }
60 else {
61         # Generate categorized module list
62         print "<table border=0 cellpadding=0 cellspacing=0 width=95% align=center><tr><td><table border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
63         $usercol = defined($gconfig{'cs_header'}) ||
64                    defined($gconfig{'cs_table'}) ||
65                    defined($gconfig{'cs_page'});
66         foreach $c (@cats) {
67                 $t = $cats{$c};
68                 if ($in{'cat'} eq $c) {
69                         print "<td bgcolor=#bae3ff>",
70                           "<img src=images/tabs/blue_left.jpg alt=\"\">","</td>\n";
71                         print "<td bgcolor=#bae3ff>&nbsp;<b>$t</b>&nbsp;</td>\n";
72                         print "<td bgcolor=#bae3ff>",
73                           "<img src=images/tabs/blue_right.jpg alt=\"\">","</td>\n";
74                         }
75 #               print "<td width=10></td>\n";
76                 }
77         print "</tr></table> <table border=0 cellpadding=0 cellspacing=0 ",
78               "width=100% bgcolor=#FFFFFF background=images/msctile2.jpg>\n";
79         print "<tr><td><table width=100% cellpadding=5>\n";
80
81         # Display the modules in this category
82         $pos = 0;
83         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
84         $per = 100.0 / $cols;
85         foreach $m (@msc_modules) {
86                 next if ($m->{'category'} ne $in{'cat'});
87
88                 if ($pos % $cols == 0) { print "<tr>\n"; }
89                 print "<td valign=top align=center width=$per\%>\n";
90                 print "<table border bgcolor=#ffffff><tr><td><a href=/$m->{'dir'}/>",
91                       "<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
92                       "</td></tr></table>\n";
93                 print "<a href=/$m->{'dir'}/><font color=#000000>$m->{'desc'}</font></a></td>\n";
94                 if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
95                 }
96         while($pos++ % $cols) {
97                 print "<td width=$per\%></td>\n";
98                 }
99         print "</table></td></tr></table></td></tr></table>";
100
101     print qq~<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
102   <tr>
103     <td background="images/white_bar.jpg" nowrap><img src="images/white_bar.jpg"></td>
104   </tr>
105 </table>~;
106
107     print qq~<p><table width="98%" border="0" cellspacing="0" cellpadding="0" height="4" align="center">
108   <tr>
109     <td background="images/white_bar2.jpg" nowrap><img src="images/white_bar2.jpg"></td>
110   </tr>
111 </table><p>~;
112
113         }
114
115 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
116     !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
117     $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
118         print "<table width=100% cellpadding=0 cellspacing=0><tr>\n";
119         if ($gconfig{'skill_'.$base_remote_user}) {
120                 print "<td><b>$text{'main_skill'}:</b>\n";
121                 foreach $s ('high', 'medium', 'low') {
122                         print "&nbsp;|&nbsp;" if ($done_first_skill++);
123                         if ($gconfig{'skill_'.$base_remote_user} eq $s) {
124                                 print $text{'skill_'.$s};
125                                 }
126                         else {
127                                 print "<a href='switch_skill.cgi?skill=$s&",
128                                    "cat=$in{'cat'}'>", "<font color=000000>", $text{'skill_'.$s},"</font></a>";
129                                 }
130                         }
131                 print "</td>\n";
132                 }
133     print "<table width=95% align=center><tr><td width=100%><b><font color='#FFFFFF'>&nbsp;&nbsp;";
134     print &text('main_version', $ver, $hostname, $ostr)
135         if (!$gconfig{'nohostname'});
136     print "</font></b>\n";
137     print "</td>\n";
138
139 print "<td align=right><a href='http://www.msclinux.com/'>",
140           "<img src='images/theme_by.jpg' border='0'></a>&nbsp;&nbsp;</div><br>\n";
141     print "</tr></table>\n";
142
143         }
144
145 &footer();
146
147
148 sub chop_font {
149
150         foreach $l (split(//, $t)) {
151             $ll = ord($l);
152             if ($ll > 127 && $lang->{'charset'}) {
153                 print "<img src=images/letters2/$ll.$lang->{'charset'}.gif alt=\"$l\" align=bottom border=0>";
154                 }
155             elsif ($l eq " ") {
156                 print "<img src=images/letters2/$ll.gif alt=\"\&nbsp;\" align=bottom border=0>";
157                 }
158             else {
159                 print "<img src=images/letters2/$ll.gif alt=\"$l\" align=bottom border=0>";
160                 }
161             }
162
163 }