8 |
use DateTime; |
use DateTime; |
9 |
use vars qw(%In $MyURL); |
use vars qw(%In $MyURL); |
10 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
11 |
|
use XML::Writer; |
12 |
|
use IO::File; |
13 |
|
|
14 |
my $on_page = 100; |
my $on_page = 100; |
15 |
my $pager_pages = 10; |
my $pager_pages = 10; |
310 |
sub getGzipSize($$) |
sub getGzipSize($$) |
311 |
{ |
{ |
312 |
my ($hostID, $backupNum) = @_; |
my ($hostID, $backupNum) = @_; |
|
my $ret; |
|
313 |
my $sql; |
my $sql; |
314 |
my $dbh = get_dbh(); |
my $dbh = get_dbh(); |
315 |
|
|
897 |
return $retHTML; |
return $retHTML; |
898 |
} |
} |
899 |
|
|
900 |
|
sub dumpArchive2XML($$) |
901 |
|
{ |
902 |
|
my ($arcID, $filename) = @_; |
903 |
|
my $dbh; |
904 |
|
my $sth; |
905 |
|
my $sth_backups; |
906 |
|
my $sth_files; |
907 |
|
my $row; |
908 |
|
my $row_backups; |
909 |
|
my $row_files; |
910 |
|
my %archive; |
911 |
|
my $output = new IO::File(">$filename"); |
912 |
|
my $writer = new XML::Writer(OUTPUT=>$output, NEWLINES => 1); |
913 |
|
|
914 |
|
|
915 |
|
$dbh = get_dbh(); |
916 |
|
# my $bpc = BackupPC::Lib->new(undef, undef, 1) || die; |
917 |
|
# my %Conf = $bpc->Conf(); |
918 |
|
|
919 |
|
# my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
920 |
|
# my $user = $Conf{SearchUser} || ''; |
921 |
|
|
922 |
|
my $files_sql = q{ |
923 |
|
SELECT |
924 |
|
files.name AS filename, |
925 |
|
files.path AS filepath, |
926 |
|
files.date AS filedate, |
927 |
|
files.type AS filetype, |
928 |
|
files.size AS filesize |
929 |
|
FROM files, backups, shares |
930 |
|
WHERE files.backupnum=backups.num AND |
931 |
|
files.shareid=shares.id AND |
932 |
|
shares.hostid=backups.hostid AND |
933 |
|
backups.id=? |
934 |
|
}; |
935 |
|
|
936 |
|
my $backups_sql = q{ |
937 |
|
SELECT backups.id AS backupid, |
938 |
|
hosts.name AS hostname, |
939 |
|
backups.num AS backupnum, |
940 |
|
backups.date AS backupdate, |
941 |
|
backups.type AS backuptype, |
942 |
|
shares.name AS sharename, |
943 |
|
backups.size AS backupsize, |
944 |
|
backups.inc_size AS inc_size, |
945 |
|
backups.inc_deleted AS inc_deleted |
946 |
|
FROM backups, archive_backup, hosts, shares |
947 |
|
WHERE archive_backup.backup_id = backups.id |
948 |
|
AND hosts.id=backups.hostid |
949 |
|
AND shares.id=backups.shareid |
950 |
|
AND archive_backup.archive_id = ? |
951 |
|
}; |
952 |
|
|
953 |
|
$dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 1 }); |
954 |
|
|
955 |
|
$sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date FROM archive WHERE ID=?"); |
956 |
|
$sth->execute($arcID); |
957 |
|
$row = $sth->fetchrow_hashref(); |
958 |
|
$writer->startTag("archive", "dvd_nr" => $row->{'dvd_nr'}, |
959 |
|
"total_size" => $row->{'total_size'}, |
960 |
|
"username" => $row->{'username'}, |
961 |
|
"date" => $row->{'date'} |
962 |
|
); |
963 |
|
|
964 |
|
|
965 |
|
$writer->startTag("note"); |
966 |
|
$writer->characters( $row->{'note'}); |
967 |
|
$writer->endTag("note"); |
968 |
|
$sth_backups = $dbh->prepare( $backups_sql ); |
969 |
|
$sth_backups->execute($arcID); |
970 |
|
while ($row_backups = $sth_backups->fetchrow_hashref()) |
971 |
|
{ |
972 |
|
$writer->startTag("backup", |
973 |
|
"host" => $row_backups->{'hostname'}, |
974 |
|
"num" => $row_backups->{'backupnum'}, |
975 |
|
"date" => $row_backups->{'backupdate'}, |
976 |
|
"type" => $row_backups->{'backuptype'}, |
977 |
|
"share"=> $row_backups->{'sharename'}, |
978 |
|
"size" => $row_backups->{'backupsize'}, |
979 |
|
"inc_size" => $row_backups->{'inc_size'}, |
980 |
|
"inc_deleted" => $row_backups->{'inc_deleted'} |
981 |
|
); |
982 |
|
|
983 |
|
$sth_files = $dbh->prepare( |
984 |
|
$files_sql |
985 |
|
); |
986 |
|
$sth_files->execute($row_backups->{'backupid'}); |
987 |
|
while ($row_files = $sth_files->fetchrow_hashref()) |
988 |
|
{ |
989 |
|
$writer->startTag("file", |
990 |
|
"path" => $row_files->{'filepath'}, |
991 |
|
"date" => $row_files->{'filedate'}, |
992 |
|
"type" => $row_files->{'filetype'}, |
993 |
|
"size" => $row_files->{'filesize'} |
994 |
|
); |
995 |
|
$writer->characters( $row_files->{'filename'}); |
996 |
|
$writer->endTag("file"); |
997 |
|
} |
998 |
|
$writer->endTag("backup"); |
999 |
|
} |
1000 |
|
|
1001 |
|
$writer->endTag("archive"); |
1002 |
|
$writer->end(); |
1003 |
|
|
1004 |
|
} |
1005 |
|
|
1006 |
1; |
1; |