X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLib.pm;h=aee4743082b3f8b53d4f14cbdf5098e9b20ee30b;hp=baa168f7431a1ba476a53efd1894f84087e285a9;hb=ce708288691ba7dd95a8dac7a468bc0e4c1d6588;hpb=329e870f56fb6572fa697998d33676588034c149 diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index baa168f..aee4743 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. # @@ -48,7 +48,7 @@ use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc); use vars qw(%Status %Info %Jobs @BgQueue @UserQueue @CmdQueue %QueueLen %StatusHost); use vars qw($Hosts $HostsMTime $ConfigMTime $PrivAdmin); -use vars qw(%UserEmailInfo $UserEmailInfoMTime %RestoreReq); +use vars qw(%UserEmailInfo $UserEmailInfoMTime %RestoreReq %ArchiveReq); use vars qw($Lang); @ISA = qw(Exporter); @@ -80,7 +80,7 @@ use vars qw($Lang); %Status %Info %Jobs @BgQueue @UserQueue @CmdQueue %QueueLen %StatusHost $Hosts $HostsMTime $ConfigMTime $PrivAdmin - %UserEmailInfo $UserEmailInfoMTime %RestoreReq + %UserEmailInfo $UserEmailInfoMTime %RestoreReq %ArchiveReq $Lang ); @@ -93,15 +93,6 @@ sub NewRequest $Cgi = new CGI; %In = $Cgi->Vars; - # - # We require that Apache pass in $ENV{SCRIPT_NAME} and $ENV{REMOTE_USER}. - # The latter requires .ht_access style authentication. Replace this - # code if you are using some other type of authentication, and have - # a different way of getting the user name. - # - $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)) ); @@ -111,12 +102,25 @@ sub NewRequest $Lang = $bpc->Lang(); $ConfigMTime = $bpc->ConfigMTime(); } elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { - $bpc->ConfigRead(); - %Conf = $bpc->Conf(); - $ConfigMTime = $bpc->ConfigMTime(); - $Lang = $bpc->Lang(); + $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 ( $ENV{REMOTE_USER} eq "" ); + + # + # We require that Apache pass in $ENV{SCRIPT_NAME} and $ENV{REMOTE_USER}. + # The latter requires .ht_access style authentication. Replace this + # code if you are using some other type of authentication, and have + # a different way of getting the user name. + # + $MyURL = $ENV{SCRIPT_NAME}; + $User = $ENV{REMOTE_USER}; + # # Clean up %ENV for taint checking # @@ -156,7 +160,6 @@ sub timeStamp2 { my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_[0] == 0 ? time : $_[0] ); - $year += 1900; $mon++; if ( $Conf{CgiDateFormatMMDD} ) { return sprintf("$mon/$mday %02d:%02d", $hour, $min); @@ -218,10 +221,6 @@ sub ErrorExit my(@mesg) = @_; my($head) = shift(@mesg); my($mesg) = join("
\n", @mesg);
- $Conf{CgiHeaderFontType} ||= "arial";
- $Conf{CgiHeaderFontSize} ||= "3";
- $Conf{CgiNavBarBgColor} ||= "#ddeeee";
- $Conf{CgiHeaderBgColor} ||= "#99cc33";
if ( !defined($ENV{REMOTE_USER}) ) {
$mesg .= <
+
+ EOF - NavSectionTitle("BackupPC"); - print " \n"; - if ( defined($In{host}) && defined($Hosts->{$In{host}}) ) { - my $host = $In{host}; - NavSectionTitle( eval("qq{$Lang->{Host_Inhost}}") ); - NavSectionStart(); - NavLink("?host=${EscURI($host)}", $Lang->{Home}); - NavLink("?action=view&type=LOG&host=${EscURI($host)}", $Lang->{LOG_file}); - NavLink("?action=LOGlist&host=${EscURI($host)}", $Lang->{Old_LOGs}); - if ( -f "$TopDir/pc/$host/SmbLOG.bad" - || -f "$TopDir/pc/$host/SmbLOG.bad.z" - || -f "$TopDir/pc/$host/XferLOG.bad" - || -f "$TopDir/pc/$host/XferLOG.bad.z" ) { - NavLink("?action=view&type=XferLOGbad&host=${EscURI($host)}", - $Lang->{Last_bad_XferLOG}); - NavLink("?action=view&type=XferErrbad&host=${EscURI($host)}", - $Lang->{Last_bad_XferLOG_errors_only}); - } - if ( -f "$TopDir/pc/$host/config.pl" ) { - NavLink("?action=view&type=config&host=${EscURI($host)}", $Lang->{Config_file}); - } - NavSectionEnd(); + + if ( defined($Hosts) && defined($host) && defined($Hosts->{$host}) ) { + print " ";
+ NavSectionTitle("${EscURI($host)}");
+ print <
+EOF
+ NavLink("?host=${EscURI($host)}",
+ "$host $Lang->{Home}", " class=\"navbar\"");
+ NavLink("?action=browse&host=${EscURI($host)}",
+ $Lang->{Browse}, " class=\"navbar\"") if ( !$noBrowse );
+ NavLink("?action=view&type=LOG&host=${EscURI($host)}",
+ $Lang->{LOG_file}, " class=\"navbar\"");
+ NavLink("?action=LOGlist&host=${EscURI($host)}",
+ $Lang->{LOG_files}, " class=\"navbar\"");
+ if ( -f "$TopDir/pc/$host/SmbLOG.bad"
+ || -f "$TopDir/pc/$host/SmbLOG.bad.z"
+ || -f "$TopDir/pc/$host/XferLOG.bad"
+ || -f "$TopDir/pc/$host/XferLOG.bad.z" ) {
+ NavLink("?action=view&type=XferLOGbad&host=${EscURI($host)}",
+ $Lang->{Last_bad_XferLOG}, " class=\"navbar\"");
+ NavLink("?action=view&type=XferErrbad&host=${EscURI($host)}",
+ $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\"");
+ }
+ print " \n";
}
- NavSectionTitle($Lang->{NavSectionTitle_});
- NavSectionStart();
- foreach my $l ( @adminLinks ) {
- if ( $PrivAdmin || $l->{priv} ) {
- NavLink($l->{link}, $l->{name});
- } else {
- NavLink(undef, $l->{name});
- }
+ print("\n$content\n");
+ if ( defined($contentSub) && ref($contentSub) eq "CODE" ) {
+ while ( (my $s = &$contentSub()) ne "" ) {
+ print($s);
+ }
}
- NavSectionEnd();
- NavSectionTitle($Lang->{Hosts});
+ print($contentPost) if ( defined($contentPost) );
print < $Lang->{Host_or_User_name} |
- |