added new logo to default theme
[webmin.git] / index.cgi
1 #!/usr/local/bin/perl
2 # Display all Webmin modules visible to the current user
3
4 require './web-lib.pl';
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 %access = &get_module_acl();
21
22 # Build a list of all modules
23 @modules = &get_visible_module_infos();
24
25 if (!defined($in{'cat'})) {
26         # Maybe redirect to some module after login
27         local $goto = &get_goto_module(\@modules);
28         if ($goto) {
29                 &redirect($goto->{'dir'}.'/');
30                 exit;
31                 }
32         }
33
34 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
35 if ($gconfig{'alt_startpage'}) {
36         # Tim's webmin header
37         &header(&text('main_title', $ver, $hostname, $ostr));
38         print "<TABLE class='header' id='alt_startpage' BORDER=0 WIDTH=100%>\n";
39         print "<TR><TD WIDTH=20% ALIGN=left>\n";
40         print "Version $ver<BR>$hostname<BR>$ostr</TD>";
41         print "<TD WIDTH=60% ALIGN=center>\n";
42         print "<IMG SRC=\"images/newlogo.gif\" BORDER=0>";
43         print "</TD><TD WIDTH=20% ALIGN=right>";
44         print "<a href=http://www.webmin.com/>$text{'main_homepage'}</a><br>";
45         print "<a href=feedback_form.cgi>$text{'main_feedback'}</a>"
46                 if ($gconfig{'nofeedbackcc'} != 2 && $access{'feedback'});
47         if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
48             $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
49                 print "<br><br>\n";
50                 if ($main::session_id) {
51                         print "<a href='session_login.cgi?logout=1'>",
52                               "$text{'main_logout'}</a>";
53                         }
54                 else {
55                         print "<a href=switch_user.cgi>$text{'main_switch'}</a>";
56                         }
57                 }
58         print "</TD></TR></TABLE><HR id='header_hr'><P>\n\n";
59         }
60 else {
61         # Standard webmin header
62         if ($gconfig{'texttitles'}) {
63                 @args = ( $text{'main_title2'}, undef );
64                 }
65         else {
66                 @args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
67                             &text('main_title', $ver, $hostname, $ostr),
68                           "images/webmin-blue.png" );
69                 if ($gconfig{'showlogin'}) {
70                         $args[0] = $remote_user." : ".$args[0];
71                         }
72                 }
73         &header(@args, undef, undef, 1, 1,
74                 $tconfig{'brand'} ? 
75                 "<a href=$tconfig{'brand_url'}>$tconfig{'brand'}</a>" :
76                 $gconfig{'brand'} ? 
77                 "<a href=$gconfig{'brand_url'}>$gconfig{'brand'}</a>" :
78                 "<a href=http://www.webmin.com/>$text{'main_homepage'}</a>".
79                 ($gconfig{'nofeedbackcc'} == 2 || !$access{'feedback'} ? "" :
80                   "<br><a href=feedback_form.cgi>$text{'main_feedback'}</a>")
81                 );
82         print "<center><font size=+1>",
83             &text('main_version', $ver, $hostname, $ostr),"</font></center>\n"
84                 if (!$gconfig{'nohostname'});
85         print "<hr id='header_hr'><p>\n";
86         }
87 print $text{'main_header'};
88
89 if (!@modules) {
90         # use has no modules!
91         print "<p class='main_none'><b>$text{'main_none'}</b><p>\n";
92         }
93 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
94     $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
95         # Generate main menu with all modules on one page
96         print "<center><table id='mods' cellpadding=5 cellspacing=0 width=100%>\n";
97         $pos = 0;
98         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
99         $per = 100.0 / $cols;
100         foreach $m (@modules) {
101                 if ($pos % $cols == 0) { print "<tr $cb>\n"; }
102                 print "<td valign=top align=center width=$per\%>\n";
103                 local $idx = $m->{'index_link'};
104                 print "<table border><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
105                       "<img src=$m->{'dir'}/images/icon.gif border=0 ",
106                       "width=48 height=48></a></td></tr></table>\n";
107                 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
108                 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
109                 $pos++;
110                 }
111         print "</table></center><p><hr id='mods_hr'>\n";
112         }
113 else {
114         # Display under categorised tabs
115         &ReadParse();
116         %cats = &list_categories(\@modules);
117         @cats = sort { $b cmp $a } keys %cats;
118         $cats = @cats;
119         $per = $cats ? 100.0 / $cats : 100;
120         if (!defined($in{'cat'})) {
121                 # Use default category
122                 if (defined($gconfig{'deftab'}) &&
123                     &indexof($gconfig{'deftab'}, @cats) >= 0) {
124                         $in{'cat'} = $gconfig{'deftab'};
125                         }
126                 else {
127                         $in{'cat'} = $cats[0];
128                         }
129                 }
130         elsif (!$cats{$in{'cat'}}) {
131                 $in{'cat'} = "";
132                 }
133         print "<table id='cattabs' border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
134         $usercol = defined($gconfig{'cs_header'}) ||
135                    defined($gconfig{'cs_table'}) ||
136                    defined($gconfig{'cs_page'});
137         foreach $c (@cats) {
138                 $t = $cats{$c};
139                 if ($in{'cat'} eq $c) {
140                         print "<td class='usercoll' valign=top $cb>", $usercol ? "<br>" :
141                           "<img src=images/lc2.gif alt=\"\">","</td>\n";
142                         print "<td class='usercolc' id='selectedcat' $cb>&nbsp;<b>$t</b>&nbsp;</td>\n";
143                         print "<td class='usercolr' valign=top $cb>", $usercol ? "<br>" :
144                           "<img src=images/rc2.gif alt=\"\">","</td>\n";
145                         }
146                 else {
147                         print "<td class='usercoll' valign=top $tb>", $usercol ? "<br>" :
148                           "<img src=images/lc1.gif alt=\"\">","</td>\n";
149                         print "<td class='usercolc' $tb>&nbsp;",
150                               "<a href=$gconfig{'webprefix'}/?cat=$c><b>$t</b></a>&nbsp;</td>\n";
151                         print "<td class='usercolr' valign=top $tb>", $usercol ? "<br>" :
152                           "<img src=images/rc1.gif alt=\"\">","</td>\n";
153                         }
154                 print "<td width=10></td>\n";
155                 }
156         print "</tr></table> <table id='mods' border=0 cellpadding=0 cellspacing=0 ",
157               "width=100% $cb>\n";
158         print "<tr><td><table width=100% cellpadding=5>\n";
159
160         # Display the modules in this category
161         $pos = 0;
162         $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
163         $per = 100.0 / $cols;
164         foreach $m (@modules) {
165                 next if ($m->{'category'} ne $in{'cat'});
166
167                 if ($pos % $cols == 0) { print "<tr>\n"; }
168                 local $idx = $m->{'index_link'};
169                 print "<td valign=top align=center width=$per\%>\n";
170                 print "<table border bgcolor=#ffffff><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
171                       "<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
172                       "</td></tr></table>\n";
173                 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
174                 if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
175                 }
176         while($pos++ % $cols) {
177                 print "<td width=$per\%></td>\n";
178                 }
179         print "</table></td></tr></table><p><hr id='mods_hr'>\n";
180         }
181
182 # Check for incorrect OS
183 if (&foreign_available("webmin")) {
184         &foreign_require("webmin", "webmin-lib.pl");
185         %realos = &webmin::detect_operating_system(undef, 1);
186         if ($realos{'os_version'} ne $gconfig{'os_version'} ||
187             $realos{'os_type'} ne $gconfig{'os_type'}) {
188                 print "<form action=webmin/fix_os.cgi>\n";
189                 print "<p><center>",&webmin::text('os_incorrect',
190                         $realos{'real_os_type'},
191                         $realos{'real_os_version'}),"<p>\n";
192                 print "<input type=submit ",
193                       "value='$webmin::text{'os_fix'}'>\n";
194                 print "</center>\n";
195                 print "</form>\n";
196                 }
197         }
198
199 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
200     !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && !$ENV{'ANONYMOUS_USER'} &&
201     $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
202         print "<table id='altlogout' width=100% cellpadding=0 cellspacing=0><tr>\n";
203         if ($main::session_id) {
204                 print "<td align=right><a href='session_login.cgi?logout=1'>",
205                       "$text{'main_logout'}</a></td>\n";
206                 }
207         else {
208                 print "<td align=right><a href=switch_user.cgi>",
209                       "$text{'main_switch'}</a></td>\n";
210                 }
211         print "</tr></table>\n";
212         }
213
214 print $text{'main_footer'};
215 &footer();
216