/[BackupPC]/trunk/lib/BackupPC/CGI/BurnMedia.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/BackupPC/CGI/BurnMedia.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (show annotations)
Sat Aug 20 17:19:48 2005 UTC (18 years, 8 months ago) by dpavlin
File size: 2012 byte(s)
fix archive to backup medium (but it still doesn't have functionality)

1 package BackupPC::CGI::BurnMedia;
2
3 use strict;
4 use BackupPC::CGI::Lib qw(:all);
5 use BackupPC::SearchLib;
6 use Data::Dumper;
7 use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc);
8
9 my $dsn = $Conf{SearchDSN};
10 my $db_user = $Conf{SearchUser} || '';
11
12 sub action() {
13 my $cont = "";
14 my $title;
15 my $subtitle;
16 my @files;
17
18 my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } );
19
20 BackupPC::CGI::Lib::NewRequest();
21 $cont = Dumper(%In);
22 if (!defined($In{submitBurner})) {
23 $title = eval(q{ ${h1($Lang->{Burn_media})}});
24 $cont = Dumper(%In);
25 $subtitle = eval(q{ ${h2($Lang->{Burn_media_select})}});
26 $cont = <<EOF;
27
28 $title
29 $subtitle
30
31 EOF
32
33 $cont .= "Backups that have files not archived:<br>";
34 $cont .= BackupPC::SearchLib::displayBackupsGrid();
35
36 } else {
37
38 my $mediumName = "DVD";
39
40 $title = eval(q{ ${h1($Lang->{Burn_media})}});
41 $subtitle = eval(q{ ${h2($Lang->{Burn_media_assign})}});
42 $cont = <<EOF;
43
44 $title
45 $subtitle
46
47 EOF
48
49 # insert DVD first,
50 my $sql = q{ SELECT MAX(num)+1 AS maxNum FROM dvds; };
51
52 my $sth = $dbh->prepare($sql);
53 $sth->execute();
54
55 my ($mediumNum) = $sth->fetchrow_array();
56 $mediumNum ||= '0';
57
58 $mediumName = "DVD".$mediumNum;
59 $sth = $dbh->prepare (q{
60 INSERT INTO dvds (num, name)
61 VALUES
62 (?,?)
63 });
64
65 $sth->execute($mediumNum, $mediumName);
66
67 my $dvdid = $dbh->last_insert_id(undef,undef,'dvds',undef);
68
69 my $updateSQL = q{
70 UPDATE files
71 SET dvdid=?
72 WHERE files.shareID IN (
73 SELECT ID FROM shares WHERE hostID=?
74 ) AND
75 files.backupNum=?
76 };
77
78 my $update_sth = $dbh->prepare($updateSQL);
79 my $orQuery = "";
80
81 # then, assign dvdid to files
82 foreach my $key (keys(%In)) {
83 if ($key =~ /fcb/) {
84 my ($hID, $bNo) = split(/_/, $In{$key});
85 $update_sth->execute($dvdid, $hID, $bNo);
86 }
87 }
88 $cont .= "Backups assigned to media ".$mediumName;
89 }
90
91 Header($Lang->{Burn_media}, "", 1, "", $cont);
92 Trailer();
93 $dbh->disconnect();
94 }
95
96 1;

  ViewVC Help
Powered by ViewVC 1.1.26