#
#========================================================================
#
-# Version 2.1.0_CVS, released 8 Feb 2004.
+# Version 2.1.0, released 20 Jun 2004.
#
# See http://backuppc.sourceforge.net.
#
$Lang = $bpc->Lang();
$ConfigMTime = $bpc->ConfigMTime();
} elsif ( $bpc->ConfigMTime() != $ConfigMTime ) {
- $bpc->ServerMesg("log Re-read config file because mtime changed");
- $bpc->ServerMesg("server reload");
+ $bpc->ConfigRead();
+ %Conf = $bpc->Conf();
+ $Lang = $bpc->Lang();
+ $ConfigMTime = $bpc->ConfigMTime();
}
#
#
$MyURL = $ENV{SCRIPT_NAME};
$User = $ENV{REMOTE_USER};
+ #
+ # Handle LDAP uid=user when using mod_authz_ldap
+ #
+ $User = $1 if ( $User =~ /uid=([^,]+)/i );
#
# Clean up %ENV for taint checking
{map {$_, 1} split(",", $Hosts->{$host}{moreUsers}) }
}
}
+
+ #
+ # Untaint the host name
+ #
+ if ( $In{host} =~ /^([\w.\s-]+)$/ ) {
+ $In{host} = $1;
+ } else {
+ delete($In{host});
+ }
}
sub timeStamp2
{
my($status) = @_;
ServerConnect();
+ %Status = () if ( $status =~ /\bhosts\b/ );
+ %StatusHost = () if ( $status =~ /\bhost\(/ );
my $reply = $bpc->ServerMesg("status $status");
$reply = $1 if ( $reply =~ /(.*)/s );
eval($reply);
# ignore status related to admin and trashClean jobs
if ( $status =~ /\bhosts\b/ ) {
- delete($Status{$bpc->adminJob});
+ foreach my $host ( grep(/admin/, keys(%Status)) ) {
+ delete($Status{$host}) if ( $bpc->isAdminJob($host) );
+ }
delete($Status{$bpc->trashJob});
}
}
$Privileged ||= $Conf{CgiAdminUsers} eq "*";
}
$PrivAdmin = $Privileged;
+ return $Privileged if ( !defined($host) );
+
$Privileged ||= $User eq $Hosts->{$host}{user};
$Privileged ||= defined($Hosts->{$host}{moreUsers}{$User});
-
return $Privileged;
}
#
sub GetUserHosts
{
- my($host, $getAll) = @_;
+ my($getAll) = @_;
my @hosts;
if ( $getAll && CheckPermission() ) {
sub Header
{
- my($title, $content, $noBrowse) = @_;
+ my($title, $content, $noBrowse, $contentSub, $contentPost) = @_;
my @adminLinks = (
- { link => "", name => $Lang->{Status},
+ { link => "", name => $Lang->{Status}},
+ { link => "?action=adminOpts", name => $Lang->{Admin_Options},
+ priv => 1},
+ { link => "?action=editConfig", name => "Edit Config",
+ priv => 1},
+ { link => "?action=editHosts", name => "Edit Hosts",
priv => 1},
- { link => "?action=adminOpts", name => $Lang->{Admin_Options} },
- { link => "?action=summary", name => $Lang->{PC_Summary},
+ { link => "?action=summary", name => $Lang->{PC_Summary}},
+ { link => "?action=view&type=LOG", name => $Lang->{LOG_file},
priv => 1},
- { link => "?action=view&type=LOG", name => $Lang->{LOG_file} },
- { link => "?action=LOGlist", name => $Lang->{Old_LOGs} },
- { link => "?action=emailSummary", name => $Lang->{Email_summary} },
- { link => "?action=view&type=config", name => $Lang->{Config_file} },
- { link => "?action=view&type=hosts", name => $Lang->{Hosts_file} },
- { link => "?action=queue", name => $Lang->{Current_queues} },
- { link => "?action=view&type=docs", name => $Lang->{Documentation},
+ { link => "?action=LOGlist", name => $Lang->{Old_LOGs},
priv => 1},
- { link => "http://backuppc.sourceforge.net/faq", name => "FAQ",
+ { link => "?action=emailSummary", name => $Lang->{Email_summary},
priv => 1},
- { link => "http://backuppc.sourceforge.net", name => "SourceForge",
+ { link => "?action=view&type=config", name => $Lang->{Config_file},
priv => 1},
+ { link => "?action=view&type=hosts", name => $Lang->{Hosts_file},
+ priv => 1},
+ { link => "?action=queue", name => $Lang->{Current_queues},
+ priv => 1},
+ @{$Conf{CgiNavBarLinks} || []},
);
my $host = $In{host};
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>$title</title>
-$Conf{CSSstylesheet}
+<link rel=stylesheet type="text/css" href="$Conf{CgiImageDirURL}/$Conf{CgiCSSFile}" title="CSSFile">
$Conf{CgiHeaders}
</head><body onLoad="document.getElementById('NavMenu').style.height=document.body.scrollHeight">
-<img src="$Conf{CgiImageDirURL}/logo.gif" hspace="5" vspace="7"><br>
+<a href="http://backuppc.sourceforge.net"><img src="$Conf{CgiImageDirURL}/logo.gif" hspace="5" vspace="7" border="0"></a><br>
EOF
if ( defined($Hosts) && defined($host) && defined($Hosts->{$host}) ) {
print "<div class=\"NavMenu\">";
- NavSectionTitle("${EscURI($host)}");
+ NavSectionTitle("${EscHTML($host)}");
print <<EOF;
</div>
<div class="NavMenu">
$Lang->{Last_bad_XferLOG_errors_only},
" class=\"navbar\"");
}
- if ( -f "$TopDir/pc/$host/config.pl" ) {
- NavLink("?action=view&type=config&host=${EscURI($host)}",
- $Lang->{Config_file}, " class=\"navbar\"");
+ if ( -f "$TopDir/pc/$host/config.pl"
+ || ($host ne "config" && -f "$TopDir/conf/$host.pl") ) {
+ NavLink("?action=editConfig&host=${EscURI($host)}",
+ "Edit Config", " class=\"navbar\"");
}
- print <<EOF;
-</div>
-<div id="Content">
-$content
-<br><br><br>
-</div>
-<div class="NavMenu" style="height:100%" id="NavMenu">
-EOF
- } else {
- print <<EOF;
-<div id="Content">
-$content
+ print "</div>\n";
+ }
+ print("<div id=\"Content\">\n$content\n");
+ if ( defined($contentSub) && ref($contentSub) eq "CODE" ) {
+ while ( (my $s = &$contentSub()) ne "" ) {
+ print($s);
+ }
+ }
+ print($contentPost) if ( defined($contentPost) );
+ print <<EOF;
<br><br><br>
</div>
<div class="NavMenu" id="NavMenu" style="height:100%">
EOF
- }
my $hostSelectbox = "<option value=\"#\">$Lang->{Select_a_host}</option>";
- my @hosts = GetUserHosts($In{host}, $Conf{CgiNavBarAdminAllHosts});
+ my @hosts = GetUserHosts($Conf{CgiNavBarAdminAllHosts});
if ( defined($Hosts) && %$Hosts > 0 && @hosts ) {
NavSectionTitle($Lang->{Hosts});
foreach my $host ( @hosts ) {
<br><br>
EOF
}
- print <<EOF;
+ if ( $Conf{CgiSearchBoxEnable} ) {
+ print <<EOF;
<form action="$MyURL" method="get">
<input type="text" name="host" size="14" maxlength="64">
<input type="hidden" name="action" value="hostInfo"><input type="submit" value="$Lang->{Go}" name="ignore">
</form>
EOF
+ }
NavSectionTitle($Lang->{NavSectionTitle_});
foreach my $l ( @adminLinks ) {
- if ( $PrivAdmin || $l->{priv} ) {
- NavLink($l->{link}, $l->{name});
+ if ( $PrivAdmin || !$l->{priv} ) {
+ my $txt = $l->{lname} ne "" ? $Lang->{$l->{lname}} : $l->{name};
+ NavLink($l->{link}, $txt);
+ }
}
-}
-print <<EOF;
+ print <<EOF;
<br><br><br>
</div>
EOF