2 # Display all Webmin modules visible to the current user
4 BEGIN { push(@INC, ".."); };
8 $hostname = &get_display_hostname();
9 $ver = &get_webmin_version();
10 &get_miniserv_config(\%miniserv);
11 if ($gconfig{'real_os_type'}) {
12 if ($gconfig{'os_version'} eq "*") {
13 $ostr = $gconfig{'real_os_type'};
16 $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
20 $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
22 %access = &get_module_acl();
24 # Build a list of all modules
25 @modules = &get_visible_module_infos();
27 if (!defined($in{'cat'})) {
28 # Maybe redirect to some module after login
29 local $goto = &get_goto_module(\@modules);
31 &redirect($goto->{'dir'}.'/');
36 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
37 if ($gconfig{'alt_startpage'}) {
39 &header(&text('main_title', $ver, $hostname, $ostr));
40 print "<TABLE class='header' id='alt_startpage' BORDER=0 WIDTH=100%>\n";
41 print "<TR><TD WIDTH=20% ALIGN=left>\n";
42 print "Version $ver<BR>$hostname<BR>$ostr</TD>";
43 print "<TD WIDTH=60% ALIGN=center>\n";
44 print "<IMG SRC=\"images/newlogo.gif\" BORDER=0>";
45 print "</TD><TD WIDTH=20% ALIGN=right>";
46 print "<a href=http://www.webmin.com/>$text{'main_homepage'}</a><br>";
47 print "<a href=feedback_form.cgi>$text{'main_feedback'}</a>"
48 if ($gconfig{'nofeedbackcc'} != 2 && $access{'feedback'});
49 if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
50 $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
52 if ($main::session_id) {
53 print "<a href='session_login.cgi?logout=1'>",
54 "$text{'main_logout'}</a>";
57 print "<a href=switch_user.cgi>$text{'main_switch'}</a>";
60 print "</TD></TR></TABLE><HR id='header_hr'><P>\n\n";
63 # Standard webmin header
64 if ($gconfig{'texttitles'}) {
65 @args = ( $text{'main_title2'}, undef );
68 @args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
69 &text('main_title', $ver, $hostname, $ostr),
70 "images/webmin-blue.png" );
71 if ($gconfig{'showlogin'}) {
72 $args[0] = $remote_user." : ".$args[0];
75 &header(@args, undef, undef, 1, 1,
77 "<a href=$tconfig{'brand_url'}>$tconfig{'brand'}</a>" :
79 "<a href=$gconfig{'brand_url'}>$gconfig{'brand'}</a>" :
80 "<a href=http://www.webmin.com/>$text{'main_homepage'}</a>".
81 ($gconfig{'nofeedbackcc'} == 2 || !$access{'feedback'} ? "" :
82 "<br><a href=feedback_form.cgi>$text{'main_feedback'}</a>")
84 print "<center><font size=+1>",
85 &text('main_version', $ver, $hostname, $ostr),"</font></center>\n"
86 if (!$gconfig{'nohostname'});
87 print "<hr id='header_hr'><p>\n";
89 print $text{'main_header'};
93 print "<p class='main_none'><b>$text{'main_none'}</b><p>\n";
95 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
96 $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
97 # Generate main menu with all modules on one page
98 print "<center><table id='mods' cellpadding=5 cellspacing=0 width=100%>\n";
100 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
101 $per = 100.0 / $cols;
102 foreach $m (@modules) {
103 if ($pos % $cols == 0) { print "<tr $cb>\n"; }
104 print "<td valign=top align=center width=$per\%>\n";
105 local $idx = $m->{'index_link'};
106 print "<table border><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
107 "<img src=$m->{'dir'}/images/icon.gif border=0 ",
108 "width=48 height=48></a></td></tr></table>\n";
109 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
110 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
113 print "</table></center><p><hr id='mods_hr'>\n";
116 # Display under categorised tabs
118 %cats = &list_categories(\@modules);
119 @cats = sort { $b cmp $a } keys %cats;
121 $per = $cats ? 100.0 / $cats : 100;
122 if (!defined($in{'cat'})) {
123 # Use default category
124 if (defined($gconfig{'deftab'}) &&
125 &indexof($gconfig{'deftab'}, @cats) >= 0) {
126 $in{'cat'} = $gconfig{'deftab'};
129 $in{'cat'} = $cats[0];
132 elsif (!$cats{$in{'cat'}}) {
135 print "<table id='cattabs' border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
136 $usercol = defined($gconfig{'cs_header'}) ||
137 defined($gconfig{'cs_table'}) ||
138 defined($gconfig{'cs_page'});
141 if ($in{'cat'} eq $c) {
142 print "<td class='usercoll' valign=top $cb>", $usercol ? "<br>" :
143 "<img src=images/lc2.gif alt=\"\">","</td>\n";
144 print "<td class='usercolc' id='selectedcat' $cb> <b>$t</b> </td>\n";
145 print "<td class='usercolr' valign=top $cb>", $usercol ? "<br>" :
146 "<img src=images/rc2.gif alt=\"\">","</td>\n";
149 print "<td class='usercoll' valign=top $tb>", $usercol ? "<br>" :
150 "<img src=images/lc1.gif alt=\"\">","</td>\n";
151 print "<td class='usercolc' $tb> ",
152 "<a href=$gconfig{'webprefix'}/?cat=$c><b>$t</b></a> </td>\n";
153 print "<td class='usercolr' valign=top $tb>", $usercol ? "<br>" :
154 "<img src=images/rc1.gif alt=\"\">","</td>\n";
156 print "<td width=10></td>\n";
158 print "</tr></table> <table id='mods' border=0 cellpadding=0 cellspacing=0 ",
160 print "<tr><td><table width=100% cellpadding=5>\n";
162 # Display the modules in this category
164 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
165 $per = 100.0 / $cols;
166 foreach $m (@modules) {
167 next if ($m->{'category'} ne $in{'cat'});
169 if ($pos % $cols == 0) { print "<tr>\n"; }
170 local $idx = $m->{'index_link'};
171 print "<td valign=top align=center width=$per\%>\n";
172 print "<table border bgcolor=#ffffff><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
173 "<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
174 "</td></tr></table>\n";
175 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
176 if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
178 while($pos++ % $cols) {
179 print "<td width=$per\%></td>\n";
181 print "</table></td></tr></table><p><hr id='mods_hr'>\n";
184 # Check for incorrect OS
185 if (&foreign_check("webmin")) {
186 &foreign_require("webmin", "webmin-lib.pl");
187 &webmin::show_webmin_notifications();
190 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
191 !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && !$ENV{'ANONYMOUS_USER'} &&
192 $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
193 print "<table id='altlogout' width=100% cellpadding=0 cellspacing=0><tr>\n";
194 if ($main::session_id) {
195 print "<td align=right><a href='session_login.cgi?logout=1'>",
196 "$text{'main_logout'}</a></td>\n";
199 print "<td align=right><a href=switch_user.cgi>",
200 "$text{'main_switch'}</a></td>\n";
202 print "</tr></table>\n";
205 print $text{'main_footer'};