/[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 259 by dpavlin, Mon Dec 12 20:59:58 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 108  sub getWhere($) { Line 120  sub getWhere($) {
120          return join(" and ", @conditions);          return join(" and ", @conditions);
121  }  }
122    
123    my $sort_def = {
124            search => {
125                    default => 'date_a',
126                    sql => {
127                            share_d => 'shares.name DESC',
128                            share_a => 'shares.name ASC',
129                            path_d => 'files.path DESC',
130                            path_a => 'files.path ASC',
131                            num_d => 'files.backupnum DESC',
132                            num_a => 'files.backupnum ASC',
133                            size_d => 'files.size DESC',
134                            size_a => 'files.size ASC',
135                            date_d => 'files.date DESC',
136                            date_a => 'files.date ASC',
137                    },
138                    est => {
139                            share_d => 'sname STRD',
140                            share_a => 'sname STRA',
141                            path_d => 'filepath STRD',
142                            path_a => 'filepath STRA',
143                            num_d => 'backupnum NUMD',
144                            num_a => 'backupnum NUMA',
145                            size_d => 'size NUMD',
146                            size_a => 'size NUMA',
147                            date_d => 'date NUMD',
148                            date_a => 'date NUMA',
149                    }
150            }, burn => {
151                    default => 'date_a',
152                    sql => {
153                            share_d => 'host DESC, share DESC',
154                            share_a => 'host ASC, share ASC',
155                            num_d => 'backupnum DESC',
156                            num_a => 'backupnum ASC',
157                            date_d => 'date DESC',
158                            date_a => 'date ASC',
159                            age_d => 'age DESC',
160                            age_a => 'age ASC',
161                            size_d => 'size DESC',
162                            size_a => 'size ASC',
163                            incsize_d => 'inc_size DESC',
164                            incsize_a => 'inc_size ASC',
165                    }
166            }
167    };
168    
169    sub getSort($$$) {
170            my ($part,$type, $sort_order) = @_;
171    
172            die "unknown part: $part" unless ($sort_def->{$part});
173            die "unknown type: $type" unless ($sort_def->{$part}->{$type});
174    
175            $sort_order ||= $sort_def->{$part}->{'default'};
176    
177            if (my $ret = $sort_def->{$part}->{$type}->{$sort_order}) {
178                    return $ret;
179            } else {
180                    # fallback to default sort order
181                    return $sort_def->{$part}->{$type}->{ $sort_def->{$part}->{'default'} };
182            }
183    }
184    
185  sub getFiles($) {  sub getFiles($) {
186          my ($param) = @_;          my ($param) = @_;
# Line 139  sub getFiles($) { Line 212  sub getFiles($) {
212          my $where = getWhere($param);          my $where = getWhere($param);
213          $sql_where = " WHERE ". $where if ($where);          $sql_where = " WHERE ". $where if ($where);
214    
215            my $order = getSort('search', 'sql', $param->{'sort'});
216    
217          my $sql_order = qq{          my $sql_order = qq{
218                  ORDER BY files.date                  ORDER BY $order
219                  LIMIT $on_page                  LIMIT $on_page
220                  OFFSET ?                  OFFSET ?
221          };          };
# Line 182  sub getHyperEstraier_url($) { Line 257  sub getHyperEstraier_url($) {
257          if ($use_hest =~ m#^http://#) {          if ($use_hest =~ m#^http://#) {
258                  $index_node_url = $use_hest;                  $index_node_url = $use_hest;
259          } else {          } else {
260                  $index_path = $TopDir . '/' . $index_path;                  $index_path = $TopDir . '/' . $use_hest;
261                  $index_path =~ s#//#/#g;                  $index_path =~ s#//#/#g;
262          }          }
263          return ($index_path, $index_node_url);          return ($index_path, $index_node_url);
# Line 239  sub getFilesHyperEstraier($) { Line 314  sub getFilesHyperEstraier($) {
314    
315  #       $cond->set_max( $offset + $on_page );  #       $cond->set_max( $offset + $on_page );
316          $cond->set_options( $HyperEstraier::Condition::SURE );          $cond->set_options( $HyperEstraier::Condition::SURE );
317          $cond->set_order( 'date NUMA' );          $cond->set_order( getSort('search', 'est', $param->{'sort'} ) );
318    
319          # get the result of search          # get the result of search
320          my @res;          my @res;
# Line 270  sub getFilesHyperEstraier($) { Line 345  sub getFilesHyperEstraier($) {
345                  }                  }
346    
347                  my $row;                  my $row;
348                  foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) {                  foreach my $c (qw/fid hname sname backupnum filepath date type size/) {
349                          $row->{$c} = $doc->attr($c);                          $row->{$c} = $doc->attr($c);
350                  }                  }
351                  push @res, $row;                  push @res, $row;
# Line 295  sub getGzipName($$$) Line 370  sub getGzipName($$$)
370                    
371  }  }
372    
373    sub get_tgz_size_by_name($) {
374            my $name = shift;
375    
376            my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name;
377    
378            my $size = -1;
379    
380            if (-f "${tgz}.tar.gz") {
381                    $size = (stat("${tgz}.tar.gz"))[7];
382            } elsif (-d $tgz) {
383                    opendir(my $dir, $tgz) || die "can't opendir $tgz: $!";
384                    my @parts = grep { !/^\./ && !/md5/ && -f "$tgz/$_" } readdir($dir);
385                    $size = 0;
386                    foreach my $part (@parts) {
387                            $size += (stat("$tgz/$part"))[7] || die "can't stat $tgz/$part: $!";
388                    }
389                    closedir $dir;
390            } else {
391                    return -1;
392            }
393    
394            return $size;
395    }
396    
397  sub getGzipSize($$)  sub getGzipSize($$)
398  {  {
399          my ($hostID, $backupNum) = @_;          my ($hostID, $backupNum) = @_;
         my $ret;  
400          my $sql;          my $sql;
401          my $dbh = get_dbh();          my $dbh = get_dbh();
402                    
# Line 316  sub getGzipSize($$) Line 414  sub getGzipSize($$)
414          $sth->execute($hostID, $backupNum);          $sth->execute($hostID, $backupNum);
415    
416          my $row = $sth->fetchrow_hashref();          my $row = $sth->fetchrow_hashref();
417            
418          my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) =          return get_tgz_size_by_name(
419                          stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.                  getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})
420                                  getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));          );
           
         return $ret;      
