\n";
my $selwidth = (get_left_frame_width() - 70)."px";
if ($mode eq "modules") {
# Only showing Webmin modules
@leftitems = &list_modules_webmin_menu();
foreach my $l (@leftitems) {
$l->{'members'} = [ grep { !$modmenu{$_->{'id'}} } @{$l->{'members'}} ];
}
push(@leftitems, { 'type' => 'hr' });
}
else {
# Only show items under some title OR items that have no title
my ($lefttitle) = grep { $_->{'id'} eq $mode } @lefttitles;
my %titlemods = map { $_->{'module'}, $_ } @lefttitles;
@leftitems = grep { $_->{'module'} eq $mode ||
!$titlemods{$_->{'module'}} } @leftitems;
}
# Show Webmin search form
my $cansearch = ($gaccess{'webminsearch'} || '') ne '0' &&
!$sects->{'nosearch'};
if ($mode eq "modules" && $cansearch) {
push(@leftitems, { 'type' => 'input',
'desc' => ' ',
'tags' => " placeholder='$text{'left_search'}' style='width: 92%;'",
'size' => 10,
'name' => 'search',
'cgi' => '/webmin_search.cgi', });
push(@leftitems, { 'type' => 'hr' });
}
# Show system information link
push(@leftitems, { 'type' => 'item',
'id' => 'home',
'desc' => $text{'left_home'},
'link' => '/right.cgi',
'icon' => '/images/gohome.png' });
# Show refresh modules link
if ($mode eq "modules" && foreign_available("webmin")) {
push(@leftitems, { 'type' => 'item',
'id' => 'refresh',
'desc' => $text{'main_refreshmods'},
'link' => '/webmin/refresh_modules.cgi',
'icon' => '/images/reload.png' });
}
# Show logout link
get_miniserv_config(\%miniserv);
if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
$ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
my $logout = { 'type' => 'item',
'id' => 'logout',
'target' => 'window',
'icon' => '/images/stock_quit.png' };
if ($main::session_id) {
$logout->{'desc'} = $text{'main_logout'};
$logout->{'link'} = '/session_login.cgi?logout=1';
}
else {
$logout->{'desc'} = $text{'main_switch'};
$logout->{'link'} = '/switch_user.cgi';
}
push(@leftitems, $logout);
}
# Show link back to original Webmin server
if ($ENV{'HTTP_WEBMIN_SERVERS'}) {
push(@leftitems, { 'type' => 'item',
'desc' => $text{'header_servers'},
'link' => $ENV{'HTTP_WEBMIN_SERVERS'},
'icon' => '/images/webmin-small.gif',
'target' => 'window' });
}
show_menu_items_list(\@leftitems, 0);
print "
\n";
print <
(function() {
var imgs = document.querySelectorAll('img[src]'),
mailfolders = 0;
imgs.forEach(function(img) {
var i = document.createElement("i");
if (img.src) {
if (img.src.includes('webmin-small.png')) {
i.classList.add('ff', 'ff-webmin');
} else if (img.src.includes('usermin-small.png')) {
i.classList.add('ff', 'ff-webmin', 'ff-usermin');
} else if (img.src.includes('virtualmin.png')) {
i.classList.add('ff', 'ff-virtualmin');
} else if (img.src.includes('vm2.png')) {
i.classList.add('ff', 'ff-cloudmin');
} else if (img.src.includes('index.png')) {
i.classList.add('ff', 'ff-fw', 'ff-virtualmin-tick');
} else if (img.src.includes('graph.png')) {
i.classList.add('ff', 'ff-fw', 'ff-chart');
} else if (img.src.includes('gohome.png')) {
i.classList.add('ff', 'ff-fw', 'ff-home');
} else if (img.src.includes('stock_quit.png')) {
i.classList.add('ff', 'ff-fw', 'ff-sign-out');
} else if (img.src.includes('reload.png')) {
i.classList.add('ff', 'ff-fw', 'ff-refresh');
} else if (img.src.includes('mail.') && !mailfolders) {
i.classList.add('ff', 'ff-mail');
mailfolders = 1;
} else if (img.src.includes('mail.') && mailfolders) {
i.classList.add('ff', 'ff-folder-open');
} else if (img.src.includes('address.')) {
i.classList.add('ff', 'ff-address-book');
} else if (img.src.includes('address.')) {
i.classList.add('ff', 'ff-address-book');
} else if (img.src.includes('sig.')) {
i.classList.add('ff', 'ff-signature');
} else if (img.src.includes('changepass.')) {
i.classList.add('ff', 'ff-lock');
}
if (i.classList.length) {
img.replaceWith(i);
}
}
});
var inputs = document.querySelectorAll('input[src]');
inputs.forEach(function(input) {
var b = document.createElement("button"),
i = document.createElement("i");
if (input.src) {
if (input.src.includes('ok.png')) {
i.classList.add('ff', 'ff-play-circle');
b.type = 'submit';
b.classList.add('servers-submit');
b.appendChild(i);
input.replaceWith(b);
}
}
});
})();
EOF
print "
\n";
popup_footer();
# show_menu_items_list(&list, indent)
# Actually prints the HTML for menu items
sub show_menu_items_list
{
my ($items, $indent) = @_;
foreach my $item (@$items) {
if ($item->{'type'} eq 'item') {
# Link to some page
my $it = $item->{'target'} || '';
my $t = $it eq 'new' ? '_blank' :
$it eq 'window' ? '_top' : 'right';
my $link = add_webprefix($item->{'link'});
if ($item->{'link'} =~ /^(https?):\/\//) {
$t = '_blank';
$link = $item->{'link'};
}
if ($item->{'icon'}) {
my $icon = add_webprefix($item->{'icon'});
print "
";
}
print "\n";
}
elsif ($item->{'type'} eq 'cat') {
# Start of a new category
my $c = $item->{'id'};
print "";
print "$item->{'desc'}";
show_menu_items_list($item->{'members'}, $indent+1);
print "\n";
}
elsif ($item->{'type'} eq 'html') {
# Some HTML block
print "
",$item->{'html'},"
\n";
}
elsif ($item->{'type'} eq 'text') {
# A line of text
print "
",
html_escape($item->{'desc'}),"
\n";
}
elsif ($item->{'type'} eq 'hr') {
# Separator line
print "\n";
}
elsif ($item->{'type'} eq 'menu' || $item->{'type'} eq 'input') {
# For with an input of some kind
if ($item->{'cgi'}) {
my $cgi = add_webprefix($item->{'cgi'});
print "\n";
}
elsif ($item->{'type'} eq 'title') {
# Nothing to print here, as it is used for the tab title
}
}
}
# module_to_menu_item(&module)
# Converts a module to the hash ref format expected by show_menu_items_list
sub module_to_menu_item
{
my ($minfo) = @_;
return { 'type' => 'item',
'id' => $minfo->{'dir'},
'desc' => $minfo->{'desc'},
'link' => '/'.$minfo->{'dir'}.'/' };
}
# add_webprefix(link)
# If a URL starts with a / , add webprefix
sub add_webprefix
{
my ($link) = @_;
return $link =~ /^\// ? &get_webprefix().$link : $link;
}