Edit: /usr/share/usermin/index.cgi (5781B)
#!/usr/bin/perl
require './web-lib.pl';
&init_config();
&ReadParse();
$hostname = &get_display_hostname();
$ver = &get_webmin_version();
&get_miniserv_config(\%miniserv);
if ($gconfig{'real_os_type'}) {
$ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
}
else {
$ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
}
# Build a list of all modules
@modules = &get_available_module_infos(1);
if (!defined($in{'cat'})) {
# Maybe redirect to some module after login
local $goto = &get_goto_module(\@modules);
if ($goto) {
&redirect($goto->{'dir'}.'/');
exit;
}
}
$gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
if ($gconfig{'texttitles'}) {
@args = ( $text{'main_title2'}, undef );
}
else {
@args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
&text('main_title', $ver, $hostname, $ostr),
"images/usermin.gif" );
}
&header(@args, undef, undef, 1, 1,
$tconfig{'brand'} ?
"
$tconfig{'brand'}" :
$gconfig{'brand'} ?
"
$gconfig{'brand'}" :
"
$text{'main_homepage'}".
($gconfig{'feedback'} ? "
$text{'main_feedback'}" : "")
);
print "
",
&text('main_version', $ver, $hostname, $ostr),"\n"
if (!$gconfig{'nohostname'});
print "
\n";
print $text{'main_header'};
if (!@modules) {
# use has no modules!
print "
$text{'main_none'}
\n";
}
elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
$gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
# Generate main menu with all modules on one page
print "
\n";
$pos = 0;
$cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
$per = 100.0 / $cols;
foreach $m (@modules) {
if ($pos % $cols == 0) { print "\n"; }
print "| \n";
local $idx = $m->{'index_link'};
my $alink = "$gconfig{'webprefix'}/@{[&urlize($m->{'dir'})]}/$idx";
print "\n";
print "@{[&html_escape($m->{'desc'})]} | \n";
if ($pos % $cols == $cols - 1) { print "
\n"; }
$pos++;
}
print "
\n";
}
else {
# Display under categorised tabs
&read_file("$config_directory/webmin.catnames", \%catnames);
foreach $m (@modules) {
$c = $m->{'category'};
next if ($cats{$c});
if (defined($catnames{$c})) {
$cats{$c} = $catnames{$c};
}
elsif ($text{"category_$c"}) {
$cats{$c} = $text{"category_$c"};
}
else {
# try to get category name from module ..
local %mtext = &load_language($m->{'dir'});
if ($mtext{"category_$c"}) {
$cats{$c} = $mtext{"category_$c"};
}
else {
$c = $m->{'category'} = "";
$cats{$c} = $text{"category_$c"};
}
}
}
@cats = sort { $b cmp $a } keys %cats;
$cats = @cats;
$per = $cats ? 100.0 / $cats : 100;
if (!defined($in{'cat'})) {
# Use default category
if (defined($gconfig{'deftab'}) &&
&indexof($gconfig{'deftab'}, @cats) >= 0) {
$in{'cat'} = $gconfig{'deftab'};
}
else {
$in{'cat'} = $cats[0];
}
}
elsif (!$cats{$in{'cat'}}) {
$in{'cat'} = "";
}
print "
\n";
$usercol = defined($gconfig{'cs_header'}) ||
defined($gconfig{'cs_table'}) ||
defined($gconfig{'cs_page'});
foreach $c (@cats) {
$t = $cats{$c};
if ($in{'cat'} eq $c) {
print "", $usercol ? " " :
" "," | \n";
print " $t | \n";
print "", $usercol ? " " :
" "," | \n";
}
else {
print "", $usercol ? " " :
" "," | \n";
print " ",
"@{[&html_escape($t)]} | \n";
print "", $usercol ? " " :
" "," | \n";
}
print " | \n";
}
print "
\n";
print "\n";
# Display the modules in this category
$pos = 0;
$cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
$per = 100.0 / $cols;
foreach $m (@modules) {
next if ($m->{'category'} ne $in{'cat'});
if ($pos % $cols == 0) { print "\n"; }
print "| \n";
my $mlink = "$gconfig{'webprefix'}/@{[&urlize($m->{'dir'})]}/";
print "\n";
print "@{[&html_escape($m->{'desc'})]} | \n";
if ($pos++ % $cols == $cols - 1) { print " \n"; }
}
while($pos++ % $cols) {
print " | \n";
}
print " |
\n";
}
if ($miniserv{'logout'} && !$gconfig{'alt_startpage'} &&
!$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
$ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
print "
\n";
}
print $text{'main_footer'};
&footer();