From a7690ea45972ea3db587bd94fa573edf20d75c91 Mon Sep 17 00:00:00 2001 From: cbarratt Date: Sun, 17 Aug 2003 01:56:24 +0000 Subject: [PATCH] * Various tweaks to recent changes, including additional patches from Josh and Paul. Added host selection list to restore page. Tweak CSS and layout. * Fixed $Conf{HardLinkMax} limit check in BackupPC::Lib; reported by Ross Skaliotis. --- ChangeLog | 12 ++- bin/BackupPC_dump | 6 +- conf/config.pl | 39 +++----- lib/BackupPC/CGI/Archive.pm | 22 ++--- lib/BackupPC/CGI/ArchiveInfo.pm | 4 +- lib/BackupPC/CGI/Browse.pm | 33 ++----- lib/BackupPC/CGI/DirHistory.pm | 23 ++--- lib/BackupPC/CGI/Lib.pm | 156 +++++++++++++++----------------- lib/BackupPC/CGI/Restore.pm | 9 ++ lib/BackupPC/CGI/Summary.pm | 3 +- lib/BackupPC/Lang/en.pm | 20 ++-- lib/BackupPC/Lang/fr.pm | 18 ++-- lib/BackupPC/Lib.pm | 3 +- lib/BackupPC/View.pm | 8 +- 14 files changed, 176 insertions(+), 180 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b4a846..4f9edef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,15 @@ # Version __VERSION__, __RELEASEDATE__ #------------------------------------------------------------------------ +* GFK updated fr.pm from en.pm. + +* Various tweaks to recent changes, including additional patches + from Josh and Paul. Added host selection list to restore page. + Tweak CSS and layout. + +* Fixed $Conf{HardLinkMax} limit check in BackupPC::Lib; reported + by Ross Skaliotis. + * Major changes from Ryan Kucera to add style sheets to the CGI interface, allowing easy customization. Added new icons and BackupPC logo. Numerous navigation improvements. @@ -67,7 +76,8 @@ fatal. This is used to catch miscellaneous Xfer errors that result in no files being backed up. A new config parameter $Conf{BackupZeroFilesIsFatal} (defaults to 1) and can be set to - zero to turn off this check. Suggested by Guillaume Filion. + zero to turn off this check. Suggested by Guillaume Filion. + Additional change: this check only applies to a full dump. * SMB: now detect NT_STATUS_ACCESS_DENIED on entire share or BackupFilesOnly (also ERRDOS - ERRnoaccess (Access denied.) for older versions of diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index f59e38a..11fc3db 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -688,10 +688,10 @@ for my $shareName ( @$ShareNames ) { } # -# If any share had zero files then consider the dump bad +# If this is a full, and any share had zero files then consider the dump bad # -if ( $stat{hostError} eq "" - && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) { +if ( $type eq "full" && $stat{hostError} eq "" + && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) { $stat{hostError} = $noFilesErr; $stat{xferOK} = 0; } diff --git a/conf/config.pl b/conf/config.pl index 8c58140..c086992 100644 --- a/conf/config.pl +++ b/conf/config.pl @@ -241,7 +241,7 @@ $Conf{BackupPCUserVerify} = 1; # # Maximum number of hardlinks supported by the $TopDir file system # that BackupPC uses. Most linux or unix file systems should support -# at least 32000 hardlinks per file, or 64K in other cases. If a pool +# at least 32000 hardlinks per file, or 64000 in other cases. If a pool # file already has this number of hardlinks, a new pool file is created # so that new hardlinks can be accommodated. This limit will only # be hit if an identical file appears at least this number of times @@ -1500,7 +1500,7 @@ h2 { p { font-family:arial,sans-serif; - font-size:.8em + font-size:.9em } a { @@ -1508,6 +1508,10 @@ a { font-size:1em; color:#3333ff } + +li { + font-size:.9em; +} a:hover { color:#cc0000; @@ -1516,8 +1520,6 @@ a:hover { a.NavCurrent { font-weight:bold; - padding-left:5px; - padding-right:5px; } a.navbar { @@ -1544,19 +1546,22 @@ a.navbar { padding:3px; padding-left:10px } - + .border { border-bottom:1px solid #000000; - border-left:1px dotted #666666 + border-left:1px dotted #666666; + font-size:.9em; } .tableheader { + font-size:.8em; font-weight:bold; background-color:#cccccc } .fviewheader { font-weight:bold; + font-size:.8em; color:#ffffff; background-color:#999999 } @@ -1564,7 +1569,8 @@ a.navbar { .fviewborder { border-bottom:1px solid #000000; border-left:1px dotted #666666; - background-color:#dddddd + background-color:#dddddd; + font-size:.9em; } .fviewon { @@ -1611,7 +1617,7 @@ div.NavMenu a { font-size:.8em; display:block; margin-left:8px; - padding:3px; + padding:2px; } div.NavTitle { @@ -1622,23 +1628,6 @@ div.NavTitle { font-weight:bold } -div.HostOn { - width:18%; - background-color:#ddeeee; - padding:3px; - padding-left:10px; -} - -div.HostOnContent { - background-color:#ddeeee; - padding:5px; -} - -div.HostOnContent a { - font-size:.8em; - display:block; -} - #Content { float:right; width:80%; diff --git a/lib/BackupPC/CGI/Archive.pm b/lib/BackupPC/CGI/Archive.pm index 43a9b8e..2a774eb 100644 --- a/lib/BackupPC/CGI/Archive.pm +++ b/lib/BackupPC/CGI/Archive.pm @@ -70,10 +70,10 @@ sub action $fullSizeTot += $fullSize + $incrSizeTot; $fullSize = sprintf("%.2f", ($fullSize + $incrSizeTot) / 1000); $str = < - ${HostLink($host)} - ${UserLink($Hosts->{$host}{user})} - $fullSize + + ${HostLink($host)} + ${UserLink($Hosts->{$host}{user})} + $fullSize EOF $checkBoxCnt++; if ( @Backups == 0 ) { @@ -90,9 +90,8 @@ EOF $strGood .= < EOF - Header($Lang->{BackupPC__Archive}); - print eval ("qq{$Lang->{BackupPC_Archive}}"); - + my $content = eval("qq{$Lang->{BackupPC_Archive}}"); + Header(eval("qq{$Lang->{BackupPC__Archive}}"),$content); Trailer(); } else { @@ -163,8 +162,8 @@ EOF # Tell the user what options they have # - Header($Lang->{BackupPC__Archive}); - print eval ("qq{$Lang->{BackupPC_Archive2}}"); + my $content = eval("qq{$Lang->{BackupPC_Archive2}}"); + Header(eval("qq{$Lang->{BackupPC__Archive}}"),$content); Trailer(); } elsif ( $In{type} == 2 ) { my $reqFileName; @@ -223,8 +222,9 @@ EOF $reply = $bpc->ServerMesg("archive $User $archivehost $reqFileName"); $str = eval("qq{$Lang->{Archive_requested}}"); - Header($Lang->{BackupPC__Archive}); - print eval ("qq{$Lang->{BackupPC_Archive_Reply_from_server}}"); + + my $content = eval("qq{$Lang->{BackupPC_Archive_Reply_from_server}}"); + Header(eval("qq{$Lang->{BackupPC__Archive}}"),$content); Trailer(); } diff --git a/lib/BackupPC/CGI/ArchiveInfo.pm b/lib/BackupPC/CGI/ArchiveInfo.pm index effb362..962aa0c 100644 --- a/lib/BackupPC/CGI/ArchiveInfo.pm +++ b/lib/BackupPC/CGI/ArchiveInfo.pm @@ -79,8 +79,8 @@ EOF $counter++; } - Header(eval("qq{$Lang->{Archive___num_details_for__host}}")); - print(eval("qq{$Lang->{Archive___num_details_for__host2 }}")); + my $content = eval("qq{$Lang->{Archive___num_details_for__host2 }}"); + Header(eval("qq{$Lang->{Archive___num_details_for__host}}"),$content); Trailer(); } diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm index 3eb7f30..70dd4a1 100644 --- a/lib/BackupPC/CGI/Browse.pm +++ b/lib/BackupPC/CGI/Browse.pm @@ -218,11 +218,7 @@ EOF if ( $gotDir ) { $fileStr .= < -
-  $iconStr - -  $fDisp -
+  $iconStr $fDisp $attrStr @@ -230,11 +226,7 @@ EOF } else { $fileStr .= < -
-  $iconStr - -  $fDisp -
+  $iconStr $fDisp $attrStr @@ -290,23 +282,18 @@ EOF } else { $fileStr = eval("qq{$Lang->{The_directory_is_empty}}"); } - my @otherDirs; my $pathURI = $dir; my $shareURI = $share; $pathURI =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg; $shareURI =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg; - foreach my $i ( $view->backupList($share, $dir) ) { - push(@otherDirs, $i); - } - if ( @otherDirs ) { - my $otherDirs = join(",\n", @otherDirs); - my $inc = 0; - foreach my $value (@otherDirs) { - my $selected = undef; - my $showDate = timeStamp2($Backups[$inc]{startTime}); - $selected = " selected" if ($value == $num); - $otherDirs .= "\n"; - $inc++; + if ( my @otherDirs = $view->backupList($share, $dir) ) { + my $otherDirs; + foreach my $i ( @otherDirs ) { + my $selected; + my $showDate = timeStamp2($Backups[$i]{startTime}); + my $backupNum = $Backups[$i]{num}; + $selected = " selected" if ( $backupNum == $num ); + $otherDirs .= "\n"; } $filledBackup .= eval("qq{$Lang->{Visit_this_directory_in_backup}}"); } diff --git a/lib/BackupPC/CGI/DirHistory.pm b/lib/BackupPC/CGI/DirHistory.pm index 728068f..f19bf94 100644 --- a/lib/BackupPC/CGI/DirHistory.pm +++ b/lib/BackupPC/CGI/DirHistory.pm @@ -71,7 +71,8 @@ sub action ErrorExit($Lang->{Nice_try__but_you_can_t_put}); } - for ( $i = 0 ; $i < @Backups ; $i++ ) { + my @backupList = $view->backupList($share, $dir); + foreach $i ( @backupList ) { my $backupTime = timeStamp2($Backups[$i]{startTime}); my $num = $Backups[$i]{num}; $backupNumStr .= "$fDisp"; - my($colSpan, $url, $inode, $type); - my $tdClass = ' class="histView"'; - for ( $i = 0 ; $i < @Backups ; $i++ ) { + $fileStr .= "$fDisp"; + my($colSpan, $url, $inode, $type); + my $tdClass = ' class="histView"'; + foreach $i ( @backupList ) { my($path); if ( $colSpan > 0 ) { # @@ -110,16 +111,16 @@ sub action $colSpan++; next; } - $fileStr .= "" + $fileStr .= "" . "$url"; $colSpan = 0; - $tdClass = ' class="histView"'; + $tdClass = ' class="histView"'; } if ( !defined($hist->{$f}[$i]) ) { $colSpan = 1; $url = " "; $inode = -3; # special value for missing - $tdClass = ' class="histViewMis"'; + $tdClass = ' class="histViewMis"'; next; } if ( $dir eq "" ) { @@ -155,7 +156,7 @@ EOF $colSpan = 1; } if ( $colSpan > 0 ) { - $fileStr .= "$url"; + $fileStr .= "$url"; $colSpan = 0; } $fileStr .= "\n"; @@ -165,8 +166,8 @@ EOF $dirDisplay =~ s{//+}{/}g; $dirDisplay =~ s{/+$}{}g; $dirDisplay = "/" if ( $dirDisplay eq "" ); - my $content = eval("qq{$Lang->{DirHistory_for__host}}"); - Header(eval("qq{$Lang->{DirHistory_backup_for__host}}"), $content); + my $content = eval("qq{$Lang->{DirHistory_for__host}}"); + Header(eval("qq{$Lang->{DirHistory_backup_for__host}}"), $content); Trailer(); } diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index 1a22698..4bc7227 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -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 { @@ -328,27 +328,22 @@ sub CheckPermission # # 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($host, $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; } # @@ -397,7 +392,8 @@ sub Header { 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,6 +407,8 @@ sub Header { link => "http://backuppc.sourceforge.net", name => "SourceForge", priv => 1}, ); + my $host = $In{host}; + print $Cgi->header(); print < @@ -421,67 +419,66 @@ $Conf{CgiHeaders}
EOF - if (!defined($In{host})) { - print <{$host}) ) { + print "
"; + NavSectionTitle("${EscURI($host)}"); + print < +