2 # Display all Webmin modules visible to the current user
4 BEGIN { push(@INC, ".."); };
9 $hostname = &get_display_hostname();
10 $ver = &get_webmin_version();
11 &get_miniserv_config(\%miniserv);
12 if ($gconfig{'real_os_type'}) {
13 if ($gconfig{'os_version'} eq "*") {
14 $ostr = $gconfig{'real_os_type'};
17 $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
21 $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
23 %access = &get_module_acl();
25 # Build a list of all modules
26 @modules = &get_visible_module_infos();
28 if (!defined($in{'cat'})) {
29 # Maybe redirect to some module after login
30 local $goto = &get_goto_module(\@modules);
32 &redirect($goto->{'dir'}.'/');
37 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
38 if ($gconfig{'alt_startpage'}) {
40 &header(&text('main_title', $ver, $hostname, $ostr));
41 print "<TABLE class='header' id='alt_startpage' BORDER=0 WIDTH=100%>\n";
42 print "<TR><TD WIDTH=20% ALIGN=left>\n";
43 print "Version $ver<BR>$hostname<BR>$ostr</TD>";
44 print "<TD WIDTH=60% ALIGN=center>\n";
45 print "<IMG SRC=\"images/newlogo.gif\" BORDER=0>";
46 print "</TD><TD WIDTH=20% ALIGN=right>";
47 print "<a href=http://www.webmin.com/>$text{'main_homepage'}</a><br>";
48 print "<a href=feedback_form.cgi>$text{'main_feedback'}</a>"
49 if ($gconfig{'nofeedbackcc'} != 2 && $access{'feedback'});
50 if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
51 $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
53 if ($main::session_id) {
54 print "<a href='session_login.cgi?logout=1'>",
55 "$text{'main_logout'}</a>";
58 print "<a href=switch_user.cgi>$text{'main_switch'}</a>";
61 print "</TD></TR></TABLE><HR id='header_hr'><P>\n\n";
64 # Standard webmin header
65 if ($gconfig{'texttitles'}) {
66 @args = ( $text{'main_title2'}, undef );
69 @args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
70 &text('main_title', $ver, $hostname, $ostr),
71 "images/webmin-blue.png" );
72 if ($gconfig{'showlogin'}) {
73 $args[0] = $remote_user." : ".$args[0];
76 &header(@args, undef, undef, 1, 1,
78 "<a href=$tconfig{'brand_url'}>$tconfig{'brand'}</a>" :
80 "<a href=$gconfig{'brand_url'}>$gconfig{'brand'}</a>" :
81 "<a href=http://www.webmin.com/>$text{'main_homepage'}</a>".
82 ($gconfig{'nofeedbackcc'} == 2 || !$access{'feedback'} ? "" :
83 "<br><a href=feedback_form.cgi>$text{'main_feedback'}</a>")
85 print "<center><font size=+1>",
86 &text('main_version', $ver, $hostname, $ostr),"</font></center>\n"
87 if (!$gconfig{'nohostname'});
88 print "<hr id='header_hr'><p>\n";
90 print $text{'main_header'};
94 print "<p class='main_none'><b>$text{'main_none'}</b><p>\n";
96 elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
97 $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
98 # Generate main menu with all modules on one page
99 print "<center><table id='mods' cellpadding=5 cellspacing=0 width=100%>\n";
101 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
102 $per = 100.0 / $cols;
103 foreach $m (@modules) {
104 if ($pos % $cols == 0) { print "<tr $cb>\n"; }
105 print "<td valign=top align=center width=$per\%>\n";
106 local $idx = $m->{'index_link'};
107 print "<table border><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
108 "<img src=$m->{'dir'}/images/icon.gif border=0 ",
109 "width=48 height=48></a></td></tr></table>\n";
110 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
111 if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
114 print "</table></center><p><hr id='mods_hr'>\n";
117 # Display under categorised tabs
119 %cats = &list_categories(\@modules);
120 @cats = sort { $b cmp $a } keys %cats;
122 $per = $cats ? 100.0 / $cats : 100;
123 if (!defined($in{'cat'})) {
124 # Use default category
125 if (defined($gconfig{'deftab'}) &&
126 &indexof($gconfig{'deftab'}, @cats) >= 0) {
127 $in{'cat'} = $gconfig{'deftab'};
130 $in{'cat'} = $cats[0];
133 elsif (!$cats{$in{'cat'}}) {
136 print "<table id='cattabs' border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
137 $usercol = defined($gconfig{'cs_header'}) ||
138 defined($gconfig{'cs_table'}) ||
139 defined($gconfig{'cs_page'});
142 if ($in{'cat'} eq $c) {
143 print "<td class='usercoll' valign=top $cb>", $usercol ? "<br>" :
144 "<img src=images/lc2.gif alt=\"\">","</td>\n";
145 print "<td class='usercolc' id='selectedcat' $cb> <b>$t</b> </td>\n";
146 print "<td class='usercolr' valign=top $cb>", $usercol ? "<br>" :
147 "<img src=images/rc2.gif alt=\"\">","</td>\n";
150 print "<td class='usercoll' valign=top $tb>", $usercol ? "<br>" :
151 "<img src=images/lc1.gif alt=\"\">","</td>\n";
152 print "<td class='usercolc' $tb> ",
153 "<a href=$gconfig{'webprefix'}/?cat=$c><b>$t</b></a> </td>\n";
154 print "<td class='usercolr' valign=top $tb>", $usercol ? "<br>" :
155 "<img src=images/rc1.gif alt=\"\">","</td>\n";
157 print "<td width=10></td>\n";
159 print "</tr></table> <table id='mods' border=0 cellpadding=0 cellspacing=0 ",
161 print "<tr><td><table width=100% cellpadding=5>\n";
163 # Display the modules in this category
165 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
166 $per = 100.0 / $cols;
167 foreach $m (@modules) {
168 next if ($m->{'category'} ne $in{'cat'});
170 if ($pos % $cols == 0) { print "<tr>\n"; }
171 local $idx = $m->{'index_link'};
172 print "<td valign=top align=center width=$per\%>\n";
173 print "<table border bgcolor=#ffffff><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
174 "<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
175 "</td></tr></table>\n";
176 print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
177 if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
179 while($pos++ % $cols) {
180 print "<td width=$per\%></td>\n";
182 print "</table></td></tr></table><p><hr id='mods_hr'>\n";
185 # Check for incorrect OS
186 if (&foreign_check("webmin")) {
187 &foreign_require("webmin", "webmin-lib.pl");
188 &webmin::show_webmin_notifications();
191 if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
192 !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && !$ENV{'ANONYMOUS_USER'} &&
193 $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
194 print "<table id='altlogout' width=100% cellpadding=0 cellspacing=0><tr>\n";
195 if ($main::session_id) {
196 print "<td align=right><a href='session_login.cgi?logout=1'>",
197 "$text{'main_logout'}</a></td>\n";
200 print "<td align=right><a href=switch_user.cgi>",
201 "$text{'main_switch'}</a></td>\n";
203 print "</tr></table>\n";
206 print $text{'main_footer'};