#!/usr/bin/perl
# Show the left-side menu of Webmin modules
use strict;
use warnings;
require 'old-blue-theme/blue-theme-lib.pl';
&ReadParse();
our ($current_theme, $remote_user, %gconfig);
our %text = &load_language($current_theme);
my %gaccess = &get_module_acl(undef, "");
&popup_header();
print <
EOF
# Show login
my @leftmenu;
push(@leftmenu, { 'type' => 'text',
'desc' => &text('left_login', $remote_user) });
push(@leftmenu, { 'type' => 'hr' });
# Webmin modules
push(@leftmenu, &list_modules_webmin_menu());
# Show module/help search form
if ($gaccess{'webminsearch'}) {
push(@leftmenu, { 'type' => 'input',
'cgi' => &get_webprefix().'/webmin_search.cgi',
'name' => 'search',
'desc' => $text{'left_search'},
'size' => 15 });
}
push(@leftmenu, { 'type' => 'hr' });
# Show current module's log search, if logging
if ($gconfig{'log'} && &foreign_available("webminlog")) {
push(@leftmenu, { 'type' => 'item',
'desc' => $text{'left_logs'},
'link' => '/webminlog/',
'icon' => '/images/logs.gif',
'onclick' => 'show_logs(); return false;' });
}
# Show info link
push(@leftmenu, { 'type' => 'item',
'desc' => $text{'left_home'},
'link' => '/right.cgi',
'icon' => '/images/gohome.gif' });
# Show feedback link, but only if a custom email is set
%gaccess = &get_module_acl(undef, "");
if (&get_product_name() eq 'webmin' && # For Webmin
!$ENV{'ANONYMOUS_USER'} &&
$gconfig{'nofeedbackcc'} != 2 &&
$gaccess{'feedback'} &&
$gconfig{'feedback_to'} ||
&get_product_name() eq 'usermin' && # For Usermin
!$ENV{'ANONYMOUS_USER'} &&
$gconfig{'feedback'}
) {
push(@leftmenu, { 'type' => 'item',
'desc' => $text{'left_feedback'},
'link' => '/feedback_form.cgi',
'icon' => '/images/mail-small.gif' });
}
# Show refresh modules link, for master admin
if (&foreign_available("webmin")) {
push(@leftmenu, { 'type' => 'item',
'desc' => $text{'main_refreshmods'},
'link' => '/webmin/refresh_modules.cgi',
'icon' => '/images/refresh-small.gif' });
}
# Show logout link
my %miniserv;
&get_miniserv_config(\%miniserv);
if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
$ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
my $logout = { 'type' => 'item',
'icon' => '/images/stock_quit.gif',
'target' => 'window' };
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(@leftmenu, $logout);
}
# Show link back to original Webmin server
if ($ENV{'HTTP_WEBMIN_SERVERS'}) {
push(@leftmenu, { 'type' => 'item',
'desc' => $text{'header_servers'},
'link' => $ENV{'HTTP_WEBMIN_SERVERS'},
'icon' => '/images/webmin-small.gif',
'target' => 'window' });
}
# Actually output the menu
print "\n";
print "
| \n";
&show_menu_items_list(\@leftmenu, 0);
print " |
\n";
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 $t = $item->{'target'} eq 'new' ? '_blank' :
$item->{'target'} eq 'window' ? '_top' : 'right';
if ($item->{'icon'}) {
my $icon = add_webprefix($item->{'icon'});
print "".
"

\n";
}
my $cls = $item->{'icon'} ? 'aftericon' :
$indent ? 'linkindented' : 'leftlink';
print "
";
my $link = add_webprefix($item->{'link'});
my $tags = $item->{'onclick'} ?
"onClick='".$item->{'onclick'}."'" : "";
print "
".
"$item->{'desc'}";
print "
";
if ($item->{'icon'}) {
print "
";
}
print "\n";
}
elsif ($item->{'type'} eq 'cat') {
# Start of a new category
my $c = $item->{'id'};
print "";
print "

\n";
print "
";
print "
\n";
print "\n";
&show_menu_items_list($item->{'members'}, $indent+1);
print "
\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 'input') {
# For with an input of some kind
my $cgi = add_webprefix($item->{'cgi'});
print "\n";
}
}
}
# add_webprefix(link)
# If a URL starts with a / , add webprefix
sub add_webprefix
{
my ($link) = @_;
return $link =~ /^\// ? &get_webprefix().$link : $link;
}