421  }  }
422    
423  sub getBackupsNotBurned() {  sub getVolumes($) {
424            my $id = shift;
425    
426            my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
427    
428            my $sth = $dbh->prepare(qq{
429                    select
430                            size
431                    from backup_parts
432                    where backup_id = ?
433                    order by part_nr asc
434            });
435    
436            $sth->execute($id);
437    
438            my $cumulative_size = 0;
439            my $volumes = 1;
440    
441            while(my ($size) = $sth->fetchrow_array) {
442                    if ($cumulative_size + $size > $max_archive_size) {
443                            $volumes++;
444                            $cumulative_size = $size;
445                    } else {
446                            $cumulative_size += $size;
447                    }
448            }
449    
450            return ($volumes,$cumulative_size);
451    }
452    
453    sub getBackupsNotBurned($) {
454    
455            my $param = shift;
456          my $dbh = get_dbh();          my $dbh = get_dbh();
457    
458          my $sql = q{          my $order = getSort('burn', 'sql', $param->{'sort'});
459    
460    print STDERR "## sort=". ($param->{'sort'} || 'no sort param') . " burn sql order: $order\n";
461    
462            my $sql = qq{
463                  SELECT                  SELECT
464                          backups.hostID AS hostID,                          backups.hostID AS hostID,
465                          hosts.name AS host,                          hosts.name AS host,
# Line 336  sub getBackupsNotBurned() { Line 467  sub getBackupsNotBurned() {
467                          backups.num AS backupnum,                          backups.num AS backupnum,
468                          backups.type AS type,                          backups.type AS type,
469                          backups.date AS date,                          backups.date AS date,
470                            date_part('epoch',now()) - backups.date as age,
471                          backups.size AS size,                          backups.size AS size,
472                          backups.id AS id,                          backups.id AS id,
473                          backups.inc_size AS inc_size                          backups.inc_size AS inc_size,
474                            backups.parts AS parts
475                  FROM backups                  FROM backups
476                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
477                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
# Line 354  sub getBackupsNotBurned() { Line 487  sub getBackupsNotBurned() {
487                          backups.type,                          backups.type,
488                          backups.date,                          backups.date,
489                          backups.size,                          backups.size,
490                          backups.inc_size                          backups.inc_size,
491                  ORDER BY backups.date                          backups.parts
492                    ORDER BY $order
493          };          };
494          my $sth = $dbh->prepare( $sql );          my $sth = $dbh->prepare( $sql );
495          my @ret;          my @ret;
496          $sth->execute();          $sth->execute();
497    
498          while ( my $row = $sth->fetchrow_hashref() ) {          while ( my $row = $sth->fetchrow_hashref() ) {
499                  $row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );                  $row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) );
500                  $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024);                  #$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );
501    
502                    my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
503                    if ($row->{size} > $max_archive_size) {
504                            ($row->{volumes}, $row->{inc_size_calc}) = getVolumes($row->{id});
505                    }
506    
507                    $row->{size} = sprintf("%0.2f", $row->{size} / 1024 / 1024);
508    
509                  # do some cluster calculation (approximate) and convert to kB                  # do some cluster calculation (approximate)
510                  $row->{'inc_size'} = int(($row->{'inc_size'} + 1023 ) / ( 2 * 1024 ) * 2);                  $row->{inc_size} = int(($row->{inc_size} + 1023 ) / ( 2 * 1024 ) * 2);
511                    $row->{inc_size_calc} ||= $row->{inc_size};
512                  push @ret, $row;                  push @ret, $row;
513          }          }
514                
515          return @ret;                return @ret;
516  }  }
517    
518  sub displayBackupsGrid() {  sub displayBackupsGrid($) {
519    
520            my $param = shift;
521    
522            my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
523            my $max_archive_file_size = $Conf{MaxArchiveFileSize}  || die "no MaxFileInSize";
524    
525          my $retHTML .= q{          my $retHTML .= q{
526                  <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">                  <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">
# Line 480  DIV#fixedBox #submitBurner { Line 627  DIV#fixedBox #submitBurner {
627          z-index: 3;          z-index: 3;
628          background-color: transparent;          background-color: transparent;
629  }  }
630    
631    #volumes {
632            padding: 0.4em;
633            display: none;
634            width: 100%;
635            font-size: 80%;
636            color: #ff0000;
637            text-align: center;
638    }
639  -->  -->
640  </style>  </style>
641  <script type="text/javascript">  <script type="text/javascript">
# Line 489  var debug_div = null; Line 645  var debug_div = null;
645  EOF3  EOF3
646    
647          # take maximum archive size from configuration          # take maximum archive size from configuration
648          $retHTML .= 'var media_size = '. $Conf{MaxArchiveSize} .';';          $retHTML .= qq{
649    var media_size = $max_archive_size ;
650    var max_file_size = $max_archive_file_size;
651    
652    };
653    
654          $retHTML .= <<'EOF3';          $retHTML .= <<'EOF3';
655    
656  function debug(msg) {  function debug(msg) {
657  //      return; // Disable debugging          return; // Disable debugging
658    
659          if (! debug_div) debug_div = document.getElementById('debug');          if (! debug_div) debug_div = document.getElementById('debug');
660    
# Line 550  function checkAll(location) { Line 710  function checkAll(location) {
710          update_sum(suma);          update_sum(suma);
711  }  }
712    
713  function update_sum(suma) {  function update_sum(suma, suma_disp) {
714            if (! suma_disp) suma_disp = suma;
715            suma_disp = Math.floor(suma_disp / 1024);
716            element_id('forma').elements['totalsize_kb'].value = suma_disp;
717          element_id('forma').elements['totalsize'].value = suma;          element_id('forma').elements['totalsize'].value = suma;
718          pbar_set(suma, media_size);          pbar_set(suma, media_size);
719          debug('total size: ' + suma);          debug('total size: ' + suma);
# Line 566  function sumiraj(e) { Line 729  function sumiraj(e) {
729                  } else {                  } else {
730                          suma -= size;                          suma -= size;
731                  }                  }
732    
733                    var volumes = parseInt( element_id("prt" + e.name.substr(3)).value);
734                    if (volumes > 1) {
735                            if (e.checked) {
736                                    element_id("volumes").innerHTML = "This will take "+volumes+" mediums!";
737                                    element_id("volumes").style.display = 'block';
738                                    suma = size;
739                                    update_sum(suma);
740                                    return suma;
741                            } else {
742                                    suma -= size;
743                                    element_id("volumes").style.display = 'none';
744                            }
745                    }
746    
747                    if (suma < 0) suma = 0;
748          } else {          } else {
749                  suma = 0;                  suma = 0;
750                  for (var i = 0; i < len; i++) {                  for (var i = 0; i < len; i++) {
# Line 654  self.onload = self.document.onload = sel Line 833  self.onload = self.document.onload = sel
833  </script>  </script>
834  <div id="fixedBox">  <div id="fixedBox">
835    
836  Size: <input type="text" name="totalsize" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB  <input type="hidden" name="totalsize"/>
837    Size: <input type="text" name="totalsize_kb" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB
838    
839  <div id="mContainer">  <div id="mContainer">
840          <div id="gradient">&nbsp;</div>          <div id="gradient">&nbsp;</div>
# Line 663  Size: <input type="text" name="totalsize Line 843  Size: <input type="text" name="totalsize
843  </div>  </div>
844  <br/>  <br/>
845    
846    <div id="volumes">&nbsp;</div>
847    
848  Note:  Note:
849  <textarea name="note" cols="10" rows="5" id="note"></textarea>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
850    
# Line 683  EOF3 Line 865  EOF3
865                          <td class="tableheader">                          <td class="tableheader">
866                                  <input type="checkbox" name="allFiles" id="allFiles" onClick="checkAll('allFiles');">                                  <input type="checkbox" name="allFiles" id="allFiles" onClick="checkAll('allFiles');">
867                          </td>                          </td>
868                          <td align="center">Share</td>          } .
869                          <td align="center">Backup no</td>                  sort_header($param, 'Share', 'share', 'center') .
870                    sort_header($param, '#', 'num', 'center') .
871            qq{
872                          <td align="center">Type</td>                          <td align="center">Type</td>
873                          <td align="center">date</td>          } .
874                          <td align="center">age/days</td>                  sort_header($param, 'Date', 'date', 'center') .
875                          <td align="center">size/MB</td>                  sort_header($param, 'Age/days', 'age', 'center') .
876                          <td align="center">gzip size/kB</td>                  sort_header($param, 'Size/Mb', 'size', 'center') .
877                          </tr>                  sort_header($param, 'gzip size/Kb', 'incsize', 'center') .
878            qq{
879                            <td align="center">medias</td></tr>
880          };          };
881    
882          my @color = (' bgcolor="#e0e0e0"', '');          my @color = (' bgcolor="#e0e0e0"', '');
# Line 699  EOF3 Line 884  EOF3
884          my $i = 0;          my $i = 0;
885          my $host = '';          my $host = '';
886    
887          foreach my $backup ( getBackupsNotBurned() ) {          foreach my $backup ( getBackupsNotBurned($param) ) {
888    
889                  if ($host ne $backup->{'host'}) {                  if ($host ne $backup->{'host'}) {
890                          $i++;                          $i++;
# Line 718  EOF3 Line 903  EOF3
903                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
904                  }                  }
905    
906                    my $img_url = $Conf{CgiImageDirURL};
907    
908                  $retHTML .=                  $retHTML .=
909                          '</td>' .                          '</td>' .
910                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
# Line 727  EOF3 Line 914  EOF3
914                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
915                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
916                          '<td align="right">' . $backup->{'inc_size'} .                          '<td align="right">' . $backup->{'inc_size'} .
917                          '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .                          '<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size_calc'} .'"></td>' .
918                            '<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'volumes'} .'"></td>' .
919                            '<td align="left">' . ( qq{<img src="$img_url/icon-cd.gif" alt="media">} x $backup->{volumes} ) . '</td>' .
920    
921                          "</tr>\n";                          "</tr>\n";
922          }          }
# Line 779  sub displayGrid($) { Line 968  sub displayGrid($) {
968          <table style="fview" width="100%" border="0" cellpadding="2" cellspacing="0">          <table style="fview" width="100%" border="0" cellpadding="2" cellspacing="0">
969                  <tr class="fviewheader">                  <tr class="fviewheader">
970                  <td></td>                  <td></td>
971                  <td align="center">Share</td>          };
972                  <td align="center">Type and Name</td>  
973                  <td align="center">#</td>          sub sort_header($$$$) {
974                  <td align="center">Size</td>                  my ($param, $display, $name, $align) = @_;
975                  <td align="center">Date</td>  
976                    my ($sort_what, $sort_direction) = split(/_/,$param->{'sort'},2);
977    
978                    my $old_sort = $param->{'sort'};
979    
980                    my $html = qq{<td align="$align"};
981                    my $arrow = '';
982    
983                    if (lc($sort_what) eq lc($name)) {
984                            my $direction = lc($sort_direction);
985    
986                            # swap direction or fallback to default
987                            $direction =~ tr/ad/da/;
988                            $direction = 'a' unless ($direction =~ /[ad]/);
989    
990                            $param->{'sort'} = $name . '_' . $direction;
991                            $html .= ' style="border: 1px solid #808080;"';
992                    
993                            # add unicode arrow for direction
994                            $arrow .= '&nbsp;';
995                            $arrow .= $direction eq 'a'  ?  '&#9650;'
996                                    : $direction eq 'd'  ?  '&#9660;'
997                                    :                       ''
998                                    ;
999    
1000                    } else {
1001                            $param->{'sort'} = $name . '_a';
1002                    }
1003    
1004                    $html .= '><a href="' . page_uri($param) . '">' . $display . '</a>' . $arrow . '</td>';
1005                    $param->{'sort'} = $old_sort;
1006    
1007                    return $html;
1008            }
1009    
1010            $retHTML .=
1011                    sort_header($param, 'Share', 'share', 'center') .
1012                    sort_header($param, 'Type and Name', 'path', 'center') .
1013                    sort_header($param, '#', 'num', 'center') .
1014                    sort_header($param, 'Size', 'size', 'center') .
1015                    sort_header($param, 'Date', 'date', 'center');
1016    
1017            $retHTML .= qq{
1018                  <td align="center">Media</td>                  <td align="center">Media</td>
1019                  </tr>                  </tr>
1020          };          };
# Line 803  sub displayGrid($) { Line 1034  sub displayGrid($) {
1034                  return sprintf(qq{<a href="?action=%s&host=%s&num=%d&share=%s&dir=%s">%s</a>}, $action, @_);                  return sprintf(qq{<a href="?action=%s&host=%s&num=%d&share=%s&dir=%s">%s</a>}, $action, @_);
1035          }          }
1036    
1037            my $sth_archived;
1038            my %archived_cache;
1039    
1040            sub check_archived($$$) {
1041                    my ($host, $share, $num) = @_;
1042    
1043                    if (my $html = $archived_cache{"$host $share $num"}) {
1044                            return $html;
1045                    }
1046    
1047                    $sth_archived ||= $dbh->prepare(qq{
1048                            select
1049                                    dvd_nr, note,
1050                                    count(archive_burned.copy) as copies
1051                            from archive
1052                            inner join archive_burned on archive_burned.archive_id = archive.id
1053                            inner join archive_backup on archive.id = archive_backup.archive_id
1054                            inner join backups on backups.id = archive_backup.backup_id
1055                            inner join hosts on hosts.id = backups.hostid
1056                            inner join shares on shares.id = backups.shareid
1057                            where hosts.name = ? and shares.name = ? and backups.num = ?
1058                            group by dvd_nr, note
1059                    });
1060    
1061                    my @mediums;
1062    
1063                    $sth_archived->execute($host, $share, $num);
1064                    while (my $row = $sth_archived->fetchrow_hashref()) {
1065                            push @mediums, '<abbr title="' .
1066                                    $row->{'note'} .
1067                                    ' [' . $row->{'copies'} . ']' .
1068                                    '">' .$row->{'dvd_nr'} .
1069                                    '</abbr>';
1070                    }
1071    
1072                    my $html = join(", ",@mediums);
1073                    $archived_cache{"$host $share $num"} = $html;
1074                    return $html;
1075            }
1076    
1077          my $i = $offset * $on_page;          my $i = $offset * $on_page;
1078    
1079          foreach $file (@{ $files }) {          foreach $file (@{ $files }) {
# Line 819  sub displayGrid($) { Line 1090  sub displayGrid($) {
1090                          qq{<td class="fviewborder" align="center">} . restore_link( $typeStr, ${EscURI( $file->{'hname'} )}, $file->{'backupnum'}, ${EscURI( $file->{'sname'})}, ${EscURI( $file->{'filepath'} )}, $file->{'backupnum'} ) . qq{</td>} .                          qq{<td class="fviewborder" align="center">} . restore_link( $typeStr, ${EscURI( $file->{'hname'} )}, $file->{'backupnum'}, ${EscURI( $file->{'sname'})}, ${EscURI( $file->{'filepath'} )}, $file->{'backupnum'} ) . qq{</td>} .
1091                          qq{<td class="fviewborder" align="right">} . $file->{'size'} . qq{</td>} .                          qq{<td class="fviewborder" align="right">} . $file->{'size'} . qq{</td>} .
1092                          qq{<td class="fviewborder">} . epoch_to_iso( $file->{'date'} ) . qq{</td>} .                          qq{<td class="fviewborder">} . epoch_to_iso( $file->{'date'} ) . qq{</td>} .
1093                          qq{<td class="fviewborder">} . '?' . qq{</td>};                          qq{<td class="fviewborder">} . check_archived( $file->{'hname'}, $file->{'sname'}, $file->{'backupnum'} ) . qq{</td>};
1094    
1095                  $retHTML .= "</tr>";                  $retHTML .= "</tr>";
1096          }          }
# Line 834  sub displayGrid($) { Line 1105  sub displayGrid($) {
1105          my $max_page = int( $results / $on_page );          my $max_page = int( $results / $on_page );
1106          my $page = 0;          my $page = 0;
1107    
1108          sub page_link($$$) {          sub page_uri($) {
1109                  my ($param,$page,$display) = @_;                  my $param = shift || die "no param?";
   
                 $param->{'offset'} = $page;  
1110    
1111                  my $html = '<a href = "' . $MyURL;                  my $uri = $MyURL;
1112                  my $del = '?';                  my $del = '?';
1113                  foreach my $k (keys %{ $param }) {                  foreach my $k (keys %{ $param }) {
1114                          if ($param->{$k}) {                          if ($param->{$k}) {
1115                                  $html .= $del . $k . '=' . ${EscURI( $param->{$k} )};                                  $uri .= $del . $k . '=' . ${EscURI( $param->{$k} )};
1116                                  $del = '&';                                  $del = '&';
1117                          }                          }
1118                  }                  }
1119                  $html .= '">' . $display . '</a>';                  return $uri;
1120            }
1121    
1122            sub page_link($$$) {
1123                    my ($param,$page,$display) = @_;
1124    
1125                    $param->{'offset'} = $page if (defined($page));
1126    
1127                    my $html = '<a href = "' . page_uri($param) . '">' . $display . '</a>';
1128          }          }
1129    
1130          $retHTML .= '<div style="text-align: center;">';          $retHTML .= '<div style="text-align: center;">';

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

  ViewVC Help
Powered by ViewVC 1.1.26