/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.52  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.26