X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLib.pm;h=40950f8c18d74aeae519189d23f62e08936f9e32;hp=1a2269820eefa4e242140273d854c822d8a59163;hb=8f5625f9cdf47f8e04be654c4954838b2df3e26d;hpb=2c925d6ec7c074dc543b458a00136d77d9e201b1 diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index 1a22698..40950f8 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.1.0beta0, released 20 Mar 2004. # # See http://backuppc.sourceforge.net. # @@ -93,11 +93,24 @@ sub NewRequest $Cgi = new CGI; %In = $Cgi->Vars; + if ( !defined($bpc) ) { + ErrorExit($Lang->{BackupPC__Lib__new_failed__check_apache_error_log}) + if ( !($bpc = BackupPC::Lib->new(undef, undef, 1)) ); + $TopDir = $bpc->TopDir(); + $BinDir = $bpc->BinDir(); + %Conf = $bpc->Conf(); + $Lang = $bpc->Lang(); + $ConfigMTime = $bpc->ConfigMTime(); + } elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { + $bpc->ServerMesg("log Re-read config file because mtime changed"); + $bpc->ServerMesg("server reload"); + } + # # Default REMOTE_USER so in a miminal installation the user # has a sensible default. # - $ENV{REMOTE_USER} = $Conf{BackupPCUser} if ( !defined($ENV{REMOTE_USER}) ); + $ENV{REMOTE_USER} = $Conf{BackupPCUser} if ( $ENV{REMOTE_USER} eq "" ); # # We require that Apache pass in $ENV{SCRIPT_NAME} and $ENV{REMOTE_USER}. @@ -108,19 +121,6 @@ sub NewRequest $MyURL = $ENV{SCRIPT_NAME}; $User = $ENV{REMOTE_USER}; - if ( !defined($bpc) ) { - ErrorExit($Lang->{BackupPC__Lib__new_failed__check_apache_error_log}) - if ( !($bpc = BackupPC::Lib->new(undef, undef, 1)) ); - $TopDir = $bpc->TopDir(); - $BinDir = $bpc->BinDir(); - %Conf = $bpc->Conf(); - $Lang = $bpc->Lang(); - $ConfigMTime = $bpc->ConfigMTime(); - } elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { - $bpc->ServerMesg("log Re-read config file because mtime changed"); - $bpc->ServerMesg("server reload"); - } - # # Clean up %ENV for taint checking # @@ -264,8 +264,8 @@ sub ServerConnect if ( CheckPermission() && -f $Conf{ServerInitdPath} && $Conf{ServerInitdStartCmd} ne "" ) { - Header(eval("qq{$Lang->{Unable_to_connect_to_BackupPC_server}}")); - print (eval("qq{$Lang->{Admin_Start_Server}}")); + my $content = eval("qq{$Lang->{Admin_Start_Server}}"); + Header(eval("qq{$Lang->{Unable_to_connect_to_BackupPC_server}}"), $content); Trailer(); exit(1); } else { @@ -320,35 +320,31 @@ sub CheckPermission $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; } # # Returns the list of hosts that should appear in the navigation bar -# for this user. If $Conf{CgiNavBarAdminAllHosts} is set, the admin -# gets all the hosts. Otherwise, regular users get hosts for which -# they are the user or are listed in the moreUsers column in the -# hosts file. +# for this user. If $getAll is set, the admin gets all the hosts. +# Otherwise, regular users get hosts for which they are the user or +# are listed in the moreUsers column in the hosts file. # sub GetUserHosts { - my($host) = @_; + my($getAll) = @_; my @hosts; - if ( $Conf{CgiNavBarAdminAllHosts} && CheckPermission() ) { + if ( $getAll && CheckPermission() ) { @hosts = sort keys %$Hosts; } else { @hosts = sort grep { $Hosts->{$_}{user} eq $User || defined($Hosts->{$_}{moreUsers}{$User}) } keys(%$Hosts); } - # - # return the selected host first (if present) - # - return @hosts if ( !defined($host) || !grep(/^$host$/, @hosts) ); - return ($host, grep(!/^$host$/, @hosts)); + return @hosts; } # @@ -392,12 +388,13 @@ sub ConfirmIPAddress sub Header { - my($title, $content) = @_; + my($title, $content, $noBrowse, $contentSub, $contentPost) = @_; my @adminLinks = ( { link => "", name => $Lang->{Status}, priv => 1}, { link => "?action=adminOpts", name => $Lang->{Admin_Options} }, - { link => "?action=summary", name => $Lang->{PC_Summary} }, + { link => "?action=summary", name => $Lang->{PC_Summary}, + 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} }, @@ -411,77 +408,75 @@ sub Header { link => "http://backuppc.sourceforge.net", name => "SourceForge", priv => 1}, ); + my $host = $In{host}; + print $Cgi->header(); print < $title -$Conf{CSSstylesheet} + $Conf{CgiHeaders}
EOF - if (!defined($In{host})) { - print < -$content -


+ + if ( defined($Hosts) && defined($host) && defined($Hosts->{$host}) ) { + print "
"; + NavSectionTitle("${EscURI($host)}"); + print < -