/[BackupPC]/trunk/lib/BackupPC/SearchLib.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/SearchLib.pm

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

revision 171 by dpavlin, Mon Oct 10 14:32:31 2005 UTC revision 197 by dpavlin, Thu Oct 13 18:33:00 2005 UTC
# Line 8  use DBI; Line 8  use DBI;
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;
# Line 68  sub dates_from_form($) { Line 70  sub dates_from_form($) {
70                  $mm =~ s/\D//g;                  $mm =~ s/\D//g;
71                  $dd =~ s/\D//g;                  $dd =~ s/\D//g;
72    
73                    my $h = my $m = my $s = 0;
74                    if ($suffix eq 'to') {
75                            $h = 23;
76                            $m = 59;
77                            $s = 59;
78                    }
79    
80                  my $dt = new DateTime(                  my $dt = new DateTime(
81                          year => $yyyy,                          year => $yyyy,
82                          month => $mm,                          month => $mm,
83                          day => $dd                          day => $dd,
84                            hour => $h,
85                            minute => $m,
86                            second => $s,
87                  );                  );
88                  print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n";                  print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n";
89                  return $dt->epoch || 'NULL';                  return $dt->epoch || 'NULL';
# Line 100  sub getWhere($) { Line 112  sub getWhere($) {
112          push @conditions, qq{ files.date >= $files_from } if ($files_from);          push @conditions, qq{ files.date >= $files_from } if ($files_from);
113          push @conditions, qq{ files.date <= $files_to } if ($files_to);          push @conditions, qq{ files.date <= $files_to } if ($files_to);
114    
115          print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" | ",@conditions);          print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" and ",@conditions);
116    
117          push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'});          push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'});
118          push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'});          push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'});
# Line 295  sub getGzipName($$$) Line 307  sub getGzipName($$$)
307                    
308  }  }
309    
310    sub get_tgz_size_by_name($) {
311            my $name = shift;
312    
313            my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name;
314    
315            my $size = -1;
316    
317            if (-f $tgz) {
318                    $size = (stat($tgz))[7];
319            } elsif (-d $tgz) {
320                    opendir(my $dir, $tgz) || die "can't opendir $tgz: $!";
321                    my @parts = grep { !/^\./ && -f "$tgz/$_" } readdir($dir);
322                    $size = 0;
323                    foreach my $part (@parts) {
324                            $size += (stat("$tgz/$part"))[7] || die "can't stat $tgz/$part: $!";
325                    }
326                    closedir $dir;
327            }
328    
329            return $size;
330    }
331    
332  sub getGzipSize($$)  sub getGzipSize($$)
333  {  {
334          my ($hostID, $backupNum) = @_;          my ($hostID, $backupNum) = @_;
         my $ret;  
335          my $sql;          my $sql;
336          my $dbh = get_dbh();          my $dbh = get_dbh();
337                    
# Line 316  sub getGzipSize($$) Line 349  sub getGzipSize($$)
349          $sth->execute($hostID, $backupNum);          $sth->execute($hostID, $backupNum);
350    
351          my $row = $sth->fetchrow_hashref();          my $row = $sth->fetchrow_hashref();
352            
353          my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) =          return get_tgz_size_by_name(
354                          stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.                  getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})
355                                  getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));          );
           
         return $ret;      
356  }  }
357    
358  sub getBackupsNotBurned() {  sub getBackupsNotBurned() {
# Line 338  sub getBackupsNotBurned() { Line 369  sub getBackupsNotBurned() {
369                          backups.date AS date,                          backups.date AS date,
370                          backups.size AS size,                          backups.size AS size,
371                          backups.id AS id,                          backups.id AS id,
372                          backups.inc_size AS inc_size                          backups.inc_size AS inc_size,
373                            backups.parts AS parts
374                  FROM backups                  FROM backups
375                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
376                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
# Line 354  sub getBackupsNotBurned() { Line 386  sub getBackupsNotBurned() {
386                          backups.type,                          backups.type,
387                          backups.date,                          backups.date,
388                          backups.size,                          backups.size,
389                          backups.inc_size                          backups.inc_size,
390                            backups.parts
391                  ORDER BY backups.date                  ORDER BY backups.date
392          };          };
393          my $sth = $dbh->prepare( $sql );          my $sth = $dbh->prepare( $sql );
# Line 480  DIV#fixedBox #submitBurner { Line 513  DIV#fixedBox #submitBurner {
513          z-index: 3;          z-index: 3;
514          background-color: transparent;          background-color: transparent;
515  }  }
516    
517    #parts {
518            padding: 0.4em;
519            display: none;
520            width: 100%;
521            font-size: 80%;
522            color: #ff0000;
523            text-align: center;
524    }
525  -->  -->
526  </style>  </style>
527  <script type="text/javascript">  <script type="text/javascript">
# Line 494  EOF3 Line 536  EOF3
536          $retHTML .= <<'EOF3';          $retHTML .= <<'EOF3';
537    
538  function debug(msg) {  function debug(msg) {
539  //      return; // Disable debugging          return; // Disable debugging
540    
541          if (! debug_div) debug_div = document.getElementById('debug');          if (! debug_div) debug_div = document.getElementById('debug');
542    
# Line 550  function checkAll(location) { Line 592  function checkAll(location) {
592          update_sum(suma);          update_sum(suma);
593  }  }
594    
595  function update_sum(suma) {  function update_sum(suma, suma_disp) {
596          element_id('forma').elements['totalsize'].value = suma;          if (! suma_disp) suma_disp = suma;
597            element_id('forma').elements['totalsize'].value = suma_disp;
598          pbar_set(suma, media_size);          pbar_set(suma, media_size);
599          debug('total size: ' + suma);          debug('total size: ' + suma);
600  }  }
# Line 566  function sumiraj(e) { Line 609  function sumiraj(e) {
609                  } else {                  } else {
610                          suma -= size;                          suma -= size;
611                  }                  }
612    
613                    var parts = parseInt( element_id("prt" + e.name.substr(3)).value);
614                    if (suma > media_size && suma == size && parts > 1) {
615                            element_id("parts").innerHTML = "This will take "+parts+" mediums!";
616                            element_id("parts").style.display = 'block';
617                            update_sum(media_size, suma);
618                            suma = media_size;
619                            return suma;
620                    } else {
621                            element_id("parts").style.display = 'none';
622                    }
623    
624                    if (suma < 0) suma = 0;
625          } else {          } else {
626                  suma = 0;                  suma = 0;
627                  for (var i = 0; i < len; i++) {                  for (var i = 0; i < len; i++) {
# Line 663  Size: <input type="text" name="totalsize Line 719  Size: <input type="text" name="totalsize
719  </div>  </div>
720  <br/>  <br/>
721    
722    <div id="parts">&nbsp;</div>
723    
724  Note:  Note:
725  <textarea name="note" cols="10" rows="5" id="note"></textarea>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
726    
# Line 727  EOF3 Line 785  EOF3
785                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
786                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
787                          '<td align="right">' . $backup->{'inc_size'} .                          '<td align="right">' . $backup->{'inc_size'} .
788                          '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .                          '<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .
789                            '<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'parts'} .'"></td>' .
790    
791                          "</tr>\n";                          "</tr>\n";
792          }          }

Legend:
Removed from v.171  
changed lines
  Added in v.197

  ViewVC Help
Powered by ViewVC 1.1.26