897 |
return $retHTML; |
return $retHTML; |
898 |
} |
} |
899 |
|
|
|
sub dumpArchive2XML($$) |
|
|
{ |
|
|
my ($arcID, $filename) = @_; |
|
|
my $dbh; |
|
|
my $sth; |
|
|
my $sth_backups; |
|
|
my $sth_files; |
|
|
my $row; |
|
|
my $row_backups; |
|
|
my $row_files; |
|
|
my %archive; |
|
|
my $output = new IO::File(">$filename"); |
|
|
my $writer = new XML::Writer(OUTPUT=>$output, NEWLINES => 1); |
|
|
|
|
|
|
|
|
$dbh = get_dbh(); |
|
|
# my $bpc = BackupPC::Lib->new(undef, undef, 1) || die; |
|
|
# my %Conf = $bpc->Conf(); |
|
|
|
|
|
# my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
|
|
# my $user = $Conf{SearchUser} || ''; |
|
|
|
|
|
my $files_sql = q{ |
|
|
SELECT |
|
|
files.name AS filename, |
|
|
files.path AS filepath, |
|
|
files.date AS filedate, |
|
|
files.type AS filetype, |
|
|
files.size AS filesize |
|
|
FROM files, backups, shares |
|
|
WHERE files.backupnum=backups.num AND |
|
|
files.shareid=shares.id AND |
|
|
shares.hostid=backups.hostid AND |
|
|
backups.id=? |
|
|
}; |
|
|
|
|
|
my $backups_sql = q{ |
|
|
SELECT backups.id AS backupid, |
|
|
hosts.name AS hostname, |
|
|
backups.num AS backupnum, |
|
|
backups.date AS backupdate, |
|
|
backups.type AS backuptype, |
|
|
shares.name AS sharename, |
|
|
backups.size AS backupsize, |
|
|
backups.inc_size AS inc_size, |
|
|
backups.inc_deleted AS inc_deleted |
|
|
FROM backups, archive_backup, hosts, shares |
|
|
WHERE archive_backup.backup_id = backups.id |
|
|
AND hosts.id=backups.hostid |
|
|
AND shares.id=backups.shareid |
|
|
AND archive_backup.archive_id = ? |
|
|
}; |
|
|
|
|
|
$dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 1 }); |
|
|
|
|
|
$sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date FROM archive WHERE ID=?"); |
|
|
$sth->execute($arcID); |
|
|
$row = $sth->fetchrow_hashref(); |
|
|
$writer->startTag("archive", "dvd_nr" => $row->{'dvd_nr'}, |
|
|
"total_size" => $row->{'total_size'}, |
|
|
"username" => $row->{'username'}, |
|
|
"date" => $row->{'date'} |
|
|
); |
|
|
|
|
|
|
|
|
$writer->startTag("note"); |
|
|
$writer->characters( $row->{'note'}); |
|
|
$writer->endTag("note"); |
|
|
$sth_backups = $dbh->prepare( $backups_sql ); |
|
|
$sth_backups->execute($arcID); |
|
|
while ($row_backups = $sth_backups->fetchrow_hashref()) |
|
|
{ |
|
|
$writer->startTag("backup", |
|
|
"host" => $row_backups->{'hostname'}, |
|
|
"num" => $row_backups->{'backupnum'}, |
|
|
"date" => $row_backups->{'backupdate'}, |
|
|
"type" => $row_backups->{'backuptype'}, |
|
|
"share"=> $row_backups->{'sharename'}, |
|
|
"size" => $row_backups->{'backupsize'}, |
|
|
"inc_size" => $row_backups->{'inc_size'}, |
|
|
"inc_deleted" => $row_backups->{'inc_deleted'} |
|
|
); |
|
|
|
|
|
$sth_files = $dbh->prepare( |
|
|
$files_sql |
|
|
); |
|
|
$sth_files->execute($row_backups->{'backupid'}); |
|
|
while ($row_files = $sth_files->fetchrow_hashref()) |
|
|
{ |
|
|
$writer->startTag("file", |
|
|
"path" => $row_files->{'filepath'}, |
|
|
"date" => $row_files->{'filedate'}, |
|
|
"type" => $row_files->{'filetype'}, |
|
|
"size" => $row_files->{'filesize'} |
|
|
); |
|
|
$writer->characters( $row_files->{'filename'}); |
|
|
$writer->endTag("file"); |
|
|
} |
|
|
$writer->endTag("backup"); |
|
|
} |
|
|
|
|
|
$writer->endTag("archive"); |
|
|
$writer->end(); |
|
|
|
|
|
} |
|
|
|
|
900 |
1; |
1; |