Handle hostnames with upper-case letters
[webmin.git] / caldera / index_top.cgi
1 #!/usr/local/bin/perl
2 # index_top.cgi
3 # Display the top frame using the Caldera icons and style
4
5 BEGIN { push(@INC, ".."); };
6 use WebminCore;
7 &init_config();
8 $hostname = &get_display_hostname();
9 $ver = &get_webmin_version();
10 &ReadParse();
11 if ($gconfig{'real_os_type'}) {
12         $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
13         }
14 else {
15         $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
16         }
17
18 # Build a list of all modules
19 @modules = &get_visible_module_infos();
20
21 # Work out what categories exist, and which is current
22 %cats = &list_categories(\@modules);
23 @cats = sort { $b cmp $a } keys %cats;
24 $cats = @cats;
25 $per = $cats ? 100.0 / $cats : 100;
26 if (!defined($in{'cat'})) {
27         # Use default category
28         if (defined($gconfig{'deftab'})) {
29                 $in{'cat'} = $gconfig{'deftab'};
30                 }
31         else {
32                 $in{'cat'} = $cats[0];
33                 }
34         }
35 elsif (!$cats{$in{'cat'}}) {
36         $in{'cat'} = "";
37         }
38
39 # Display title and categories
40 &PrintHeader();
41 print <<EOF;
42 <!doctype html public \"-//W3C//DTD HTML 3.2 Final//EN\">
43 <HTML>
44
45 <HEAD>
46 <LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
47 </HEAD>
48
49 <BODY LINK="#FFFFFF" VLINK="#FFFFFF" MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" TOPMARGIN="0" BACKGROUND="images/navbg.gif">
50
51   <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="1">
52     <TR>
53       <TD HEIGHT="35"  VALIGN="top" ALIGN="left" WIDTH=100% background="images/webmin-header.gif"><br></TD>
54       <TD WIDTH="100%" HEIGHT="1" ALIGN="LEFT" VALIGN="BOTTOM" BACKGROUND="images/navbg.gif">
55         <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BACKGROUND="images/blue-bg.gif" WIDTH="100%">
56           <TR>
57 EOF
58 foreach $c (@cats) {
59         if ($in{'cat'} eq $c) {
60                 print "<TD width=1% HEIGHT=24 BACKGROUND=images/folder-on.gif VALIGN=TOP ALIGN=LEFT><IMG SRC=images/spacer.gif HEIGHT=6 WIDTH=72><BR><NOBR><IMG SRC=images/spacer.gif WIDTH=6 HEIGHT=1><TABLE WIDTH=72 CELLPADDING=0 CELLSPACING=0 BORDER=0 BACKGROUND=''><TR><TD><CENTER><SPAN CLASS=navActive2>$cats{$c}</SPAN></CENTER></TD></TR></TABLE></NOBR></TD>\n";
61                 }
62         else {
63                 print "<TD width=1% HEIGHT=24 BACKGROUND=images/folder-off.gif VALIGN=TOP ALIGN=LEFT><IMG SRC=images/spacer.gif HEIGHT=6 WIDTH=72><BR><NOBR><IMG SRC=images/spacer.gif WIDTH=6 HEIGHT=1><TABLE WIDTH=72 CELLPADDING=0 CELLSPACING=0 BORDER=0 BACKGROUND=''><TR><TD><CENTER><A TARGET=top HREF='index_top.cgi?cat=$c' CLASS=navInactive>$cats{$c}</A></CENTER></TD></TR></TABLE></NOBR></TD>\n";
64                 }
65         }
66 $vtext =&text('main_title', $ver, $hostname, $ostr)
67         if (!$gconfig{'nohostname'});
68 if ($main::session_id) {
69         $switch = "<a href='session_login.cgi?logout=1' target=_top CLASS=bodyNav>".
70                   "$text{'main_logout'}</a>";
71         }
72 else {
73         $switch = "<a href=switch_user.cgi target=_top CLASS=bodyNav>".
74                   "$text{'main_switch'}</a>";
75         }
76 print <<EOF;
77 <TD WIDTH=1% HEIGHT="24" BACKGROUND="images/folder-off.gif" VALIGN="TOP" ALIGN="RIGHT"><IMG SRC="images/spacer.gif" HEIGHT="6" WIDTH="80"><BR><NOBR><A TARGET="_top" HREF="http://www.calderasystems.com/" CLASS="navInactive2">Home</A><SPAN CLASS="bodyText"> | </SPAN><A HREF="mailto:support\@calderasystems.com" CLASS="navInactive2">Feedback</A><IMG SRC="images/spacer.gif" HEIGHT="1" WIDTH="6"></NOBR></TD></TR></TABLE></TD>
78           </TR>
79         </TABLE>
80       </TD>
81     </TR>
82     <TR>
83       <TD COLSPAN="2" WIDTH="100%" HEIGHT="19">
84         <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
85           <TR>
86             <TD BACKGROUND="images/gradient-bg.gif" WIDTH="75%" HEIGHT="19"><IMG SRC="images/spacer.gif" WIDTH="95" HEIGHT="1"><SPAN CLASS="EightPoint"><NOBR>$vtext</NOBR></SPAN></TD>
87             <TD BACKGROUND="images/main-bg-pixel.gif" WIDTH="25%" HEIGHT="19" ALIGN=RIGHT>$switch</TD>
88           </TR>
89         </TABLE>
90       </TD>
91     </TR>
92     <TR>
93       <TD BACKGROUND="images/main-bg-pixel.gif" COLSPAN="2" WIDTH="100%" VALIGN="TOP" ALIGN="LEFT">
94           <TABLE BACKGROUND="images/main-bg-pixel.gif" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
95 EOF
96
97 # Display icons in this category
98 $pos = 0;
99 foreach $m (@modules) {
100         next if ($m->{'category'} ne $in{'cat'});
101         if ($pos % 3 == 0) { print "<tr>\n"; }
102         local $lnk = $m->{'index_link'};
103         local $img = -r "$theme_root_directory/$m->{'dir'}/images/icon.gif" ?
104                                 "/$m->{'dir'}/images/icon.gif" :
105                                 "/template.gif";
106         print "<TD width=1%><A TARGET=body HREF='$gconfig{'webprefix'}/$m->{'dir'}/$lnk'><IMG SRC='$gconfig{'webprefix'}$img' WIDTH=55 HEIGHT=24 BORDER=0></A></TD><TD WIDTH=32%><A TARGET=body HREF='$gconfig{'webprefix'}/$m->{'dir'}/$lnk' CLASS=bodyNav>$m->{'desc'}</A></TD>\n";
107         if ($pos++ % 3 == 2) { print "</tr>\n"; }
108         }
109
110 print <<EOF;
111 <TR> <TD COLSPAN="6"><IMG SRC="images/spacer.gif" WIDTH="10" HEIGHT="100"></TD> </TR>
112 </TABLE> </TD> </TR> </TABLE>
113 </BODY>
114 </HTML>
115 EOF
116