Handle hostnames with upper-case letters
[webmin.git] / warp-theme / 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_display_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_visible_module_infos()
24         if (!length(@msc_modules));
25
26 if (!defined($in{'cat'})) {
27         # Maybe redirect to some module after login
28         local $goto = &get_goto_module(\@msc_modules);
29         if ($goto) {
30                 &redirect($goto->{'dir'}.'/');
31                 exit;
32                 }
33         }
34
35 # Show standard header
36 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
37 $theme_index_page = 1;
38 &header($gconfig{'nohostname'} ? $text{'main_title2'} :
39         &text('main_title', $ver, $hostname, $ostr), "",
40         undef, undef, 1, 1);
41 print $text{'main_header'};
42
43 if (!@msc_modules) {
44         # use has no modules!
45         print "<p><b>$text{'main_none'}</b><p>\n";
46         }
47 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
48     $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
49         # Generate main menu with all modules on one page
50         print "<center><table cellpadding=0>\n";
51         $pos = 0;
52         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
53         $per = 100.0 / $cols;
54         foreach $m (@msc_modules) {
55                 if ($pos % $cols == 0) { print "<tr>\n"; }
56                 print "<td valign=top align=center>\n";
57                 local $idx = $m->{'index_link'};
58                 print "<table border><tr><td><a href=$m->{'dir'}/$idx>",
59                       "<img src=$m->{'dir'}/images/icon.gif border=0 ",
60                       "width=48 height=48></a></td></tr></table>\n";
61                 print "<a href=$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
62                 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
63                 $pos++;
64                 }
65         print "</table></center><p><table width='100%' bgcolor='#FFFFFF'><tr><td></td></tr></table><br>\n";
66         }
67 else {
68         # Generate categorized module list
69         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";
70         $usercol = defined($gconfig{'cs_header'}) ||
71                    defined($gconfig{'cs_table'}) ||
72                    defined($gconfig{'cs_page'});
73         foreach $c (@cats) {
74                 $t = $cats{$c};
75                 if ($in{'cat'} eq $c) {
76                         print "<td bgcolor=#bae3ff>",
77                           "<img src=images/tabs/blue_left.jpg alt=\"\">","</td>\n";
78                         print "<td bgcolor=#bae3ff>&nbsp;<b>$t</b>&nbsp;</td>\n";
79                         print "<td bgcolor=#bae3ff>",
80                           "<img src=images/tabs/blue_right.jpg alt=\"\">","</td>\n";
81                         }
82 #               print "<td width=10></td>\n";
83                 }
84         print "</tr></table> <table border=0 cellpadding=0 cellspacing=0 ",
85               "width=100% bgcolor=#FFFFFF background=images/msctile2.jpg>\n";
86         print "<tr><td><table width=100% cellpadding=5>\n";
87
88         # Display the modules in this category
89         $pos = 0;
90         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
91         $per = 100.0 / $cols;
92         foreach $m (@msc_modules) {
93                 next if ($m->{'category'} ne $in{'cat'});
94
95                 if ($pos % $cols == 0) { print "<tr>\n"; }
96                 print "<td valign=top align=center width=$per\%>\n";
97                 print "<table border bgcolor=#ffffff><tr><td><a href=$m->{'dir'}/>",
98                       "<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
99                       "</td></tr></table>\n";
100                 print "<a href=$m->{'dir'}/><font color=#000000>$m->{'desc'}</font></a></td>\n";
101                 if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
102                 }
103         while($pos++ % $cols) {
104                 print "<td width=$per\%></td>\n";
105                 }
106         print "</table></td></tr></table></td></tr></table>";
107
108     print qq~<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
109   <tr>
110     <td background="images/white_bar.jpg" nowrap><img src="images/white_bar.jpg"></td>
111   </tr>
112 </table>~;
113
114     print qq~<p><table width="98%" border="0" cellspacing="0" cellpadding="0" height="4" align="center">
115   <tr>
116     <td background="images/white_bar2.jpg" nowrap><img src="images/white_bar2.jpg"></td>
117   </tr>
118 </table><p>~;
119
120         }
121
122 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
123     !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
124     $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
125     print "<table width=95% align=center><tr><td width=100%><b><font color='#FFFFFF'>&nbsp;&nbsp;";
126     print &text('main_version', $ver, $hostname, $ostr)
127         if (!$gconfig{'nohostname'});
128     print "</font></b>\n";
129     print "</td>\n";
130
131     print "</tr></table>\n";
132         }
133
134 print $text{'main_footer'};
135 &footer();
136
137
138 sub chop_font {
139
140         foreach $l (split(//, $t)) {
141             $ll = ord($l);
142             if ($ll > 127 && $lang->{'charset'}) {
143                 print "<img src=images/letters2/$ll.$lang->{'charset'}.gif alt=\"$l\" align=bottom border=0>";
144                 }
145             elsif ($l eq " ") {
146                 print "<img src=images/letters2/$ll.gif alt=\"\&nbsp;\" align=bottom border=0>";
147                 }
148             else {
149                 print "<img src=images/letters2/$ll.gif alt=\"$l\" align=bottom border=0>";
150                 }
151             }
152
153 }