Handle hostnames with upper-case letters
[webmin.git] / mscstyle_mini / 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         $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
11         }
12 else {
13         $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
14         }
15 &ReadParse();
16
17 # Redirect if the user has only one module
18 @msc_modules = &get_visible_module_infos()
19         if (!scalar(@msc_modules));
20 if (@msc_modules == 1 && $gconfig{'gotoone'}) {
21         &redirect("$msc_modules[0]->{'dir'}/");
22         exit;
23         }
24
25 # Show standard header
26 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
27 &header($gconfig{'nohostname'} ? $text{'main_title2'} :
28         &text('main_title', $ver, $hostname, $ostr), "",
29         undef, undef, 1, 1);
30
31 if (!@msc_modules) {
32         # use has no modules!
33         print "<p><b>$text{'main_none'}</b><p>\n";
34         }
35 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
36     $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
37         # Generate main menu with all modules on one page
38         print "<center><table cellpadding=0>\n";
39         $pos = 0;
40         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
41         $per = 100.0 / $cols;
42         foreach $m (@msc_modules) {
43                 if ($pos % $cols == 0) { print "<tr>\n"; }
44                 print "<td valign=top align=center>\n";
45                 print "<table border><tr><td><a href=/$m->{'dir'}/>",
46                       "<img src=$m->{'dir'}/images/icon.gif border=0 ",
47                       "width=20 height=20></a></td></tr></table>\n";
48                 print "<a href=/$m->{'dir'}/>$m->{'desc'}</a></td>\n";
49                 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
50                 $pos++;
51                 }
52         print "</table></center><p><table width='100%' bgcolor='#FFFFFF'><tr><td></td></tr></table>\n";
53         }
54 else {
55         # Generate categorized module list
56         print "<table border=0 cellpadding=0 cellspacing=0 width=100% align=center><tr><td><table border=0 cellpadding=0 cellspacing=0 width=100% height=20><tr>\n";
57         $usercol = defined($gconfig{'cs_header'}) ||
58                    defined($gconfig{'cs_table'}) ||
59                    defined($gconfig{'cs_page'});
60         foreach $c (@cats) {
61                 $t = $cats{$c};
62                 if ($in{'cat'} eq $c) {
63                         print "<td bgcolor=#424242><b><font color=#FFFFFF><center>$t</center></font></b></td>\n";
64                         }
65                 }
66         print "</tr></table>";
67 &make_sep;
68         print "<table width=100% cellpadding=5>\n";
69
70         # Display the modules in this category
71         foreach $m (@msc_modules) {
72                 next if ($m->{'category'} ne $in{'cat'});
73
74                 print "<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff><tr><td><a href=/$m->{'dir'}/>",
75                       "<img src=$m->{'dir'}/images/icon.gif alt=\"\" width=25 height=25 border=1></a>",
76                       "</td><td width=100% bgcolor=#9e9aa2>\n";
77                 print "&nbsp;<a href=/$m->{'dir'}/>"; &chop_font2; print "</a></td></tr></table>\n";
78 &make_sep;
79                 }
80
81         }
82
83 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
84     !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
85     $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
86         print "<table width=100% cellpadding=0 cellspacing=0><tr>\n";
87         if ($gconfig{'skill_'.$base_remote_user}) {
88                 print "<td><b>$text{'main_skill'}:</b>\n";
89                 foreach $s ('high', 'medium', 'low') {
90                         print "&nbsp;|&nbsp;" if ($done_first_skill++);
91                         if ($gconfig{'skill_'.$base_remote_user} eq $s) {
92                                 print $text{'skill_'.$s};
93                                 }
94                         else {
95                                 print "<a href='switch_skill.cgi?skill=$s&",
96                                    "cat=$in{'cat'}'>", "<font color=000000>", $text{'skill_'.$s},"</font></a>";
97                                 }
98                         }
99                 print "</td>\n";
100                 }
101         }
102
103 &footer();
104
105
106 sub chop_font {
107
108         foreach $l (split(//, $t)) {
109             $ll = ord($l);
110             if ($ll > 127 && $lang->{'charset'}) {
111                 print "<img src=images/letters2/$ll.$lang->{'charset'}.gif alt=\"$l\" align=bottom border=0>";
112                 }
113             elsif ($l eq " ") {
114                 print "<img src=images/letters2/$ll.gif alt=\"\&nbsp;\" align=bottom border=0>";
115                 }
116             else {
117                 print "<img src=images/letters2/$ll.gif alt=\"$l\" align=bottom border=0>";
118                 }
119             }
120
121 }
122
123 sub chop_font2 {
124
125         foreach $l (split(//, $m->{'desc'})) {
126             $ll = ord($l);
127             if ($ll > 127 && $lang->{'charset'}) {
128                 print "<img src=images/letters2/$ll.$lang->{'charset'}.gif alt=\"$l\" align=middle border=0>";
129                 }
130             elsif ($l eq " ") {
131                 print "<img src=images/letters2/$ll.gif alt=\"\&nbsp;\" align=middle border=0>";
132                 }
133             else {
134                 print "<img src=images/letters2/$ll.gif alt=\"$l\" align=middle border=0>";
135                 }
136             }
137
138 }
139