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