2 # Display all Webmin modules visible to the current user
4 require './web-lib.pl';
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'};
14 $ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
18 $ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
20 %access = &get_module_acl();
22 # Build a list of all modules
23 @modules = &get_visible_module_infos();
25 if (!defined($in{'cat'})) {
26 # Maybe redirect to some module after login
27 local $goto = &get_goto_module(\@modules);
29 &redirect($goto->{'dir'}.'/');
34 $gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
35 if ($gconfig{'alt_startpage'}) {
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) {
50 if ($main::session_id) {
51 print "<a href='session_login.cgi?logout=1'>",
52 "$text{'main_logout'}</a>";
55 print "<a href=switch_user.cgi>$text{'main_switch'}</a>";
58 print "</TD></TR></TABLE><HR id='header_hr'><P>\n\n";
61 # Standard webmin header
62 if ($gconfig{'texttitles'}) {
63 @args = ( $text{'main_title2'}, undef );
66 @args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
67 &text('main_title', $ver, $hostname, $ostr),
68 "images/newlogo.gif" );
69 if ($gconfig{'showlogin'}) {
70 $args[0] = $remote_user." : ".$args[0];
73 &header(@args, undef, undef, 1, 1,
75 "<a href=$tconfig{'brand_url'}>$tconfig{'brand'}</a>" :
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>")
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";
87 print $text{'main_header'};
91 print "<p class='main_none'><b>$text{'main_none'}</b><p>\n";
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";
98 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
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"; }
111 print "</table></center><p><hr id='mods_hr'>\n";
114 # Display under categorised tabs
116 %cats = &list_categories(\@modules);
117 @cats = sort { $b cmp $a } keys %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'};
127 $in{'cat'} = $cats[0];
130 elsif (!$cats{$in{'cat'}}) {
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'});
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> <b>$t</b> </td>\n";
143 print "<td class='usercolr' valign=top $cb>", $usercol ? "<br>" :
144 "<img src=images/rc2.gif alt=\"\">","</td>\n";
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> ",
150 "<a href=$gconfig{'webprefix'}/?cat=$c><b>$t</b></a> </td>\n";
151 print "<td class='usercolr' valign=top $tb>", $usercol ? "<br>" :
152 "<img src=images/rc1.gif alt=\"\">","</td>\n";
154 print "<td width=10></td>\n";
156 print "</tr></table> <table id='mods' border=0 cellpadding=0 cellspacing=0 ",
158 print "<tr><td><table width=100% cellpadding=5>\n";
160 # Display the modules in this category
162 $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
163 $per = 100.0 / $cols;
164 foreach $m (@modules) {
165 next if ($m->{'category'} ne $in{'cat'});
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"; }
176 while($pos++ % $cols) {
177 print "<td width=$per\%></td>\n";
179 print "</table></td></tr></table><p><hr id='mods_hr'>\n";
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";
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";
208 print "<td align=right><a href=switch_user.cgi>",
209 "$text{'main_switch'}</a></td>\n";
211 print "</tr></table>\n";
214 print $text{'main_footer'};